generated from john/python-template
23 lines
574 B
Python
23 lines
574 B
Python
"""Shared test fixtures.
|
|
|
|
Every test gets a fresh in-memory SQLite database so tests are
|
|
isolated, fast, and leave no artifacts on disk.
|
|
"""
|
|
|
|
import pytest
|
|
from sqlmodel import Session, SQLModel, create_engine
|
|
from sqlmodel.pool import StaticPool
|
|
|
|
|
|
@pytest.fixture
|
|
def session():
|
|
"""Provide a clean database session for each test."""
|
|
engine = create_engine(
|
|
"sqlite://",
|
|
connect_args={"check_same_thread": False},
|
|
poolclass=StaticPool,
|
|
)
|
|
SQLModel.metadata.create_all(engine)
|
|
with Session(engine) as session:
|
|
yield session
|