Test Coverageยค
Coverage is measured on every push to main and the results are committed to reports/coverage.json.
Summaryยค
import json
from pathlib import Path
def format_coverage(pct: float) -> str:
if pct == 100:
return "โ
100.0%"
elif pct >= 80:
return f"๐ก {pct:.1f}%"
else:
return f"๐ด {pct:.1f}%"
report_path = Path("reports/coverage.json")
if not report_path.exists():
print("*No coverage data yet โ run `make test` to generate it.*")
else:
data = json.loads(report_path.read_text())
totals = data["totals"]
pct = totals["percent_covered"]
covered = totals["covered_lines"]
total = totals["num_statements"]
print(f"**Overall coverage:** `{pct:.1f}%` ({covered}/{total} statements)\n")
rows = [
(
path.replace("src/", "").replace("/", ".").removesuffix(".py"),
info["summary"]["covered_lines"],
info["summary"]["num_statements"],
info["summary"]["percent_covered"],
)
for path, info in sorted(data["files"].items())
if "src/" in path
]
print("| Module | Covered | Statements | Coverage |")
print("|:-------|--------:|-----------:|:---------|")
for module, covered, stmts, pct_m in rows:
print(f"| `{module}` | {covered} | {stmts} | {format_coverage(pct_m)} |")
Overall coverage: 92.4% (290/314 statements)
| Module | Covered | Statements | Coverage |
|---|---|---|---|
docchex.__init__ |
21 | 21 | โ 100.0% |
docchex.__main__ |
0 | 4 | ๐ด 0.0% |
docchex._internal.__init__ |
0 | 0 | โ 100.0% |
docchex._internal.cli |
21 | 21 | โ 100.0% |
docchex._internal.debug |
57 | 63 | ๐ก 90.5% |
docchex._internal.evaluation.__init__ |
1 | 1 | โ 100.0% |
docchex._internal.evaluation.ai |
5 | 5 | โ 100.0% |
docchex._internal.evaluation.engine |
12 | 12 | โ 100.0% |
docchex._internal.models |
32 | 32 | โ 100.0% |
docchex._internal.parsing.__init__ |
1 | 1 | โ 100.0% |
docchex._internal.parsing.base |
15 | 16 | ๐ก 93.8% |
docchex._internal.parsing.pdf |
19 | 19 | โ 100.0% |
docchex._internal.parsing.text |
7 | 12 | ๐ด 58.3% |
docchex._internal.rules.__init__ |
1 | 1 | โ 100.0% |
docchex._internal.rules.base |
14 | 15 | ๐ก 93.3% |
docchex._internal.rules.builtin.__init__ |
1 | 1 | โ 100.0% |
docchex._internal.rules.builtin.required_section |
17 | 17 | โ 100.0% |
docchex._internal.rules.builtin.word_count |
22 | 22 | โ 100.0% |
docchex._internal.rules.loader |
44 | 51 | ๐ก 86.3% |