test_error_handler_no_match() — flask Function Reference
Architecture documentation for the test_error_handler_no_match() function in test_user_error_handler.py from the flask codebase.
Entity Profile
Dependency Diagram
graph TD 83f3c516_c657_0814_90c6_9df372dd9137["test_error_handler_no_match()"] f3be1606_1a20_1a1b_2703_48b5b295bc8d["test_user_error_handler.py"] 83f3c516_c657_0814_90c6_9df372dd9137 -->|defined in| f3be1606_1a20_1a1b_2703_48b5b295bc8d style 83f3c516_c657_0814_90c6_9df372dd9137 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
tests/test_user_error_handler.py lines 10–58
def test_error_handler_no_match(app, client):
class CustomException(Exception):
pass
@app.errorhandler(CustomException)
def custom_exception_handler(e):
assert isinstance(e, CustomException)
return "custom"
with pytest.raises(TypeError) as exc_info:
app.register_error_handler(CustomException(), None)
assert "CustomException() is an instance, not a class." in str(exc_info.value)
with pytest.raises(ValueError) as exc_info:
app.register_error_handler(list, None)
assert "'list' is not a subclass of Exception." in str(exc_info.value)
@app.errorhandler(500)
def handle_500(e):
assert isinstance(e, InternalServerError)
if e.original_exception is not None:
return f"wrapped {type(e.original_exception).__name__}"
return "direct"
with pytest.raises(ValueError) as exc_info:
app.register_error_handler(999, None)
assert "Use a subclass of HTTPException" in str(exc_info.value)
@app.route("/custom")
def custom_test():
raise CustomException()
@app.route("/keyerror")
def key_error():
raise KeyError()
@app.route("/abort")
def do_abort():
flask.abort(500)
app.testing = False
assert client.get("/custom").data == b"custom"
assert client.get("/keyerror").data == b"wrapped KeyError"
assert client.get("/abort").data == b"direct"
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does test_error_handler_no_match() do?
test_error_handler_no_match() is a function in the flask codebase, defined in tests/test_user_error_handler.py.
Where is test_error_handler_no_match() defined?
test_error_handler_no_match() is defined in tests/test_user_error_handler.py at line 10.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free