Skip to content

Commit d246a67

Browse files
authored
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.
1 parent 29d018a commit d246a67

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

Lib/test/test_time.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -470,8 +470,9 @@ def test_monotonic(self):
470470
t2 = time.monotonic()
471471
dt = t2 - t1
472472
self.assertGreater(t2, t1)
473-
# Issue #20101: On some Windows machines, dt may be slightly low
474-
self.assertTrue(0.45 <= dt <= 1.0, dt)
473+
# bpo-20101: tolerate a difference of 50 ms because of bad timer
474+
# resolution on Windows
475+
self.assertTrue(0.450 <= dt)
475476

476477
# monotonic() is a monotonic but non adjustable clock
477478
info = time.get_clock_info('monotonic')
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Change test_time.test_monotonic() to test only the lower bound of elapsed time
2+
after a sleep command rather than the upper bound. This prevents unnecessary
3+
test failures on slow buildbots. Patch by Victor Stinner.

0 commit comments

Comments
 (0)