From 5639f3db7f12647694c4ef03437af00227f45f58 Mon Sep 17 00:00:00 2001 From: Mike Gerber Date: Thu, 24 Apr 2025 16:44:29 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=94=20=20Add=20a=20tests=20that=20checks?= =?UTF-8?q?=20if=20plain=20text=20files=20with=20BOM=20are=20read=20correc?= =?UTF-8?q?tly?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/dinglehopper/tests/test_ocr_files.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/dinglehopper/tests/test_ocr_files.py b/src/dinglehopper/tests/test_ocr_files.py index 342507a..0c2a500 100644 --- a/src/dinglehopper/tests/test_ocr_files.py +++ b/src/dinglehopper/tests/test_ocr_files.py @@ -182,3 +182,15 @@ def test_plain(tmp_path): result = plain_text("ocr.txt") expected = "First, a line.\nAnd a second line." assert result == expected + + +def test_plain_BOM(tmp_path): + """Test that plain text files with BOM are read correctly.""" + BOM = "\ufeff" + with working_directory(tmp_path): + with open("ocr.txt", "w") as ocrf: + ocrf.write(BOM + "First, a line.\nAnd a second line.\n") + + result = plain_text("ocr.txt") + expected = "First, a line.\nAnd a second line." + assert result == expected