Commit 15560a83 authored by Heungsub Lee's avatar Heungsub Lee

More test cases to prevent side-effect of #607 fix

parent b58abeea
...@@ -7,16 +7,30 @@ class ExpectedError(greentest.ExpectedException): ...@@ -7,16 +7,30 @@ class ExpectedError(greentest.ExpectedException):
pass pass
def f():
gevent.sleep(999)
class TestKillWithException(greentest.TestCase): class TestKillWithException(greentest.TestCase):
def test_kill_without_exception(self): def test_kill_without_exception(self):
g = gevent.spawn() g = gevent.spawn(f)
g.kill() g.kill()
assert g.successful() assert g.successful()
assert isinstance(g.get(), gevent.GreenletExit) assert isinstance(g.get(), gevent.GreenletExit)
def test_kill_with_exception(self): def test_kill_with_exception(self):
g = gevent.spawn() # issue-607 pointed this case.
g = gevent.spawn(f)
g.kill(ExpectedError)
assert not g.successful()
self.assertRaises(ExpectedError, g.get)
assert g.value is None
assert isinstance(g.exception, ExpectedError)
def test_kill_with_exception_after_started(self):
g = gevent.spawn(f)
g.join(0)
g.kill(ExpectedError) g.kill(ExpectedError)
assert not g.successful() assert not g.successful()
self.assertRaises(ExpectedError, g.get) self.assertRaises(ExpectedError, g.get)
......
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