feat: 添加 doc/xls/ppt 旧格式文档静态测试文件支持

- 更新 .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 变更
This commit is contained in:
2026-03-11 00:30:47 +08:00
parent 725b91374f
commit fad0edc46a
27 changed files with 493 additions and 14 deletions

View File

@@ -195,3 +195,87 @@ def temp_xlsx(tmp_path):
return _create_xlsx
# 静态测试文件目录
FIXTURES_DIR = Path(__file__).parent / "fixtures"
@pytest.fixture
def doc_fixture_path():
"""返回 DOC 静态测试文件目录"""
return FIXTURES_DIR / "doc"
@pytest.fixture
def xls_fixture_path():
"""返回 XLS 静态测试文件目录"""
return FIXTURES_DIR / "xls"
@pytest.fixture
def ppt_fixture_path():
"""返回 PPT 静态测试文件目录"""
return FIXTURES_DIR / "ppt"
def _get_static_file_path(fixture_dir, filename):
"""获取静态文件路径,不存在时跳过测试"""
file_path = fixture_dir / filename
if not file_path.exists():
pytest.skip(f"静态测试文件不存在: {file_path}")
return str(file_path)
@pytest.fixture
def simple_doc_path(doc_fixture_path):
"""返回简单 DOC 测试文件路径"""
return _get_static_file_path(doc_fixture_path, "simple.doc")
@pytest.fixture
def with_headings_doc_path(doc_fixture_path):
"""返回带标题的 DOC 测试文件路径"""
return _get_static_file_path(doc_fixture_path, "with_headings.doc")
@pytest.fixture
def with_table_doc_path(doc_fixture_path):
"""返回带表格的 DOC 测试文件路径"""
return _get_static_file_path(doc_fixture_path, "with_table.doc")
@pytest.fixture
def simple_xls_path(xls_fixture_path):
"""返回简单 XLS 测试文件路径"""
return _get_static_file_path(xls_fixture_path, "simple.xls")
@pytest.fixture
def multiple_sheets_xls_path(xls_fixture_path):
"""返回多工作表 XLS 测试文件路径"""
return _get_static_file_path(xls_fixture_path, "multiple_sheets.xls")
@pytest.fixture
def with_formulas_xls_path(xls_fixture_path):
"""返回带公式 XLS 测试文件路径"""
return _get_static_file_path(xls_fixture_path, "with_formulas.xls")
@pytest.fixture
def simple_ppt_path(ppt_fixture_path):
"""返回简单 PPT 测试文件路径"""
return _get_static_file_path(ppt_fixture_path, "simple.ppt")
@pytest.fixture
def multiple_slides_ppt_path(ppt_fixture_path):
"""返回多幻灯片 PPT 测试文件路径"""
return _get_static_file_path(ppt_fixture_path, "multiple_slides.ppt")
@pytest.fixture
def with_images_ppt_path(ppt_fixture_path):
"""返回带图片 PPT 测试文件路径"""
return _get_static_file_path(ppt_fixture_path, "with_images.ppt")