- Notifications
You must be signed in to change notification settings - Fork28
Open
Description
Describe the bug
Currently because of broken lifespan integration in pytest, you need to duplicate code like:
@pytest_asyncio.fixture(scope="session")asyncdefapp_client(app):awaitcreate_index_templates()awaitcreate_collection_index()asyncwithAsyncClient(transport=ASGITransport(app=app),base_url="http://test-server" )asc:yieldc
despite having:
@asynccontextmanagerasyncdeflifespan(app:FastAPI):"""Lifespan handler for FastAPI app. Initializes index templates and collections at startup."""awaitcreate_index_templates()awaitcreate_collection_index()yield
It'sfairly simple to fix, feel free to use this code:
- https://github.com/openstreetmap-ng/openstreetmap-ng/blob/main/tests/utils/lifespan_manager.py
- https://github.com/openstreetmap-ng/openstreetmap-ng/blob/2ae47ba66659a4993a78acffa0a7126f95f87abc/tests/conftest.py#L51-L59
This should make the tests more consistent with the actual deployment.
Metadata
Metadata
Assignees
Labels
No labels