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

Jeffrey P Shell jeffrey@zope.com
Wed, 8 Aug 2001 15:20:13 -0400


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

Modified Files:
      Tag: Zope-2_4-branch
	testrunner.py 
Log Message:
Removed 'unittest.py' from lib/python, as our version was quite out of date 
with
the one that now ships in Python 2.1.  Also updated testrunner to make use of 
the new unittest and have a 'quiet' mode option.


=== Zope/utilities/testrunner.py 1.10.4.2 => 1.10.4.3 ===
 
 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)