def test_on_valid():
 error_dict = {'errors': {'so': 'many'}}
 expected = hug.output_format.json(error_dict)
 assert (hug.output_format.mp4_video(error_dict, hug.Response()) == expected)
 assert (hug.output_format.png_image(error_dict, hug.Response()) == expected)
 @hug.output_format.on_valid('image', hug.output_format.file)
 def my_output_format(data):
  raise ValueError('This should never be called')
 assert my_output_format(error_dict, hug.Response())

def test_on_valid ( ) : error_dict = { 'errors' : { 'so' : 'many' } } expected = hug . output_format . json ( error_dict ) assert ( hug . output_format . mp4_video ( error_dict , hug . Response ( ) ) == expected ) assert ( hug . output_format . png_image ( error_dict , hug . Response ( ) ) == expected ) @ hug . output_format . on_valid ( 'image' , hug . output_format . file ) def my_output_format ( data ) : raise ValueError ( 'This should never be called' ) assert my_output_format ( error_dict , hug . Response ( ) )
test to ensure formats that use on_valid content types gracefully handle error dictionaries .