Commit 684f07cc authored by Denis Bilenko's avatar Denis Bilenko

add test__timeout.py

parent bd2c5966
import greentest
import gevent
DELAY = 0.01
class Test(greentest.TestCase):
def test_direct_raise_class(self):
try:
raise gevent.Timeout
except gevent.Timeout, t:
assert not t.pending, repr(t)
def test_direct_raise_instance(self):
timeout = gevent.Timeout()
try:
raise timeout
except gevent.Timeout, t:
assert timeout is t, (timeout, t)
assert not t.pending, repr(t)
def test_with_timeout(self):
self.assertRaises(gevent.Timeout, gevent.with_timeout, DELAY, gevent.sleep, DELAY*2)
X = object()
r = gevent.with_timeout(DELAY, gevent.sleep, DELAY*2, timeout_value=X)
assert r is X, (r, X)
r = gevent.with_timeout(DELAY*2, gevent.sleep, DELAY, timeout_value=X)
assert r is None, r
if __name__=='__main__':
greentest.main()
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