- 更新 .gitattributes,将 fixtures 目录所有文件纳入 Git LFS - 在 tests/test_readers/conftest.py 中添加静态文件 fixtures - 添加 doc/xls/ppt 静态测试文件(9个文件) - 更新各旧格式解析器测试用例使用静态文件 - 更新一致性测试使用静态文件 - 在 README.md 中添加 fixtures 使用规范 - 同步 delta specs 到主 specs(doc-reader/xls-reader/ppt-reader/reader-testing/test-fixtures) - 归档 add-static-test-fixtures 变更
50 lines
1.6 KiB
Python
50 lines
1.6 KiB
Python
"""测试 MarkItDown XLS Reader 的解析功能。"""
|
|
|
|
import pytest
|
|
import os
|
|
from readers.xls import markitdown
|
|
|
|
|
|
class TestMarkitdownXlsReaderParse:
|
|
"""测试 MarkItDown XLS Reader 的 parse 方法。"""
|
|
|
|
def test_module_importable(self):
|
|
"""测试模块可以正确导入。"""
|
|
assert markitdown is not None
|
|
assert hasattr(markitdown, 'parse')
|
|
assert callable(markitdown.parse)
|
|
|
|
def test_file_not_exists(self, tmp_path):
|
|
"""测试文件不存在的情况。"""
|
|
non_existent_file = str(tmp_path / "non_existent.xls")
|
|
|
|
content, error = markitdown.parse(non_existent_file)
|
|
|
|
# 验证返回 None 和错误信息
|
|
assert content is None
|
|
assert error is not None
|
|
|
|
def test_parse_simple_xls(self, simple_xls_path):
|
|
"""测试解析简单 XLS 文件。"""
|
|
content, error = markitdown.parse(simple_xls_path)
|
|
|
|
# 只要不崩溃即可
|
|
if content is not None:
|
|
assert len(content.strip()) > 0
|
|
|
|
def test_parse_multiple_sheets_xls(self, multiple_sheets_xls_path):
|
|
"""测试解析多工作表 XLS 文件。"""
|
|
content, error = markitdown.parse(multiple_sheets_xls_path)
|
|
|
|
# 只要不崩溃即可
|
|
if content is not None:
|
|
assert len(content.strip()) > 0
|
|
|
|
def test_parse_with_formulas_xls(self, with_formulas_xls_path):
|
|
"""测试解析带公式 XLS 文件。"""
|
|
content, error = markitdown.parse(with_formulas_xls_path)
|
|
|
|
# 只要不崩溃即可
|
|
if content is not None:
|
|
assert len(content.strip()) > 0
|