From 337ddd947c23d0c427b8483715fff0123127c04e Mon Sep 17 00:00:00 2001 From: Denis Bilenko Date: Wed, 10 Dec 2008 16:06:39 +0600 Subject: [PATCH] added 'throw_args' test for api.timeout --- greentest/test__api_timeout.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/greentest/test__api_timeout.py b/greentest/test__api_timeout.py index 5355950..ad3d93d 100644 --- a/greentest/test__api_timeout.py +++ b/greentest/test__api_timeout.py @@ -35,6 +35,20 @@ class Test(unittest.TestCase): except ValueError: pass + # basically, anything that greenlet.throw accepts work: + try: + 1/0 + except: + try: + with timeout(DELAY, *sys.exc_info()): + sleep(DELAY*2) + assert 'should not get there' + assert 'should not get there' + except ZeroDivisionError: + pass + else: + assert 'should not get there' + # It's possible to cancel the timer inside the block: with timeout(DELAY) as timer: timer.cancel()