test(files): cover BOM-marked Unicode text

This commit is contained in:
Zihan Xu authored and chengyongru committed 2026-09-23 00:29:52 +08:00
1 parent 394b4f2cc3
commit 6707004a2a
1 file changed
+17
+17
View File
@@ -121,6 +121,23 @@ class TestReadDedup:
assert "1| name" in result
assert "2| café" in result
@pytest.mark.parametrize("encoding", ["utf-8-sig", "utf-16", "utf-32"])
@pytest.mark.asyncio
async def test_bom_marked_unicode_text_uses_declared_encoding(
self,
tool,
tmp_path,
encoding,
):
f = tmp_path / "unicode.txt"
f.write_bytes("Hello 世界\nSecond line".encode(encoding))
result = await tool.execute(path=str(f))
assert "1| Hello 世界" in result
assert "2| Second line" in result
assert "\x00" not in result
# ---------------------------------------------------------------------------
# Cross-session isolation (issue #3571)