(app, client)
| 280 | |
| 281 | |
| 282 | def 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 | |
| 302 | def test_subdomain(): |