[Zope-Checkins] CVS: Zope/utilities - ExtensionBuilder.py:1.2.6.1 testrunner.py:1.10.8.1

Shane Hathaway shane@digicool.com
Thu, 9 Aug 2001 13:33:47 -0400


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

Modified Files:
      Tag: NR-branch
	ExtensionBuilder.py testrunner.py 
Log Message:
Sync NR-branch with trunk.  Sorry about so many checkin messages...


=== Zope/utilities/ExtensionBuilder.py 1.2 => 1.2.6.1 ===
                  'lib/python/ZODB',
                  'lib/python/BTrees',
+                 'lib/python/AccessControl',
                  'lib/python/SearchIndex',
                  'lib/python/Shared/DC/xml/pyexpat',
                  'lib/python/Products/PluginIndexes/TextIndex/Splitter/ZopeSplitter',


=== Zope/utilities/testrunner.py 1.10 => 1.10.8.1 ===
 
 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
@@ -65,16 +61,14 @@
         return function()
 
     def smellsLikeATest(self, filepath, find=string.find):
-        file=open(filepath, 'r')
-        lines=file.readlines()
+        file = open(filepath, 'r')
+        text = file.read()
         file.close()
-        for line in lines:
-            if find(line, 'def test_suite(') > -1:
-                return 1
-        return 0
+        return ((find(text, 'unittest') > -1) or
+                (find(text, 'framework.py') > -1))
 
     def runSuite(self, suite):
-        runner=pyunit.TextTestRunner()
+        runner=unittest.TextTestRunner(verbosity=VERBOSE)
         runner.run(suite)
 
     def report(self, message):
@@ -89,6 +83,8 @@
     def runPath(self, pathname):
         """Run all tests found in the directory named by pathname
            and all subdirectories."""
+        if not os.path.isabs(pathname):
+            pathname = os.path.join(self.basepath, pathname)
         names=os.listdir(pathname)
         for name in names:
             fname, ext=os.path.splitext(name)
@@ -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)