[Zope3-checkins] SVN: zope.testing/branches/ctheune-cleanup/src/zope/testing/testrunner/runner.py moved doctest setup/shutdown to the feature setup/shutdown phase

Christian Theune ct at gocept.com
Sun May 4 05:13:01 EDT 2008


Log message for revision 86321:
  moved doctest setup/shutdown to the feature setup/shutdown phase
  

Changed:
  U   zope.testing/branches/ctheune-cleanup/src/zope/testing/testrunner/runner.py

-=-
Modified: zope.testing/branches/ctheune-cleanup/src/zope/testing/testrunner/runner.py
===================================================================
--- zope.testing/branches/ctheune-cleanup/src/zope/testing/testrunner/runner.py	2008-05-04 09:09:09 UTC (rev 86320)
+++ zope.testing/branches/ctheune-cleanup/src/zope/testing/testrunner/runner.py	2008-05-04 09:13:00 UTC (rev 86321)
@@ -199,6 +199,29 @@
                 new_flags |= getattr(gc, op)
             gc.set_debug(new_flags)
 
+        # Set up doctest support
+        self.old_reporting_flags = doctest.set_unittest_reportflags(0)
+        reporting_flags = 0
+        if self.options.ndiff:
+            reporting_flags = doctest.REPORT_NDIFF
+        if self.options.udiff:
+            if reporting_flags:
+                output.error("Can only give one of --ndiff, --udiff, or --cdiff")
+                sys.exit(1)
+            reporting_flags = doctest.REPORT_UDIFF
+        if self.options.cdiff:
+            if reporting_flags:
+                output.error("Can only give one of --ndiff, --udiff, or --cdiff")
+                sys.exit(1)
+            reporting_flags = doctest.REPORT_CDIFF
+        if self.options.report_only_first_failure:
+            reporting_flags |= doctest.REPORT_ONLY_FIRST_FAILURE
+
+        if reporting_flags:
+            doctest.set_unittest_reportflags(reporting_flags)
+        else:
+            doctest.set_unittest_reportflags(self.old_reporting_flags)
+
     def find_tests(self):
         pass
 
@@ -229,28 +252,6 @@
                 msg = "Running tests at level %d" % self.options.at_level
             output.info(msg)
 
-        self.old_reporting_flags = doctest.set_unittest_reportflags(0)
-        reporting_flags = 0
-        if self.options.ndiff:
-            reporting_flags = doctest.REPORT_NDIFF
-        if self.options.udiff:
-            if reporting_flags:
-                output.error("Can only give one of --ndiff, --udiff, or --cdiff")
-                sys.exit(1)
-            reporting_flags = doctest.REPORT_UDIFF
-        if self.options.cdiff:
-            if reporting_flags:
-                output.error("Can only give one of --ndiff, --udiff, or --cdiff")
-                sys.exit(1)
-            reporting_flags = doctest.REPORT_CDIFF
-        if self.options.report_only_first_failure:
-            reporting_flags |= doctest.REPORT_ONLY_FIRST_FAILURE
-
-        if reporting_flags:
-            doctest.set_unittest_reportflags(reporting_flags)
-        else:
-            doctest.set_unittest_reportflags(self.old_reporting_flags)
-
         # Add directories to the path
         for path in self.options.path:
             if path not in sys.path:
@@ -356,11 +357,11 @@
 
             output.modules_with_import_problems(import_errors)
 
-        doctest.set_unittest_reportflags(self.old_reporting_flags)
-
         self.failed = bool(import_errors or failures or errors)
 
     def shutdown_features(self):
+        doctest.set_unittest_reportflags(self.old_reporting_flags)
+
         if self.options.gc_option:
             gc.set_debug(self.old_flags)
 



More information about the Zope3-Checkins mailing list