From 7355b3505506b6e0db51b0f86e6e843ca342b477 Mon Sep 17 00:00:00 2001 From: Zihan Xu <2024010904024@std.uestc.edu.cn> Date: Tue, 22 Sep 2026 21:45:16 +0800 Subject: [PATCH] test(documents): cover BOM-marked text extraction --- tests/test_document_parsing.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/test_document_parsing.py b/tests/test_document_parsing.py index 568bd0ab9..2e5b3d10d 100644 --- a/tests/test_document_parsing.py +++ b/tests/test_document_parsing.py @@ -42,6 +42,14 @@ class TestExtractText: result = extract_text(txt_file) assert result == content + @pytest.mark.parametrize("encoding", ["utf-8-sig", "utf-16", "utf-32"]) + def test_extract_text_respects_unicode_bom(self, tmp_path: Path, encoding: str): + txt_file = tmp_path / "unicode.txt" + content = "Hello 世界\nSecond line" + txt_file.write_bytes(content.encode(encoding)) + + assert extract_text(txt_file) == content + def test_extract_text_accepts_string_path(self, tmp_path: Path): """String paths retain the compatibility behavior of Path inputs.""" txt_file = tmp_path / "string-path.txt"