[Zope-Checkins] CVS: Zope/utilities - testrunner.py:1.13

Jeremy Hylton jeremy@zope.com
Tue, 7 Aug 2001 16:04:16 -0400


Update of /cvs-repository/Zope/utilities
In directory cvs.zope.org:/tmp/cvs-serv4784/utilities

Modified Files:
	testrunner.py 
Log Message:
Update Zope test suite to use unittest from Python 2.1 standard library

The unittest file in Zope/lib/python is history.

testrunner.py output has changed slightly.  When a test fails, it
prints a Python traceback.  The script has also grown a -q option that
produces less output when the test suite is run.




=== Zope/utilities/testrunner.py 1.12 => 1.13 ===
 
 import sys, os, imp, string, getopt, traceback
+import unittest
 
-pyunit=None
-
+VERBOSE = 2
 
 class TestRunner:
     """Test suite runner"""
@@ -43,10 +43,6 @@
             sys.path.insert(0, pjoin(path, 'lib/python'))
             sys.path.insert(1, path)
 
-        global pyunit
-        import unittest
-        pyunit=unittest
-
     def getSuiteFromFile(self, filepath):
         if not os.path.isfile(filepath):
             raise ValueError, '%s is not a file' % filepath
@@ -72,7 +68,7 @@
                 (find(text, 'framework.py') > -1))
 
     def runSuite(self, suite):
-        runner=pyunit.TextTestRunner()
+        runner=unittest.TextTestRunner(verbosity=VERBOSE)
         runner.run(suite)
 
     def report(self, message):
@@ -152,15 +148,24 @@
           Run the test suite found in the file specified. The filepath
           should be a fully qualified path to the file to be run.
 
+       -q
+       
+          Run tests without producing verbose output.  The tests are
+          normally run in verbose mode, which produces a line of
+          output for each test that includes the name of the test and
+          whether it succeeded.  Quiet mode prints a period as
+          each test runs.
+
        -h
 
-          Display usage information.\n"""
+          Display usage information.
+    """
 
     pathname=None
     filename=None
     test_all=None
 
-    options, arg=getopt.getopt(args, 'ahd:f:')
+    options, arg=getopt.getopt(args, 'ahd:f:q')
     if not options:
         err_exit(usage_msg)
     for name, value in options:
@@ -173,6 +178,9 @@
             filename=string.strip(value)
         elif name == 'h':
             err_exit(usage_msg, 0)
+        elif name == 'q':
+            global VERBOSE
+            VERBOSE = 1
         else:
             err_exit(usage_msg)