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 |
""" |
""" |
32 |
import sys |
import sys |
33 |
|
import traceback |
34 |
sys.path.insert(0, ".") |
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 |
from gzz.client import GraphicsAPI |
from gzz.client import GraphicsAPI |
39 |
|
|
|
graphicswindow = None |
|
|
def getGraphicsWindow(): |
|
|
global graphicswindow |
|
|
if not graphicswindow: |
|
|
graphicswindow = GraphicsAPI.getInstance().createWindow() |
|
|
return graphicswindow |
|
|
|
|
40 |
true = 1 |
true = 1 |
41 |
false = 0 |
false = 0 |
42 |
enableJNI = false |
enableJNI = false |
100 |
raise e |
raise e |
101 |
|
|
102 |
tests["needGL"] = needGL |
tests["needGL"] = needGL |
|
tests["getGraphicsWindow"] = getGraphicsWindow |
|
103 |
try: |
try: |
104 |
exec compiledTestFile in tests |
exec compiledTestFile in tests |
105 |
except NeedGLError, e: |
except NeedGLError, e: |
112 |
self.module = imp.new_module(%s) |
self.module = imp.new_module(%s) |
113 |
self.module.unittestObject = self |
self.module.unittestObject = self |
114 |
self.module.needGL = needGL |
self.module.needGL = needGL |
|
self.module.getGraphicsWindow = getGraphicsWindow |
|
115 |
exec faildefs in self.module.__dict__ |
exec faildefs in self.module.__dict__ |
116 |
exec self.code in self.module.__dict__ |
exec self.code in self.module.__dict__ |
117 |
''' |
''' |
144 |
|
|
145 |
|
|
146 |
def docstring(obj): |
def docstring(obj): |
147 |
if obj.__doc__ != None: return '"""%s"""' % (obj.__doc__,) |
if getattr(obj,"__doc__", None) != None: |
148 |
|
return '"""%s"""' % (obj.__doc__,) |
149 |
else: return "" |
else: return "" |
150 |
|
|
151 |
|
|
187 |
try: |
try: |
188 |
unittest.TextTestRunner(verbosity=2).run(suite(test)) |
unittest.TextTestRunner(verbosity=2).run(suite(test)) |
189 |
except: |
except: |
190 |
print sys.exc_info() |
typ, val, tra = sys.exc_info() |
191 |
|
print (repr((typ, val, tra))) |
192 |
|
l = traceback.format_list(traceback.extract_tb(tra)) |
193 |
|
print "\n".join(l) |
194 |
java.lang.System.exit(0) |
java.lang.System.exit(0) |
195 |
GraphicsAPI.getInstance().startUpdateManager(Starter()) |
GraphicsAPI.getInstance().startUpdateManager(Starter()) |
196 |
|
|