From 74bc75fb7ccd70de4e917d7123ac775237f2b8f3 Mon Sep 17 00:00:00 2001 From: Abdessamad Derraz <3028866+Abdess@users.noreply.github.com> Date: Tue, 6 Oct 2026 08:53:58 +0200 Subject: [PATCH] fix: anchor the slot mode test on the override lookup --- tests/test_slots.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/tests/test_slots.py b/tests/test_slots.py index 444b2fe3..4b2b6bd7 100644 --- a/tests/test_slots.py +++ b/tests/test_slots.py @@ -3,6 +3,7 @@ from __future__ import annotations import os +import re import shutil import sys import tempfile @@ -336,13 +337,18 @@ class TestBuilderAndVerifierAgree(unittest.TestCase): def test_neither_reimplements_the_mode_test(self): # A local "if mode == md5" beside the override would drift from the - # arbitration rule the moment either side is edited. + # arbitration rule the moment either side is edited. The anchor is the + # override lookup both sides must perform; the old anchor was a string + # the test above forbids, so the window was the whole file. + mode_test = re.compile(r"""[=!]=\s*["'](?:md5|sha1|existence)["']""") for name in ("generate_pack.py", "verify.py"): source = Path(__file__).resolve().parents[1] / "scripts" / name body = source.read_text(encoding="utf-8") - marker = body.find("decision.serves_both") - window = body[max(0, marker - 600):marker] - self.assertNotIn('verification_mode") == "md5"', window, name) + anchors = [m.start() for m in re.finditer(r"slot_overrides\.get\(", body)] + self.assertTrue(anchors, name) + for at in anchors: + window = body[max(0, at - 600):at + 600] + self.assertIsNone(mode_test.search(window), name) class TestSelfContradictingDestinations(unittest.TestCase):