mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
gh-110088, gh-109878: Fix test_asyncio timeouts (#110092)
Fix test_asyncio timeouts: don't measure the maximum duration, a test
should not measure a CI performance. Only measure the minimum
duration when a task has a timeout or delay. Add CLOCK_RES to
test_asyncio.utils.
(cherry picked from commit db0a258e79
)
This commit is contained in:
parent
d81bcc2327
commit
184ce1414b
7 changed files with 19 additions and 54 deletions
|
@ -294,10 +294,11 @@ class EventLoopTestsMixin:
|
|||
# 15.6 msec, we use fairly long sleep times here (~100 msec).
|
||||
|
||||
def test_run_until_complete(self):
|
||||
delay = 0.100
|
||||
t0 = self.loop.time()
|
||||
self.loop.run_until_complete(asyncio.sleep(0.1))
|
||||
t1 = self.loop.time()
|
||||
self.assertTrue(0.08 <= t1-t0 <= 0.8, t1-t0)
|
||||
self.loop.run_until_complete(asyncio.sleep(delay))
|
||||
dt = self.loop.time() - t0
|
||||
self.assertGreaterEqual(dt, delay - test_utils.CLOCK_RES)
|
||||
|
||||
def test_run_until_complete_stopped(self):
|
||||
|
||||
|
@ -1695,7 +1696,6 @@ class EventLoopTestsMixin:
|
|||
self.loop._run_once = _run_once
|
||||
|
||||
async def wait():
|
||||
loop = self.loop
|
||||
await asyncio.sleep(1e-2)
|
||||
await asyncio.sleep(1e-4)
|
||||
await asyncio.sleep(1e-6)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue