MCPcopy Create free account
hub / github.com/pallets/flask / test_request_processing

Function test_request_processing

tests/test_blueprints.py:696–724  ·  view source on GitHub ↗
(app, client)

Source from the content-addressed store, hash-verified

694
695
696def test_request_processing(app, client):
697 bp = flask.Blueprint("bp", __name__)
698 evts = []
699
700 @bp.before_request
701 def before_bp():
702 evts.append("before")
703
704 @bp.after_request
705 def after_bp(response):
706 response.data += b"|after"
707 evts.append("after")
708 return response
709
710 @bp.teardown_request
711 def teardown_bp(exc):
712 evts.append("teardown")
713
714 # Setup routes for testing
715 @bp.route("/bp")
716 def bp_endpoint():
717 return "request"
718
719 app.register_blueprint(bp)
720
721 assert evts == []
722 rv = client.get("/bp")
723 assert rv.data == b"request|after"
724 assert evts == ["before", "after", "teardown"]
725
726
727def test_app_request_processing(app, client):

Callers

nothing calls this directly

Calls 2

register_blueprintMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected