Files
2026Technology-Competition/docs/coverage-report.md
T

2.6 KiB
Raw Blame History

代码覆盖率报告

  • 日期:2026-08-09
  • 工具:pytest-cov 7.1.0 / coverage 7.15.4
  • 范围:src/genesis(排除 tests 自身)
  • 阈值:fail_under = 90pyproject.toml [tool.coverage.report]),未达标时 pytest 退出码非 0
  • 全量用例:58 passed,无 skip
  • 输出:终端摘要(--cov-report=term-missing)、HTMLhtmlcov/index.html,已 .gitignore

总览

指标
语句总数 571
未覆盖语句 12
分支总数 150
未覆盖分支 12
总覆盖率 96.67%
最低模块 table_extractor.py 88%
最高模块 9 个文件 100%

分模块

模块 Stmts Miss Branch BrPart Cover 未覆盖行
__init__.py 1 0 100%
data_models.py 180 0 100%
excel_reader.py 12 0 2 0 100%
free_text_extractor.py 22 0 10 0 100%
merge_fill.py 15 0 10 0 100%
paragraph_splitter.py 17 0 10 0 100%
provenance.py 2 0 100%
sheet_detector.py 20 0 14 0 100%
config.py 128 1 24 1 99% 134
sheet_nature.py 33 2 18 3 90% 26, 32, 40→44
table_extractor.py 24 2 10 2 88% 32, 37
formatting_detector.py 40 3 20 2 92% 1516, 22, 31→33
excel_parser.py 77 4 32 4 93% 3637, 61, 66→65, 100

未覆盖点说明(12 语句 + 12 分支)

主要未覆盖区域属于防御分支 / 异常路径:

  • config.py:134unset(_env) 分支(枚举加载外的环境变量消除路径)
  • sheet_nature.py:26/32 — 空白行修正 / value 缺失兜底
  • table_extractor.py:32/37column_letter 越界兜底 / 空列头兜底
  • formatting_detector.py:15-22 — 非法 RGB 字符串剔除分支
  • excel_parser.py:36-37,61,100 — 空表跳过、header_row<0 回落、无表头 free_text 直接文本化

均为「非法输入 / 防御分支」,非主路径;当前 96.67% 已满足红线 90%。

门槛策略

  • pyproject.toml 已固化 fail_under = 90(含 12 个 branch 分支统计)
  • 每次 python -m pytest 默认附带覆盖率检查;未来若引入重业务逻辑(LLM/Writer 里程碑),可将 fail_under 抬至 95~98 并补充新用例

后续可选增强(非当前阻塞)

  • fail_under 提升至 95% 时需补上述 12 行(多为防御分支,成本低)
  • 可在 CI 中将 --cov-report=html 或 junit/xml 纳入流水线归档