MCPcopy Index your code
hub / github.com/hugapi/hug / test_accept_with_http_errors

Function test_accept_with_http_errors

tests/test_output_format.py:297–313  ·  view source on GitHub ↗

Ensure that content type based output formats work for HTTP error responses

()

Source from the content-addressed store, hash-verified

295
296
297def test_accept_with_http_errors():
298 """Ensure that content type based output formats work for HTTP error responses"""
299 formatter = hug.output_format.accept(
300 {"application/json": hug.output_format.json, "text/plain": hug.output_format.text},
301 default=hug.output_format.json,
302 )
303
304 api = hug.API("test_accept_with_http_errors")
305 hug.default_output_format(api=api)(formatter)
306
307 @hug.get("/500", api=api)
308 def error_500():
309 raise hug.HTTPInternalServerError("500 Internal Server Error", "This is an example")
310
311 response = hug.test.get(api, "/500")
312 assert response.status == "500 Internal Server Error"
313 assert response.data == {"errors": {"500 Internal Server Error": "This is an example"}}
314
315
316def test_suffix():

Callers

nothing calls this directly

Calls 2

acceptMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected