diff options
author | Victor Stinner <vstinner@python.org> | 2023-09-29 13:49:30 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-29 11:49:30 +0000 |
commit | db0a258e796703e12befea9d6dec04e349ca2f5b (patch) | |
tree | 2f64962f2798a8b06bb22a38ce56eab7fc8683eb /Lib/test/test_asyncio/test_timeouts.py | |
parent | e27adc68ccee8345e05b7516e6b46f6c7ff53371 (diff) | |
download | cpython-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_timeouts.py')
-rw-r--r-- | Lib/test/test_asyncio/test_timeouts.py | 20 |
1 files changed, 0 insertions, 20 deletions
diff --git a/Lib/test/test_asyncio/test_timeouts.py b/Lib/test/test_asyncio/test_timeouts.py index 8b6b9a1fea0..e9b59b95351 100644 --- a/Lib/test/test_asyncio/test_timeouts.py +++ b/Lib/test/test_asyncio/test_timeouts.py @@ -46,7 +46,6 @@ class TimeoutTests(unittest.IsolatedAsyncioTestCase): self.assertTrue(cm2.expired()) async def test_waiter_cancelled(self): - loop = asyncio.get_running_loop() cancelled = False with self.assertRaises(TimeoutError): async with asyncio.timeout(0.01): @@ -59,39 +58,26 @@ class TimeoutTests(unittest.IsolatedAsyncioTestCase): async def test_timeout_not_called(self): loop = asyncio.get_running_loop() - t0 = loop.time() async with asyncio.timeout(10) as cm: await asyncio.sleep(0.01) t1 = loop.time() self.assertFalse(cm.expired()) - # 2 sec for slow CI boxes - self.assertLess(t1-t0, 2) self.assertGreater(cm.when(), t1) async def test_timeout_disabled(self): - loop = asyncio.get_running_loop() - t0 = loop.time() async with asyncio.timeout(None) as cm: await asyncio.sleep(0.01) - t1 = loop.time() self.assertFalse(cm.expired()) self.assertIsNone(cm.when()) - # 2 sec for slow CI boxes - self.assertLess(t1-t0, 2) async def test_timeout_at_disabled(self): - loop = asyncio.get_running_loop() - t0 = loop.time() async with asyncio.timeout_at(None) as cm: await asyncio.sleep(0.01) - t1 = loop.time() self.assertFalse(cm.expired()) self.assertIsNone(cm.when()) - # 2 sec for slow CI boxes - self.assertLess(t1-t0, 2) async def test_timeout_zero(self): loop = asyncio.get_running_loop() @@ -101,8 +87,6 @@ class TimeoutTests(unittest.IsolatedAsyncioTestCase): await asyncio.sleep(10) t1 = loop.time() self.assertTrue(cm.expired()) - # 2 sec for slow CI boxes - self.assertLess(t1-t0, 2) self.assertTrue(t0 <= cm.when() <= t1) async def test_timeout_zero_sleep_zero(self): @@ -113,8 +97,6 @@ class TimeoutTests(unittest.IsolatedAsyncioTestCase): await asyncio.sleep(0) t1 = loop.time() self.assertTrue(cm.expired()) - # 2 sec for slow CI boxes - self.assertLess(t1-t0, 2) self.assertTrue(t0 <= cm.when() <= t1) async def test_timeout_in_the_past_sleep_zero(self): @@ -125,8 +107,6 @@ class TimeoutTests(unittest.IsolatedAsyncioTestCase): await asyncio.sleep(0) t1 = loop.time() self.assertTrue(cm.expired()) - # 2 sec for slow CI boxes - self.assertLess(t1-t0, 2) self.assertTrue(t0 >= cm.when() <= t1) async def test_foreign_exception_passed(self): |