Skip to content

Commit 279cc29

Browse files
committed
the lifespan manager cannot be used with the TestClient
1 parent b2426d8 commit 279cc29

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

services/director-v2/tests/conftest.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,10 +206,14 @@ async def initialized_app(mock_env: EnvVarsDict) -> AsyncIterable[FastAPI]:
206206

207207

208208
@pytest.fixture()
209-
async def client(initialized_app: FastAPI) -> AsyncIterator[TestClient]:
209+
async def client(mock_env: EnvVarsDict) -> AsyncIterator[TestClient]:
210210
# NOTE: this way we ensure the events are run in the application
211211
# since it starts the app on a test server
212-
with TestClient(initialized_app, raise_server_exceptions=True) as test_client:
212+
settings = AppSettings.create_from_envs()
213+
app = init_app(settings)
214+
# NOTE: we cannot use the initialized_app fixture here as the TestClient also creates it
215+
print("Application settings\n", settings.model_dump_json(indent=2))
216+
with TestClient(app, raise_server_exceptions=True) as test_client:
213217
yield test_client
214218

215219

0 commit comments

Comments
 (0)