Skip to content
Myr

Add coverage for Blueprint teardown request method

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

Test the following methods in the Blueprint object: teardown_request, and teardown_app_request. This PR increases the coverage of blueprint module by 3%.

authored by Randy Liou · committed by Randy Liou · parent a690ae2 · Browse files · 1 file+9 added−3 removed
This commit

State

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

Diff stats

1 file+9 added−3 removed

  • tests:+9 added−3 removed

1 file+9 added−3 removed

modified:tests/test_blueprints.py+9 added-3 removed
690 unmodified lines
691 def after_bp(response):692 response.data += b'|after'693 evts.append('after')694 return response695 @bp.teardown_request696 def teardown_bp(exc):697 evts.append('teardown')698699 # Setup routes for testing700 @bp.route('/bp')701 def bp_endpoint():
3 unmodified lines
705706 assert evts == []707 rv = app.test_client().get('/bp')708 assert rv.data == b'request|after'706 assert evts == ['before', 'after']709 assert evts == ['before', 'after', 'teardown']710711def test_app_request_processing():712 app = flask.Flask(__name__)713 bp = flask.Blueprint('bp', __name__)
9 unmodified lines
723 def after_app(response):724 response.data += b'|after'725 evts.append('after')726 return response727 @bp.teardown_app_request728 def teardown_app(exc):729 evts.append('teardown')730731 app.register_blueprint(bp)732733 # Setup routes for testing
6 unmodified lines
740741 # first request742 resp = app.test_client().get('/').data743 assert resp == b'request|after'738 assert evts == ['first', 'before', 'after']744 assert evts == ['first', 'before', 'after', 'teardown']745746 # second request747 resp = app.test_client().get('/').data748 assert resp == b'request|after'743 assert evts == ['first', 'before', 'after', 'before', 'after']749 assert evts == ['first'] + ['before', 'after', 'teardown'] * 2