test: add test cases for docx equation rendering
This commit is contained in:
parent
c7e7d52441
commit
c782df2b20
2 changed files with 13 additions and 0 deletions
BIN
packages/markitdown/tests/test_files/equations.docx
vendored
Normal file
BIN
packages/markitdown/tests/test_files/equations.docx
vendored
Normal file
Binary file not shown.
|
|
@ -1,6 +1,7 @@
|
||||||
#!/usr/bin/env python3 -m pytest
|
#!/usr/bin/env python3 -m pytest
|
||||||
import io
|
import io
|
||||||
import os
|
import os
|
||||||
|
import re
|
||||||
import shutil
|
import shutil
|
||||||
import openai
|
import openai
|
||||||
import pytest
|
import pytest
|
||||||
|
|
@ -187,6 +188,18 @@ def test_docx_comments() -> None:
|
||||||
validate_strings(result, DOCX_COMMENT_TEST_STRINGS)
|
validate_strings(result, DOCX_COMMENT_TEST_STRINGS)
|
||||||
|
|
||||||
|
|
||||||
|
def test_docx_equations() -> None:
|
||||||
|
markitdown = MarkItDown()
|
||||||
|
docx_file = os.path.join(TEST_FILES_DIR, "equations.docx")
|
||||||
|
result = markitdown.convert(docx_file)
|
||||||
|
|
||||||
|
# Check for inline equation m=1 (wrapped with single $) is present
|
||||||
|
assert "$m=1$" in result.text_content, "Inline equation $m=1$ not found"
|
||||||
|
|
||||||
|
# Find block equations wrapped with double $$ and check if they are present
|
||||||
|
block_equations = re.findall(r'\$\$(.+?)\$\$', result.text_content)
|
||||||
|
assert block_equations, "No block equations found in the document."
|
||||||
|
|
||||||
def test_input_as_strings() -> None:
|
def test_input_as_strings() -> None:
|
||||||
markitdown = MarkItDown()
|
markitdown = MarkItDown()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue