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.
This commit is contained in:
Victor Stinner 2019-04-24 00:15:12 +02:00 committed by GitHub
parent 29d018aa63
commit d246a6766b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions

View 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')

View File

@ -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.