mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-11-19 21:37:12 +03:00
55a4e326c8
The old-venv carry read any `venv/` or `.venv/` with a site-packages as the install's pre-PM state. On a data root with no recorded selection (a test's HERMES_HOME, a borrowing launch) beside a developer checkout, the `.venv` that CONTRIBUTING.md has contributors build (`pm.build_env --out .venv`) was unioned into every sync: a narrow request gained `all` and the dev env's anchors, and CI's core-only `--extras '[]'` would record `[all]`. A main-era installer always installed Hermes into its venv from a tree without `pm`. The carry now requires that: a `hermes_agent` dist-info whose top_level lacks `pm`. A venv built from a PM tree lists `pm`, and a bare `uv venv` holds no Hermes, so neither is carried. tests/pm also stops reading the running checkout's venvs, and the legacy fixtures build the main-era venv through one helper.
45 lines
1.8 KiB
Python
45 lines
1.8 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))
|
|
|
|
|
|
@pytest.fixture(autouse=True)
|
|
def checkout_venvs_are_not_an_install(monkeypatch):
|
|
"""The checkout running the suite is never a test's pre-PM install.
|
|
|
|
Many PM tests keep ``repo_root`` at the real checkout under an isolated HERMES_HOME (no
|
|
recorded selection), where PM reads that checkout's ``venv/`` or ``.venv/`` as the old
|
|
install's. Whatever a contributor keeps there must not change what those tests select; a
|
|
test of the legacy carry builds its own tree under ``tmp_path``.
|
|
"""
|
|
from pm import extras
|
|
|
|
checkout = Path(__file__).resolve().parents[2]
|
|
real = extras._pre_pm_site_packages
|
|
monkeypatch.setattr(extras, "_pre_pm_site_packages",
|
|
lambda root: [] if Path(root).resolve() == checkout else real(root))
|