Debian Codegraph @

test/jpypetest/test_repr.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 from jpype.types import *
20 from jpype import JPackage, java
21 import common
22
23
24 class ReprTestCase(common.JPypeTestCase):
25
26 def setUp(self):
27 common.JPypeTestCase.setUp(self)
28
29 def testClass(self):
30 cls = JClass("java.lang.String")
31 self.assertIsInstance(str(cls), str)
32 self.assertIsInstance(repr(cls), str)
33
34 def testMethod(self):
35 JS = JClass("java.lang.String")
36 method = JS.substring
37 self.assertIsInstance(str(method), str)
38 self.assertIsInstance(repr(method), str)
39
40 def testField(self):
41 JS = JClass("java.lang.String")
42 field = JS.__dict__['CASE_INSENSITIVE_ORDER']
43 self.assertIsInstance(str(JS.substring), str)
44 self.assertIsInstance(repr(JS.substring), str)
45
46 def testMonitor(self):
47 JI = JClass("java.lang.Integer")
48 with jpype.synchronized(JI) as monitor:
49 self.assertIsInstance(str(monitor), str)
50 self.assertIsInstance(repr(monitor), str)
51
52 def testArray(self):
53 array = JArray(JInt)([1, 2, 3])
54 self.assertIsInstance(str(array), str)
55 self.assertIsInstance(repr(array), str)
56
57 def testObject(self):
58 obj = JObject("abc", JObject)
59 self.assertIsInstance(str(obj), str)
60 self.assertIsInstance(repr(obj), str)