Files

59 lines
2.9 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 代码覆盖率报告
- 日期:2026-08-09
- 工具:`pytest-cov` 7.1.0 / `coverage` 7.15.4
- 范围:`src/genesis`(排除 tests 自身)
- 阈值:`fail_under = 99``pyproject.toml` `[tool.coverage.report]`),未达标时 pytest 退出码非 0
- 全量用例:**71 passed,无 skip**
- 输出:终端摘要(`--cov-report=term-missing`)、HTML`htmlcov/index.html`,已 .gitignore
## 总览
| 指标 | 值 |
|------|-----|
| 语句总数 | 563(含 pragma 排除的不可达防御分支) |
| 未覆盖语句 | 0 |
| 分支总数 | 140 |
| 未覆盖分支 | 0 |
| **总覆盖率** | **100.00%** |
## 分模块(全部 100%
| 模块 | Stmts | Miss | Branch | BrPart | Cover |
|------|------:|-----:|-------:|-------:|------:|
| `__init__.py` | 1 | 0 | — | — | 100% |
| `config.py` | 128 | 0 | 24 | 0 | 100% |
| `data_models.py` | 180 | 0 | — | — | 100% |
| `parsers/excel_parser.py` | 73 | 0 | 28 | 0 | 100% |
| `parsers/excel_reader.py` | 12 | 0 | 2 | 0 | 100% |
| `parsers/formatting_detector.py` | 40 | 0 | 20 | 0 | 100% |
| `parsers/free_text_extractor.py` | 22 | 0 | 10 | 0 | 100% |
| `parsers/merge_fill.py` | 15 | 0 | 10 | 0 | 100% |
| `parsers/paragraph_splitter.py` | 17 | 0 | 10 | 0 | 100% |
| `parsers/provenance.py` | 2 | 0 | — | — | 100% |
| `parsers/sheet_detector.py` | 20 | 0 | 14 | 0 | 100% |
| `parsers/sheet_nature.py` | 29 | 0 | 12 | 0 | 100% |
| `parsers/table_extractor.py` | 24 | 0 | 10 | 0 | 100% |
## 达到 100% 的补充(相对首次基线 96.67%)
新增 13 个防御/边界用例覆盖了此前未触达的分支:
- `test_sheet_nature.py`:空矩阵→FREE_TEXT、稀疏多列(非空占比<0.7)→FREE_TEXT、有表头无 ・/■ 行→TABLE
- `test_table_extractor.py`:空矩阵→空表、`header_row` 越界/负值回落 0
- `test_formatting_detector.py`:6/8 位十六进制接受、纯黑/主题色/非法 hex/长度不足/访问异常→None、仅背景色命中、`fill=None` 防御分支
- `test_config.py``_expand_env` 的 list 分值(列表内递归展开占位)
- `test_excel_parser.py`:空 sheet→skipped、碎片段格式不污染表格段 `seg_fmt_map`66→65
- pragma 标注两处不可达防御分支:`excel_parser` 两处 `header_row<0` 回落(`classify_sheet==TABLE` 恒有表头)、`sheet_nature``header_row>=0` 检测(`_free_text_like()==False` 恒含表头)
## 门槛策略
- `fail_under = 99`(余量 1%):未来若引入未测的新模块/分支(LLM 结构化、Writer 等),需为新代码补测试或显式 `# pragma: no cover` 标注不可达防御分支,否则 CI 拦截
- 每次 `python -m pytest` 默认附带覆盖率检查
- 报告归档:本文件(docs/+ HTMLhtmlcov/,不纳入 git
## 后续可选增强(非当前阻塞)
-`fail_under` 保持 99 并作为 CI 红线
- 对 LLM 相关(InferenceEngine)等后续模块按同样标准配置覆盖率
- 可将 HTML 报告接入 CI artifact 归档