test_default_error_handler() — flask Function Reference
Architecture documentation for the test_default_error_handler() function in test_user_error_handler.py from the flask codebase.
Entity Profile
Dependency Diagram
graph TD f3070812_5410_0b9e_f347_7e04d10e1e63["test_default_error_handler()"] f3be1606_1a20_1a1b_2703_48b5b295bc8d["test_user_error_handler.py"] f3070812_5410_0b9e_f347_7e04d10e1e63 -->|defined in| f3be1606_1a20_1a1b_2703_48b5b295bc8d style f3070812_5410_0b9e_f347_7e04d10e1e63 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
tests/test_user_error_handler.py lines 163–214
def test_default_error_handler():
bp = flask.Blueprint("bp", __name__)
@bp.errorhandler(HTTPException)
def bp_exception_handler(e):
assert isinstance(e, HTTPException)
assert isinstance(e, NotFound)
return "bp-default"
@bp.errorhandler(Forbidden)
def bp_forbidden_handler(e):
assert isinstance(e, Forbidden)
return "bp-forbidden"
@bp.route("/undefined")
def bp_registered_test():
raise NotFound()
@bp.route("/forbidden")
def bp_forbidden_test():
raise Forbidden()
app = flask.Flask(__name__)
@app.errorhandler(HTTPException)
def catchall_exception_handler(e):
assert isinstance(e, HTTPException)
assert isinstance(e, NotFound)
return "default"
@app.errorhandler(Forbidden)
def catchall_forbidden_handler(e):
assert isinstance(e, Forbidden)
return "forbidden"
@app.route("/forbidden")
def forbidden():
raise Forbidden()
@app.route("/slash/")
def slash():
return "slash"
app.register_blueprint(bp, url_prefix="/bp")
c = app.test_client()
assert c.get("/bp/undefined").data == b"bp-default"
assert c.get("/bp/forbidden").data == b"bp-forbidden"
assert c.get("/undefined").data == b"default"
assert c.get("/forbidden").data == b"forbidden"
# Don't handle RequestRedirect raised when adding slash.
assert c.get("/slash", follow_redirects=True).data == b"slash"
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does test_default_error_handler() do?
test_default_error_handler() is a function in the flask codebase, defined in tests/test_user_error_handler.py.
Where is test_default_error_handler() defined?
test_default_error_handler() is defined in tests/test_user_error_handler.py at line 163.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free