Issue #20452: Fix test_time_and_call_at() of test_asyncio on Windows
authorVictor Stinner <victor.stinner@gmail.com>
Sat, 1 Feb 2014 01:18:52 +0000 (02:18 +0100)
committerVictor Stinner <victor.stinner@gmail.com>
Sat, 1 Feb 2014 01:18:52 +0000 (02:18 +0100)
Use the granularity to check the minimum time delta, instead of arbitrary
value.

Lib/test/test_asyncio/test_base_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():