Files
hermes-agent/tests/pm/conftest.py
ethernet a00ca233f8 fix(pm): voice enables audio-io through PM; public plugin-state readers; PM tests isolate the machine home
- voice_mode: `_import_audio` asks `pm.ensure_import("audio-io")` before importing
  sounddevice, so `/voice on` turns the feature on (or reports exactly why PM
  refused: lazy installs off, platform gate, restart needed) instead of printing a
  `python -c "from pm import sync_venv…"` one-liner for the user to run.
- pm.plugins_state: `read_home_selection` and `dependency_homes` are the public
  readers; memory_provider_migration and plugins_cmd stop importing underscored names.
- pm.store: the `sha256_file` shim is gone; the authority test asserts the Store has no
  file hash of its own rather than patching one.
- tests/pm/conftest: `isolated_machine_home` is autouse (Path.home, HOME, USERPROFILE,
  HERMES_HOME all under tmp_path); `@pytest.mark.real_machine_home` opts a module out
  — the four suites that spawn children with a home they build themselves.
- activate / activate.ps1 / Dockerfile followed hermes_cli.runtime_paths to
  pm.environments (the earlier sweep only covered .py).
- pm.registry loads builtins through importlib so a test patching `pm.packages` in
  sys.modules still registers the security packages.
2026-09-19 00:48:11 -04:00

28 lines
1.0 KiB
Python

"""Shared fixtures for the PM suite."""
from pathlib import Path
import pytest
def pytest_configure(config):
config.addinivalue_line(
"markers", "real_machine_home: keep Path.home() intact (a subprocess or stage_runtime needs the real one)")
@pytest.fixture(autouse=True)
def isolated_machine_home(request, tmp_path, monkeypatch):
"""Machine-scoped PM state (store, caches, profiles root) lands under tmp_path.
The root conftest already sandboxes HERMES_HOME; PM additionally keys its machine cache
off the home directory, so that moves too — in this process (Path.home) and in any child
(HOME / USERPROFILE). Opt out with ``@pytest.mark.real_machine_home``.
"""
if request.node.get_closest_marker("real_machine_home"):
return
home = tmp_path / ".hermes"
home.mkdir(exist_ok=True)
monkeypatch.setattr(Path, "home", lambda: tmp_path)
monkeypatch.setenv("HOME", str(tmp_path))
monkeypatch.setenv("USERPROFILE", str(tmp_path))
monkeypatch.setenv("HERMES_HOME", str(home))