(test_client_factory: TestClientFactory)
| 420 | |
| 421 | @deprecated_lifespan |
| 422 | def test_app_async_gen_lifespan(test_client_factory: TestClientFactory) -> None: |
| 423 | startup_complete = False |
| 424 | cleanup_complete = False |
| 425 | |
| 426 | async def lifespan(app: ASGIApp) -> AsyncGenerator[None, None]: |
| 427 | nonlocal startup_complete, cleanup_complete |
| 428 | startup_complete = True |
| 429 | yield |
| 430 | cleanup_complete = True |
| 431 | |
| 432 | app = Starlette(lifespan=lifespan) # type: ignore |
| 433 | |
| 434 | assert not startup_complete |
| 435 | assert not cleanup_complete |
| 436 | with test_client_factory(app): |
| 437 | assert startup_complete |
| 438 | assert not cleanup_complete |
| 439 | assert startup_complete |
| 440 | assert cleanup_complete |
| 441 | |
| 442 | |
| 443 | @deprecated_lifespan |
nothing calls this directly
no test coverage detected