Commit 5fd7fdcf authored by Denis Bilenko's avatar Denis Bilenko

test__greenlet.py: add test for join(); use GenericWaitTestCase

parent 72503017
......@@ -23,7 +23,6 @@ import sys
import greentest
import gevent
import re
import time
from gevent import sleep, with_timeout, getcurrent
from gevent import greenlet
from gevent.event import Event, AsyncResult
......@@ -508,25 +507,15 @@ class TestStr(greentest.TestCase):
self.assertEqual(hexobj.sub('X', str(g)), '<Greenlet at X: <bound method A.method of <__main__.A object at X>>>')
class TestJoinAll(greentest.TestCase):
class TestJoin(greentest.GenericWaitTestCase):
def test_outer_timeout_is_not_lost(self):
t = gevent.Timeout.start_new(0.01)
try:
gevent.joinall([gevent.spawn(gevent.sleep, 10)], timeout=0.02)
except gevent.Timeout, ex:
assert ex is t, (ex, t)
else:
raise AssertionError('must raise Timeout')
gevent.sleep(0.02)
def wait(self, timeout):
gevent.spawn(gevent.sleep, 10).join(timeout=timeout)
def test_returns_after_timeout(self):
start = time.time()
gevent.joinall([gevent.spawn(gevent.sleep, 10)], timeout=0.01)
# joinall simply returns after timeout expires
delay = time.time() - start
assert 0.01 <= delay < 0.01 + 0.01, delay
class TestJoinAll(greentest.GenericWaitTestCase):
def wait(self, timeout):
gevent.joinall([gevent.spawn(gevent.sleep, 10)], timeout=timeout)
def assert_ready(g):
......
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