diff options
author | Victor Stinner <vstinner@redhat.com> | 2019-01-08 00:27:27 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-08 00:27:27 (GMT) |
commit | ddd7c422fd89a053700f9ed5272cf732ccb09088 (patch) | |
tree | f7f82943d5d1b4ff2b53db6dc965063ab33b90ff | |
parent | df8e1fb4e388e18430a9be8c6ceeb03c330f166c (diff) | |
download | cpython-ddd7c422fd89a053700f9ed5272cf732ccb09088.zip cpython-ddd7c422fd89a053700f9ed5272cf732ccb09088.tar.gz cpython-ddd7c422fd89a053700f9ed5272cf732ccb09088.tar.bz2 |
bpo-33717: pythoninfo logs information of all clocks (GH-11460)
test.pythoninfo now logs information of all clocks, not only time.time() and
time.perf_counter().
-rw-r--r-- | Lib/test/pythoninfo.py | 15 | ||||
-rw-r--r-- | Misc/NEWS.d/next/Tests/2019-01-07-23-22-44.bpo-33717.GhHXv8.rst | 2 |
2 files changed, 14 insertions, 3 deletions
diff --git a/Lib/test/pythoninfo.py b/Lib/test/pythoninfo.py index 26bcf5f..7ce6bf7 100644 --- a/Lib/test/pythoninfo.py +++ b/Lib/test/pythoninfo.py @@ -6,6 +6,7 @@ import errno import re import sys import traceback +import warnings def normalize_text(text): @@ -380,9 +381,17 @@ def collect_time(info_add): copy_attributes(info_add, time, 'time.%s', attributes) if hasattr(time, 'get_clock_info'): - for clock in ('time', 'perf_counter'): - tinfo = time.get_clock_info(clock) - info_add('time.get_clock_info(%s)' % clock, tinfo) + for clock in ('clock', 'monotonic', 'perf_counter', + 'process_time', 'thread_time', 'time'): + try: + # prevent DeprecatingWarning on get_clock_info('clock') + with warnings.catch_warnings(record=True): + clock_info = time.get_clock_info(clock) + except ValueError: + # missing clock like time.thread_time() + pass + else: + info_add('time.get_clock_info(%s)' % clock, clock_info) def collect_datetime(info_add): diff --git a/Misc/NEWS.d/next/Tests/2019-01-07-23-22-44.bpo-33717.GhHXv8.rst b/Misc/NEWS.d/next/Tests/2019-01-07-23-22-44.bpo-33717.GhHXv8.rst new file mode 100644 index 0000000..05338a3 --- /dev/null +++ b/Misc/NEWS.d/next/Tests/2019-01-07-23-22-44.bpo-33717.GhHXv8.rst @@ -0,0 +1,2 @@ +test.pythoninfo now logs information of all clocks, not only time.time() and +time.perf_counter(). |