[Zope3-checkins] SVN: zope.testing/trunk/src/zope/testing/testrunner.py For large test suites "25 minutes 3 seconds" is easier to understand than "1503

Marius Gedminas marius at pov.lt
Thu Jul 19 10:14:34 EDT 2007


Log message for revision 78154:
  For large test suites "25 minutes 3 seconds" is easier to understand than "1503
  seconds".
  
  

Changed:
  U   zope.testing/trunk/src/zope/testing/testrunner.py

-=-
Modified: zope.testing/trunk/src/zope/testing/testrunner.py
===================================================================
--- zope.testing/trunk/src/zope/testing/testrunner.py	2007-07-19 13:41:48 UTC (rev 78153)
+++ zope.testing/trunk/src/zope/testing/testrunner.py	2007-07-19 14:14:33 UTC (rev 78154)
@@ -378,7 +378,11 @@
 
     def format_seconds(self, n_seconds):
         """Format a time in seconds."""
-        return "%.3f seconds" % n_seconds
+        if n_seconds >= 60:
+            n_minutes, n_seconds = divmod(n_seconds, 60)
+            return "%d minutes %.3f seconds" % (n_minutes, n_seconds)
+        else:
+            return "%.3f seconds" % n_seconds
 
     def format_seconds_short(self, n_seconds):
         """Format a time in seconds (short version)."""
@@ -697,7 +701,14 @@
 
     def format_seconds(self, n_seconds, normal='normal'):
         """Format a time in seconds."""
-        return self.colorize('number', "%.3f" % n_seconds, normal) + ' seconds'
+        if n_seconds >= 60:
+            n_minutes, n_seconds = divmod(n_seconds, 60)
+            return "%s minutes %s seconds" % (
+                        self.colorize('number', '%d' % n_minutes, normal),
+                        self.colorize('number', '%.3f' % n_seconds, normal))
+        else:
+            return "%s seconds" % (
+                        self.colorize('number', '%.3f' % n_seconds, normal))
 
     def summary(self, n_tests, n_failures, n_errors, n_seconds):
         """Summarize the results."""



More information about the Zope3-Checkins mailing list