[Zope3-checkins]
SVN: zope.testing/branches/ctheune-cleanup/src/zope/testing/testrunner/
started moving out filtering tests away into its own feature
Christian Theune
ct at gocept.com
Sun May 4 11:47:13 EDT 2008
Log message for revision 86392:
started moving out filtering tests away into its own feature
Changed:
A zope.testing/branches/ctheune-cleanup/src/zope/testing/testrunner/filter.py
U zope.testing/branches/ctheune-cleanup/src/zope/testing/testrunner/runner.py
-=-
Added: zope.testing/branches/ctheune-cleanup/src/zope/testing/testrunner/filter.py
===================================================================
--- zope.testing/branches/ctheune-cleanup/src/zope/testing/testrunner/filter.py (rev 0)
+++ zope.testing/branches/ctheune-cleanup/src/zope/testing/testrunner/filter.py 2008-05-04 15:47:13 UTC (rev 86392)
@@ -0,0 +1,49 @@
+##############################################################################
+#
+# Copyright (c) 2004-2008 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""Filter which tests to run.
+
+$Id: __init__.py 86218 2008-05-03 14:17:26Z ctheune $
+"""
+
+import time
+import zope.testing.testrunner.feature
+
+
+class Filter(zope.testing.testrunner.feature.Feature):
+ """Filters all tests registered until now."""
+
+ active = True
+
+ def global_setup(self):
+ tests = self.runner.tests_by_layer_name
+ options = self.runner.options
+
+ if 'unit' in tests:
+ # We start out assuming unit tests should run and look for reasons
+ # why they shouldn't be run.
+ should_run = True
+ if (not options.non_unit) and not options.resume_layer:
+ if options.layer:
+ should_run = False
+ for pat in options.layer:
+ if pat('unit'):
+ should_run = True
+ break
+ else:
+ should_run = True
+ else:
+ should_run = False
+
+ if not should_run:
+ tests.pop('unit')
Property changes on: zope.testing/branches/ctheune-cleanup/src/zope/testing/testrunner/filter.py
___________________________________________________________________
Name: svn:eol-style
+ native
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 15:30:37 UTC (rev 86391)
+++ zope.testing/branches/ctheune-cleanup/src/zope/testing/testrunner/runner.py 2008-05-04 15:47:13 UTC (rev 86392)
@@ -41,6 +41,7 @@
import zope.testing.testrunner.selftest
import zope.testing.testrunner.profiling
import zope.testing.testrunner.timing
+import zope.testing.testrunner.filter
import zope.testing.testrunner.garbagecollection
@@ -191,45 +192,31 @@
self.features.append(zope.testing.testrunner.garbagecollection.Threshold(self))
self.features.append(zope.testing.testrunner.garbagecollection.Debug(self))
self.features.append(zope.testing.testrunner.find.Find(self))
+ self.features.append(zope.testing.testrunner.filter.Filter(self))
# Remove all features that aren't activated
self.features = [f for f in self.features if f.active]
def run_tests(self):
- """Find and run tests
+ """Run all tests that were registered.
- 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.
"""
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
- for pat in self.options.layer:
- if pat('unit'):
- should_run = True
- break
- else:
- should_run = True
+ if self.options.list_tests:
+ self.options.output.list_of_tests(tests, 'unit')
+ else:
+ self.options.output.info("Running unit tests:")
+ self.nlayers += 1
+ try:
+ self.ran += run_tests(self.options, tests, 'unit',
+ self.failures, self.errors)
+ except EndRun:
+ self.failed = True
+ return
- if should_run:
- if self.options.list_tests:
- self.options.output.list_of_tests(tests, 'unit')
- else:
- self.options.output.info("Running unit tests:")
- self.nlayers += 1
- try:
- self.ran += run_tests(self.options, tests, 'unit',
- self.failures, self.errors)
- except EndRun:
- self.failed = True
- return
-
setup_layers = {}
layers_to_run = list(ordered_layers(self.tests_by_layer_name))
More information about the Zope3-Checkins
mailing list