MCPcopy Create free account
hub / github.com/pallets/flask / test_error_handler_blueprint

Function test_error_handler_blueprint

tests/test_user_error_handler.py:136–160  ·  view source on GitHub ↗
(app)

Source from the content-addressed store, hash-verified

134
135
136def test_error_handler_blueprint(app):
137 bp = flask.Blueprint("bp", __name__)
138
139 @bp.errorhandler(500)
140 def bp_exception_handler(e):
141 return "bp-error"
142
143 @bp.route("/error")
144 def bp_test():
145 raise InternalServerError()
146
147 @app.errorhandler(500)
148 def app_exception_handler(e):
149 return "app-error"
150
151 @app.route("/error")
152 def app_test():
153 raise InternalServerError()
154
155 app.register_blueprint(bp, url_prefix="/bp")
156
157 c = app.test_client()
158
159 assert c.get("/error").data == b"app-error"
160 assert c.get("/bp/error").data == b"bp-error"
161
162
163def test_default_error_handler():

Callers

nothing calls this directly

Calls 3

test_clientMethod · 0.80
register_blueprintMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected