From ff3ea99a16d24b2c86e1623dca85cbe0bdb2cbd1 Mon Sep 17 00:00:00 2001 From: Krzysztof kuhy Rudnicki Date: Sun, 23 Aug 2026 14:53:29 +0200 Subject: [PATCH] Fix a test that only passed in a directory named testsAndMisc test_passes_store_and_repo_root asserted env["PYTHONPATH"].endswith("testsAndMisc"), which is a property of the checkout's directory name rather than of the code. It fails in any worktree, which is where ci-mirror runs its gates. Assert against the value reindex.py actually computes, Path(reindex.__file__).resolve().parents[2]. Exact equality is a stronger check than the suffix match it replaces. This was invisible until now because ci-mirror invoked pytest_changed_packages.py with no arguments, and that script returns 0 on empty argv -- so the pre-push pytest stage never ran. The next commit fixes the invocation. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01PJrqKERAo5QUeEHWS5Asgp --- ...ndex-path-independent-test-2026-08-23.json | 30 +++++++++++++++++++ python_pkg/archwiki_rag/tests/test_reindex.py | 3 +- 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 docs/superpowers/evidence/archwiki-reindex-path-independent-test-2026-08-23.json diff --git a/docs/superpowers/evidence/archwiki-reindex-path-independent-test-2026-08-23.json b/docs/superpowers/evidence/archwiki-reindex-path-independent-test-2026-08-23.json new file mode 100644 index 00000000..7d9fdb7b --- /dev/null +++ b/docs/superpowers/evidence/archwiki-reindex-path-independent-test-2026-08-23.json @@ -0,0 +1,30 @@ +{ + "intent": "Make test_passes_store_and_repo_root pass in any checkout, not only one whose directory happens to be named 'testsAndMisc'.", + "scope": [ + "python_pkg/archwiki_rag/tests/test_reindex.py", + "Non-goal: changing reindex.py production behaviour" + ], + "changes": [ + "Replaced the hardcoded assertion env['PYTHONPATH'].endswith('testsAndMisc') with an exact comparison against the repo root the code itself computes, Path(reindex.__file__).resolve().parents[2].", + "The assertion is strengthened, not weakened: exact equality replaces a suffix match." + ], + "verification": [ + { + "command": "python -m pytest python_pkg/archwiki_rag/tests/test_reindex.py -q", + "result": "pass", + "evidence": "19 passed, run both in /home/kuhy/testsAndMisc and in a worktree at /tmp/meas-gIJ1/co" + }, + { + "command": "python meta/scripts/pytest_changed_packages.py in a clean worktree", + "result": "pass", + "evidence": "2101 passed, TOTAL coverage 100.00% (7082 stmts, 1742 branches, 0 missing)" + } + ], + "risks": [ + "None material: the test now asserts against the same expression the source uses, so a genuine PYTHONPATH regression still fails it." + ], + "rollback": [ + "git revert the commit", + "Re-run the archwiki_rag test module; it will pass again in ~/testsAndMisc but resume failing in any differently-named checkout" + ] +} diff --git a/python_pkg/archwiki_rag/tests/test_reindex.py b/python_pkg/archwiki_rag/tests/test_reindex.py index 6f5da913..93e924e2 100644 --- a/python_pkg/archwiki_rag/tests/test_reindex.py +++ b/python_pkg/archwiki_rag/tests/test_reindex.py @@ -143,7 +143,8 @@ class TestRunReindex: env = mock_run.call_args.kwargs["env"] assert env["KNOWLEDGE_RAG_DIR"] == "/store" - assert env["PYTHONPATH"].endswith("testsAndMisc") + expected_root = Path(reindex.__file__).resolve().parents[2] + assert env["PYTHONPATH"] == str(expected_root) @patch(f"{MOD}.subprocess.run") def test_prepends_to_existing_pythonpath(self, mock_run: MagicMock) -> None: