Skip to content

Commit 65c216e

Browse files
authored
bpo-33723: Fix test_time.test_thread_time() (GH-10724)
Tolerate up to 30 ms, instead of 15 min, in other threads.
1 parent 433433f commit 65c216e

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

Lib/test/test_time.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,8 @@ def test_process_time(self):
496496
self.assertLess(stop - start, 0.020)
497497

498498
# bpo-33723: A busy loop of 100 ms should increase process_time()
499-
# by at least 15 ms
499+
# by at least 15 ms. Tolerate 15 ms because of the bad resolution of
500+
# the clock on Windows (around 15.6 ms).
500501
min_time = 0.015
501502
busy_time = 0.100
502503

@@ -534,8 +535,11 @@ def test_thread_time(self):
534535
self.assertLess(stop - start, 0.020)
535536

536537
# bpo-33723: A busy loop of 100 ms should increase thread_time()
537-
# by at least 15 ms
538+
# by at least 15 ms, but less than 30 ms in other threads.
539+
# Tolerate 15 and 30 ms because of the bad resolution
540+
# of the clock on Windows (around 15.6 ms).
538541
min_time = 0.015
542+
max_time = 0.030
539543
busy_time = 0.100
540544

541545
# thread_time() should include CPU time spent in current thread...
@@ -550,7 +554,7 @@ def test_thread_time(self):
550554
t.start()
551555
t.join()
552556
stop = time.thread_time()
553-
self.assertLess(stop - start, min_time)
557+
self.assertLess(stop - start, max_time)
554558

555559
info = time.get_clock_info('thread_time')
556560
self.assertTrue(info.monotonic)

0 commit comments

Comments
 (0)