The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test(pm): align engine fixtures with public builds
ethernet8bf20a3bc8e1
diff --git a/tests/pm/test_environment_build.py b/tests/pm/test_environment_build.pyindex a1ef0518823..db8ee2578c4 100644--- a/tests/pm/test_environment_build.py+++ b/tests/pm/test_environment_build.py@@ -141,7 +141,8 @@ build_editable = build_wheelreturn source, uv, env-def test_public_build_installs_all_extras_at_explicit_destination(installable_project, tmp_path, monkeypatch):[email protected]("sealed", [False, True])+def test_public_build_installs_all_extras_at_explicit_destination(installable_project, tmp_path, monkeypatch, sealed):from pm import build_environmentimport pm.pathsimport pm.workspace@@ -154,11 +155,17 @@ def test_public_build_installs_all_extras_at_explicit_destination(installable_prexecutable = build_environment(source=source, python=Path(sys.executable), out=tmp_path / "native environment",cache=tmp_path / "cache", env=env, all_extras=True, offline=True,+ sealed=sealed,)assert _run([str(executable), "-I", "-c","import root_app, member_dep, chosen_dep, other_dep; print(root_app.VALUE)"],cwd=tmp_path, env=env) == "installed from the explicit source"assert executable.parent.parent == tmp_path / "native environment"+ from hermes_cli.runtime_paths import site_packages++ site = site_packages(executable.parent.parent)+ assert (site / "_virtualenv.pth").exists() is not sealed+ assert (site / "construction_root.pth").is_file(), "load-bearing .pth must survive sealing"assert (source / "uv.lock").read_bytes() == lockedassert dict(os.environ) == beforeassert not Path(env["HERMES_HOME"]).exists()@@ -320,6 +327,11 @@ def test_failed_build_removes_only_its_candidate(installable_project, tmp_path,out=previous, env=env, cache=tmp_path / "cache", offline=True)cfg = (previous / "pyvenv.cfg").read_bytes()source_lock = (source / "uv.lock").read_bytes()+ # Check destination refusal with valid inputs. The contract does not specify+ # which error comes first when the source is also damaged.+ with pytest.raises(FileExistsError):+ build_environment(source=source, python=Path(sys.executable),+ out=previous, env=env, cache=tmp_path / "cache", offline=True)if damage == "source":(source / "root_app.py").unlink()elif damage == "check":@@ -334,9 +346,6 @@ def test_failed_build_removes_only_its_candidate(installable_project, tmp_path,build_environment(source=source, python=Path(sys.executable),out=candidate, env=env, cache=tmp_path / "cold-cache", offline=True)assert not candidate.exists()- with pytest.raises(FileExistsError):- build_environment(source=source, python=Path(sys.executable),- out=previous, env=env, cache=tmp_path / "cache", offline=True)assert (previous / "pyvenv.cfg").read_bytes() == cfgassert _run([str(executable), "-I", "-c", "import base_dep; print(base_dep.__version__)"],cwd=tmp_path, env=env) == "1.0"diff --git a/tests/pm/test_plugin_survival_contract.py b/tests/pm/test_plugin_survival_contract.pyindex 81fc22c94b6..235d98e5db0 100644--- a/tests/pm/test_plugin_survival_contract.py+++ b/tests/pm/test_plugin_survival_contract.py@@ -81,6 +81,7 @@ def test_sidecar_no_root_pyproject_excludes_nested_and_external(tmp_path, monkey'[project]\nname = "mnemosyne-sidecar"\nversion = "1.0.0"\n', encoding="utf-8")+ monkeypatch.setattr(Path, "home", lambda: tmp_path)monkeypatch.setenv("HERMES_HOME", str(home))assert ws._is_member_candidate(wrapper) is False, (@@ -162,6 +163,7 @@ def admission_env(tmp_path, monkeypatch):ensure = importlib.import_module("pm.ensure")import pm.paths+ monkeypatch.setattr(Path, "home", lambda: tmp_path)monkeypatch.setenv("HERMES_HOME", str(home))monkeypatch.setattr(pm.paths, "repo_root", lambda: core)monkeypatch.setattr(ws.paths, "repo_root", lambda: core)diff --git a/tests/pm/test_workspace_output_encoding.py b/tests/pm/test_workspace_output_encoding.pyindex 20053dfa152..5a21c2d5f33 100644--- a/tests/pm/test_workspace_output_encoding.py+++ b/tests/pm/test_workspace_output_encoding.py@@ -2,6 +2,8 @@import importlibimport locale+import os+from pathlib import Pathimport subprocessimport sys@@ -41,9 +43,12 @@ def test_uv_failure_retains_utf8_build_diagnostic(raw = diagnostic.encode("utf-8") + suffix + b"\n"expected = diagnostic + ("�" if suffix else "")monkeypatch.setattr(ws, "_generate_pyproject", lambda *a, **k: (tmp_path, False))- from pathlib import Path+ from pm.environment import PythonEnvironment- monkeypatch.setattr("pm._uv._toolchain", lambda **kwargs: (Path(sys.executable), Path(sys.executable)))+ environment = PythonEnvironment(+ uv=Path(sys.executable), python=Path(sys.executable),+ destination=tmp_path / "venv", cache=tmp_path / "cache", env=dict(os.environ),+ )completed = []def run_uv(cmd, **kwargs):@@ -55,9 +60,10 @@ def test_uv_failure_retains_utf8_build_diagnostic(completed.append(result)return result- monkeypatch.setattr(ws.subprocess, "run", run_uv)+ monkeypatch.setattr("pm.environment.subprocess.run", run_uv)with pytest.raises(InstallError) as excinfo:- ws.lock_and_sync([], venv_dir=tmp_path / "venv", root=tmp_path)+ ws.lock_and_sync([], venv_dir=environment.destination, root=tmp_path,+ source=tmp_path, environment=environment)assert type(excinfo.value) is InstallError # A build error is not a resolver conflict.assert excinfo.value.cause == f"uv {stage} exited 17: {expected}"