"""Shared pytest fixtures for the playlist-sync test suite. This conftest is picked up automatically by pytest for all sub-directories. Only truly common, parameter-free fixtures live here. Fixtures that are specialised (different scope, different seed data, monkeypatched settings, live-deployment mode, …) remain in the individual test files. """ import pytest_asyncio from sqlalchemy.ext.asyncio import create_async_engine from sqlalchemy.pool import StaticPool from sqlmodel import SQLModel TEST_DATABASE_URL = "sqlite+aiosqlite:///:memory:" @pytest_asyncio.fixture(scope="function") async def db_engine(): """In-memory SQLite engine with all SQLModel tables created. Yields the engine for the duration of one test function, then drops all tables and disposes the engine. Used by integration and resilience tests that need a clean database per test. """ engine = create_async_engine( TEST_DATABASE_URL, connect_args={"check_same_thread": False}, poolclass=StaticPool, ) async with engine.begin() as conn: await conn.run_sync(SQLModel.metadata.create_all) yield engine async with engine.begin() as conn: await conn.run_sync(SQLModel.metadata.drop_all) await engine.dispose()