"""Pytest fixtures: redirect HERMES_HOME to a temp dir and fix sys.path.""" from __future__ import annotations import os import sys from pathlib import Path import pytest _PLUGIN_DIR = Path(__file__).resolve().parent.parent / "plugin" _HERMES_SRC = os.environ.get("PHEBY_HERMES_SRC", "/opt/hermes") for _p in (str(_PLUGIN_DIR), _HERMES_SRC): if _p not in sys.path: sys.path.insert(0, _p) @pytest.fixture(autouse=True) def _isolated_hermes_home(tmp_path, monkeypatch): """Point HERMES_HOME at a per-test temp dir (Hermes tests' convention).""" home = tmp_path / "hermes-home" home.mkdir(parents=True, exist_ok=True) monkeypatch.setenv("HERMES_HOME", str(home)) # Also neutralize any ambient PHEBY config so tests are deterministic. monkeypatch.delenv("PHEBY_SECRET", raising=False) monkeypatch.delenv("PHEBY_BIND_HOST", raising=False) monkeypatch.delenv("PHEBY_PORT", raising=False) yield str(home)