From 772996c544479ed83375ea0a89a65fe08b327195 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Fri, 13 Nov 2026 01:16:35 +0100 Subject: [PATCH] Test plan_reasons in process with the plan and the decisions outside the checkout --- bin/larv_review/test_larv_review.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/bin/larv_review/test_larv_review.py b/bin/larv_review/test_larv_review.py index 3139ab43..642526cb 100644 --- a/bin/larv_review/test_larv_review.py +++ b/bin/larv_review/test_larv_review.py @@ -8,6 +8,7 @@ import sys import tempfile import textwrap import unittest +import unittest.mock sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1])) @@ -576,6 +577,19 @@ class LarvReviewTool(unittest.TestCase): self.assertEqual(due.returncode, 0, due.stderr) self.assertTrue(due.stdout.startswith("Scoring run due:"), due.stdout) self.assertIn("floor", due.stdout) + # In this process too, where the mutation tests see it. + self.addCleanup(os.chdir, os.getcwd()) + os.chdir(self.checkout) + with unittest.mock.patch.dict(os.environ, {"HOME": str(self.config.parents[2])}): + self.assertEqual(plan_reasons("origin/main", [2]), ["ships item 2, a floor item", "leaves release 0.2.0 with no plan item"]) + (self.config.parent / "decisions.md").write_text("# Decisions\n\n## review opt-out: the comprehension check\n\nServes goal 1.\n") + self.assertEqual(plan_reasons("origin/main", [2]), []) + (self.config.parent / "decisions.md").unlink() + (self.config.parent / "todo.md").write_bytes(b"\xff") + unreadable = plan_reasons("origin/main", [2]) + assert isinstance(unreadable, Failure), unreadable + self.assertTrue(unreadable.reason.startswith(f"cannot read {self.config.parent}/todo.md: "), unreadable.reason) + (self.config.parent / "todo.md").write_text(todo(row, "| 2 | 0.2.0 | | **Reach the comprehension floor: do it.** | 1 | 1 | 3 | 1 | 1 | 1 | 9.0 |")) (self.config.parent / "decisions.md").write_text("# Decisions\n\n## review opt-out: the comprehension check\n\nServes goal 1.\n") self.assertEqual(self.run_tool("needs-scoring-run", "2").stdout, "No scoring run due.\n")