Bird
0
0

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

hard📝 Conceptual Q10 of 15
Flask - Testing Flask Applications
Why might coverage reports show less than 100% coverage even if all tests pass in a Flask app?
AFlask disables coverage reporting in production mode
BCoverage.py only counts lines with print statements
CSome code paths are not executed by tests, like error handlers or debug-only code
DTests passing means all code is covered automatically
Step-by-Step Solution
Solution:
  1. Step 1: Understand coverage vs test pass

    Tests can pass without executing every line of code.
  2. Step 2: Identify untested code paths

    Code like error handlers or debug-only branches may not run during tests, lowering coverage.
  3. Final Answer:

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

    Passing tests ≠ 100% coverage due to unrun code [OK]
Quick Trick: Passing tests don't guarantee all code lines run [OK]
Common Mistakes:
MISTAKES
  • Thinking coverage counts only print lines
  • Assuming passing tests mean full coverage
  • Believing Flask disables coverage in production

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Flask Quizzes