[Zope3-checkins] SVN: zope.testing/branches/ctheune-cleanup/src/zope/testing/testrunner/ Moved time measurements into their own feature.

Christian Theune ct at gocept.com
Sun May 4 08:41:51 EDT 2008


Log message for revision 86352:
  Moved time measurements into their own feature.
  

Changed:
  U   zope.testing/branches/ctheune-cleanup/src/zope/testing/testrunner/runner.py
  A   zope.testing/branches/ctheune-cleanup/src/zope/testing/testrunner/timing.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 12:37:38 UTC (rev 86351)
+++ zope.testing/branches/ctheune-cleanup/src/zope/testing/testrunner/runner.py	2008-05-04 12:41:50 UTC (rev 86352)
@@ -40,6 +40,7 @@
 import zope.testing.testrunner.logsupport
 import zope.testing.testrunner.selftest
 import zope.testing.testrunner.profiling
+import zope.testing.testrunner.timing
 
 
 PYREFCOUNT_PATTERN = re.compile('\[[0-9]+ refs\]')
@@ -173,6 +174,7 @@
         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))
 
         # Remove all features that aren't activated
         self.features = [f for f in self.features if f.active]
@@ -202,14 +204,6 @@
                 new_flags |= getattr(gc, op)
             gc.set_debug(new_flags)
 
-        # Set up time measurement
-        def start_time_recording():
-            self.start_time = time.time()
-        def stop_time_recording():
-            self.total_time = time.time() - self.start_time
-        self.late_initializers.append(start_time_recording)
-        self.early_shutdown.append(stop_time_recording)
-
     def find_tests(self):
         global _layer_name_cache
         _layer_name_cache.clear() # Reset to enforce test isolation

Added: zope.testing/branches/ctheune-cleanup/src/zope/testing/testrunner/timing.py
===================================================================
--- zope.testing/branches/ctheune-cleanup/src/zope/testing/testrunner/timing.py	                        (rev 0)
+++ zope.testing/branches/ctheune-cleanup/src/zope/testing/testrunner/timing.py	2008-05-04 12:41:50 UTC (rev 86352)
@@ -0,0 +1,34 @@
+##############################################################################
+#
+# 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


Property changes on: zope.testing/branches/ctheune-cleanup/src/zope/testing/testrunner/timing.py
___________________________________________________________________
Name: svn:eol-style
   + native



More information about the Zope3-Checkins mailing list