From ae34fd406c69292bd5d9a9fecd655471fb1d40dc Mon Sep 17 00:00:00 2001 From: blacktoe Date: Mon, 14 Sep 2026 20:00:05 +1000 Subject: [PATCH] test(tactics): Write the strategy fixture as bytes so windows matches the pin The converter pins its source by the sha256 of the bytes on disk, and the test helper wrote the fixture with write_text and hashed the string it had just written. On linux those are the same bytes. On windows write_text translates every newline into a carriage return and a newline, so the file on disk is not the file the pin was taken over, and the script refused its own fixture. Two tests failed from it. Write the encoded bytes instead, and take the pin over the same bytes. This is not a line ending problem in the checkout. The fixture is built in tmp_path at run time and the real source is downloaded rather than committed, so no .gitattributes rule reaches either. The Scripts workflow runs on ubuntu only, which is why this sat here rather than failing in ci. Co-Authored-By: Claude Opus 5 --- scripts/tests/test_build_strategy.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/scripts/tests/test_build_strategy.py b/scripts/tests/test_build_strategy.py index 887a23b1..b77b5290 100644 --- a/scripts/tests/test_build_strategy.py +++ b/scripts/tests/test_build_strategy.py @@ -203,12 +203,14 @@ def written(tmp_path, monkeypatch, text=None): """Run the script over a fixture, with the pin and the theme counts moved to what the fixture is, and give back what it wrote.""" text = source() if text is None else text + # the script pins its source by the bytes on disk, so write those bytes + # rather than let a windows text write turn every newline into a carriage + # return and a newline the pin was not taken over + raw = text.encode("utf-8") source_file = tmp_path / "sts.epd" - source_file.write_text(text, encoding="utf-8") + source_file.write_bytes(raw) monkeypatch.setattr( - build_strategy, - "SOURCE_SHA256", - hashlib.sha256(text.encode("utf-8")).hexdigest(), + build_strategy, "SOURCE_SHA256", hashlib.sha256(raw).hexdigest() ) monkeypatch.setattr(build_strategy, "THEMES", {"Undermine": 1}) output = tmp_path / "strategy.epd"