Handle BaseExceptions (#2222)

* Handle BaseExceptions

* Add test and changes

* Make test more idiomatic
This commit is contained in:
Diggory Blake 2017-03-31 17:07:43 +01:00 committed by Markus Unterwaditzer
parent 19d7e6532f
commit 1d4448abe3
3 changed files with 23 additions and 0 deletions

View file

@ -791,6 +791,23 @@ def test_error_handling_processing():
assert resp.data == b'internal server error'
def test_baseexception_error_handling():
app = flask.Flask(__name__)
app.config['LOGGER_HANDLER_POLICY'] = 'never'
@app.route('/')
def broken_func():
raise KeyboardInterrupt()
with app.test_client() as c:
with pytest.raises(KeyboardInterrupt):
c.get('/')
ctx = flask._request_ctx_stack.top
assert ctx.preserved
assert type(ctx._preserved_exc) is KeyboardInterrupt
def test_before_request_and_routing_errors():
app = flask.Flask(__name__)