#NEWLINE# def test_accept_custom_exception_handlers( ) : #NEWLINE# #INDENT# "Tests to ensure it's easy to custom the exception text using the accept wrapper" #NEWLINE# custom_converter = ( lambda value : ( ( str ( int ( value ) ) if value else value ) + ' converted' ) ) #NEWLINE# custom_type = hug . types . accept ( custom_converter , 'A string Value' , exception_handlers = { #NEWLINE# #INDENT# TypeError : '0 provided' , #NEWLINE# #UNINDENT# } ) #NEWLINE# assert ( custom_type ( '1' ) == '1 converted' ) #NEWLINE# with pytest . raises ( ValueError ) : #NEWLINE# #INDENT# custom_type ( 'bacon' ) #NEWLINE# #UNINDENT# with pytest . raises ( ValueError ) : #NEWLINE# #INDENT# custom_type ( 0 ) #NEWLINE# #UNINDENT# custom_type = hug . types . accept ( custom_converter , 'A string Value' , exception_handlers = { #NEWLINE# #INDENT# TypeError : KeyError , #NEWLINE# #UNINDENT# } ) #NEWLINE# with pytest . raises ( KeyError ) : #NEWLINE# #INDENT# custom_type ( 0 )