#NEWLINE# def _compare( self , expected , code ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# ( value , printed ) = self . evaluate ( code ) #NEWLINE# #UNINDENT# except ConsoleException as e : #NEWLINE# #INDENT# actual = e . exception_type #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( value is not None ) : #NEWLINE# #INDENT# print ( self . _output_fn ( value ) ) #NEWLINE# actual = ( printed + self . _output_fn ( value ) ) . strip ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# actual = printed . strip ( ) #NEWLINE# #UNINDENT# #UNINDENT# expected = expected . strip ( ) #NEWLINE# if ( ( not self . skip_locked_cases ) and ( expected != actual ) ) : #NEWLINE# #INDENT# actual = locking . lock ( self . hash_key , actual ) #NEWLINE# if ( expected != actual ) : #NEWLINE# #INDENT# print ( ) #NEWLINE# print ( '# Error: expected and actual results do not match' ) #NEWLINE# raise ConsoleException #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( expected != actual ) : #NEWLINE# #INDENT# print ( ) #NEWLINE# print ( '# Error: expected' ) #NEWLINE# print ( '\n' . join ( ( '#     {}' . format ( line ) for line in expected . split ( '\n' ) ) ) ) #NEWLINE# print ( '# but got' ) #NEWLINE# print ( '\n' . join ( ( '#     {}' . format ( line ) for line in actual . split ( '\n' ) ) ) ) #NEWLINE# raise ConsoleException