summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_asyncio/test_events.py
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2023-09-29 11:49:30 (GMT)
committerGitHub <noreply@github.com>2023-09-29 11:49:30 (GMT)
commitdb0a258e796703e12befea9d6dec04e349ca2f5b (patch)
tree2f64962f2798a8b06bb22a38ce56eab7fc8683eb /Lib/test/test_asyncio/test_events.py
parente27adc68ccee8345e05b7516e6b46f6c7ff53371 (diff)
downloadcpython-db0a258e796703e12befea9d6dec04e349ca2f5b.zip
cpython-db0a258e796703e12befea9d6dec04e349ca2f5b.tar.gz
cpython-db0a258e796703e12befea9d6dec04e349ca2f5b.tar.bz2
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.
Diffstat (limited to 'Lib/test/test_asyncio/test_events.py')
-rw-r--r--Lib/test/test_asyncio/test_events.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/Lib/test/test_asyncio/test_events.py b/Lib/test/test_asyncio/test_events.py
index f22cb5e..3ee6565 100644
--- a/Lib/test/test_asyncio/test_events.py
+++ b/Lib/test/test_asyncio/test_events.py
@@ -293,10 +293,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):
@@ -1717,7 +1718,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)