diff --git a/docs/plans/original-completion-2026-10-02/execution/p28-01/restart/probe/test_restart.py b/docs/plans/original-completion-2026-10-02/execution/p28-01/restart/probe/test_restart.py index cf16653..b551ad9 100644 --- a/docs/plans/original-completion-2026-10-02/execution/p28-01/restart/probe/test_restart.py +++ b/docs/plans/original-completion-2026-10-02/execution/p28-01/restart/probe/test_restart.py @@ -191,6 +191,24 @@ def synthetic_receipt(out): class RestartTests(unittest.TestCase): + @staticmethod + def here_inventory(): + return {str(path.relative_to(check.HERE)): hashlib.sha256(path.read_bytes()).hexdigest() + for path in check.HERE.rglob("*") if path.is_file()} + + @classmethod + def setUpClass(cls): + cls.inventory_before = cls.here_inventory() + + def setUp(self): + # Check after every test, including failures, independently of test order. + self.addCleanup(lambda: self.assertEqual(self.here_inventory(), self.inventory_before)) + + def test_zz_here_inventory_unchanged(self): + # unittest's default ordering places this after all twelve existing tests. + self.assertIn("test_restart.py", self.inventory_before) + self.assertEqual(self.here_inventory(), self.inventory_before) + def rejects(self, original, mutations, validator): for name, mutation in mutations.items(): with self.subTest(rejection=name): @@ -328,7 +346,7 @@ class RestartTests(unittest.TestCase): next(iterator) def test_d3_transfer_and_fresh_profiles(self): - with tempfile.TemporaryDirectory(dir=check.HERE) as temporary: + with tempfile.TemporaryDirectory(dir=os.environ.get("BUILD_OUTPUT_DIR") or None) as temporary: base = Path(temporary) source = base / "source" source.mkdir() @@ -366,7 +384,7 @@ class RestartTests(unittest.TestCase): check.check_probe(text.replace("GameClock.advance_minutes(1)", replacement)) def test_rs7_rs8_full_receipt_rejections(self): - with tempfile.TemporaryDirectory(dir=check.HERE) as temporary: + with tempfile.TemporaryDirectory(dir=os.environ.get("BUILD_OUTPUT_DIR") or None) as temporary: out = Path(temporary) receipt = synthetic_receipt(out) check.check_receipt(receipt, out) @@ -391,7 +409,7 @@ class RestartTests(unittest.TestCase): check.check_receipt(receipt, out) def test_d6_raw_report_and_audio(self): - with tempfile.TemporaryDirectory(dir=check.HERE) as temporary: + with tempfile.TemporaryDirectory(dir=os.environ.get("BUILD_OUTPUT_DIR") or None) as temporary: out = Path(temporary) receipt = synthetic_receipt(out) row = receipt["phases"][3] @@ -418,7 +436,7 @@ class RestartTests(unittest.TestCase): "time.sleep(0.15)\n" "if mode=='timeout': time.sleep(5)\n" "sys.exit(3 if mode=='exit' else 0)\n") - with tempfile.TemporaryDirectory(dir=check.HERE) as temporary: + with tempfile.TemporaryDirectory(dir=os.environ.get("BUILD_OUTPUT_DIR") or None) as temporary: base = Path(temporary) script = base / "fake-child" script.write_text(child)