bpo-35513, unittest: TextTestRunner uses time.perf_counter() (GH-11180)
TextTestRunner of unittest.runner now uses time.perf_counter() rather
than time.time() to measure the execution time of a test: time.time()
can go backwards, whereas time.perf_counter() is monotonic.
Similar change made in libregrtest, pprint and random.
diff --git a/Lib/test/libregrtest/runtest.py b/Lib/test/libregrtest/runtest.py
index 466b522..dc2abf2 100644
--- a/Lib/test/libregrtest/runtest.py
+++ b/Lib/test/libregrtest/runtest.py
@@ -162,7 +162,7 @@
abstest = get_abs_module(ns, test)
clear_caches()
with saved_test_environment(test, ns.verbose, ns.quiet, pgo=ns.pgo) as environment:
- start_time = time.time()
+ start_time = time.perf_counter()
the_module = importlib.import_module(abstest)
# If the test has a test_main, that will run the appropriate
# tests. If not, use normal unittest test loading.
@@ -180,7 +180,7 @@
refleak = dash_R(the_module, test, test_runner, ns.huntrleaks)
else:
test_runner()
- test_time = time.time() - start_time
+ test_time = time.perf_counter() - start_time
post_test_cleanup()
except support.ResourceDenied as msg:
if not ns.quiet and not ns.pgo: