Coverage
coreintermediateCoverage measures which lines of code actually ran during the test suite, as a percentage. It tells you what was NOT exercised at all — it does not tell you whether the lines that did run were tested correctly.
Think of it as
Coverage is a checklist of which rooms in a house someone walked through, not whether they checked anything in each room. 100% coverage means every room was visited — it says nothing about whether the visitor actually looked in the closets.
What we're doing: Run coverage against a module with an untested branch and see exactly which line it flags as missing.
- 7
- This return line is never reached — every test either adds, or divides by zero and hits the raise on the line above.
Name Stmts Miss Cover Missing
---------------------------------------
calc.py 6 1 83% 8
---------------------------------------
TOTAL 6 1 83%Why this works: Coverage counts calc.py at 6 executable statements; 5 ran, 1 (the successful division's return a / b) never did, because no test calls divide with a nonzero denominator. --cov-report=term-missing names the exact line so it is easy to find and fix.
Treating a high coverage number as proof the code is well tested
Wrong
Better
What you see: Coverage reports 100%, but the test suite would not catch calculate_discount returning the wrong value — a broken implementation still passes.
Why: Coverage only measures whether a line EXECUTED, never whether its result was correct. A test that calls code without asserting on the outcome inflates the coverage number without testing anything real.
- 83% covered — line 7 never ran — a real, findable gap
- 100% covered, no assert — the line ran, but the result was never checked
- Chasing the number — testing trivial getters instead of real edge cases
Remember: Coverage shows which lines never ran — a floor for thoroughness, not proof of correctness.
See also: test pyramid and types · testing failure scenarios

