test(diary): write fixture with explicit utf-8 to fix Windows hash assert
test_legacy_state_backfills_content_hash failed on test-windows because Path.write_text without an encoding uses the system locale (cp1252 on Windows). The em dash was written as 0x97, then read back by diary_ingest as UTF-8 with errors=replace — round-trip produced different bytes than the in-Python literal, so the assertion comparing the persisted hash to sha256(text.encode(utf-8)) diverged. Pin the write side to encoding=utf-8 so the on-disk bytes match what diary_ingest decodes. No production change.
This commit is contained in:
@@ -650,8 +650,11 @@ class TestDiaryIngest:
|
|||||||
diary_dir = tmp_path / "diaries"
|
diary_dir = tmp_path / "diaries"
|
||||||
diary_dir.mkdir()
|
diary_dir.mkdir()
|
||||||
diary_file = diary_dir / "2026-04-13.md"
|
diary_file = diary_dir / "2026-04-13.md"
|
||||||
|
# Write explicit UTF-8 so the round-trip matches how diary_ingest reads.
|
||||||
|
# Windows' default text-mode encoding is cp1252; without this the em
|
||||||
|
# dash would round-trip lossy and the hash assertion below would fail.
|
||||||
text = "# 2026-04-13\n\n## 10:00 — Test\n\nUnchanged body content here.\n"
|
text = "# 2026-04-13\n\n## 10:00 — Test\n\nUnchanged body content here.\n"
|
||||||
diary_file.write_text(text)
|
diary_file.write_text(text, encoding="utf-8")
|
||||||
palace_dir = tmp_path / "palace"
|
palace_dir = tmp_path / "palace"
|
||||||
|
|
||||||
from mempalace.diary_ingest import _state_file_for, ingest_diaries
|
from mempalace.diary_ingest import _state_file_for, ingest_diaries
|
||||||
|
|||||||
Reference in New Issue
Block a user