Skip to content
Myr

clean up

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by David Lord · committed by David Lord · parent a417e41 · Browse files · 2 files+8 added−16 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+8 added−16 removed

  • tests:+6 added−14 removed
  • other:+2 added−2 removed

2 files+8 added−16 removed

modified:flask/app.py+2 added-2 removed
1483 unmodified lines
1484 Since a request context typically also manages an application1485 context it would also be called when you pop a request context.14861487 When a teardown function was called because of an unhandled exception1488 it will be passed an error object. Note that if a :meth:`errorhandler`1489 is registered, it will handle the exception and the teardown will not1488 it will be passed an error object. If an :meth:`errorhandler` is1489 registered, it will handle the exception and the teardown will not1490 receive it.14911492 The return values of teardown functions are ignored.1493
692 unmodified lines
modified:tests/test_appctx.py+6 added-14 removed
95 unmodified lines
9697 assert cleanup_stuff == [None]9899100def test_app_tearing_down_with_handled_exception_by_app_handler(app):100def test_app_tearing_down_with_handled_exception_by_app_handler(app, client):101 app.config['PROPAGATE_EXCEPTIONS'] = True102 cleanup_stuff = []103103 class AppConfig():104 PROPAGATE_EXCEPTIONS = True105 app.config.from_object(AppConfig())106104 @app.teardown_appcontext105 def cleanup(exception):106 cleanup_stuff.append(exception)107
4 unmodified lines
112 @app.errorhandler(Exception)113 def handler(f):114 return flask.jsonify(str(f))115119 test_client = app.test_client()116 with app.app_context():121 test_client.get('/')117 client.get('/')118119 assert cleanup_stuff == [None]120121126def test_app_tearing_down_with_unhandled_exception(app):122def test_app_tearing_down_with_unhandled_exception(app, client):123 app.config['PROPAGATE_EXCEPTIONS'] = True124 cleanup_stuff = []125129 class AppConfig():130 PROPAGATE_EXCEPTIONS = True131 app.config.from_object(AppConfig())132126 @app.teardown_appcontext127 def cleanup(exception):128 cleanup_stuff.append(exception)129130 @app.route('/')131 def index():132 raise Exception('dummy')133141 test_client = app.test_client()134 with pytest.raises(Exception):135 with app.app_context():144 test_client.get('/')136 client.get('/')137138 assert len(cleanup_stuff) == 1139 assert isinstance(cleanup_stuff[0], Exception)140 assert str(cleanup_stuff[0]) == 'dummy'
79 unmodified lines