From 911a7e3a82dc1fcd1382f7d1d4f49874aa8bb5f5 Mon Sep 17 00:00:00 2001 From: Xubin Ren <52506698+Re-bin@users.noreply.github.com> Date: Thu, 23 Jul 2026 16:29:19 +0800 Subject: [PATCH] test(documents): cover vertical merged cells --- tests/test_document_parsing.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/test_document_parsing.py b/tests/test_document_parsing.py index ae552cca..e689d5f1 100644 --- a/tests/test_document_parsing.py +++ b/tests/test_document_parsing.py @@ -238,6 +238,20 @@ class TestExtractText: assert extract_text(docx_file) == "Only once" + def test_extract_text_docx_keeps_vertical_merges_compact(self, tmp_path: Path): + """Vertically merged labels appear once without shifting later columns.""" + from docx import Document + + docx_file = tmp_path / "vertical-merge.docx" + doc = Document() + table = doc.add_table(rows=2, cols=2) + table.cell(0, 0).merge(table.cell(1, 0)).text = "Group" + table.cell(0, 1).text = "First" + table.cell(1, 1).text = "Second" + doc.save(docx_file) + + assert extract_text(docx_file) == "Group\tFirst\n\tSecond" + def test_extract_text_docx_bounds_physical_table_cells( self, tmp_path: Path, monkeypatch: pytest.MonkeyPatch ):