summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_asyncio/test_events.py
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2014-02-07 22:34:58 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2014-02-07 22:34:58 (GMT)
commit85310a50a998af645acf0657737076eb064452bb (patch)
tree6b263f4a66877a3f9d824ba2744f87e8dfbbb141 /Lib/test/test_asyncio/test_events.py
parentc489e83432ef29c9c2a638c4ca290b308e5921e4 (diff)
downloadcpython-85310a50a998af645acf0657737076eb064452bb.zip
cpython-85310a50a998af645acf0657737076eb064452bb.tar.gz
cpython-85310a50a998af645acf0657737076eb064452bb.tar.bz2
Issue #20505: Remove resolution and _granularity from selectors and asyncio
* Remove selectors.BaseSelector.resolution attribute * Remove asyncio.BaseEventLoop._granularity attribute
Diffstat (limited to 'Lib/test/test_asyncio/test_events.py')
-rw-r--r--Lib/test/test_asyncio/test_events.py23
1 files changed, 7 insertions, 16 deletions
diff --git a/Lib/test/test_asyncio/test_events.py b/Lib/test/test_asyncio/test_events.py
index c11d20f..c2988c0 100644
--- a/Lib/test/test_asyncio/test_events.py
+++ b/Lib/test/test_asyncio/test_events.py
@@ -1170,28 +1170,19 @@ class EventLoopTestsMixin:
orig_run_once = self.loop._run_once
self.loop._run_once_counter = 0
self.loop._run_once = _run_once
- calls = []
@asyncio.coroutine
def wait():
loop = self.loop
- calls.append(loop._run_once_counter)
- yield from asyncio.sleep(loop._granularity * 10, loop=loop)
- calls.append(loop._run_once_counter)
- yield from asyncio.sleep(loop._granularity / 10, loop=loop)
- calls.append(loop._run_once_counter)
+ yield from asyncio.sleep(1e-2, loop=loop)
+ yield from asyncio.sleep(1e-4, loop=loop)
self.loop.run_until_complete(wait())
- 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)
+ # The ideal number of call is 6, but on some platforms, the selector
+ # may sleep at little bit less than timeout depending on the resolution
+ # of the clock used by the kernel. Tolerate 2 useless calls on these
+ # platforms.
+ self.assertLessEqual(self.loop._run_once_counter, 8)
class SubprocessTestsMixin: