[Python-checkins] cpython: Oops, undo unwanted changes in test_asyncio: mistakes of my the last sync with

victor.stinner python-checkins at python.org
Tue Feb 4 00:04:22 CET 2014


http://hg.python.org/cpython/rev/d7dc5ebc33ef
changeset:   88950:d7dc5ebc33ef
user:        Victor Stinner <victor.stinner at gmail.com>
date:        Mon Feb 03 23:59:52 2014 +0100
summary:
  Oops, undo unwanted changes in test_asyncio: mistakes of my the last sync with
Tulip (changeset d7ac90c0463a)

files:
  Lib/test/test_asyncio/test_base_events.py    |  15 +++++----
  Lib/test/test_asyncio/test_events.py         |   8 +++++
  Lib/test/test_asyncio/test_windows_events.py |   2 +-
  3 files changed, 17 insertions(+), 8 deletions(-)


diff --git a/Lib/test/test_asyncio/test_base_events.py b/Lib/test/test_asyncio/test_base_events.py
--- a/Lib/test/test_asyncio/test_base_events.py
+++ b/Lib/test/test_asyncio/test_base_events.py
@@ -116,17 +116,18 @@
             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():
diff --git a/Lib/test/test_asyncio/test_events.py b/Lib/test/test_asyncio/test_events.py
--- a/Lib/test/test_asyncio/test_events.py
+++ b/Lib/test/test_asyncio/test_events.py
@@ -1185,6 +1185,14 @@
         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:
 
diff --git a/Lib/test/test_asyncio/test_windows_events.py b/Lib/test/test_asyncio/test_windows_events.py
--- a/Lib/test/test_asyncio/test_windows_events.py
+++ b/Lib/test/test_asyncio/test_windows_events.py
@@ -105,7 +105,7 @@
         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)
 

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list