Bird
0
0

Why might coverage reports show less than 100% even if all tests pass in Django?

hard📝 Conceptual Q10 of 15
Django - Testing Django Applications
Why might coverage reports show less than 100% even if all tests pass in Django?
ASome code paths are not executed by tests, like error handlers or debug code
BTests always cover 100% if they pass
CCoverage tool has a bug and misses lines randomly
DDjango disables coverage on successful tests
Step-by-Step Solution
Solution:
  1. Step 1: Understand coverage vs test pass

    Tests can pass without executing every line, especially error or optional code.
  2. Step 2: Exclude incorrect reasons

    Coverage tools are reliable, and Django does not disable coverage on success.
  3. Final Answer:

    Some code paths are not executed by tests, like error handlers or debug code -> Option A
  4. Quick Check:

    Less than 100% coverage = untested code paths [OK]
Quick Trick: Passing tests ≠ 100% coverage; some code may be untested [OK]
Common Mistakes:
MISTAKES
  • Assuming passing tests mean full coverage
  • Blaming coverage tool bugs
  • Thinking Django disables coverage

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Django Quizzes