"""Shared pytest fixtures for unit-level (SQLite) tests.""" from __future__ import annotations from collections.abc import Iterator import pytest @pytest.fixture(autouse=True) def _ensure_test_env(monkeypatch: pytest.MonkeyPatch) -> Iterator[None]: """Force MIMIC_ENV=testing so settings load is predictable.""" monkeypatch.setenv("MIMIC_ENV", "testing") monkeypatch.setenv("MIMIC_SECRET_KEY", "test-secret-not-real") monkeypatch.setenv("MIMIC_LOG_JSON", "false") monkeypatch.setenv("MIMIC_LOG_LEVEL", "WARNING") # Pydantic Settings is cached via get_settings(); reset the cache. from mimic import config as cfg # noqa: PLC0415 (must follow env mutation) cfg.get_settings.cache_clear() try: yield finally: cfg.get_settings.cache_clear()