(app: Quart, blueprint: Blueprint)
| 53 | |
| 54 | |
| 55 | async def test_template_context_processors(app: Quart, blueprint: Blueprint) -> None: |
| 56 | @blueprint.context_processor |
| 57 | async def blueprint_context() -> dict: |
| 58 | await asyncio.sleep(0.01) # Test the ability to await |
| 59 | return {"context": "foo"} |
| 60 | |
| 61 | @blueprint.app_context_processor |
| 62 | async def app_blueprint_context() -> dict: |
| 63 | return {"global_context": "boo"} |
| 64 | |
| 65 | @app.context_processor |
| 66 | async def app_context() -> dict: |
| 67 | return {"context": "bar"} |
| 68 | |
| 69 | app.register_blueprint(blueprint) |
| 70 | |
| 71 | async with app.app_context(): |
| 72 | rendered = await render_template_string("{{ context }}") |
| 73 | assert rendered == "bar" |
| 74 | |
| 75 | async with app.test_request_context("/"): |
| 76 | rendered = await render_template_string("{{ context }} {{ global_context }}") |
| 77 | assert rendered == "foo boo" |
| 78 | |
| 79 | async with app.test_request_context("/other"): |
| 80 | rendered = await render_template_string("{{ context }} {{ global_context }}") |
| 81 | assert rendered == "bar boo" |
| 82 | |
| 83 | |
| 84 | async def test_template_globals(app: Quart, blueprint: Blueprint) -> None: |
nothing calls this directly
no test coverage detected
searching dependent graphs…