#NEWLINE# def test_exceptions( ) : #NEWLINE# #INDENT# app = App ( ) #NEWLINE# stderr = StringIO ( ) #NEWLINE# debugger = Debugger ( file = stderr ) #NEWLINE# debugger . register ( app ) #NEWLINE# while len ( app ) : #NEWLINE# #INDENT# app . flush ( ) #NEWLINE# #UNINDENT# stderr . seek ( 0 ) #NEWLINE# stderr . truncate ( ) #NEWLINE# assert debugger . _events #NEWLINE# assert debugger . _errors #NEWLINE# e = test ( raiseException = True ) #NEWLINE# app . fire ( e ) #NEWLINE# app . flush ( ) #NEWLINE# stderr . seek ( 0 ) #NEWLINE# s = stderr . read ( ) . strip ( ) #NEWLINE# assert ( s == str ( e ) ) #NEWLINE# stderr . seek ( 0 ) #NEWLINE# stderr . truncate ( ) #NEWLINE# app . flush ( ) #NEWLINE# stderr . seek ( 0 ) #NEWLINE# s = stderr . read ( ) . strip ( ) #NEWLINE# assert s . startswith ( '<exception[*]' ) #NEWLINE# stderr . seek ( 0 ) #NEWLINE# stderr . truncate ( ) #NEWLINE# debugger . _events = False #NEWLINE# debugger . _errors = False #NEWLINE# assert ( not debugger . _events ) #NEWLINE# assert ( not debugger . _errors ) #NEWLINE# e = test ( raiseException = True ) #NEWLINE# app . fire ( e ) #NEWLINE# app . flush ( ) #NEWLINE# stderr . seek ( 0 ) #NEWLINE# s = stderr . read ( ) . strip ( ) #NEWLINE# assert ( s == '' ) #NEWLINE# stderr . seek ( 0 ) #NEWLINE# stderr . truncate ( ) #NEWLINE# app . flush ( ) #NEWLINE# stderr . seek ( 0 ) #NEWLINE# s = stderr . read ( ) . strip ( ) #NEWLINE# assert ( s == '' )