test_exceptions.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:sanic 作者: channelcat 项目源码 文件源码
def test_catch_exception_list():
    app = Sanic('exception_list')

    @app.exception([SanicExceptionTestException, NotFound])
    def exception_list(request, exception):
        return text("ok")

    @app.route('/')
    def exception(request):
        raise SanicExceptionTestException("You won't see me")

    request, response = app.test_client.get('/random')
    assert response.text == 'ok'

    request, response = app.test_client.get('/')
    assert response.text == 'ok'
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号