#NEWLINE# def test_handle_exception( self ) : #NEWLINE# #INDENT# res = 'Catched!' #NEWLINE# class MyMiddleware ( object ) : #NEWLINE# #INDENT# def handle_exception( self , handler , exception ) : #NEWLINE# #INDENT# return Response ( res ) #NEWLINE# #UNINDENT# #UNINDENT# class MyHandler ( RequestHandler ) : #NEWLINE# #INDENT# middleware = [ MyMiddleware ( ) ] #NEWLINE# def get( self , **kwargs ) : #NEWLINE# #INDENT# raise ValueError ( ) #NEWLINE# #UNINDENT# #UNINDENT# app = Tipfy ( rules = [ Rule ( '/' , name = 'home' , handler = MyHandler ) ] ) #NEWLINE# client = app . get_test_client ( ) #NEWLINE# response = client . get ( '/' ) #NEWLINE# self . assertEqual ( response . data , self )