"""Pytest fixtures shared across the BioPatch test suite.""" from __future__ import annotations import subprocess import sys from pathlib import Path import pytest ROOT = Path(__file__).resolve().parent.parent @pytest.fixture(scope="session", autouse=True) def ensure_clinical_model_trained() -> None: """Make sure the RF artifact exists before any test runs. The training pipeline is deterministic (seed=42) and finishes in <2s, so re-running it in CI is cheap and keeps tests model-faithful. """ artifact = ROOT / "ai" / "artifacts" / "rf_v1.joblib" if artifact.exists(): return subprocess.run( [sys.executable, "-m", "scripts.seed_clinical_data"], cwd=ROOT, check=True, )