MCPcopy Create free account
hub / github.com/Azure-Samples/rag-postgres-openai-python / db_session

Function db_session

tests/conftest.py:361–370  ·  view source on GitHub ↗

Create a new database session with a rollback at the end of the test.

(mock_session_env, mock_azure_credential)

Source from the content-addressed store, hash-verified

359
360@pytest_asyncio.fixture(scope="function")
361async def db_session(mock_session_env, mock_azure_credential):
362 """Create a new database session with a rollback at the end of the test."""
363 engine = await create_postgres_engine_from_env()
364 async_sesion = async_sessionmaker(autocommit=False, autoflush=False, bind=engine)
365 session = async_sesion()
366 await session.begin()
367 yield session
368 await session.rollback()
369 await session.close()
370 await engine.dispose()
371
372
373@pytest_asyncio.fixture(scope="function")

Callers

nothing calls this directly

Calls 2

closeMethod · 0.80

Tested by

no test coverage detected