Commit 73f87d78 authored by Denis Bilenko's avatar Denis Bilenko

rename test__switch_exc_info.py to test__exc_info.py; wrap test in unittest; add another test

--HG--
rename : greentest/test__switch_exc_info.py => greentest/test__exc_info.py
parent d9333d0a
import gevent
import sys
import greentest
class ExpectedError(Exception):
pass
expected_error = ExpectedError('expected exception in hello')
def hello():
assert sys.exc_info() == (None, None, None), sys.exc_info()
raise expected_error
error = Exception('hello')
class Test(greentest.TestCase):
def test1(self):
try:
raise error
except:
self.hook_stderr()
g = gevent.spawn(hello)
g.join()
self.assert_stderr_traceback(expected_error)
self.assert_stderr('<Greenlet at 0x[0-9a-f]+: hello> failed with ExpectedError')
if not isinstance(g.exception, ExpectedError):
raise g.exception
try:
raise
except Exception, ex:
assert ex is error, (ex, error)
def test2(self):
gevent.core.timer(0, hello)
self.hook_stderr()
gevent.sleep(0.1)
self.assert_stderr_traceback(expected_error)
assert sys.exc_info() == (None, None, None)
if __name__ == '__main__':
greentest.main()
import gevent
import sys
def hello():
assert sys.exc_info() == (None, None, None), sys.exc_info()
error = Exception('hello')
try:
raise error
except:
gevent.spawn(hello).join()
try:
raise
except Exception, ex:
assert ex is error, (ex, error)
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