| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 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) |