diff options
author | Victor Stinner <vstinner@redhat.com> | 2018-12-17 10:30:34 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-17 10:30:34 (GMT) |
commit | 8db5b54463118e5eb60cb3582e3108623f01f5df (patch) | |
tree | bacd30bf9a8b946798ae30abf8c764d2c6f47d8d /Lib/unittest | |
parent | 2cf4c202ffeb30787c944365ba54013688b854c2 (diff) | |
download | cpython-8db5b54463118e5eb60cb3582e3108623f01f5df.zip cpython-8db5b54463118e5eb60cb3582e3108623f01f5df.tar.gz cpython-8db5b54463118e5eb60cb3582e3108623f01f5df.tar.bz2 |
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.
Diffstat (limited to 'Lib/unittest')
-rw-r--r-- | Lib/unittest/runner.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Lib/unittest/runner.py b/Lib/unittest/runner.py index 2c5ea4a..45e7e4c 100644 --- a/Lib/unittest/runner.py +++ b/Lib/unittest/runner.py @@ -168,7 +168,7 @@ class TextTestRunner(object): warnings.filterwarnings('module', category=DeprecationWarning, message=r'Please use assert\w+ instead.') - startTime = time.time() + startTime = time.perf_counter() startTestRun = getattr(result, 'startTestRun', None) if startTestRun is not None: startTestRun() @@ -178,7 +178,7 @@ class TextTestRunner(object): stopTestRun = getattr(result, 'stopTestRun', None) if stopTestRun is not None: stopTestRun() - stopTime = time.time() + stopTime = time.perf_counter() timeTaken = stopTime - startTime result.printErrors() if hasattr(result, 'separator2'): |