[Python-checkins] bpo-36454: Fix test_time.test_monotonic() (GH-12929)

Miss Islington (bot) webhook-mailer at python.org
Tue Apr 23 18:36:00 EDT 2019


https://github.com/python/cpython/commit/e1a6cf2824acb43dc80473e0d938db99856daa97
commit: e1a6cf2824acb43dc80473e0d938db99856daa97
branch: 3.7
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub <noreply at github.com>
date: 2019-04-23T15:35:55-07:00
summary:

bpo-36454: Fix test_time.test_monotonic() (GH-12929)


Change test_time.test_monotonic() to test only the lower bound of elapsed time
after a sleep command rather than the upper bound. This prevents unnecessary
test failures on slow buildbots. Patch by Victor Stinner.
(cherry picked from commit d246a6766b9d8cc625112906299c4cb019944300)

Co-authored-by: Victor Stinner <vstinner at redhat.com>

files:
A Misc/NEWS.d/next/Tests/2019-04-23-17-48-11.bpo-36454.0q4lQz.rst
M Lib/test/test_time.py

diff --git a/Lib/test/test_time.py b/Lib/test/test_time.py
index ea455c0d0d13..4e31abf4ec8e 100644
--- a/Lib/test/test_time.py
+++ b/Lib/test/test_time.py
@@ -470,8 +470,9 @@ def test_monotonic(self):
         t2 = time.monotonic()
         dt = t2 - t1
         self.assertGreater(t2, t1)
-        # Issue #20101: On some Windows machines, dt may be slightly low
-        self.assertTrue(0.45 <= dt <= 1.0, dt)
+        # bpo-20101: tolerate a difference of 50 ms because of bad timer
+        # resolution on Windows
+        self.assertTrue(0.450 <= dt)
 
         # monotonic() is a monotonic but non adjustable clock
         info = time.get_clock_info('monotonic')
diff --git a/Misc/NEWS.d/next/Tests/2019-04-23-17-48-11.bpo-36454.0q4lQz.rst b/Misc/NEWS.d/next/Tests/2019-04-23-17-48-11.bpo-36454.0q4lQz.rst
new file mode 100644
index 000000000000..151c7ab04040
--- /dev/null
+++ b/Misc/NEWS.d/next/Tests/2019-04-23-17-48-11.bpo-36454.0q4lQz.rst
@@ -0,0 +1,3 @@
+Change test_time.test_monotonic() to test only the lower bound of elapsed time
+after a sleep command rather than the upper bound. This prevents unnecessary
+test failures on slow buildbots. Patch by Victor Stinner.



More information about the Python-checkins mailing list