Skip to content

Commit d351da9

Browse files
timfelfangerer
authored andcommitted
add tests for java imports
1 parent 7005bab commit d351da9

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

graalpython/com.oracle.graal.python.test/src/tests/test_interop.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,13 +239,13 @@ def test_key_info():
239239
assert polyglot.__key_info__(o, "my_field", "modifiable")
240240
assert polyglot.__key_info__(o, "my_field", "removable")
241241
assert not polyglot.__key_info__(o, "my_field", "insertable")
242-
242+
243243
assert polyglot.__key_info__(o, "__getattribute__", "readable")
244244
assert polyglot.__key_info__(o, "__getattribute__", "invokable")
245245
assert not polyglot.__key_info__(o, "__getattribute__", "modifiable")
246246
assert not polyglot.__key_info__(o, "__getattribute__", "removable")
247247
assert not polyglot.__key_info__(o, "__getattribute__", "insertable")
248-
248+
249249
builtinObj = (1,2,3)
250250
assert polyglot.__key_info__(builtinObj, "__len__", "readable")
251251
assert polyglot.__key_info__(builtinObj, "__len__", "invokable")
@@ -297,7 +297,7 @@ def test_direct_call_of_truffle_object_methods():
297297
assert False, "calling the python equivalents for well-known functions directly should work"
298298
except NotImplementedError as e:
299299
assert "host lookup is not allowed" in str(e)
300-
300+
301301
def test_array_element_info():
302302
immutableObj = (1,2,3,4)
303303
assert polyglot.__element_info__(immutableObj, 0, "exists")
@@ -316,3 +316,18 @@ def test_array_element_info():
316316
assert not polyglot.__element_info__(mutableObj, 0, "insertable")
317317
assert polyglot.__element_info__(mutableObj, 0, "modifiable")
318318
assert polyglot.__element_info__(mutableObj, 4, "insertable")
319+
320+
def test_java_imports():
321+
import java
322+
try:
323+
al = java.type("java.util.ArrayList")()
324+
except NotImplementedError as e:
325+
assert "host lookup is not allowed" in str(e)
326+
else:
327+
import java.util.ArrayList
328+
assert repr(java.util.ArrayList()) == "[]"
329+
330+
from java.util import ArrayList
331+
assert repr(ArrayList()) == "[]"
332+
333+
assert java.util.ArrayList == ArrayList

0 commit comments

Comments
 (0)