mirror of
https://github.com/python/cpython.git
synced 2025-11-13 07:26:31 +00:00
Issue #20452: Fix test_time_and_call_at() of test_asyncio on Windows
Use the granularity to check the minimum time delta, instead of arbitrary value.
This commit is contained in:
parent
1144214639
commit
55effc6dd0
1 changed files with 8 additions and 7 deletions
|
|
@ -116,17 +116,18 @@ class BaseEventLoopTests(unittest.TestCase):
|
||||||
self.loop.stop()
|
self.loop.stop()
|
||||||
|
|
||||||
self.loop._process_events = unittest.mock.Mock()
|
self.loop._process_events = unittest.mock.Mock()
|
||||||
when = self.loop.time() + 0.1
|
delay = 0.1
|
||||||
|
|
||||||
|
when = self.loop.time() + delay
|
||||||
self.loop.call_at(when, cb)
|
self.loop.call_at(when, cb)
|
||||||
t0 = self.loop.time()
|
t0 = self.loop.time()
|
||||||
self.loop.run_forever()
|
self.loop.run_forever()
|
||||||
dt = self.loop.time() - t0
|
dt = self.loop.time() - t0
|
||||||
self.assertTrue(0.09 <= dt <= 0.9,
|
|
||||||
# Issue #20452: add more info in case of failure,
|
self.assertGreaterEqual(dt, delay - self.loop._granularity, dt)
|
||||||
# to try to investigate the bug
|
# tolerate a difference of +800 ms because some Python buildbots
|
||||||
(dt,
|
# are really slow
|
||||||
self.loop._granularity,
|
self.assertLessEqual(dt, 0.9, dt)
|
||||||
time.get_clock_info('monotonic')))
|
|
||||||
|
|
||||||
def test_run_once_in_executor_handle(self):
|
def test_run_once_in_executor_handle(self):
|
||||||
def cb():
|
def cb():
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue