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

Function test_test_client_context_binding

tests/test_testing.py:212–238  ·  view source on GitHub ↗
(app, client)

Source from the content-addressed store, hash-verified

210
211
212def test_test_client_context_binding(app, client):
213 app.testing = False
214
215 @app.route("/")
216 def index():
217 flask.g.value = 42
218 return "Hello World!"
219
220 @app.route("/other")
221 def other():
222 raise ZeroDivisionError
223
224 with client:
225 resp = client.get("/")
226 assert flask.g.value == 42
227 assert resp.data == b"Hello World!"
228 assert resp.status_code == 200
229
230 with client:
231 resp = client.get("/other")
232 assert not hasattr(flask.g, "value")
233 assert b"Internal Server Error" in resp.data
234 assert resp.status_code == 500
235 flask.g.value = 23
236
237 with pytest.raises(RuntimeError):
238 flask.g.value # noqa: B018
239
240
241def test_reuse_client(client):

Callers

nothing calls this directly

Calls 1

getMethod · 0.45

Tested by

no test coverage detected