The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(tests): resolve windows-tests merge conflicts + platform() marker migration
ethernet0f5c7803f6d5
diff --git a/tests/conftest.py b/tests/conftest.pyindex 1bcd5c6e20a..6b6ddf05acb 100644--- a/tests/conftest.py+++ b/tests/conftest.py@@ -92,6 +92,19 @@ if _hermes_home_points_at_production(os.environ.get("HERMES_HOME", "")):os.environ["HERMES_HOME"] = _SESSION_HERMES_HOMEatexit.register(shutil.rmtree, _SESSION_HERMES_HOME, True)+# PYTHONPYCACHEPREFIX is a bytecode-mirror escape hatch: when set (the+# bundled desktop app exports it as %LOCALAPPDATA%\hermes\pycache),+# importlib/pytest write .pyc files to <prefix>/<absolute source path>+# instead of next to the sources. Un-scrubbed, that mirror lands under+# the REAL hermes home and trips the real-home tripwire on any module+# imported after sandboxing (test_find_shell was the first to bite).+# Clear it so bytecode goes back beside the (already sandboxed) sources.+os.environ.pop("PYTHONPYCACHEPREFIX", None)+try:+ sys.pycache_prefix = None+except AttributeError:+ pass+# Subprocess-surviving isolation marker (#82770). PYTEST_CURRENT_TEST /# PYTEST_VERSION are pytest's own vars, and tests that spawn children# routinely rebuild the child env and strip them ("the subprocess must lookdiff --git a/tests/gateway/test_windows_service_frontend.py b/tests/gateway/test_windows_service_frontend.pyindex 22753737115..400cc6051b5 100644--- a/tests/gateway/test_windows_service_frontend.py+++ b/tests/gateway/test_windows_service_frontend.py@@ -69,7 +69,7 @@ def test_stop_marker_failure_falls_back_to_terminate(monkeypatch):assert terminated == {"pid": 99, "sig": 15}[email protected]_only[email protected]("windows")def test_no_pywin32_means_friendly_error(tmp_path, capfd):"""A user running --service BY HAND (not via SCM): pywin32 is presentbut Initialize/dispatcher refuse without the SCM — the frontend mustdiff --git a/tests/hermes_cli/test_gateway_job_teardown_live.py b/tests/hermes_cli/test_gateway_job_teardown_live.pyindex e6245c10c6e..44c772b98d6 100644--- a/tests/hermes_cli/test_gateway_job_teardown_live.py+++ b/tests/hermes_cli/test_gateway_job_teardown_live.py@@ -38,7 +38,7 @@ from pathlib import Pathimport pytestpytestmark = [- pytest.mark.windows_only,+ pytest.mark.platforms("windows"),pytest.mark.skipif(sys.platform != "win32", reason="native Windows only"),]diff --git a/tests/hermes_cli/test_linux_desktop_entry.py b/tests/hermes_cli/test_linux_desktop_entry.pyindex 3371c1f1001..aa7a3597936 100644--- a/tests/hermes_cli/test_linux_desktop_entry.py+++ b/tests/hermes_cli/test_linux_desktop_entry.py@@ -3,6 +3,7 @@from __future__ import annotationsimport stat+import sysfrom pathlib import Pathimport pytestdiff --git a/tests/hermes_cli/test_tui_npm_install.py b/tests/hermes_cli/test_tui_npm_install.pyindex 4dfbc33498c..5dba8a1b756 100644--- a/tests/hermes_cli/test_tui_npm_install.py+++ b/tests/hermes_cli/test_tui_npm_install.py@@ -254,116 +254,6 @@ def test_no_install_prebuilt_bundle_mode(tmp_path: Path, main_mod) -> None:assert main_mod._tui_need_npm_install(tmp_path) is False---def test_need_rebuild_when_tui_bundle_missing(tmp_path: Path, main_mod) -> None:- (tmp_path / "src").mkdir()- (tmp_path / "src" / "entry.tsx").write_text("console.log('src')")-- assert main_mod._tui_need_rebuild(tmp_path) is True---def test_no_rebuild_when_tui_bundle_newer_than_inputs(tmp_path: Path, main_mod) -> None:- _touch_tui_entry(tmp_path)- src = tmp_path / "src"- src.mkdir()- (src / "entry.tsx").write_text("console.log('src')")- os.utime(src / "entry.tsx", (100, 100))- os.utime(tmp_path / "dist" / "entry.js", (200, 200))-- assert main_mod._tui_need_rebuild(tmp_path) is False---def test_rebuild_when_tui_source_newer_than_bundle(tmp_path: Path, main_mod) -> None:- _touch_tui_entry(tmp_path)- src = tmp_path / "src"- src.mkdir()- (src / "entry.tsx").write_text("console.log('src')")- os.utime(tmp_path / "dist" / "entry.js", (100, 100))- os.utime(src / "entry.tsx", (200, 200))-- assert main_mod._tui_need_rebuild(tmp_path) is True---def test_make_tui_argv_skips_build_only_on_termux_when_fresh(- tmp_path: Path, main_mod, monkeypatch-) -> None:- _touch_tui_entry(tmp_path)- monkeypatch.setenv("TERMUX_VERSION", "1")- monkeypatch.setattr(main_mod, "_tui_need_npm_install", lambda _root: False)- monkeypatch.setattr(main_mod, "_tui_need_rebuild", lambda _root: False)- monkeypatch.setattr(main_mod.shutil, "which", lambda name: f"/bin/{name}")-- def fail_run(*_args, **_kwargs):- raise AssertionError("fresh Termux TUI launch must not rebuild")-- monkeypatch.setattr(main_mod.subprocess, "run", fail_run)-- argv, cwd = main_mod._make_tui_argv(tmp_path, tui_dev=False)-- assert argv[1:] == ["--expose-gc", str(tmp_path / "dist" / "entry.js")]- assert cwd == tmp_path---def test_make_tui_argv_skips_install_on_termux_when_bundle_fresh(- tmp_path: Path, main_mod, monkeypatch-) -> None:- _touch_tui_entry(tmp_path)- monkeypatch.setenv("TERMUX_VERSION", "1")- monkeypatch.setattr(main_mod, "_tui_need_npm_install", lambda _root: True)- monkeypatch.setattr(main_mod, "_tui_need_rebuild", lambda _root: False)- monkeypatch.setattr(main_mod.shutil, "which", lambda name: f"/bin/{name}")-- def fail_run(*_args, **_kwargs):- raise AssertionError("fresh Termux TUI launch must not run npm")-- monkeypatch.setattr(main_mod.subprocess, "run", fail_run)-- argv, cwd = main_mod._make_tui_argv(tmp_path, tui_dev=False)-- assert argv[1:] == ["--expose-gc", str(tmp_path / "dist" / "entry.js")]- assert cwd == tmp_path---def test_make_tui_argv_scopes_npm_install_on_termux_workspace(- tmp_path: Path, main_mod, monkeypatch-) -> None:- tui_dir = tmp_path / "ui-tui"- tui_dir.mkdir()- (tui_dir / "package.json").write_text("{}")- ink_dir = tui_dir / "packages" / "hermes-ink"- ink_dir.mkdir(parents=True)- (ink_dir / "package.json").write_text("{}")- (tmp_path / "package-lock.json").write_text("{}")-- monkeypatch.setenv("TERMUX_VERSION", "1")- monkeypatch.setattr(main_mod, "_tui_need_npm_install", lambda _root: True)- monkeypatch.setattr(main_mod, "_tui_need_rebuild", lambda _root: True)- monkeypatch.setattr(main_mod.shutil, "which", lambda name: f"/bin/{name}")- calls = []-- def fake_run(*args, **kwargs):- calls.append((args, kwargs))- return types.SimpleNamespace(returncode=0, stdout="", stderr="")-- monkeypatch.setattr(main_mod.subprocess, "run", fake_run)-- main_mod._make_tui_argv(tui_dir, tui_dev=False)-- install_cmd = calls[0][0][0]- assert install_cmd[1:7] == [- "install",- "--workspace",- "ui-tui",- "--workspace",- "ui-tui/packages/hermes-ink",- "--include-workspace-root=false",- ]- assert calls[0][1]["cwd"] == str(tmp_path)- _assert_utf8_replace_capture(calls[0][1])- _assert_utf8_replace_capture(calls[1][1])--def test_make_tui_argv_keeps_desktop_workspace_install_behaviour(tmp_path: Path, main_mod, monkeypatch) -> None:@@ -374,7 +264,10 @@ def test_make_tui_argv_keeps_desktop_workspace_install_behaviour(monkeypatch.setenv("PREFIX", "/usr")monkeypatch.setattr(main_mod, "_tui_need_npm_install", lambda _root: True)- monkeypatch.setattr(main_mod.shutil, "which", lambda name: f"/bin/{name}")+ monkeypatch.setattr(+ "hermes_constants.find_node_executable",+ lambda name: f"/bin/{name}",+ )calls = []def fake_run(*args, **kwargs):@@ -385,7 +278,8 @@ def test_make_tui_argv_keeps_desktop_workspace_install_behaviour(main_mod._make_tui_argv(tui_dir, tui_dev=False)- assert calls[0][0][0][1:] == [+ assert calls[0][0][0] == [+ "/bin/npm","install","--workspace","ui-tui",@@ -416,7 +310,10 @@ def test_make_tui_argv_npm_install_forces_include_dev(monkeypatch.setenv("PREFIX", "/usr")monkeypatch.setenv("NODE_ENV", "production")monkeypatch.setattr(main_mod, "_tui_need_npm_install", lambda _root: True)- monkeypatch.setattr(main_mod.shutil, "which", lambda name: f"/bin/{name}")+ monkeypatch.setattr(+ "hermes_constants.find_node_executable",+ lambda name: f"/bin/{name}",+ )calls = []def fake_run(*args, **kwargs):@@ -428,7 +325,7 @@ def test_make_tui_argv_npm_install_forces_include_dev(main_mod._make_tui_argv(tui_dir, tui_dev=False)install_cmd = calls[0][0][0]- assert install_cmd[1] == "install"+ assert install_cmd[:2] == ["/bin/npm", "install"]assert "--include=dev" in install_cmd@@ -438,7 +335,10 @@ def test_make_tui_argv_keeps_desktop_always_build_behaviour(_touch_tui_entry(tmp_path)monkeypatch.setenv("PREFIX", "/usr")monkeypatch.setattr(main_mod, "_tui_need_npm_install", lambda _root: False)- monkeypatch.setattr(main_mod.shutil, "which", lambda name: f"/bin/{name}")+ monkeypatch.setattr(+ "hermes_constants.find_node_executable",+ lambda name: f"/bin/{name}",+ )calls = []def fake_run(*args, **kwargs):@@ -450,7 +350,7 @@ def test_make_tui_argv_keeps_desktop_always_build_behaviour(main_mod._make_tui_argv(tmp_path, tui_dev=False)assert calls- assert calls[0][0][0][-2:] == ["run", "build"]+ assert calls[0][0][0] == ["/bin/npm", "run", "build"]_assert_utf8_replace_capture(calls[0][1])@@ -464,7 +364,10 @@ def test_make_tui_argv_decodes_dev_prebuild_with_utf8_replace(tsx.write_text("")monkeypatch.setattr(main_mod, "_tui_need_npm_install", lambda _root: False)- monkeypatch.setattr(main_mod.shutil, "which", lambda name: f"/bin/{name}")+ monkeypatch.setattr(+ "hermes_constants.find_node_executable",+ lambda name: f"/bin/{name}",+ )calls = []def fake_run(*args, **kwargs):@@ -477,7 +380,7 @@ def test_make_tui_argv_decodes_dev_prebuild_with_utf8_replace(assert argv == [str(tsx), "src/entry.tsx"]assert cwd == tmp_path- assert calls[0][0][0][-2:] == ["run", "build"]+ assert calls[0][0][0] == ["/bin/npm", "run", "build"]assert calls[0][1]["cwd"] == str(ink_dir)_assert_utf8_replace_capture(calls[0][1])@@ -487,7 +390,7 @@ def test_make_tui_argv_exits_with_recovery_hint_when_workspace_unrecoverable() -> None:"""Missing ui-tui + no git checkout → clean error, never touches node/npm."""monkeypatch.delenv("HERMES_TUI_DIR", raising=False)- monkeypatch.setattr(main_mod, "_ensure_tui_node", lambda: None)+ monkeypatch.setattr(main_mod, "_ensure_tui_workspace", lambda _root: None)bundled_entry = tmp_path / "bundled" / "entry.js"bundled_entry.parent.mkdir(parents=True)@@ -499,7 +402,7 @@ def test_make_tui_argv_exits_with_recovery_hint_when_workspace_unrecoverable(return "/usr/bin/node"raise AssertionError(f"unexpected shutil.which({name!r}) call — bundled path must not need npm/git")- monkeypatch.setattr(main_mod.shutil, "which", which)+ monkeypatch.setattr("hermes_constants.find_node_executable", which)def fail_run(*_args, **_kwargs):raise AssertionError("bundled TUI path must not spawn any subprocess (no npm install/build, no git restore)")@@ -513,7 +416,7 @@ def test_make_tui_argv_exits_with_recovery_hint_when_workspace_unrecoverable(argv, cwd = main_mod._make_tui_argv(tui_dir, tui_dev=False)- assert argv[1:] == ["--expose-gc", str(bundled_entry)]+ assert argv == ["/usr/bin/node", "--expose-gc", str(bundled_entry)]assert cwd == bundled_entry.parent@@ -716,7 +619,10 @@ def test_make_tui_argv_omits_workspace_and_scrubs_esbuild_override(monkeypatch.setenv("PREFIX", "/usr")monkeypatch.setenv("ESBUILD_BINARY_PATH", "/opt/esbuild-0.28.2")monkeypatch.setattr(main_mod, "_tui_need_npm_install", lambda _root: True)- monkeypatch.setattr(main_mod.shutil, "which", lambda name: f"/bin/{name}")+ monkeypatch.setattr(+ "hermes_constants.find_node_executable",+ lambda name: f"/bin/{name}",+ )calls = []def fake_run(*args, **kwargs):diff --git a/tests/hermes_cli/test_update_cron_deadlock_guard.py b/tests/hermes_cli/test_update_cron_deadlock_guard.pyindex d4cce9746ae..1ffcc85b338 100644--- a/tests/hermes_cli/test_update_cron_deadlock_guard.py+++ b/tests/hermes_cli/test_update_cron_deadlock_guard.py@@ -20,7 +20,7 @@ from unittest.mock import patchimport pytest-linux_only = pytest.mark.linux_only+linux_only = pytest.mark.platforms("linux")class TestAncestorDetectionGuard:diff --git a/tests/test_install_ps1_managed_python_provenance.py b/tests/test_install_ps1_managed_python_provenance.pyindex 5c91721a327..cefa8bc4503 100644--- a/tests/test_install_ps1_managed_python_provenance.py+++ b/tests/test_install_ps1_managed_python_provenance.py@@ -13,7 +13,7 @@ import pytestfrom tests.install_ps1_fake_uv import compile_fake_uv-pytestmark = pytest.mark.windows_only+pytestmark = pytest.mark.platforms("windows")_INSTALL_PS1 = Path(__file__).resolve().parents[1] / "scripts" / "install.ps1"diff --git a/tests/test_powershell_script_syntax.py b/tests/test_powershell_script_syntax.pyindex d164f4e310e..90f19f08850 100644--- a/tests/test_powershell_script_syntax.py+++ b/tests/test_powershell_script_syntax.py@@ -66,7 +66,7 @@ def test_repo_has_powershell_scripts_to_gate() -> None:assert "install.ps1" in names, PS1_SCRIPTS[email protected]_only[email protected]("windows")def test_powershell_scripts_parse(tmp_path: Path) -> None:host = _powershell_host()assert host is not None, "no PowerShell host on a Windows runner"diff --git a/tests/tools/test_approval_timeout_overflow.py b/tests/tools/test_approval_timeout_overflow.pyindex 82fc238312b..537cb973478 100644--- a/tests/tools/test_approval_timeout_overflow.py+++ b/tests/tools/test_approval_timeout_overflow.py@@ -82,11 +82,6 @@ class TestApprovalTimeoutOverflowClamp:# for the platform-aware primary bound; the fallback stays below# the narrowest one, the Windows DWORD-ms cap).assert 0 < value < 0xFFFFFFFF / 1000.0-- # The fallback mirrors the per-host MAX_SAFE_TIMEOUT_S ceiling- # (imported BEFORE the block — the check itself must not depend on- # the patched-away import).- assert value == int(MAX_SAFE_TIMEOUT_S)# Still platform-safe for the crashing primitive.lock = threading.Lock()assert lock.acquire(timeout=value)diff --git a/tests/tools/test_find_shell.py b/tests/tools/test_find_shell.pyindex 0b41f8be598..98a93f53d92 100644--- a/tests/tools/test_find_shell.py+++ b/tests/tools/test_find_shell.py@@ -110,7 +110,7 @@ class TestFindBashCollapsedToPmShell:Program Files) and the ASLR diagnostic were deleted — the store is theauthority on bundled bash."""- @pytest.mark.windows_only+ @pytest.mark.platforms("windows")def test_delegates_to_pm_shell(self, monkeypatch):"""_find_bash returns whatever pm.shell() resolves (store bash orprovisioned PATH)."""