/[gzz]/gzz/test/testutil.py
ViewVC logotype

Diff of /gzz/test/testutil.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.16 by benja, Wed Oct 9 08:46:04 2002 UTC revision 1.17 by tjl, Wed Oct 9 14:38:42 2002 UTC
# Line 30  can be tangled into unittests... Line 30  can be tangled into unittests...
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
# Line 58  def tests(files): Line 67  def tests(files):
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):
# Line 94  def load(file): Line 105  def load(file):
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      '''      '''
# Line 144  def suite(files, omit=[]): Line 156  def suite(files, omit=[]):
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
# Line 164  if __name__ == '__main__': Line 175  if __name__ == '__main__':
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    

Legend:
Removed from v.1.16  
changed lines
  Added in v.1.17

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26