[Python-checkins] cpython: regrtest: round final timing towards +inf

victor.stinner python-checkins at python.org
Sun Mar 27 12:28:23 EDT 2016


https://hg.python.org/cpython/rev/c06cbf1525ec
changeset:   100768:c06cbf1525ec
user:        Victor Stinner <victor.stinner at gmail.com>
date:        Sun Mar 27 18:28:15 2016 +0200
summary:
  regrtest: round final timing towards +inf

files:
  Lib/test/libregrtest/main.py |  11 ++++++++---
  1 files changed, 8 insertions(+), 3 deletions(-)


diff --git a/Lib/test/libregrtest/main.py b/Lib/test/libregrtest/main.py
--- a/Lib/test/libregrtest/main.py
+++ b/Lib/test/libregrtest/main.py
@@ -1,5 +1,6 @@
 import datetime
 import faulthandler
+import math
 import os
 import platform
 import random
@@ -106,9 +107,13 @@
             self.skipped.append(test)
             self.resource_denieds.append(test)
 
-    def time_delta(self):
+    def time_delta(self, ceil=False):
         seconds = time.monotonic() - self.start_time
-        return datetime.timedelta(seconds=int(seconds))
+        if ceil:
+            seconds = math.ceil(seconds)
+        else:
+            seconds = int(seconds)
+        return datetime.timedelta(seconds=seconds)
 
     def display_progress(self, test_index, test):
         if self.ns.quiet:
@@ -409,7 +414,7 @@
             r.write_results(show_missing=True, summary=True,
                             coverdir=self.ns.coverdir)
 
-        print("Total duration: %s" % self.time_delta())
+        print("Total duration: %s" % self.time_delta(ceil=True))
 
         if self.ns.runleaks:
             os.system("leaks %d" % os.getpid())

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list