Skip to content

The agent that grows with you

test(update): trim the salvaged finder/hand-off tests to two invariants per fix

teknium17f9b95eb8d1a
diff --git a/tests/hermes_cli/test_update_handoff_checkout_cwd.py b/tests/hermes_cli/test_update_handoff_checkout_cwd.py
index 15c8c9055fb..bdb76e019e4 100644
--- a/tests/hermes_cli/test_update_handoff_checkout_cwd.py
+++ b/tests/hermes_cli/test_update_handoff_checkout_cwd.py
@@ -158,41 +158,3 @@ def test_outside_cwd_child_reaches_the_new_package(monkeypatch, tmp_path):
break
time.sleep(0.1)
assert marker.read_text(encoding="utf-8") == "sync:sync"
-
-
-def test_unrelated_import_error_still_fails(monkeypatch, tmp_path):
- checkout, outside, _finder = _layout(tmp_path)
- monkeypatch.chdir(outside)
- monkeypatch.setattr(handoff, "write_handoff", lambda payload: tmp_path / "handoff.json")
- monkeypatch.setattr(
- handoff,
- "post_swap_command",
- lambda path, tail: [sys.executable, "-c", "import this_package_is_not_in_the_tree"],
- )
- monkeypatch.setattr(handoff, "post_swap_child_env", lambda: os.environ.copy())
- monkeypatch.setattr(handoff, "_post_swap_cwd", lambda: str(checkout))
- monkeypatch.setattr(handoff, "_running_from_windows_shim", lambda: False)
- monkeypatch.setattr(sys, "stdin", open(os.devnull, "r"))
-
- assert handoff.continue_update_in_fresh_interpreter({}, argv_tail=[]) != 0
-
-
-def test_current_map_imports_without_the_checkout_cwd(tmp_path):
- """A package already visible on PYTHONPATH does not need the hand-off cwd."""
- _checkout, outside, _finder = _layout(tmp_path)
- visible = tmp_path / "visible"
- pkg = visible / "handoff_newpkg"
- pkg.mkdir(parents=True)
- (pkg / "__init__.py").write_text("MARKER = 'sync'\n", encoding="utf-8")
- env = os.environ.copy()
- env["PYTHONPATH"] = str(visible)
- proc = subprocess.run(
- [sys.executable, "-c", "import handoff_newpkg; print(handoff_newpkg.MARKER)"],
- cwd=outside,
- env=env,
- capture_output=True,
- text=True,
- check=False,
- )
- assert proc.returncode == 0
- assert proc.stdout.strip() == "sync"
diff --git a/tests/hermes_cli/test_update_skip_unchanged_editable_install.py b/tests/hermes_cli/test_update_skip_unchanged_editable_install.py
index 190146d8735..bc05e16d712 100644
--- a/tests/hermes_cli/test_update_skip_unchanged_editable_install.py
+++ b/tests/hermes_cli/test_update_skip_unchanged_editable_install.py
@@ -71,29 +71,26 @@ def _declare_packages(repo, include):
@pytest.mark.parametrize("annotated", [False, True])
-def test_stale_map_refuses_the_skip(repo, monkeypatch, annotated):
- """A missing top-level name refuses the skip for both finder spellings."""
+def test_stale_or_unreadable_finder_map_refuses_the_skip(repo, monkeypatch, annotated):
+ """A map missing a top-level name (either finder spelling) or an unparseable finder refuses
+ the skip even though the pull touched no packaging file."""
_declare_packages(repo, ["agent", "agent.*", "newpkg", "newpkg.*"])
before = _head(repo)
(repo / "newpkg").mkdir()
(repo / "newpkg" / "__init__.py").write_text("")
_commit(repo, "add package")
- _finder(repo, {"agent": str(repo / "agent"), "cli": str(repo / "cli")}, annotated=annotated)
+ site = _finder(repo, {"agent": str(repo / "agent"), "cli": str(repo / "cli")}, annotated=annotated)
monkeypatch.setattr("hermes_cli.update_cmd_deps.project_venv_dir", lambda _: repo / "venv")
assert _editable_install_is_current(GIT, repo, before) is False
+ (site / "__editable___hermes_agent_0_21_4_finder.py").write_text("MAPPING = (\n", encoding="utf-8")
+ assert _editable_install_is_current(GIT, repo, before) is False
[email protected]("annotated", [False, True])
@pytest.mark.parametrize("layout", ["lib/python3.11/site-packages", "Lib/site-packages"])
-def test_covered_map_skips_source_churn(repo, monkeypatch, layout, annotated):
- """A map that already names the checkout still skips source edits."""
+def test_covered_map_skips_source_churn(repo, monkeypatch, layout):
+ """A map that already names the checkout still skips source edits (POSIX and Windows venvs)."""
_declare_packages(repo, ["agent", "agent.*"])
- _finder(
- repo,
- {"agent": str(repo / "agent"), "cli": str(repo / "cli")},
- layout=layout,
- annotated=annotated,
- )
+ _finder(repo, {"agent": str(repo / "agent"), "cli": str(repo / "cli")}, layout=layout)
monkeypatch.setattr("hermes_cli.update_cmd_deps.project_venv_dir", lambda _: repo / "venv")
before = _head(repo)
(repo / "agent" / "loop.py").write_text("y = 2\n")
@@ -101,15 +98,6 @@ def test_covered_map_skips_source_churn(repo, monkeypatch, layout, annotated):
assert _editable_install_is_current(GIT, repo, before) is True
-def test_unreadable_finder_fails_closed(repo, monkeypatch):
- before = _head(repo)
- site = repo / "venv" / "lib" / "python3.11" / "site-packages"
- site.mkdir(parents=True)
- (site / "__editable___hermes_agent_0_21_4_finder.py").write_text("MAPPING = (\n", encoding="utf-8")
- monkeypatch.setattr("hermes_cli.update_cmd_deps.project_venv_dir", lambda _: repo / "venv")
- assert _editable_install_is_current(GIT, repo, before) is False
-
-
def test_source_only_pull_skips_the_reinstall(repo):
"""The common update: .py churn inside already-mapped packages."""
before = _head(repo)