[3.11] gh-110088, gh-109878: Fix test_asyncio timeouts (#110092) (#110099)

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:
Victor Stinner 2023-09-29 14:16:15 +02:00 committed by GitHub
parent d81bcc2327
commit 184ce1414b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 19 additions and 54 deletions

View file

@ -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)