added test for api.timeout that checks no references to the error object were leaked

This commit is contained in:
Denis Bilenko
2008-12-10 16:07:51 +06:00
parent 337ddd947c
commit b52925860d

View File

@@ -1,9 +1,13 @@
from __future__ import with_statement
import unittest
import weakref
import time
from eventlet.api import sleep, timeout, TimeoutError
DELAY = 0.01
class Error(Exception):
pass
class Test(unittest.TestCase):
def test_api(self):
@@ -64,6 +68,14 @@ class Test(unittest.TestCase):
delta = (time.time()-start)
assert delta<XDELAY*2, delta
def test_ref(self):
err = Error()
err_ref = weakref.ref(err)
with timeout(DELAY*2, err):
sleep(DELAY)
del err
assert not err_ref(), repr(err_ref())
def test_nested_timeout(self):
with timeout(DELAY, None):
with timeout(DELAY*2, None):