30 |
NOTE: testutil.py itself runs all tests in test/ when run as main. |
NOTE: testutil.py itself runs all tests in test/ when run as main. |
31 |
test.py runs only tests in the test/gzz/ subtree. |
test.py runs only tests in the test/gzz/ subtree. |
32 |
""" |
""" |
33 |
|
import sys |
34 |
|
sys.path.insert(0, ".") |
35 |
|
|
36 |
import unittest, os.path, fnmatch, string, imp |
import unittest, os.path, fnmatch, string, imp |
37 |
import java |
import java |
38 |
|
|
39 |
|
graphicswindow = None |
40 |
|
def getGraphicsWindow(): |
41 |
|
global graphicswindow |
42 |
|
if not graphicswindow: |
43 |
|
graphicswindow = GraphicsAPI.getInstance().createWindow() |
44 |
|
return graphicswindow |
45 |
|
|
46 |
true = 1 |
true = 1 |
47 |
false = 0 |
false = 0 |
48 |
enableJNI = false |
enableJNI = false |
67 |
return tests |
return tests |
68 |
|
|
69 |
faildefs = compile(""" |
faildefs = compile(""" |
70 |
|
def failUnlessApprox(delta, first, second, msg = None): |
71 |
|
unittestObject.failUnless(abs(first-second) <= delta, msg) |
72 |
def failUnlessEqual(first, second, msg = None): |
def failUnlessEqual(first, second, msg = None): |
73 |
unittestObject.failUnlessEqual(first, second, msg) |
unittestObject.failUnlessEqual(first, second, msg) |
74 |
def failIf(expr, msg = None): |
def failIf(expr, msg = None): |
105 |
def setUp(self): |
def setUp(self): |
106 |
self.module = imp.new_module(%s) |
self.module = imp.new_module(%s) |
107 |
self.module.unittestObject = self |
self.module.unittestObject = self |
108 |
|
self.module.getGraphicsWindow = getGraphicsWindow |
109 |
exec faildefs in self.module.__dict__ |
exec faildefs in self.module.__dict__ |
110 |
exec self.code in self.module.__dict__ |
exec self.code in self.module.__dict__ |
111 |
''' |
''' |
156 |
|
|
157 |
if __name__ == '__main__': |
if __name__ == '__main__': |
158 |
test = ['test/'] |
test = ['test/'] |
|
import sys |
|
159 |
if len(sys.argv) > 1: |
if len(sys.argv) > 1: |
160 |
sys.path.insert(0, ".") |
sys.path.insert(0, ".") |
161 |
import getopt |
import getopt |
175 |
test.remove('jni') |
test.remove('jni') |
176 |
except ValueError: |
except ValueError: |
177 |
pass |
pass |
178 |
unittest.TextTestRunner(verbosity=2).run(suite(test)) |
from gzz.client import GraphicsAPI |
179 |
|
class Starter(java.lang.Runnable): |
180 |
|
def run(self): |
181 |
|
unittest.TextTestRunner(verbosity=2).run(suite(test)) |
182 |
|
GraphicsAPI.getInstance().startUpdateManager(Starter()) |
183 |
|
|
184 |
|
|
185 |
|
|