# #region TestSessionConfig [C:2] [TYPE Module] [SEMANTICS test, conftest, db] # @BRIEF Shared pytest fixtures and session configuration for backend tests. # @RELATION BINDS_TO -> [init_db] # @PRE All test modules use sys.path patching to import from src/. # @POST Database tables exist before test session executes. import sys from pathlib import Path sys.path.insert(0, str(Path(__file__).parent.parent / "src")) import pytest @pytest.fixture(scope="session", autouse=True) def ensure_db_tables(): """Ensure all tables exist before test session. This fixture runs once per test session, creating all registered SQLAlchemy tables. Individual test modules may also create their own in-memory engines — this guarantees the real engine schema is initialized for tests that depend on it. """ from src.core.database import init_db init_db() # #endregion TestSessionConfig