Debian Codegraph @

test/jpypetest/test_module2.py

raw symbols SCIP
1 # *****************************************************************************
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14 #
15 # See NOTICE file for details.
16 #
17 # *****************************************************************************
18 import jpype
19 import _jpype
20 import common
21
22
23 class ModuleTestCase2(common.JPypeTestCase):
24 def setUp(self):
25 common.JPypeTestCase.setUp(self)
26
27 def testMonitorOnNull(self):
28 value = jpype.JObject(None)
29 with self.assertRaises(TypeError):
30 _jpype._JMonitor(value)
31
32 def testMonitorOnString(self):
33 value = jpype.JString("foo")
34 with self.assertRaises(TypeError):
35 _jpype._JMonitor(value)
36
37 def testMonitorOnPrim(self):
38 value = jpype.JInt(1)
39 with self.assertRaises(TypeError):
40 _jpype._JMonitor(value)
41
42 def testMonitorInitBad(self):
43 with self.assertRaises(TypeError):
44 _jpype._JMonitor()
45
46 def testMonitorInitBad2(self):
47 with self.assertRaises(TypeError):
48 _jpype._JMonitor(None)
49
50 def testMonitorStr(self):
51 obj = jpype.java.lang.Object()
52 monitor = _jpype._JMonitor(obj)
53 self.assertIsInstance(str(monitor), str)
54
55 def testProxyInitBad(self):
56 with self.assertRaises(TypeError):
57 _jpype._JProxy(None)
58
59 def testProxyInitBad2(self):
60 with self.assertRaises(TypeError):
61 _jpype._JProxy(None, None, None)
62
63 def testProxyInitBad3(self):
64 with self.assertRaises(TypeError):
65 _jpype._JProxy(None, None, tuple([None, None]))
66
67 def testProxyNoInterfaces(self):
68 with self.assertRaises(TypeError):
69 proxy = _jpype._JProxy(None, None, tuple())
70
71 def testValueStr(self):
72 obj = jpype.JClass("java.lang.Object")()
73 self.assertIsInstance(str(obj), str)