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

Function test_client_json_no_app_context

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

Source from the content-addressed store, hash-verified

280
281
282def test_client_json_no_app_context(app, client):
283 @app.route("/hello", methods=["POST"])
284 def hello():
285 return f"Hello, {flask.request.json['name']}!"
286
287 class Namespace:
288 count = 0
289
290 def add(self, app):
291 self.count += 1
292
293 ns = Namespace()
294
295 with appcontext_popped.connected_to(ns.add, app):
296 rv = client.post("/hello", json={"name": "Flask"})
297
298 assert rv.get_data(as_text=True) == "Hello, Flask!"
299 assert ns.count == 1
300
301
302def test_subdomain():

Callers

nothing calls this directly

Calls 2

NamespaceClass · 0.85
postMethod · 0.45

Tested by

no test coverage detected