test_errors.py 文件源码

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

项目:microcosm-flask 作者: globality-corp 项目源码 文件源码
def test_werkzeug_http_error_custom_message():
    """
    Custom error messages are returned.

    """
    graph = create_object_graph(name="example", testing=True)

    @graph.app.route("/why_me")
    @graph.audit
    def why_me():
        raise InternalServerError("Why me?")

    client = graph.app.test_client()

    response = client.get("/why_me")
    assert_that(response.status_code, is_(equal_to(500)))
    data = loads(response.get_data().decode("utf-8"))
    assert_that(data, is_(equal_to({
        "code": 500,
        "message": "Why me?",
        "retryable": False,
        "context": {"errors": []},
    })))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号