codex-python / tests /test_coverage.py
tailot's picture
Upload folder using huggingface_hub
f4952b6 verified
Raw History Blame Contribute Delete
1.32 kB
"""The suite enters the package it ships: a floor keeps dark corners from piling up."""
from __future__ import annotations
import json
import os
import subprocess
import sys
from pathlib import Path
import pytest
ROOT = Path(__file__).resolve().parents[1]
# Measured at 95.9 percent when this floor was first written; ten points of
# margin let one refactor breathe without letting a whole module go dark.
FLOOR = 90.0
@pytest.mark.skipif(
os.environ.get("LINGOLOGOS_COVERAGE_CHILD") == "1",
reason="this test is the measurement: inside the traced child it would nest forever",
)
def test_the_suite_enters_most_of_the_package_it_ships(tmp_path: Path) -> None:
report = tmp_path / "coverage.json"
status = subprocess.run(
[
sys.executable,
"-B",
"tools/measure_coverage.py",
"--floor",
str(FLOOR),
"--report",
str(report),
],
cwd=str(ROOT),
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
).returncode
assert status == 0, "the traced suite failed or the coverage floor was missed"
payload = json.loads(report.read_text(encoding="utf-8"))
assert payload["percent"] >= FLOOR
assert payload["total"] > 100, "a denominator that small measures nothing"