From d9662a5cf5a6a73b8dca3983db5ce3467e3b069e Mon Sep 17 00:00:00 2001 From: abhay-codes07 Date: Mon, 17 Aug 2026 00:09:37 +0530 Subject: [PATCH] test(install): stop three Windows failures that assume the POSIX layout None of these three test the thing that breaks them; the assertion, not the product, is what assumes POSIX. No product code changes. test_codex_skill_uses_graphify_with_existing_graph read skill-codex.md through read_text() with no encoding=, so on Windows the locale codepage decoded the file's UTF-8 em dash as cp1252 and "Fast path - existing graph" never matched. Both reads of that file in this module now pass encoding="utf-8", so the sibling test cannot start failing the day one of its assertions gains a non-ASCII character. Same defect #2209 fixes in test_merge_chunks_validation.py and test_pipeline.py; that PR does not touch test_install.py, so there is no overlap. test_hermes_skill_destination_posix_uses_home patched platform.system() to "Linux" to reach the non-Windows branch, but that does not change pathlib's flavour: Path stays WindowsPath, str(dst) comes back with backslashes, and the forward-slash suffix could never match. The branch under test was being reached correctly; only the comparison was wrong, so it now compares as_posix(). test_skill_roundtrip_at_real_destination[user-hermes] patched Path.home and then asserted the destination lands under it, but hermes on Windows resolves through %LOCALAPPDATA% rather than ~ (#1403), and LOCALAPPDATA still pointed at the session-wide sandbox home from conftest._sandbox_home. Redirecting it alongside the Path.home patch is what the test already means by "home" -- it mirrors what conftest does, scoped to this test's directory -- so the assertion checks the real destination again instead of passing by accident of platform. The three gemini failures in test_uninstall_scope.py and test_install_references.py look like the same class but are not, and are deliberately left alone: they hardcode ~/.gemini/skills/graphify while the install lands in ~/.agents/skills/graphify on Windows, a destination shared with the agents platform. Whether the test or the product is wrong is #2800, and the two answers need opposite edits to these same tests. --- tests/test_install.py | 12 +++++++++--- tests/test_install_roundtrip.py | 5 +++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/tests/test_install.py b/tests/test_install.py index 7e74487cb..4660e7b48 100644 --- a/tests/test_install.py +++ b/tests/test_install.py @@ -259,7 +259,7 @@ def test_codex_skill_contains_spawn_agent(): """Codex skill file must reference spawn_agent.""" import graphify - skill = (Path(graphify.__file__).parent / "skill-codex.md").read_text() + skill = (Path(graphify.__file__).parent / "skill-codex.md").read_text(encoding="utf-8") assert "spawn_agent" in skill @@ -271,7 +271,10 @@ def test_codex_skill_uses_graphify_with_existing_graph(): fast-path block, which jumps straight to the query flow when a graph exists. """ import graphify - skill = (Path(graphify.__file__).parent / "skill-codex.md").read_text() + # encoding= matters: the skill is UTF-8 and the assertions below carry an em + # dash and an en dash. Without it Windows decodes through the locale codepage + # and the match fails on a file that is perfectly fine. + skill = (Path(graphify.__file__).parent / "skill-codex.md").read_text(encoding="utf-8") assert "Fast path — existing graph" in skill assert "skip Steps 1–5 entirely and jump straight to `## For /graphify query`" in skill assert "graphify query" in skill @@ -1161,7 +1164,10 @@ def test_hermes_skill_destination_posix_uses_home(): from graphify.__main__ import _platform_skill_destination with patch("graphify.__main__.platform.system", return_value="Linux"): dst = _platform_skill_destination("hermes", project=False) - assert str(dst).endswith(".hermes/skills/graphify/SKILL.md"), dst + # Compare the path, not the host's separator: patching platform.system() does + # not change pathlib's flavour, so on Windows dst is still a WindowsPath and + # str() renders backslashes. The POSIX branch IS being exercised here. + assert dst.as_posix().endswith(".hermes/skills/graphify/SKILL.md"), dst def _cli_dispatched_commands() -> set[str]: diff --git a/tests/test_install_roundtrip.py b/tests/test_install_roundtrip.py index 68216e6b3..e719619c2 100644 --- a/tests/test_install_roundtrip.py +++ b/tests/test_install_roundtrip.py @@ -57,6 +57,11 @@ def test_skill_roundtrip_at_real_destination(platform, project, tmp_path, monkey home.mkdir() project_dir.mkdir() monkeypatch.chdir(project_dir) + # hermes resolves its Windows destination through %LOCALAPPDATA%, not ~ (#1403), + # so patching Path.home alone leaves it pointing at conftest._sandbox_home and + # the startswith(home) check below compares against the wrong tree. Redirect it + # to this test's home, mirroring what conftest does session-wide. + monkeypatch.setenv("LOCALAPPDATA", str(home / "AppData" / "Local")) with patch("graphify.__main__.Path.home", return_value=home): dst = mainmod._platform_skill_destination(