]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.11] gh-109833: Fix asyncio test_wait_for() (GH-109834) (#109838)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Mon, 25 Sep 2023 14:22:41 +0000 (07:22 -0700)
committerGitHub <noreply@github.com>
Mon, 25 Sep 2023 14:22:41 +0000 (16:22 +0200)
gh-109833: Fix asyncio test_wait_for() (GH-109834)

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.
(cherry picked from commit f29bc9c9a0a6794c6b8a9e84a7ba9237b427a10a)

Co-authored-by: Victor Stinner <vstinner@python.org>
Lib/test/test_asyncio/test_waitfor.py

index 45498fa097f6bccab7c7e3781fdd4f857c334a75..07dbab3b39ca2b01fb09f80696b14cd8c47cd9bc 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):