"""Shared test fixtures. The stub-mode smoke tests must be deterministic regardless of the developer's local apps/vision/.env (which may set VISION_RECOGNIZER=fast_alpr for real-model work). An OS environment variable takes precedence over the .env file in pydantic-settings, so we force stub mode for the whole test session before the app's lifespan builds the recognizer. Tests that exercise the real recognizer set their own override explicitly. """ from __future__ import annotations import os import pytest @pytest.fixture(autouse=True) def _force_stub_recognizer() -> None: """Pin the recognizer to the model-free stub for every test (overrides .env).""" prev = os.environ.get("VISION_RECOGNIZER") os.environ["VISION_RECOGNIZER"] = "stub" try: yield finally: if prev is None: os.environ.pop("VISION_RECOGNIZER", None) else: os.environ["VISION_RECOGNIZER"] = prev