summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2014-02-07 23:36:32 +0100
committerVictor Stinner <victor.stinner@gmail.com>2014-02-07 23:36:32 +0100
commit757189c319ac2e8108a232d211703fbf2283dbad (patch)
tree64967c88facc03ccd7a91117bd0fb730aa348c3f /tests
parent9cf186282bee509a646104339176c0eef7c770fb (diff)
downloadtrollius-757189c319ac2e8108a232d211703fbf2283dbad.tar.gz
Remove resolution and _granularity from selectors and asyncio
* Remove selectors.BaseSelector.resolution attribute * Remove asyncio.BaseEventLoop._granularity attribute
Diffstat (limited to 'tests')
-rw-r--r--tests/test_base_events.py3
-rw-r--r--tests/test_events.py23
2 files changed, 9 insertions, 17 deletions
diff --git a/tests/test_base_events.py b/tests/test_base_events.py
index 0d90d3f..5b05684 100644
--- a/tests/test_base_events.py
+++ b/tests/test_base_events.py
@@ -124,7 +124,8 @@ class BaseEventLoopTests(unittest.TestCase):
self.loop.run_forever()
dt = self.loop.time() - t0
- self.assertGreaterEqual(dt, delay - self.loop._granularity, dt)
+ # 50 ms: maximum granularity of the event loop
+ self.assertGreaterEqual(dt, delay - 0.050, dt)
# tolerate a difference of +800 ms because some Python buildbots
# are really slow
self.assertLessEqual(dt, 0.9, dt)
diff --git a/tests/test_events.py b/tests/test_events.py
index c11d20f..c2988c0 100644
--- a/tests/test_events.py
+++ b/tests/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: