MCPcopy
hub / github.com/encode/starlette / test_app_async_gen_lifespan

Function test_app_async_gen_lifespan

tests/test_applications.py:422–440  ·  view source on GitHub ↗
(test_client_factory: TestClientFactory)

Source from the content-addressed store, hash-verified

420
421@deprecated_lifespan
422def 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

Callers

nothing calls this directly

Calls 2

StarletteClass · 0.90
test_client_factoryFunction · 0.85

Tested by

no test coverage detected