fix: a truth hash conflict is reported once

Generating the model for every platform met the same two GameIndex.yaml declarations once per platform, and check_freshness opened on six identical warnings.
This commit is contained in:
Abdessamad Derraz committed 2026-10-20 04:46:03 +02:00
1 parent 50790a2988
commit 1ae2854474
2 files changed
+32 -5

No files matched your search

+19
View File
@@ -5553,5 +5553,24 @@ class AStepThatCannotFailTheRunIsNotShownFailed(unittest.TestCase):
(ROOT / "scripts" / "pipeline.py").read_text(encoding="utf-8"))
class AHashConflictIsReportedOnce(unittest.TestCase):
"""check_freshness opened on six copies of one truth.py warning, one per
platform whose model met the same two GameIndex.yaml declarations."""
def test_the_same_pair_prints_once(self):
import contextlib
import io
import truth
truth._CONFLICTS_SHOWN.clear()
err = io.StringIO()
with contextlib.redirect_stderr(err):
for _platform in range(6):
existing = {"name": "x.yaml", "sha1": "a" * 40}
truth._merge_hashes(existing, {"name": "x.yaml", "sha1": "b" * 40}, "core")
self.assertEqual(err.getvalue().count("WARNING"), 1)
if __name__ == "__main__":
unittest.main()