f6dbfc575e
Test files:
- test_sample_plugin.py: 'dirctly' -> 'directly'
- test_cli_vectors.py: 'readds' -> 'reads'
- test_module_misc.py: 'targted' -> 'targeted' (2 occurrences)
Source files:
- _doc_intel_converter.py: 'availiable' -> 'available' in docstring
Verified clean with:
codespell --skip='.git,test_files,ThirdPartyNotices.md,SECURITY.md,\
SUPPORT.md,CODE_OF_CONDUCT.md,latex_dict.py,omml.py,ocr_test_data,\
*.pdf,*.docx,*.pptx,*.xlsx,*.xls,*.png,*.jpg,*.jpeg,*.wav,*.mp3,\
*.mp4,*.zip,*.epub,*.msg,*.rtf' packages/ README.md
44 lines
1.3 KiB
Python
44 lines
1.3 KiB
Python
#!/usr/bin/env python3 -m pytest
|
|
import os
|
|
|
|
from markitdown import MarkItDown, StreamInfo
|
|
from markitdown_sample_plugin import RtfConverter
|
|
|
|
TEST_FILES_DIR = os.path.join(os.path.dirname(__file__), "test_files")
|
|
|
|
RTF_TEST_STRINGS = {
|
|
"This is a Sample RTF File",
|
|
"It is included to test if the MarkItDown sample plugin can correctly convert RTF files.",
|
|
}
|
|
|
|
|
|
def test_converter() -> None:
|
|
"""Tests the RTF converter directly."""
|
|
with open(os.path.join(TEST_FILES_DIR, "test.rtf"), "rb") as file_stream:
|
|
converter = RtfConverter()
|
|
result = converter.convert(
|
|
file_stream=file_stream,
|
|
stream_info=StreamInfo(
|
|
mimetype="text/rtf", extension=".rtf", filename="test.rtf"
|
|
),
|
|
)
|
|
|
|
for test_string in RTF_TEST_STRINGS:
|
|
assert test_string in result.text_content
|
|
|
|
|
|
def test_markitdown() -> None:
|
|
"""Tests that MarkItDown correctly loads the plugin."""
|
|
md = MarkItDown(enable_plugins=True)
|
|
result = md.convert(os.path.join(TEST_FILES_DIR, "test.rtf"))
|
|
|
|
for test_string in RTF_TEST_STRINGS:
|
|
assert test_string in result.text_content
|
|
|
|
|
|
if __name__ == "__main__":
|
|
"""Runs this file's tests from the command line."""
|
|
test_converter()
|
|
test_markitdown()
|
|
print("All tests passed.")
|