Merge branch 'mjpieters-appcontext_ignore_handled_exception'

This commit is contained in:
Markus Unterwaditzer 2015-03-23 16:44:32 +01:00
commit 33bad011c3
6 changed files with 48 additions and 8 deletions

View file

@ -78,6 +78,21 @@ def test_app_tearing_down_with_previous_exception():
assert cleanup_stuff == [None]
def test_app_tearing_down_with_handled_exception():
cleanup_stuff = []
app = flask.Flask(__name__)
@app.teardown_appcontext
def cleanup(exception):
cleanup_stuff.append(exception)
with app.app_context():
try:
raise Exception('dummy')
except Exception:
pass
assert cleanup_stuff == [None]
def test_custom_app_ctx_globals_class():
class CustomRequestGlobals(object):
def __init__(self):

View file

@ -48,6 +48,21 @@ def test_teardown_with_previous_exception():
assert buffer == []
assert buffer == [None]
def test_teardown_with_handled_exception():
buffer = []
app = flask.Flask(__name__)
@app.teardown_request
def end_of_request(exception):
buffer.append(exception)
with app.test_request_context():
assert buffer == []
try:
raise Exception('dummy')
except Exception:
pass
assert buffer == [None]
def test_proper_test_request_context():
app = flask.Flask(__name__)
app.config.update(