generated from john/python-template
UI style refresh continued
This commit is contained in:
+9
-5
@@ -15,7 +15,6 @@ from transcription.config import Settings
|
||||
from transcription.config import get_settings
|
||||
from transcription.db.engine import get_database_url
|
||||
from transcription.db.engine import get_engine
|
||||
from transcription.db.operations import create_all
|
||||
from transcription.db.session import dispose_session_factory
|
||||
from transcription.db.session import get_session_factory
|
||||
from transcription.db.session import session_scope
|
||||
@@ -42,8 +41,15 @@ async def default_settings():
|
||||
"""Provide default settings for tests."""
|
||||
settings = get_settings(database_url="sqlite:///:memory:")
|
||||
db_url = get_database_url(settings)
|
||||
await create_all(engine=get_engine(database_url=db_url))
|
||||
return settings
|
||||
engine = get_engine(database_url=db_url)
|
||||
|
||||
# Cached in-memory engines persist across tests; reset schema per test for isolation.
|
||||
async with engine.begin() as connection:
|
||||
await connection.run_sync(SQLModel.metadata.drop_all)
|
||||
await connection.run_sync(SQLModel.metadata.create_all)
|
||||
|
||||
yield settings
|
||||
await dispose_session_factory(db_url)
|
||||
|
||||
|
||||
@pytest_asyncio.fixture
|
||||
@@ -53,8 +59,6 @@ async def async_session(default_settings: Settings):
|
||||
async with session_scope(database_url=db_url) as async_session:
|
||||
yield async_session
|
||||
|
||||
await dispose_session_factory(db_url)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def default_session_factory(default_settings: Settings):
|
||||
|
||||
Reference in New Issue
Block a user