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

Function test_context_refcounts

tests/test_appctx.py:167–190  ·  view source on GitHub ↗
(app, client)

Source from the content-addressed store, hash-verified

165
166
167def test_context_refcounts(app, client):
168 called = []
169
170 @app.teardown_request
171 def teardown_req(error=None):
172 called.append("request")
173
174 @app.teardown_appcontext
175 def teardown_app(error=None):
176 called.append("app")
177
178 @app.route("/")
179 def index():
180 with app_ctx:
181 with request_ctx:
182 pass
183
184 assert flask.request.environ["werkzeug.request"] is not None
185 return ""
186
187 res = client.get("/")
188 assert res.status_code == 200
189 assert res.data == b""
190 assert called == ["request", "app"]
191
192
193def test_clean_pop(app):

Callers

nothing calls this directly

Calls 1

getMethod · 0.45

Tested by

no test coverage detected