aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/test/test_asyncio/test_waitfor.py
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2023-09-29 13:49:30 +0200
committerGitHub <noreply@github.com>2023-09-29 11:49:30 +0000
commitdb0a258e796703e12befea9d6dec04e349ca2f5b (patch)
tree2f64962f2798a8b06bb22a38ce56eab7fc8683eb /Lib/test/test_asyncio/test_waitfor.py
parente27adc68ccee8345e05b7516e6b46f6c7ff53371 (diff)
downloadcpython-db0a258e796703e12befea9d6dec04e349ca2f5b.tar.gz
cpython-db0a258e796703e12befea9d6dec04e349ca2f5b.zip
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_waitfor.py')
-rw-r--r--Lib/test/test_asyncio/test_waitfor.py15
1 files changed, 0 insertions, 15 deletions
diff --git a/Lib/test/test_asyncio/test_waitfor.py b/Lib/test/test_asyncio/test_waitfor.py
index e714b154c5c..d52f32534a0 100644
--- a/Lib/test/test_asyncio/test_waitfor.py
+++ b/Lib/test/test_asyncio/test_waitfor.py
@@ -66,17 +66,12 @@ class AsyncioWaitForTest(unittest.IsolatedAsyncioTestCase):
fut = loop.create_future()
fut.set_result('done')
- t0 = loop.time()
ret = await asyncio.wait_for(fut, 0)
- t1 = loop.time()
self.assertEqual(ret, 'done')
self.assertTrue(fut.done())
- self.assertLess(t1 - t0, 0.1)
async def test_wait_for_timeout_less_then_0_or_0_coroutine_do_not_started(self):
- loop = asyncio.get_running_loop()
-
foo_started = False
async def foo():
@@ -84,12 +79,9 @@ class AsyncioWaitForTest(unittest.IsolatedAsyncioTestCase):
foo_started = True
with self.assertRaises(asyncio.TimeoutError):
- t0 = loop.time()
await asyncio.wait_for(foo(), 0)
- t1 = loop.time()
self.assertEqual(foo_started, False)
- self.assertLess(t1 - t0, 0.1)
async def test_wait_for_timeout_less_then_0_or_0(self):
loop = asyncio.get_running_loop()
@@ -113,18 +105,14 @@ class AsyncioWaitForTest(unittest.IsolatedAsyncioTestCase):
await started
with self.assertRaises(asyncio.TimeoutError):
- t0 = loop.time()
await asyncio.wait_for(fut, timeout)
- t1 = loop.time()
self.assertTrue(fut.done())
# it should have been cancelled due to the timeout
self.assertTrue(fut.cancelled())
self.assertEqual(foo_running, False)
- self.assertLess(t1 - t0, 0.1)
async def test_wait_for(self):
- loop = asyncio.get_running_loop()
foo_running = None
async def foo():
@@ -139,13 +127,10 @@ class AsyncioWaitForTest(unittest.IsolatedAsyncioTestCase):
fut = asyncio.create_task(foo())
with self.assertRaises(asyncio.TimeoutError):
- t0 = loop.time()
await asyncio.wait_for(fut, 0.1)
- t1 = loop.time()
self.assertTrue(fut.done())
# it should have been cancelled due to the timeout
self.assertTrue(fut.cancelled())
- self.assertLess(t1 - t0, support.SHORT_TIMEOUT)
self.assertEqual(foo_running, False)
async def test_wait_for_blocking(self):