Files
lyxy-document/tests/test_readers/test_pptx/test_consistency.py
lanyuanxiaoyao 9daff73589 refactor: 调整模块导入路径,简化引用结构
- 更新 openspec/config.yaml 中 git 任务相关说明
- 将 scripts.core.* 改为 core.*,scripts.readers.* 改为 readers.*
- 优化 lyxy_document_reader.py 中 sys.path 设置方式
- 同步更新所有测试文件的导入路径
2026-03-09 15:44:51 +08:00

43 lines
1.4 KiB
Python

"""测试所有 PPTX Readers 的一致性。"""
import pytest
from readers.pptx import (
docling,
markitdown,
native_xml,
python_pptx,
unstructured,
)
class TestPptxReadersConsistency:
"""验证所有 PPTX Readers 解析同一文件时核心文字内容一致。"""
def test_all_readers_parse_same_content(self, temp_pptx):
"""测试所有 Readers 解析同一文件时核心内容一致。"""
file_path = temp_pptx(slides=[
("测试标题", "这是测试幻灯片内容。"),
("第二页", "第二页的内容。")
])
parsers = [
("docling", docling.parse),
("markitdown", markitdown.parse),
("native_xml", native_xml.parse),
("python_pptx", python_pptx.parse),
("unstructured", unstructured.parse),
]
successful_results = []
for name, parser in parsers:
content, error = parser(file_path)
if content is not None and content.strip():
successful_results.append((name, content))
assert len(successful_results) > 0, "没有任何 reader 成功解析文件"
core_texts = ["测试标题", "幻灯片", "内容", "第二页"]
for name, content in successful_results:
assert any(text in content for text in core_texts), \
f"{name} 解析结果不包含核心内容"