mirror of
https://github.com/d3vyce/fastapi-toolsets.git
synced 2026-08-04 23:54:09 +00:00
Version 4.0.0 (#263)
* fix: lock_tables acquires dedicated session to enforce RAII lock boundaries (#261) * fix: make lock_tables generic over session type (#270) * docs: fix zensical warnings * Version 4.0.0 * docs: add v4 migration + fix lock_tables documentation
This commit is contained in:
@@ -439,6 +439,21 @@ async def engine():
|
||||
await engine.dispose()
|
||||
|
||||
|
||||
@pytest.fixture(scope="function")
|
||||
async def session_maker(engine):
|
||||
"""Provide a session factory with tables created and dropped around the test."""
|
||||
async with engine.begin() as conn:
|
||||
await conn.run_sync(Base.metadata.create_all)
|
||||
|
||||
factory = async_sessionmaker(engine, expire_on_commit=False)
|
||||
|
||||
try:
|
||||
yield factory
|
||||
finally:
|
||||
async with engine.begin() as conn:
|
||||
await conn.run_sync(Base.metadata.drop_all)
|
||||
|
||||
|
||||
@pytest.fixture(scope="function")
|
||||
async def db_session(engine):
|
||||
"""Create a test database session with tables.
|
||||
|
||||
Reference in New Issue
Block a user