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
Provenance
- Commit
9560f22- Tree
9789032- Author
David Lord <davidism@gmail.com>- Committer
David Lord <davidism@gmail.com>- Parent
a417e41
2 files changed+8 added−16 removed
modified:flask/app.py+2 added-2 removed
1483 unmodified lines1484 Since a request context typically also manages an application1485 context it would also be called when you pop a request context.1486 1487 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.1491 1492 The return values of teardown functions are ignored.1493 692 unmodified linesmodified:tests/test_appctx.py+6 added-14 removed
95 unmodified lines96 97 assert cleanup_stuff == [None]98 99 100-def test_app_tearing_down_with_handled_exception_by_app_handler(app):100+def test_app_tearing_down_with_handled_exception_by_app_handler(app, client):101+ app.config['PROPAGATE_EXCEPTIONS'] = True102 cleanup_stuff = []103 103- class AppConfig():104- PROPAGATE_EXCEPTIONS = True105- app.config.from_object(AppConfig())106-104 @app.teardown_appcontext105 def cleanup(exception):106 cleanup_stuff.append(exception)107 4 unmodified lines112 @app.errorhandler(Exception)113 def handler(f):114 return flask.jsonify(str(f))115 119- test_client = app.test_client()116 with app.app_context():121- test_client.get('/')117+ client.get('/')118 119 assert cleanup_stuff == [None]120 121 126-def test_app_tearing_down_with_unhandled_exception(app):122+def test_app_tearing_down_with_unhandled_exception(app, client):123+ app.config['PROPAGATE_EXCEPTIONS'] = True124 cleanup_stuff = []125 129- class AppConfig():130- PROPAGATE_EXCEPTIONS = True131- app.config.from_object(AppConfig())132-126 @app.teardown_appcontext127 def cleanup(exception):128 cleanup_stuff.append(exception)129 130 @app.route('/')131 def index():132 raise Exception('dummy')133 141- test_client = app.test_client()134 with pytest.raises(Exception):135 with app.app_context():144- test_client.get('/')136+ client.get('/')137 138 assert len(cleanup_stuff) == 1139 assert isinstance(cleanup_stuff[0], Exception)140 assert str(cleanup_stuff[0]) == 'dummy'79 unmodified lines