def test_accept_custom_exception_handlers():
 custom_converter = (lambda value: ((str(int(value)) if value else value) + ' converted'))
 custom_type = hug.types.accept(custom_converter, 'A string Value', exception_handlers={TypeError: '0 provided'})
 assert (custom_type('1') == '1 converted')
 with pytest.raises(ValueError):
  custom_type('bacon')
 with pytest.raises(ValueError):
  custom_type(0)
 custom_type = hug.types.accept(custom_converter, 'A string Value', exception_handlers={TypeError: KeyError})
 with pytest.raises(KeyError):
  custom_type(0)

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