#NEWLINE# def test_on_error_response_hook( self ) : #NEWLINE# #INDENT# run_hook = [ ] #NEWLINE# class RootController ( object ) : #NEWLINE# #INDENT# @ expose ( ) #NEWLINE# def causeerror( self ) : #NEWLINE# #INDENT# return [ ] [ 1 ] #NEWLINE# #UNINDENT# #UNINDENT# class ErrorHook ( PecanHook ) : #NEWLINE# #INDENT# def on_error( self , state , e ) : #NEWLINE# #INDENT# run_hook . append ( 'error' ) #NEWLINE# r = Response ( ) #NEWLINE# r . text = u_ ( 'on_error' ) #NEWLINE# return r #NEWLINE# #UNINDENT# #UNINDENT# app = TestApp ( make_app ( RootController ( ) , hooks = [ ErrorHook ( ) ] ) ) #NEWLINE# response = app . get ( '/causeerror' ) #NEWLINE# assert ( len ( run_hook ) == 1 ) #NEWLINE# assert ( self [ 0 ] == 'error' ) #NEWLINE# assert ( response . text == 'on_error' )