(test_client_factory: TestClientFactory)
| 624 | |
| 625 | |
| 626 | def test_lifespan_state_unsupported(test_client_factory: TestClientFactory) -> None: |
| 627 | @contextlib.asynccontextmanager |
| 628 | async def lifespan(app: ASGIApp) -> AsyncGenerator[dict[str, str], None]: |
| 629 | yield {"foo": "bar"} |
| 630 | |
| 631 | app = Router( |
| 632 | lifespan=lifespan, |
| 633 | routes=[Mount("/", PlainTextResponse("hello, world"))], |
| 634 | ) |
| 635 | |
| 636 | async def no_state_wrapper(scope: Scope, receive: Receive, send: Send) -> None: |
| 637 | del scope["state"] |
| 638 | await app(scope, receive, send) |
| 639 | |
| 640 | with pytest.raises(RuntimeError, match='The server does not support "state" in the lifespan scope'): |
| 641 | with test_client_factory(no_state_wrapper): |
| 642 | raise AssertionError("Should not be called") # pragma: no cover |
| 643 | |
| 644 | |
| 645 | def test_lifespan_state_async_cm(test_client_factory: TestClientFactory) -> None: |
nothing calls this directly
no test coverage detected