MCPcopy Create free account
hub / github.com/pallets/quart / test_nested_callback_order

Function test_nested_callback_order

tests/test_blueprints.py:386–467  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

384
385
386async def test_nested_callback_order() -> None:
387 app = Quart(__name__)
388
389 parent = Blueprint("parent", __name__)
390 child = Blueprint("child", __name__)
391
392 @app.before_request
393 async def app_before1() -> None:
394 g.setdefault("seen", []).append("app_1")
395
396 @app.teardown_request
397 async def app_teardown1(exc: BaseException | None = None) -> None:
398 assert g.seen.pop() == "app_1"
399
400 @app.before_request
401 async def app_before2() -> None:
402 g.setdefault("seen", []).append("app_2")
403
404 @app.teardown_request
405 async def app_teardown2(exc: BaseException | None = None) -> None:
406 assert g.seen.pop() == "app_2"
407
408 @app.context_processor
409 async def app_ctx() -> dict:
410 return dict(key="app")
411
412 @parent.before_request
413 async def parent_before1() -> None:
414 g.setdefault("seen", []).append("parent_1")
415
416 @parent.teardown_request
417 async def parent_teardown1(exc: BaseException | None = None) -> None:
418 assert g.seen.pop() == "parent_1"
419
420 @parent.before_request
421 async def parent_before2() -> None:
422 g.setdefault("seen", []).append("parent_2")
423
424 @parent.teardown_request
425 async def parent_teardown2(exc: BaseException | None = None) -> None:
426 assert g.seen.pop() == "parent_2"
427
428 @parent.context_processor
429 async def parent_ctx() -> dict:
430 return dict(key="parent")
431
432 @child.before_request
433 async def child_before1() -> None:
434 g.setdefault("seen", []).append("child_1")
435
436 @child.teardown_request
437 async def child_teardown1(exc: BaseException | None = None) -> None:
438 assert g.seen.pop() == "child_1"
439
440 @child.before_request
441 async def child_before2() -> None:
442 g.setdefault("seen", []).append("child_2")
443

Callers

nothing calls this directly

Calls 5

test_clientMethod · 0.95
QuartClass · 0.90
BlueprintClass · 0.90
get_dataMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…