diff --git a/apps/api/tests/conftest.py b/apps/api/tests/conftest.py index 9a2af3a..5c79ed0 100644 --- a/apps/api/tests/conftest.py +++ b/apps/api/tests/conftest.py @@ -34,8 +34,12 @@ def event_loop() -> Generator[Any, None, None]: @pytest.fixture(scope="session") async def db_engine() -> AsyncGenerator[AsyncEngine, None]: engine = create_async_engine(TEST_DATABASE_URL, echo=False, poolclass=NullPool) - async with engine.begin() as conn: - await conn.run_sync(Base.metadata.create_all) + try: + async with engine.begin() as conn: + await conn.run_sync(Base.metadata.create_all) + except Exception as exc: + await engine.dispose() + pytest.skip(f"PostgreSQL unavailable for tests: {exc}") yield engine async with engine.begin() as conn: await conn.run_sync(Base.metadata.drop_all)