bpo-33723: Fix test_time.test_thread_time() (GH-8267) · python/cpython@d6345de
@@ -529,19 +529,24 @@ def test_thread_time(self):
529529# on Windows
530530self.assertLess(stop - start, 0.020)
531531532+# bpo-33723: A busy loop of 100 ms should increase thread_time()
533+# by at least 15 ms
534+min_time = 0.015
535+busy_time = 0.100
536+532537# thread_time() should include CPU time spent in current thread...
533538start = time.thread_time()
534-busy_wait(0.100)
539+busy_wait(busy_time)
535540stop = time.thread_time()
536-self.assertGreaterEqual(stop - start, 0.020) # machine busy?
541+self.assertGreaterEqual(stop - start, min_time)
537542538543# ...but not in other threads
539-t = threading.Thread(target=busy_wait, args=(0.100,))
544+t = threading.Thread(target=busy_wait, args=(busy_time,))
540545start = time.thread_time()
541546t.start()
542547t.join()
543548stop = time.thread_time()
544-self.assertLess(stop - start, 0.020)
549+self.assertLess(stop - start, min_time)
545550546551info = time.get_clock_info('thread_time')
547552self.assertTrue(info.monotonic)