forked from orbit-oss/flask
Corrected after response for error handlers
Before this change after request functions were not correctly invoked for error handlers.
This commit is contained in:
parent
dbcd64e2ee
commit
9cd32cac32
3 changed files with 50 additions and 4 deletions
|
|
@ -768,6 +768,29 @@ def test_error_handling():
|
|||
assert b'forbidden' == rv.data
|
||||
|
||||
|
||||
def test_error_handling_processing():
|
||||
app = flask.Flask(__name__)
|
||||
app.config['LOGGER_HANDLER_POLICY'] = 'never'
|
||||
|
||||
@app.errorhandler(500)
|
||||
def internal_server_error(e):
|
||||
return 'internal server error', 500
|
||||
|
||||
@app.route('/')
|
||||
def broken_func():
|
||||
1 // 0
|
||||
|
||||
@app.after_request
|
||||
def after_request(resp):
|
||||
resp.mimetype = 'text/x-special'
|
||||
return resp
|
||||
|
||||
with app.test_client() as c:
|
||||
resp = c.get('/')
|
||||
assert resp.mimetype == 'text/x-special'
|
||||
assert resp.data == b'internal server error'
|
||||
|
||||
|
||||
def test_before_request_and_routing_errors():
|
||||
app = flask.Flask(__name__)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue