|
22 | 22 | from pathlib import Path
|
23 | 23 | import unittest
|
24 | 24 |
|
25 |
| - |
26 |
| -@functools.wraps(jpype.startJVM) |
27 |
| -def runStartJVMTest(*args, **kwargs): |
28 |
| - jpype.startJVM(*args, **kwargs) |
29 |
| - try: |
30 |
| - assert jpype.JClass('jpype.array.TestArray') is not None |
31 |
| - except Exception as err: |
32 |
| - raise RuntimeError("Test class not found") from err |
33 |
| - |
34 |
| - |
35 | 25 | root = os.path.dirname(os.path.abspath(os.path.dirname(__file__)))
|
36 | 26 | cp = os.path.join(root, 'classes').replace('\\', '/')
|
37 | 27 |
|
@@ -62,72 +52,97 @@ def testInvalidArgsFalse(self):
|
62 | 52 | def testInvalidArgsTrue(self):
|
63 | 53 | jpype.startJVM(
|
64 | 54 | "-for_sure_InVaLiD",
|
65 |
| - ignoreUnrecognized=True, convertStrings=False, |
| 55 | + ignoreUnrecognized=True, |
| 56 | + convertStrings=False, |
66 | 57 | )
|
67 | 58 |
|
68 | 59 | def testClasspathArgKeyword(self):
|
69 |
| - runStartJVMTest(classpath=cp, convertStrings=False) |
| 60 | + jpype.startJVM(classpath=cp, convertStrings=False) |
| 61 | + assert jpype.JClass('jpype.array.TestArray') is not None |
70 | 62 |
|
71 | 63 | def testClasspathArgList(self):
|
72 |
| - runStartJVMTest(classpath=[cp], convertStrings=False) |
| 64 | + jpype.startJVM( |
| 65 | + classpath=[cp], |
| 66 | + convertStrings=False, |
| 67 | + ) |
| 68 | + assert jpype.JClass('jpype.array.TestArray') is not None |
73 | 69 |
|
74 | 70 | def testClasspathArgListEmpty(self):
|
75 |
| - runStartJVMTest(classpath=[cp, ''], convertStrings=False) |
| 71 | + jpype.startJVM( |
| 72 | + classpath=[cp, ''], |
| 73 | + convertStrings=False, |
| 74 | + ) |
| 75 | + assert jpype.JClass('jpype.array.TestArray') is not None |
76 | 76 |
|
77 | 77 | def testClasspathArgDef(self):
|
78 |
| - runStartJVMTest('-Djava.class.path=%s' % cp, convertStrings=False) |
| 78 | + jpype.startJVM('-Djava.class.path=%s' % cp, convertStrings=False) |
| 79 | + assert jpype.JClass('jpype.array.TestArray') is not None |
79 | 80 |
|
80 | 81 | def testClasspathArgPath(self):
|
81 |
| - runStartJVMTest(classpath=Path(cp), convertStrings=False) |
| 82 | + jpype.startJVM(classpath=Path(cp), convertStrings=False) |
| 83 | + assert jpype.JClass('jpype.array.TestArray') is not None |
82 | 84 |
|
83 | 85 | def testClasspathArgPathList(self):
|
84 |
| - runStartJVMTest(classpath=[Path(cp)], convertStrings=False) |
| 86 | + jpype.startJVM(classpath=[Path(cp)], convertStrings=False) |
| 87 | + assert jpype.JClass('jpype.array.TestArray') is not None |
85 | 88 |
|
86 | 89 | def testClasspathArgGlob(self):
|
87 | 90 | jpype.startJVM(classpath=os.path.join(cp, '..', 'jar', 'mrjar*'))
|
88 | 91 | assert jpype.JClass('org.jpype.mrjar.A') is not None
|
89 | 92 |
|
90 | 93 | def testClasspathTwice(self):
|
91 | 94 | with self.assertRaises(TypeError):
|
92 |
| - runStartJVMTest('-Djava.class.path=%s' % |
| 95 | + jpype.startJVM('-Djava.class.path=%s' % |
93 | 96 | cp, classpath=cp, convertStrings=False)
|
94 | 97 |
|
95 | 98 | def testClasspathBadType(self):
|
96 | 99 | with self.assertRaises(TypeError):
|
97 |
| - runStartJVMTest(classpath=1, convertStrings=False) |
| 100 | + jpype.startJVM(classpath=1, convertStrings=False) |
98 | 101 |
|
99 | 102 | def testJVMPathArg_Str(self):
|
100 |
| - runStartJVMTest(self.jvmpath, classpath=cp, convertStrings=False) |
| 103 | + jpype.startJVM(self.jvmpath, classpath=cp, convertStrings=False) |
| 104 | + assert jpype.JClass('jpype.array.TestArray') is not None |
101 | 105 |
|
102 | 106 | def testJVMPathArg_None(self):
|
103 | 107 | # It is allowed to pass None as a JVM path
|
104 |
| - runStartJVMTest(None, classpath=cp, ) |
| 108 | + jpype.startJVM( |
| 109 | + None, # type: ignore |
| 110 | + classpath=cp, |
| 111 | + ) |
| 112 | + assert jpype.JClass('jpype.array.TestArray') is not None |
105 | 113 |
|
106 | 114 | def testJVMPathArg_NoArgs(self):
|
107 |
| - runStartJVMTest(classpath=cp) |
| 115 | + jpype.startJVM( |
| 116 | + classpath=cp, |
| 117 | + ) |
| 118 | + assert jpype.JClass('jpype.array.TestArray') is not None |
108 | 119 |
|
109 | 120 | def testJVMPathArg_Path(self):
|
110 | 121 | with self.assertRaises(TypeError):
|
111 |
| - runStartJVMTest( |
| 122 | + jpype.startJVM( |
112 | 123 | # Pass a path as the first argument. This isn't supported (this is
|
113 | 124 | # reflected in the type definition), but the fact that it "works"
|
114 | 125 | # gives rise to this test.
|
115 |
| - Path(self.jvmpath), # type: ignore |
116 |
| - classpath=cp, |
| 126 | + Path(self.jvmpath), # type: ignore |
117 | 127 | convertStrings=False,
|
118 | 128 | )
|
119 | 129 |
|
120 | 130 | def testJVMPathKeyword_str(self):
|
121 |
| - runStartJVMTest(classpath=cp, jvmpath=self.jvmpath, |
122 |
| - convertStrings=False) |
| 131 | + jpype.startJVM( |
| 132 | + classpath=cp, |
| 133 | + jvmpath=self.jvmpath, |
| 134 | + convertStrings=False, |
| 135 | + ) |
| 136 | + assert jpype.JClass('jpype.array.TestArray') is not None |
123 | 137 |
|
124 | 138 | def testJVMPathKeyword_Path(self):
|
125 |
| - runStartJVMTest(jvmpath=Path(self.jvmpath), classpath=cp, convertStrings=False) |
| 139 | + jpype.startJVM(jvmpath=Path(self.jvmpath), classpath=cp, convertStrings=False) |
| 140 | + assert jpype.JClass('jpype.array.TestArray') is not None |
126 | 141 |
|
127 | 142 | def testPathTwice(self):
|
128 | 143 | with self.assertRaises(TypeError):
|
129 | 144 | jpype.startJVM(self.jvmpath, jvmpath=self.jvmpath)
|
130 | 145 |
|
131 | 146 | def testBadKeyword(self):
|
132 | 147 | with self.assertRaises(TypeError):
|
133 |
| - jpype.startJVM(invalid=True) |
| 148 | + jpype.startJVM(invalid=True) # type: ignore |
0 commit comments