Commit 701af4e5 authored by Jason Madden's avatar Jason Madden

test_hub_join_timeout under libuv: tolerances are not as tight, apparently, at...

test_hub_join_timeout under libuv: tolerances are not as tight, apparently, at least on OS X/kqueue.
parent a54cad97
from contextlib import contextmanager from contextlib import contextmanager
import gevent import gevent
import gevent.core
from gevent.event import Event from gevent.event import Event
from time import time from time import time
from _six import xrange from _six import xrange
...@@ -12,6 +13,8 @@ FUZZY = SMALL / 2 ...@@ -12,6 +13,8 @@ FUZZY = SMALL / 2
gevent.signal(1, lambda: None) # wouldn't work on windows gevent.signal(1, lambda: None) # wouldn't work on windows
from greentest import EXPECT_POOR_TIMER_RESOLUTION from greentest import EXPECT_POOR_TIMER_RESOLUTION
EXPECT_POOR_TIMER_RESOLUTION = EXPECT_POOR_TIMER_RESOLUTION or hasattr(gevent.core, 'libuv')
# We observe longer/jittery timeouts running on appveyor or running with libuv
@contextmanager @contextmanager
def expected_time(expected, fuzzy=None): def expected_time(expected, fuzzy=None):
...@@ -27,6 +30,7 @@ def expected_time(expected, fuzzy=None): ...@@ -27,6 +30,7 @@ def expected_time(expected, fuzzy=None):
assert expected - fuzzy <= elapsed <= expected + fuzzy, 'Expected: %r; elapsed: %r; fuzzy %r' % (expected, elapsed, fuzzy) assert expected - fuzzy <= elapsed <= expected + fuzzy, 'Expected: %r; elapsed: %r; fuzzy %r' % (expected, elapsed, fuzzy)
def no_time(fuzzy=(0.001 if not EXPECT_POOR_TIMER_RESOLUTION else 1.0)): def no_time(fuzzy=(0.001 if not EXPECT_POOR_TIMER_RESOLUTION else 1.0)):
return expected_time(0, fuzzy=fuzzy) return expected_time(0, fuzzy=fuzzy)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment