[Zope3-checkins] SVN: zope.testing/branches/ctheune-cleanup/src/zope/testing/testrunner/ push EndRun exception a bit down to make the `run` method a bit more

Christian Theune ct at gocept.com
Sat May 3 16:40:18 EDT 2008


Log message for revision 86294:
  push EndRun exception a bit down to make the `run` method a bit more
  straight-forward
  

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

-=-
Modified: zope.testing/branches/ctheune-cleanup/src/zope/testing/testrunner/__init__.py
===================================================================
--- zope.testing/branches/ctheune-cleanup/src/zope/testing/testrunner/__init__.py	2008-05-03 20:36:57 UTC (rev 86293)
+++ zope.testing/branches/ctheune-cleanup/src/zope/testing/testrunner/__init__.py	2008-05-03 20:40:18 UTC (rev 86294)
@@ -27,10 +27,10 @@
     # This function is here to make the whole test runner compatible before
     # the large refactoring.
     runner = Runner(defaults, args)
-    failed = runner.run()
-    if failed and runner.options.exitwithstatus:
+    runner.run()
+    if runner.failed and runner.options.exitwithstatus:
         sys.exit(1)
-    return failed
+    return runner.failed
 
 
 ###############################################################################

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-03 20:36:57 UTC (rev 86293)
+++ zope.testing/branches/ctheune-cleanup/src/zope/testing/testrunner/runner.py	2008-05-03 20:40:18 UTC (rev 86294)
@@ -76,6 +76,7 @@
         self.args = args
         self.found_suites = found_suites
         self.options = options
+        self.failed = True
 
         self.late_initializers = []
         self.early_shutdown = []
@@ -94,18 +95,13 @@
             init()
 
         try:
-            try:
-                self.find_tests()
-                failed = self.run_tests()
-            except EndRun:
-                failed = True
+            self.find_tests()
+            self.run_tests()
         finally:
             for shutdown in self.early_shutdown:
                 shutdown()
             self.shutdown_features()
 
-        return failed
-
     def configure(self):
         if self.args is None:
             self.args = sys.argv[:]
@@ -286,7 +282,11 @@
                     else:
                         output.info("Running unit tests:")
                         nlayers += 1
-                        ran += run_tests(options, tests, 'unit', failures, errors)
+                        try:
+                            ran += run_tests(options, tests, 'unit', failures, errors)
+                        except EndRun:
+                            self.failed = True
+                            return
 
         setup_layers = {}
 
@@ -308,7 +308,8 @@
         if options.list_tests:
             for layer_name, layer, tests in layers_to_run:
                 output.list_of_tests(tests, layer_name)
-            return False
+            self.failed = False
+            return
 
         start_time = time.time()
 
@@ -317,6 +318,9 @@
             try:
                 ran += run_layer(options, layer_name, layer, tests,
                                  setup_layers, failures, errors)
+            except EndRun:
+                self.failed = True
+                return
             except CanNotTearDown:
                 setup_layers = None
                 if not options.resume_layer:
@@ -358,7 +362,7 @@
         if options.gc:
             gc.set_threshold(*old_threshold)
 
-        return bool(import_errors or failures or errors)
+        self.failed = bool(import_errors or failures or errors)
 
     def shutdown_features(self):
         if self.options.profile:
@@ -505,6 +509,7 @@
         return run_tests(options, tests, layer_name, failures, errors)
 
 class SetUpLayerFailure(unittest.TestCase):
+
     def runTest(self):
         "Layer set up failure."
 



More information about the Zope3-Checkins mailing list