Commit 76f02f35 authored by Denis Bilenko's avatar Denis Bilenko

test__api.py: make test cases clean up created objects

--HG--
extra : transplant_source : %E6%A5%A8X%3De%0B%06%F2%16%AA%0FZ%F9O%1F%01%A6L%B4
parent 58b2084e
......@@ -80,29 +80,27 @@ class Test(greentest.TestCase):
class TestTimers(greentest.TestCase):
def setUp(self):
greentest.TestCase.setUp(self)
self.lst = [1]
def test_timer_fired(self):
lst = [1]
def func():
gevent.spawn_later(0.01, lst.pop)
gevent.sleep(0.02)
gevent.spawn(func)
assert self.lst == [1], self.lst
assert lst == [1], lst
gevent.sleep(0.03)
assert self.lst == [], self.lst
assert lst == [], lst
def test_spawn_is_not_cancelled(self):
lst = [1]
def func():
gevent.spawn(self.lst.pop)
gevent.spawn(lst.pop)
# exiting immediatelly, but self.lst.pop must be called
gevent.spawn(func)
gevent.sleep(0.01)
assert self.lst == [], self.lst
assert lst == [], lst
if __name__ == '__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