diff options
| author | Victor Stinner <vstinner@python.org> | 2023-10-02 19:35:29 (GMT) |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-10-02 19:35:29 (GMT) |
| commit | 0745ab88e502b56ca9a87cb6dd9cd1a23b53658a (patch) | |
| tree | 4c72eebfa7fecbfc4f7d0025f738bae7c9d80198 /Lib/test/test_asyncio/test_windows_events.py | |
| parent | c188a13c8ed3605e57caf6aa1783833f386e1c76 (diff) | |
| download | cpython-0745ab88e502b56ca9a87cb6dd9cd1a23b53658a.zip cpython-0745ab88e502b56ca9a87cb6dd9cd1a23b53658a.tar.gz cpython-0745ab88e502b56ca9a87cb6dd9cd1a23b53658a.tar.bz2 | |
[3.12] gh-110088, gh-109878: Fix test_asyncio timeouts (#110092) (#110098)
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.
(cherry picked from commit db0a258e796703e12befea9d6dec04e349ca2f5b)
Diffstat (limited to 'Lib/test/test_asyncio/test_windows_events.py')
| -rw-r--r-- | Lib/test/test_asyncio/test_windows_events.py | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/Lib/test/test_asyncio/test_windows_events.py b/Lib/test/test_asyncio/test_windows_events.py index a36119a..6e6c90a 100644 --- a/Lib/test/test_asyncio/test_windows_events.py +++ b/Lib/test/test_asyncio/test_windows_events.py @@ -163,29 +163,25 @@ class ProactorTests(test_utils.TestCase): # Wait for unset event with 0.5s timeout; # result should be False at timeout - fut = self.loop._proactor.wait_for_handle(event, 0.5) + timeout = 0.5 + fut = self.loop._proactor.wait_for_handle(event, timeout) start = self.loop.time() done = self.loop.run_until_complete(fut) elapsed = self.loop.time() - start self.assertEqual(done, False) self.assertFalse(fut.result()) - # bpo-31008: Tolerate only 450 ms (at least 500 ms expected), - # because of bad clock resolution on Windows - self.assertTrue(0.45 <= elapsed <= 0.9, elapsed) + self.assertGreaterEqual(elapsed, timeout - test_utils.CLOCK_RES) _overlapped.SetEvent(event) # Wait for set event; # result should be True immediately fut = self.loop._proactor.wait_for_handle(event, 10) - start = self.loop.time() done = self.loop.run_until_complete(fut) - elapsed = self.loop.time() - start self.assertEqual(done, True) self.assertTrue(fut.result()) - self.assertTrue(0 <= elapsed < 0.3, elapsed) # asyncio issue #195: cancelling a done _WaitHandleFuture # must not crash @@ -199,11 +195,8 @@ class ProactorTests(test_utils.TestCase): # CancelledError should be raised immediately fut = self.loop._proactor.wait_for_handle(event, 10) fut.cancel() - start = self.loop.time() with self.assertRaises(asyncio.CancelledError): self.loop.run_until_complete(fut) - elapsed = self.loop.time() - start - self.assertTrue(0 <= elapsed < 0.1, elapsed) # asyncio issue #195: cancelling a _WaitHandleFuture twice # must not crash |
