Commit 7e530ea8 authored by Victor Stinner's avatar Victor Stinner

Oops, undo unwanted changes in test_asyncio: mistakes of my the last sync with

Tulip (changeset d7ac90c0463a)
parent 10f3fafb
...@@ -116,17 +116,18 @@ class BaseEventLoopTests(unittest.TestCase): ...@@ -116,17 +116,18 @@ class BaseEventLoopTests(unittest.TestCase):
self.loop.stop() self.loop.stop()
self.loop._process_events = unittest.mock.Mock() self.loop._process_events = unittest.mock.Mock()
when = self.loop.time() + 0.1 delay = 0.1
when = self.loop.time() + delay
self.loop.call_at(when, cb) self.loop.call_at(when, cb)
t0 = self.loop.time() t0 = self.loop.time()
self.loop.run_forever() self.loop.run_forever()
dt = self.loop.time() - t0 dt = self.loop.time() - t0
self.assertTrue(0.09 <= dt <= 0.9,
# Issue #20452: add more info in case of failure, self.assertGreaterEqual(dt, delay - self.loop._granularity, dt)
# to try to investigate the bug # tolerate a difference of +800 ms because some Python buildbots
(dt, # are really slow
self.loop._granularity, self.assertLessEqual(dt, 0.9, dt)
time.get_clock_info('monotonic')))
def test_run_once_in_executor_handle(self): def test_run_once_in_executor_handle(self):
def cb(): def cb():
......
...@@ -1185,6 +1185,14 @@ class EventLoopTestsMixin: ...@@ -1185,6 +1185,14 @@ class EventLoopTestsMixin:
calls.append(self.loop._run_once_counter) calls.append(self.loop._run_once_counter)
self.assertEqual(calls, [1, 3, 5, 6]) self.assertEqual(calls, [1, 3, 5, 6])
def test_granularity(self):
granularity = self.loop._granularity
self.assertGreater(granularity, 0.0)
# Worst expected granularity: 1 ms on Linux (limited by poll/epoll
# resolution), 15.6 ms on Windows (limited by time.monotonic
# resolution)
self.assertLess(granularity, 0.050)
class SubprocessTestsMixin: class SubprocessTestsMixin:
......
...@@ -105,7 +105,7 @@ class ProactorTests(unittest.TestCase): ...@@ -105,7 +105,7 @@ class ProactorTests(unittest.TestCase):
self.loop.run_until_complete(f) self.loop.run_until_complete(f)
elapsed = self.loop.time() - start elapsed = self.loop.time() - start
self.assertFalse(f.result()) self.assertFalse(f.result())
self.assertTrue(0.18 < elapsed < 0.5, elapsed) self.assertTrue(0.18 < elapsed < 0.9, elapsed)
_overlapped.SetEvent(event) _overlapped.SetEvent(event)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment