Test Isolation Contract
Tests never read or write the real ~/.hermes. This is enforced, not just convention.
The isolate_hermes_home fixture
Section titled “The isolate_hermes_home fixture”An autouse pytest fixture in conftest.py redirects HERMES_HOME to a fresh
per-test temp directory. HOME and USERPROFILE are also pinned to the same
temp dir as a safety net for any Path.home() fallback.
The poison-file test (test_isolation.py)
Section titled “The poison-file test (test_isolation.py)”test_isolation.py plants a poisoned sentinel file in a decoy home directory and
asserts that no code path reads it. This is a fail-closed check: any new code that
reaches outside HERMES_HOME will break this test before it breaks production data.
Rule for new code: always locate Hermes files via os.environ.get("HERMES_HOME", Path.home() / ".hermes"), never via Path.home() directly.
Pricing fixture
Section titled “Pricing fixture”tests/fixtures/pricing.yaml is a committed fixture used by pricing tests.
This prevents test results from depending on whatever ~/.hermes/telemetry/pricing.yaml
your machine happens to have. New tests that need specific pricing data should
seed it in the per-test temp dir, not rely on real files.
Where do tests write?
Section titled “Where do tests write?”/tmp/pytest-of-<user>/pytest-<N>/<test_name><i>/telemetry/{telemetry.db,pricing.yaml,...}pytest’s built-in tmp_path fixture mints this per test. Override the base dir
with pytest --basetemp=DIR.
HERMES_TELEMETRY_HOME neutralization
Section titled “HERMES_TELEMETRY_HOME neutralization”HERMES_TELEMETRY_HOME outranks HERMES_HOME when resolving telemetry paths. The autouse
isolate_hermes_home fixture (conftest.py) therefore DELETES HERMES_TELEMETRY_HOME per
test, so a developer’s ambient value cannot override the tmp redirect and leak the suite into
the real ~/.hermes/telemetry. Enforced by
tests/test_isolation.py::test_conftest_neutralizes_ambient_telemetry_home.
hermes-telemetry is an independent community plugin for Hermes Agent. It is not affiliated with or endorsed by Nous Research.