]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-36454: Fix test_time.test_monotonic() (GH-12929)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Tue, 23 Apr 2019 22:35:55 +0000 (15:35 -0700)
committerGitHub <noreply@github.com>
Tue, 23 Apr 2019 22:35:55 +0000 (15:35 -0700)
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@redhat.com>
Lib/test/test_time.py
Misc/NEWS.d/next/Tests/2019-04-23-17-48-11.bpo-36454.0q4lQz.rst [new file with mode: 0644]

index ea455c0d0d1300f434ee46119393c67ee4b0be35..4e31abf4ec8eec79af8c05086bd28b0c8f05a626 100644 (file)
@@ -470,8 +470,9 @@ class TimeTestCase(unittest.TestCase):
         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 (file)
index 0000000..151c7ab
--- /dev/null
@@ -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.