Skip to content

Commit e78dace

Browse files
authored
bpo-33723: Fix test_time.test_process_time() (GH-8358)
The test failed on my laptop because the busy loop took 15.9 ms whereas the test expects at least 20 ms. Modify test_process_time() as test_thread_time() has been modified recently: only require 15 ms instead of 20 ms.
1 parent b1147e4 commit e78dace

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

Lib/test/test_time.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -496,18 +496,23 @@ def test_process_time(self):
496496
# on Windows
497497
self.assertLess(stop - start, 0.020)
498498

499+
# bpo-33723: A busy loop of 100 ms should increase process_time()
500+
# by at least 15 ms
501+
min_time = 0.015
502+
busy_time = 0.100
503+
499504
# process_time() should include CPU time spent in any thread
500505
start = time.process_time()
501-
busy_wait(0.100)
506+
busy_wait(busy_time)
502507
stop = time.process_time()
503-
self.assertGreaterEqual(stop - start, 0.020) # machine busy?
508+
self.assertGreaterEqual(stop - start, min_time)
504509

505-
t = threading.Thread(target=busy_wait, args=(0.100,))
510+
t = threading.Thread(target=busy_wait, args=(busy_time,))
506511
start = time.process_time()
507512
t.start()
508513
t.join()
509514
stop = time.process_time()
510-
self.assertGreaterEqual(stop - start, 0.020) # machine busy?
515+
self.assertGreaterEqual(stop - start, min_time)
511516

512517
info = time.get_clock_info('process_time')
513518
self.assertTrue(info.monotonic)

0 commit comments

Comments
 (0)