[3.11] gh-110088, gh-109878: Fix test_asyncio timeouts (#110092) (#110099)

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 db0a258e79)
This commit is contained in:
Victor Stinner 2023-09-29 14:16:15 +02:00 committed by GitHub
parent d81bcc2327
commit 184ce1414b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 19 additions and 54 deletions

View file

@ -273,7 +273,7 @@ class BaseEventLoopTests(test_utils.TestCase):
self.loop.stop()
self.loop._process_events = mock.Mock()
delay = 0.1
delay = 0.100
when = self.loop.time() + delay
self.loop.call_at(when, cb)
@ -282,10 +282,7 @@ class BaseEventLoopTests(test_utils.TestCase):
dt = self.loop.time() - t0
# 50 ms: maximum granularity of the event loop
self.assertGreaterEqual(dt, delay - 0.050, dt)
# tolerate a difference of +800 ms because some Python buildbots
# are really slow
self.assertLessEqual(dt, 0.9, dt)
self.assertGreaterEqual(dt, delay - test_utils.CLOCK_RES)
with self.assertRaises(TypeError, msg="when cannot be None"):
self.loop.call_at(None, cb)