]> granicus.if.org Git - python/commitdiff
Oops, undo unwanted changes in test_asyncio: mistakes of my the last sync with
authorVictor Stinner <victor.stinner@gmail.com>
Mon, 3 Feb 2014 22:59:52 +0000 (23:59 +0100)
committerVictor Stinner <victor.stinner@gmail.com>
Mon, 3 Feb 2014 22:59:52 +0000 (23:59 +0100)
Tulip (changeset d7ac90c0463a)

Lib/test/test_asyncio/test_base_events.py
Lib/test/test_asyncio/test_events.py
Lib/test/test_asyncio/test_windows_events.py

index 72f5c8a0b427c2ddd287ebf7c85a808151aef04f..1db772331d489ae62dc3c443185eb75ed951d6c3 100644 (file)
@@ -116,17 +116,18 @@ class BaseEventLoopTests(unittest.TestCase):
             self.loop.stop()
 
         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)
         t0 = self.loop.time()
         self.loop.run_forever()
         dt = self.loop.time() - t0
-        self.assertTrue(0.09 <= dt <= 0.9,
-                        # Issue #20452: add more info in case of failure,
-                        # to try to investigate the bug
-                        (dt,
-                         self.loop._granularity,
-                         time.get_clock_info('monotonic')))
+
+        self.assertGreaterEqual(dt, delay - self.loop._granularity, dt)
+        # tolerate a difference of +800 ms because some Python buildbots
+        # are really slow
+        self.assertLessEqual(dt, 0.9, dt)
 
     def test_run_once_in_executor_handle(self):
         def cb():
index 5158430fced6676cb4380ea23b2d25a9f532e59a..c11d20f9be2754c7677952ec564164a30aab2554 100644 (file)
@@ -1185,6 +1185,14 @@ class EventLoopTestsMixin:
         calls.append(self.loop._run_once_counter)
         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:
 
index 3c271ebeec07c6fee0ee3c84c73e1286150d9f9d..846049a245a72c1a9530dfc6012317200adc8958 100644 (file)
@@ -105,7 +105,7 @@ class ProactorTests(unittest.TestCase):
         self.loop.run_until_complete(f)
         elapsed = self.loop.time() - start
         self.assertFalse(f.result())
-        self.assertTrue(0.18 < elapsed < 0.5, elapsed)
+        self.assertTrue(0.18 < elapsed < 0.9, elapsed)
 
         _overlapped.SetEvent(event)