test: 添加全面的测试套件,覆盖所有 Reader 实现
- 测试数量从 83 个增加到 193 个 (+132%) - 代码覆盖率从 48% 提升到 69% (+44%) - 为每种文档格式的所有 Reader 实现创建独立测试 - 添加跨 Reader 的一致性验证测试 - 新增 4 个测试规范 (cli-testing, exception-testing, reader-testing, test-fixtures) - 更新 README 测试统计信息 测试覆盖: - DOCX: python-docx, markitdown, docling, native-xml, pypandoc, unstructured - PDF: pypdf, markitdown, docling, docling-ocr, unstructured, unstructured-ocr - HTML: html2text, markitdown, trafilatura, domscribe - PPTX: python-pptx, markitdown, docling, native-xml, unstructured - XLSX: pandas, markitdown, docling, native-xml, unstructured - CLI: 所有命令行选项和错误处理 所有 193 个测试通过。
This commit is contained in:
28
README.md
28
README.md
@@ -26,6 +26,15 @@ skill/ # SKILL 文档
|
||||
# 运行测试
|
||||
uv run pytest
|
||||
|
||||
# 运行测试并查看覆盖率
|
||||
uv run pytest --cov=scripts --cov-report=term-missing
|
||||
|
||||
# 运行特定测试文件
|
||||
uv run pytest tests/test_readers/test_docx/
|
||||
|
||||
# 运行特定测试类或方法
|
||||
uv run pytest tests/test_cli/test_main.py::TestCLIDefaultOutput::test_default_output_docx
|
||||
|
||||
# 代码格式化
|
||||
uv run black .
|
||||
uv run isort .
|
||||
@@ -34,6 +43,25 @@ uv run isort .
|
||||
uv run mypy .
|
||||
```
|
||||
|
||||
## 测试
|
||||
|
||||
项目包含完整的测试套件,覆盖 CLI 和所有 Reader 实现:
|
||||
|
||||
- **测试覆盖率**: 69%
|
||||
- **测试数量**: 193 个测试
|
||||
- **测试类型**:
|
||||
- CLI 功能测试(字数统计、行数统计、标题提取、搜索等)
|
||||
- Reader 解析测试(DOCX、PDF、HTML、PPTX、XLSX)
|
||||
- 多 Reader 实现测试(每种格式测试多个解析库)
|
||||
- 异常场景测试(文件不存在、空文件、损坏文件、特殊字符)
|
||||
- 编码测试(GBK、UTF-8 BOM 等)
|
||||
- 一致性测试(验证不同 Reader 解析结果的一致性)
|
||||
|
||||
运行测试前确保已安装所有依赖:
|
||||
```bash
|
||||
uv sync
|
||||
```
|
||||
|
||||
## 代码规范
|
||||
|
||||
- 语言:仅中文(交流、注释、文档、代码)
|
||||
|
||||
Reference in New Issue
Block a user