#NEWLINE# def test_custom_error_handlers( self ) : #NEWLINE# #INDENT# app = Tipfy ( [ Rule ( '/' , handler = AllMethodsHandler , name = 'home' ) , Rule ( '/broken' , handler = BrokenHandler , name = 'broken' ) ] , debug = False ) #NEWLINE# app . error_handlers = { #NEWLINE# #INDENT# 404 : Handle404 , #NEWLINE# 405 : Handle405 , #NEWLINE# 500 : Handle500 , #NEWLINE# #UNINDENT# } #NEWLINE# client = app . get_test_client ( ) #NEWLINE# res = client . get ( '/nowhere' ) #NEWLINE# self . assertEqual ( res . status_code , 404 ) #NEWLINE# self . assertEqual ( res . data , '404 custom handler' ) #NEWLINE# res = client . put ( '/broken' ) #NEWLINE# self . assertEqual ( res . status_code , 405 ) #NEWLINE# self . assertEqual ( res . data , '405 custom handler' ) #NEWLINE# self . assertEqual ( res . headers . get ( 'Allow' ) , 'GET' ) #NEWLINE# res = client . get ( '/broken' ) #NEWLINE# self . assertEqual ( res . status_code , 500 ) #NEWLINE# self . assertEqual ( res . data , '500 custom handler' )