<s> import gevent <EOL> import sys <EOL> import greentest <EOL> import six <EOL> if not six . PY3 : <EOL> sys . exc_clear ( ) <EOL> class ExpectedError ( Exception ) : <EOL> pass <EOL> expected_error = ExpectedError ( '<STR_LIT>' ) <EOL> def hello ( ) : <EOL> assert sys . exc_info ( ) == ( None , None , None ) , sys . exc_info ( ) <EOL> raise expected_error <EOL> def hello2 ( ) : <EOL> try : <EOL> hello ( ) <EOL> except ExpectedError : <EOL> pass <EOL> error = Exception ( '<STR_LIT:hello>' ) <EOL> class Test ( greentest . TestCase ) : <EOL> def test1 ( self ) : <EOL> try : <EOL> raise error <EOL> except : <EOL> self . expect_one_error ( ) <EOL> g = gevent . spawn ( hello ) <EOL> g . join ( ) <EOL> self . assert_error ( ExpectedError , expected_error ) <EOL> if not isinstance ( g . exception , ExpectedError ) : <EOL> raise g . exception <EOL> try : <EOL> raise <EOL> except Exception : <EOL> ex = sys . exc_info ( ) [ <NUM_LIT:1> ] <EOL> assert ex is error , ( ex , error ) <EOL> def test2 ( self ) : <EOL> timer = gevent . get_hub ( ) . loop . timer ( <NUM_LIT:0> ) <EOL> timer . start ( hello2 ) <EOL> gevent . sleep ( <NUM_LIT:0.1> ) <EOL> assert sys . exc_info ( ) == ( None , None , None ) , sys . exc_info ( ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> greentest . main ( ) </s>
