gzz-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gzz-commits] gzz/test testutil.py


From: Vesa Kaihlavirta
Subject: [Gzz-commits] gzz/test testutil.py
Date: Thu, 09 Jan 2003 07:26:04 -0500

CVSROOT:        /cvsroot/gzz
Module name:    gzz
Changes by:     Vesa Kaihlavirta <address@hidden>       03/01/09 07:26:04

Modified files:
        test           : testutil.py 

Log message:
        Tabs->4 spaces.

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/test/testutil.py.diff?tr1=1.43&tr2=1.44&r1=text&r2=text

Patches:
Index: gzz/test/testutil.py
diff -u gzz/test/testutil.py:1.43 gzz/test/testutil.py:1.44
--- gzz/test/testutil.py:1.43   Thu Dec 19 08:18:56 2002
+++ gzz/test/testutil.py        Thu Jan  9 07:26:04 2003
@@ -46,31 +46,31 @@
 
 class Result_SaveImage(unittest._TextTestResult):
     def startTest(self, test):
-       from test.tools import gfx
-       gfx.didRender = 0
-       unittest._TextTestResult.startTest(self, test)
+        from test.tools import gfx
+        gfx.didRender = 0
+        unittest._TextTestResult.startTest(self, test)
     def addError(self, test, err):
-       self.saveFailure(test)
-       unittest._TextTestResult.addError(self, test, err)
+        self.saveFailure(test)
+        unittest._TextTestResult.addError(self, test, err)
 
     def addFailure(self, test, err):
-       self.saveFailure(test)
-       unittest._TextTestResult.addFailure(self, test, err)
+        self.saveFailure(test)
+        unittest._TextTestResult.addFailure(self, test, err)
 
     def saveFailure(self, test):
-       from test.tools import gfx
-       print "SAVEFAILURE? ", gfx._didRender
-       if not gfx._didRender: 
-           return
-       name = test.id()
-       file = "testfail_"+name+".png"
-       print "Saving result of graphical test to ", file
-       s = gfx.win.getSize()
-       gzz.util.saveimage.save(file,
-           gfx.win.readPixels(0, 0, s.width, s.height),
-           s.width, s.height
-           )
-           
+        from test.tools import gfx
+        print "SAVEFAILURE? ", gfx._didRender
+        if not gfx._didRender: 
+            return
+        name = test.id()
+        file = "testfail_"+name+".png"
+        print "Saving result of graphical test to ", file
+        s = gfx.win.getSize()
+        gzz.util.saveimage.save(file,
+            gfx.win.readPixels(0, 0, s.width, s.height),
+            s.width, s.height
+            )
+            
 class SavingTestRunner(unittest.TextTestRunner):
   def _makeResult(self):
       return Result_SaveImage(self.stream, self.descriptions, self.verbosity)
@@ -96,10 +96,10 @@
 
     tests = []
     for f in files:
