Commit e94dcf35 authored by Denis Bilenko's avatar Denis Bilenko

greentest.py: make the wait/get tests sleep less

parent 5da10b9a
...@@ -251,14 +251,16 @@ gevent.hub.Hub = CountingHub ...@@ -251,14 +251,16 @@ gevent.hub.Hub = CountingHub
def test_outer_timeout_is_not_lost(self): def test_outer_timeout_is_not_lost(self):
timeout = gevent.Timeout.start_new(0.01) timeout = gevent.Timeout.start_new(0.001)
try: try:
self.wait(timeout=0.02) try:
except gevent.Timeout, ex: result = self.wait(timeout=1)
assert ex is timeout, (ex, timeout) except gevent.Timeout, ex:
else: assert ex is timeout, (ex, timeout)
raise AssertionError('must raise Timeout') else:
gevent.sleep(0.02) raise AssertionError('must raise Timeout (returned %r)' % (result, ))
finally:
timeout.cancel()
class GenericWaitTestCase(TestCase): class GenericWaitTestCase(TestCase):
...@@ -270,10 +272,10 @@ class GenericWaitTestCase(TestCase): ...@@ -270,10 +272,10 @@ class GenericWaitTestCase(TestCase):
def test_returns_none_after_timeout(self): def test_returns_none_after_timeout(self):
start = time.time() start = time.time()
result = self.wait(timeout=0.01) result = self.wait(timeout=0.001)
# join and wait simply returns after timeout expires # join and wait simply returns after timeout expires
delay = time.time() - start delay = time.time() - start
assert 0.01 - 0.001 <= delay < 0.01 + 0.01 + 0.1, delay assert 0.001 - 0.0001 <= delay < 0.001 + 0.001 + 0.01, delay
assert result is None, repr(result) assert result is None, repr(result)
......
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