From 6707004a2a38eda77ec04c43e21e21871b882199 Mon Sep 17 00:00:00 2001 From: Zihan Xu <2024010904024@std.uestc.edu.cn> Date: Tue, 22 Sep 2026 21:44:36 +0800 Subject: [PATCH] test(files): cover BOM-marked Unicode text --- tests/tools/test_read_enhancements.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/tools/test_read_enhancements.py b/tests/tools/test_read_enhancements.py index 7e5b9264e..b5fddefdb 100644 --- a/tests/tools/test_read_enhancements.py +++ b/tests/tools/test_read_enhancements.py @@ -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)