Created
May 31, 2017 07:53
-
-
Save danielknell/2e1021656f92e77bd748a1013d6942c1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Flask, Response | |
from werkzeug.exceptions import HTTPException, NotFound | |
app = Flask('test') | |
def handler(e): | |
return Response('error') | |
app.register_error_handler(HTTPException, handler) | |
@app.route('/') | |
def index(): | |
raise NotFound() | |
def test_errorhandler(): | |
client = app.test_client() | |
response = client.get('/') | |
assert response.data == "error" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Based on how _find_error_handler recurses through the mro, i would expect this to pass, as the second item in NotFound's mro is HTTPException.
Instead this fails showing the default response for the NotFound exception.
_find_error_handler is used to fetch the handler for a http exception, at line 1468 it appears to be None though.