]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-109833: Fix asyncio test_wait_for() (#109834)
authorVictor Stinner <vstinner@python.org>
Mon, 25 Sep 2023 13:27:36 +0000 (15:27 +0200)
committerGitHub <noreply@github.com>
Mon, 25 Sep 2023 13:27:36 +0000 (13:27 +0000)
Expect the test to be "short" but don't measure the exact performance
of the CI. SHORT_TIMEOUT is about 30 seconds whereas the cancelled
coroutine takes around 1 hour.

Lib/test/test_asyncio/test_waitfor.py

index d5c02ba4a01df994f60696865c4302273b89f072..e714b154c5cadfc727e0d5090b37e124d9007460 100644 (file)
@@ -1,6 +1,7 @@
 import asyncio
 import unittest
 import time
+from test import support
 
 
 def tearDownModule():
@@ -130,7 +131,7 @@ class AsyncioWaitForTest(unittest.IsolatedAsyncioTestCase):
             nonlocal foo_running
             foo_running = True
             try:
-                await asyncio.sleep(10)
+                await asyncio.sleep(support.LONG_TIMEOUT)
             finally:
                 foo_running = False
             return 'done'
@@ -144,7 +145,7 @@ class AsyncioWaitForTest(unittest.IsolatedAsyncioTestCase):
         self.assertTrue(fut.done())
         # it should have been cancelled due to the timeout
         self.assertTrue(fut.cancelled())
-        self.assertLess(t1 - t0, 0.5)
+        self.assertLess(t1 - t0, support.SHORT_TIMEOUT)
         self.assertEqual(foo_running, False)
 
     async def test_wait_for_blocking(self):