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

Function test_before_after_request_order

tests/test_basic.py:822–857  ·  view source on GitHub ↗
(app, client)

Source from the content-addressed store, hash-verified

820
821
822def test_before_after_request_order(app, client):
823 called = []
824
825 @app.before_request
826 def before1():
827 called.append(1)
828
829 @app.before_request
830 def before2():
831 called.append(2)
832
833 @app.after_request
834 def after1(response):
835 called.append(4)
836 return response
837
838 @app.after_request
839 def after2(response):
840 called.append(3)
841 return response
842
843 @app.teardown_request
844 def finish1(exc):
845 called.append(6)
846
847 @app.teardown_request
848 def finish2(exc):
849 called.append(5)
850
851 @app.route("/")
852 def index():
853 return "42"
854
855 rv = client.get("/")
856 assert rv.data == b"42"
857 assert called == [1, 2, 3, 4, 5, 6]
858
859
860def test_error_handling(app, client):

Callers

nothing calls this directly

Calls 1

getMethod · 0.45

Tested by

no test coverage detected