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

@@ -38,11 +38,37 @@ scripts/
└── encoding_detection.py # 编码检测
tests/ # 测试套件
├── test_readers/ # Reader 测试
│ └── fixtures/ # 静态测试文件Git LFS 管理)
│ ├── doc/ # DOC 旧格式测试文件
│ ├── xls/ # XLS 旧格式测试文件
│ └── ppt/ # PPT 旧格式测试文件
openspec/ # OpenSpec 规范文档
README.md # 本文档(开发者文档)
SKILL.md # AI Skill 文档
```
## 测试 Fixtures 规范
### 静态测试文件目录
`tests/test_readers/fixtures/` 目录用于存放**预先准备的静态测试文件**,特别是难以通过 Python 自动化创建的旧格式文件(.doc/.xls/.ppt
### 目录使用规则
1. **仅存放静态文件**:该目录下的文件必须是预先准备好的,禁止在测试运行时向该目录动态生成临时文件。
2. **临时文件使用 tmp_path**:测试中需要临时文件时,使用 pytest 的 `tmp_path` fixture 在其他位置创建。
3. **Git LFS 管理**:该目录下所有文件通过 Git LFS 管理,见 `.gitattributes` 配置。
### Fixture 说明
`tests/test_readers/conftest.py` 提供以下静态文件 fixtures
- 目录路径:`doc_fixture_path``xls_fixture_path``ppt_fixture_path`
- 单个文件:`simple_doc_path``with_headings_doc_path``with_table_doc_path`
文件不存在时会自动 `pytest.skip()`,保证 CI 稳定性。
## 核心概念
### Reader 机制
@@ -198,6 +224,35 @@ uv run \
pytest tests/test_readers/test_html/
```
#### 测试 DOC reader旧格式使用静态文件
```bash
uv run \
--with pytest \
--with "markitdown[docx]" \
--with pypandoc-binary \
pytest tests/test_readers/test_doc/
```
#### 测试 XLS reader旧格式使用静态文件
```bash
uv run \
--with pytest \
--with "unstructured[xlsx]" \
--with "markitdown[xls]" \
--with pandas \
--with tabulate \
--with xlrd \
pytest tests/test_readers/test_xls/
```
#### 测试 PPT reader旧格式使用静态文件
```bash
uv run \
--with pytest \
--with "markitdown[pptx]" \
pytest tests/test_readers/test_ppt/
```
#### 运行特定测试文件或方法
```bash
# 运行特定测试文件CLI 测试无需额外依赖)