forked from orbit-oss/flask
add assert message for errorhandler exception type
This commit is contained in:
parent
2062d984ab
commit
846ee2c62e
2 changed files with 11 additions and 1 deletions
|
|
@ -11,11 +11,19 @@ def test_error_handler_no_match(app, client):
|
|||
class CustomException(Exception):
|
||||
pass
|
||||
|
||||
class UnacceptableCustomException(BaseException):
|
||||
pass
|
||||
|
||||
@app.errorhandler(CustomException)
|
||||
def custom_exception_handler(e):
|
||||
assert isinstance(e, CustomException)
|
||||
return "custom"
|
||||
|
||||
with pytest.raises(
|
||||
AssertionError, match="Custom exceptions must be subclasses of Exception."
|
||||
):
|
||||
app.register_error_handler(UnacceptableCustomException, None)
|
||||
|
||||
@app.errorhandler(500)
|
||||
def handle_500(e):
|
||||
assert isinstance(e, InternalServerError)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue