[Zope3-checkins]
SVN: zope.testing/branches/ctheune-cleanup/src/zope/testing/testrunner/
Moved timings to more general statistics feature which is
also responsible to
Christian Theune
ct at gocept.com
Sun May 4 15:30:52 EDT 2008
Log message for revision 86416:
Moved timings to more general statistics feature which is also responsible to
report the total ran tests summary.
Changed:
U zope.testing/branches/ctheune-cleanup/src/zope/testing/testrunner/feature.py
U zope.testing/branches/ctheune-cleanup/src/zope/testing/testrunner/filter.py
U zope.testing/branches/ctheune-cleanup/src/zope/testing/testrunner/interfaces.py
U zope.testing/branches/ctheune-cleanup/src/zope/testing/testrunner/runner.py
A zope.testing/branches/ctheune-cleanup/src/zope/testing/testrunner/statistics.py
D zope.testing/branches/ctheune-cleanup/src/zope/testing/testrunner/timing.py
-=-
Modified: zope.testing/branches/ctheune-cleanup/src/zope/testing/testrunner/feature.py
===================================================================
--- zope.testing/branches/ctheune-cleanup/src/zope/testing/testrunner/feature.py 2008-05-04 19:24:05 UTC (rev 86415)
+++ zope.testing/branches/ctheune-cleanup/src/zope/testing/testrunner/feature.py 2008-05-04 19:30:51 UTC (rev 86416)
@@ -40,6 +40,14 @@
"""
pass
+ def layer_setup(self, layer):
+ """Executed once after a layer was set up."""
+ pass
+
+ def layer_teardown(self, layer):
+ """Executed once after a layer was run."""
+ pass
+
def test_setup(self):
"""Executed once before each test."""
pass
Modified: zope.testing/branches/ctheune-cleanup/src/zope/testing/testrunner/filter.py
===================================================================
--- zope.testing/branches/ctheune-cleanup/src/zope/testing/testrunner/filter.py 2008-05-04 19:24:05 UTC (rev 86415)
+++ zope.testing/branches/ctheune-cleanup/src/zope/testing/testrunner/filter.py 2008-05-04 19:30:51 UTC (rev 86416)
@@ -77,7 +77,3 @@
if self.runner.options.verbose:
self.runner.options.output.tests_with_errors(self.runner.errors)
self.runner.options.output.tests_with_failures(self.runner.failures)
-
- if self.runner.nlayers != 1:
- self.runner.options.output.totals(self.runner.ran, len(self.runner.failures),
- len(self.runner.errors), self.runner.total_time)
Modified: zope.testing/branches/ctheune-cleanup/src/zope/testing/testrunner/interfaces.py
===================================================================
--- zope.testing/branches/ctheune-cleanup/src/zope/testing/testrunner/interfaces.py 2008-05-04 19:24:05 UTC (rev 86415)
+++ zope.testing/branches/ctheune-cleanup/src/zope/testing/testrunner/interfaces.py 2008-05-04 19:30:51 UTC (rev 86416)
@@ -47,10 +47,16 @@
"""
- def test_setup():
+ def layer_setup(layer):
+ """Executed once after a layer was set up."""
+
+ def layer_teardown(layer):
+ """Executed once after a layer was run."""
+
+ def test_setup(test):
"""Executed once before each test."""
- def test_teardown():
+ def test_teardown(test):
"""Executed once after each test."""
def early_teardown():
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 19:24:05 UTC (rev 86415)
+++ zope.testing/branches/ctheune-cleanup/src/zope/testing/testrunner/runner.py 2008-05-04 19:30:51 UTC (rev 86416)
@@ -40,10 +40,10 @@
import zope.testing.testrunner.logsupport
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
import zope.testing.testrunner.listing
+import zope.testing.testrunner.statistics
import zope.testing.testrunner.subprocess
@@ -94,7 +94,6 @@
self.ran = 0
self.failures = []
self.errors = []
- self.nlayers = 0
self.show_report = True
self.do_run_tests = True
@@ -188,13 +187,13 @@
self.features.append(zope.testing.testrunner.coverage.Coverage(self))
self.features.append(zope.testing.testrunner.doctest.DocTest(self))
self.features.append(zope.testing.testrunner.profiling.Profiling(self))
- self.features.append(zope.testing.testrunner.timing.Timing(self))
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.subprocess.SubProcess(self))
self.features.append(zope.testing.testrunner.filter.Filter(self))
self.features.append(zope.testing.testrunner.listing.Listing(self))
+ self.features.append(zope.testing.testrunner.statistics.Statistics(self))
# Remove all features that aren't activated
self.features = [f for f in self.features if f.active]
@@ -208,7 +207,8 @@
if 'unit' in self.tests_by_layer_name:
tests = self.tests_by_layer_name.pop('unit')
self.options.output.info("Running unit tests:")
- self.nlayers += 1
+ for feature in self.features:
+ feature.layer_setup('unit')
try:
self.ran += run_tests(self.options, tests, 'unit',
self.failures, self.errors)
@@ -221,7 +221,8 @@
layers_to_run = list(self.ordered_layers())
for layer_name, layer, tests in layers_to_run:
- self.nlayers += 1
+ for feature in self.features:
+ feature.layer_setup(layer)
try:
self.ran += run_layer(self.options, layer_name, layer, tests,
setup_layers, self.failures, self.errors)
@@ -436,7 +437,6 @@
return rantotal
-
def tear_down_unneeded(options, needed, setup_layers, optional=False):
# Tear down any layers not needed for these tests. The unneeded
# layers might interfere.
Added: zope.testing/branches/ctheune-cleanup/src/zope/testing/testrunner/statistics.py
===================================================================
--- zope.testing/branches/ctheune-cleanup/src/zope/testing/testrunner/statistics.py (rev 0)
+++ zope.testing/branches/ctheune-cleanup/src/zope/testing/testrunner/statistics.py 2008-05-04 19:30:51 UTC (rev 86416)
@@ -0,0 +1,48 @@
+##############################################################################
+#
+# 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.
+#
+##############################################################################
+"""Test runner statistics
+
+$Id: __init__.py 86218 2008-05-03 14:17:26Z ctheune $
+"""
+
+import time
+import zope.testing.testrunner.feature
+
+
+class Statistics(zope.testing.testrunner.feature.Feature):
+
+ active = True
+ layers_run = 0
+ tests_run = 0
+
+ def late_setup(self):
+ self.start_time = time.time()
+
+ def early_teardown(self):
+ self.end_time = time.time()
+
+ def global_teardown(self):
+ self.total_time = self.end_time - self.start_time
+
+ def layer_setup(self, layer):
+ self.layers_run += 1
+
+ def report(self):
+ if not self.runner.do_run_tests:
+ return
+ if self.layers_run == 1:
+ return
+ self.runner.options.output.totals(
+ self.runner.ran, len(self.runner.failures), len(self.runner.errors),
+ self.total_time)
Property changes on: zope.testing/branches/ctheune-cleanup/src/zope/testing/testrunner/statistics.py
___________________________________________________________________
Name: svn:eol-style
+ native
Deleted: zope.testing/branches/ctheune-cleanup/src/zope/testing/testrunner/timing.py
===================================================================
--- zope.testing/branches/ctheune-cleanup/src/zope/testing/testrunner/timing.py 2008-05-04 19:24:05 UTC (rev 86415)
+++ zope.testing/branches/ctheune-cleanup/src/zope/testing/testrunner/timing.py 2008-05-04 19:30:51 UTC (rev 86416)
@@ -1,34 +0,0 @@
-##############################################################################
-#
-# 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.
-#
-##############################################################################
-"""Timing support.
-
-$Id: __init__.py 86218 2008-05-03 14:17:26Z ctheune $
-"""
-
-import time
-import zope.testing.testrunner.feature
-
-
-class Timing(zope.testing.testrunner.feature.Feature):
-
- active = True
-
- def late_setup(self):
- self.start_time = time.time()
-
- def early_teardown(self):
- self.end_time = time.time()
-
- def global_teardown(self):
- self.runner.total_time = self.end_time - self.start_time
More information about the Zope3-Checkins
mailing list