Created
June 14, 2019 00:32
-
-
Save jerluc/b4cae5f5a09b715872cec90ae24622b9 to your computer and use it in GitHub Desktop.
Testing aiohttp web exceptions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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