Debian Codegraph @

src/test/python/jpy_reentrant_test.py

raw symbols SCIP
1 import unittest
2
3 import jpyutil
4
5 jpyutil.init_jvm(jvm_maxmem='512M', jvm_classpath=['target/classes'])
6 import jpy
7
8 class TestReentrant(unittest.TestCase):
9 def test_reentrant_function(self):
10 PyObject = jpy.get_type('org.jpy.PyObject')
11 PyInputMode = jpy.get_type('org.jpy.PyInputMode')
12 PyModule = jpy.get_type('org.jpy.PyModule')
13
14 PyObject.executeCode('def incByOne(x): return x + 1', PyInputMode.SCRIPT)
15
16 mainModule = PyModule.getMain()
17 res = mainModule.incByOne(41)
18 self.assertEqual(res, 42)
19
20 def test_reentrant_statement(self):
21 PyObject = jpy.get_type('org.jpy.PyObject')
22 PyInputMode = jpy.get_type('org.jpy.PyInputMode')
23 PyObject.executeCode('print("hi from test_reentrant_statement")', PyInputMode.STATEMENT)
24
25 if __name__ == '__main__':
26 print('\nRunning ' + __file__)
27 unittest.main()