#NEWLINE# @ mark . parametrize ( 'code' , exceptions . TYPE_MAP . keys ( ) ) #NEWLINE# def test_raises_exceptions( recwarn , code ) : #NEWLINE# #INDENT# 'Exceptions raise, and warnings warn' #NEWLINE# res = DummyResource ( ) #NEWLINE# res . set_exception_type ( code ) #NEWLINE# try : #NEWLINE# #INDENT# res . raise_exception ( ) #NEWLINE# #UNINDENT# except exceptions . WandException as e : #NEWLINE# #INDENT# assert ( not e . __class__ . __name__ . endswith ( 'Warning' ) ) #NEWLINE# assert ( str ( w ) == 'Dummy exception' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# w = recwarn . pop ( ) #NEWLINE# assert w . category . __name__ . endswith ( 'Warning' ) #NEWLINE# assert ( 'Dummy exception' in str ( w . message ) ) #NEWLINE# assert ( recwarn . list == [ ] )