MCPcopy
hub / github.com/pallets/flask / test_blueprint_app_error_handling

Function test_blueprint_app_error_handling

tests/test_blueprints.py:80–101  ·  tests/test_blueprints.py::test_blueprint_app_error_handling
(app, client)

Source from the content-addressed store, hash-verified

78
79
80def test_blueprint_app_error_handling(app, client):
81 errors = flask.Blueprint(class="st">"errors", __name__)
82
83 @errors.app_errorhandler(403)
84 def forbidden_handler(e):
85 return class="st">"you shall not pass", 403
86
87 @app.route(class="st">"/forbidden")
88 def app_forbidden():
89 flask.abort(403)
90
91 forbidden_bp = flask.Blueprint(class="st">"forbidden_bp", __name__)
92
93 @forbidden_bp.route(class="st">"/nope")
94 def bp_forbidden():
95 flask.abort(403)
96
97 app.register_blueprint(errors)
98 app.register_blueprint(forbidden_bp)
99
100 assert client.get(class="st">"/forbidden").data == bclass="st">"you shall not pass"
101 assert client.get(class="st">"/nope").data == bclass="st">"you shall not pass"
102
103
104@pytest.mark.parametrize(

Callers

nothing calls this directly

Calls 2

register_blueprintMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected