[Zope3-checkins] SVN: zope.testing/branches/ctheune-cleanup/src/zope/testing/testrunner/runner.py move finding tests into separate method

Christian Theune ct at gocept.com
Sun May 4 06:20:55 EDT 2008


Log message for revision 86325:
  move finding tests into separate method
  
  

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 10:20:02 UTC (rev 86324)
+++ zope.testing/branches/ctheune-cleanup/src/zope/testing/testrunner/runner.py	2008-05-04 10:20:55 UTC (rev 86325)
@@ -248,20 +248,6 @@
         self.early_shutdown.append(stop_time_recording)
 
     def find_tests(self):
-        pass
-
-    def run_tests(self):
-        """Find and run tests
-
-        Passing a list of suites using the found_suites parameter will cause
-        that list of suites to be used instead of attempting to load them from
-        the filesystem. This is useful for unit testing the test runner.
-
-        Returns True if there where failures or False if all tests passed.
-
-        """
-        found_suites = self.found_suites
-
         global _layer_name_cache
         _layer_name_cache.clear() # Reset to enforce test isolation
 
@@ -282,14 +268,23 @@
             if path not in sys.path:
                 sys.path.append(path)
 
-        tests_by_layer_name = find_tests(self.options, found_suites)
+        self.tests_by_layer_name = find_tests(self.options, self.found_suites)
+        self.import_errors = self.tests_by_layer_name.pop(None, None)
+        # XXX move to reporting
+        output.import_errors(self.import_errors)
 
-        self.import_errors = tests_by_layer_name.pop(None, None)
+    def run_tests(self):
+        """Find and run tests
 
-        output.import_errors(self.import_errors)
+        Passing a list of suites using the found_suites parameter will cause
+        that list of suites to be used instead of attempting to load them from
+        the filesystem. This is useful for unit testing the test runner.
 
-        if 'unit' in tests_by_layer_name:
-            tests = tests_by_layer_name.pop('unit')
+        Returns True if there where failures or False if all tests passed.
+
+        """
+        if 'unit' in self.tests_by_layer_name:
+            tests = self.tests_by_layer_name.pop('unit')
             if (not self.options.non_unit) and not self.options.resume_layer:
                 if self.options.layer:
                     should_run = False
@@ -302,9 +297,9 @@
 
                 if should_run:
                     if self.options.list_tests:
-                        output.list_of_tests(tests, 'unit')
+                        self.options.output.list_of_tests(tests, 'unit')
                     else:
-                        output.info("Running unit tests:")
+                        self.options.output.info("Running unit tests:")
                         self.nlayers += 1
                         try:
                             self.ran += run_tests(self.options, tests, 'unit',
@@ -315,7 +310,7 @@
 
         setup_layers = {}
 
-        layers_to_run = list(ordered_layers(tests_by_layer_name))
+        layers_to_run = list(ordered_layers(self.tests_by_layer_name))
         if self.options.resume_layer is not None:
             layers_to_run = [
                 (layer_name, layer, tests)
@@ -331,7 +326,7 @@
 
         if self.options.list_tests:
             for layer_name, layer, tests in layers_to_run:
-                output.list_of_tests(tests, layer_name)
+                self.options.output.list_of_tests(tests, layer_name)
             self.failed = False
             self.show_report = False
             return
@@ -353,7 +348,7 @@
 
         if setup_layers:
             if self.options.resume_layer == None:
-                output.info("Tearing down left over layers:")
+                self.options.output.info("Tearing down left over layers:")
             tear_down_unneeded(self.options, (), setup_layers, True)
 
         self.failed = bool(self.import_errors or self.failures or self.errors)



More information about the Zope3-Checkins mailing list