pyjnius/tests/test_assignable.py

21 lines
638 B
Python

from __future__ import print_function
from __future__ import division
from __future__ import absolute_import
from future import standard_library
standard_library.install_aliases()
import unittest
from jnius import autoclass, JavaException
class AssignableFrom(unittest.TestCase):
def test_assignable(self):
ArrayList = autoclass('java.util.ArrayList')
Object = autoclass('java.lang.Object')
a = ArrayList()
# addAll accept Collection, Object must failed
self.assertRaises(JavaException, a.addAll, Object())
# while adding another ArrayList must be ok.
a.addAll(ArrayList())