-       if os.path.isdir(f):
-           os.path.walk(f, addTests, tests)
-       else:
-           tests.append(f)
+        if os.path.isdir(f):
+            os.path.walk(f, addTests, tests)
+        else:
+            tests.append(f)
     return tests
 
 faildefs = compile("""
@@ -141,20 +141,20 @@
         if tests.has_key('tearDown'):
             exec 'tearDown()' in tests
     except NeedGLError, e:
-       print "Skipping OpenGL test %s" % file
+        print "Skipping OpenGL test %s" % file
     
     # Need to check that len > 4 to avoid 
     # calling the module "test".
     testnames = [t for t in tests.keys() if t.startswith('test') and 
-                           len(t) > 4]
+                            len(t) > 4]
 
     code = '''class %s(unittest.TestCase):
         def setUp(self):
             self.module = imp.new_module(%s)
-           self.module.unittestObject = self
-           self.module.needGL = needGL
+            self.module.unittestObject = self
+            self.module.needGL = needGL
             self.module.space = space
-           exec faildefs in self.module.__dict__
+            exec faildefs in self.module.__dict__
             exec self.code in self.module.__dict__
 
         def tearDown(self):
@@ -175,8 +175,8 @@
     '''
 
     testcodes = [testcode % (t, docstring(tests[t]), t) 
-       for t in testnames 
-           if shouldRun(tests[t])]
+        for t in testnames 
+            if shouldRun(tests[t])]
 
     code += '\n'.join(testcodes) + '\n'
 
@@ -193,7 +193,7 @@
 
 def docstring(obj):
     if getattr(obj,"__doc__", None) != None: 
-       return '"""%s"""' % (obj.__doc__,)
+        return '"""%s"""' % (obj.__doc__,)
     else: return ""
 
 runfail = [None]
@@ -205,22 +205,22 @@
     m = re.search("\n\s*fail:\s*(.*?)\s*\n", doc)
     fail = None
     if m != None:
-       fail = m.group(1)
-       print "TEST FAILS IN ", obj, fail
-       if fail not in ["AWT", "GL", "*"]:
-           raise str(("Invalid docstring fail message ",obj.__doc__))
+        fail = m.group(1)
+        print "TEST FAILS IN ", obj, fail
+        if fail not in ["AWT", "GL", "*"]:
+            raise str(("Invalid docstring fail message ",obj.__doc__))
     if not (fail in runfail):
-       print "NOT RUNNING DUE TO WRONG F: ",obj
-       return 0
+        print "NOT RUNNING DUE TO WRONG F: ",obj
+        return 0
 
     m = re.search("\n\s*cost:\s*(.*?)\s*\n", doc)
     cost = 0
     if m != None:
-       cost = m.group(1)
-       print "TEST COST ",obj, cost
+        cost = m.group(1)
+        print "TEST COST ",obj, cost
     if cost > maxcost:
-       print "TOO COSTLY TEST", obj
-       return 0
+        print "TOO COSTLY TEST", obj
+        return 0
 
     # Then, check the cost of the test
     return 1
@@ -245,40 +245,40 @@
     import getopt
     import gzz.util.dbg
     opts, args = getopt.getopt(sys.argv[1:], 
-           gzz.util.dbg.short + "f:", 
-           gzz.util.dbg.long + ["--allowfail="])
+            gzz.util.dbg.short + "f:", 
+            gzz.util.dbg.long + ["--allowfail="])
     for o,a in opts:
-       print "Opt: ",o,a
-       if o in gzz.util.dbg.all:
-           gzz.util.dbg.option(o,a)
-       elif o in ("-f", "--allowfail"):
-           if a == "*":
-               runfail = ["GL", "AWT", "*"]
-           else:
-               runfail = [None, a]
+        print "Opt: ",o,a
+        if o in gzz.util.dbg.all:
+            gzz.util.dbg.option(o,a)
+        elif o in ("-f", "--allowfail"):
+            if a == "*":
+                runfail = ["GL", "AWT", "*"]
+            else:
+                runfail = [None, a]
     test = args
     try:
         if test.index('jni') >=0:
-           print "Enabling jni"
+            print "Enabling jni"
             enableJNI = true
             test.remove('jni')
     except ValueError:
         pass
     if len(test) == 0:
-       test = ['test/']
+        test = ['test/']
     sys.path.extend(test)
     class Starter(java.lang.Runnable):
-       def run(self):
-           try:
-               SavingTestRunner(verbosity=2).run(suite(test))
-           except:
-               typ, val, tra = sys.exc_info()
-               print (repr((typ, val)))
-               print str(val)
-               l = traceback.format_list(traceback.extract_tb(tra))
-               print "\n".join(l)
-           print "Calling system.exit"
-           java.lang.System.exit(0)
+        def run(self):
+            try:
+                SavingTestRunner(verbosity=2).run(suite(test))
+            except:
+                typ, val, tra = sys.exc_info()
+                print (repr((typ, val)))
+                print str(val)
+                l = traceback.format_list(traceback.extract_tb(tra))
+                print "\n".join(l)
+            print "Calling system.exit"
+            java.lang.System.exit(0)
     GraphicsAPI.getInstance().startUpdateManager(Starter())
 
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]