Skip to content

Instantly share code, notes, and snippets.

@jerluc
Created June 14, 2019 00:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jerluc/b4cae5f5a09b715872cec90ae24622b9 to your computer and use it in GitHub Desktop.
Save jerluc/b4cae5f5a09b715872cec90ae24622b9 to your computer and use it in GitHub Desktop.
Testing aiohttp web exceptions
from aiohttp import web
def test_exception(request):
text_or_reason = request.query["type"]
raise web.HTTPBadRequest(**{text_or_reason: "The request was bad!"})
if __name__ == "__main__":
app = web.Application()
app.add_routes([web.get("/test_exception", test_exception)])
web.run_app(app)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment