""" Root conftest — runs before pytest collects any test files or imports any production modules. Creates a temporary keyring.yaml from the test keyring so that `import config` works without the real keyring.yaml. Must live at the repo root (not inside tests/) to fire before collection. """ import shutil from pathlib import Path _REPO_ROOT = Path(__file__).parent _TEST_KEYRING = _REPO_ROOT / "tests" / "keyring_test.yaml" _KEYRING = _REPO_ROOT / "keyring.yaml" # If the real keyring.yaml doesn't exist, copy the test version so config.py # can load at module import time. This file is gitignored. if not _KEYRING.exists() and _TEST_KEYRING.exists(): shutil.copy2(_TEST_KEYRING, _KEYRING)