Skip to content

Your lightweight open-source personal agent.

test(documents): preserve nested block order

Xubin Renc3ec2e665f62
diff --git a/tests/test_document_parsing.py b/tests/test_document_parsing.py
index e689d5f1e..980edf6b5 100644
--- a/tests/test_document_parsing.py
+++ b/tests/test_document_parsing.py
@@ -208,6 +208,7 @@ class TestExtractText:
nested = outer_cell.add_table(rows=1, cols=2)
nested.cell(0, 0).text = "Email"
nested.cell(0, 1).text = "[email protected]"
+ outer_cell.add_paragraph("Preferred contact")
doc.save(docx_file)
result = extract_text(docx_file)
@@ -216,7 +217,13 @@ class TestExtractText:
assert "Contact" in result
assert "Email" in result
assert "[email protected]" in result
- assert result.index("Contact") < result.index("Email") < result.index("[email protected]")
+ assert "Preferred contact" in result
+ assert (
+ result.index("Contact")
+ < result.index("Email")
+ < result.index("[email protected]")
+ < result.index("Preferred contact")
+ )
def test_extract_text_docx_does_not_expand_grid_spans(
self, tmp_path: Path, monkeypatch: pytest.MonkeyPatch