Please ignore secret bonuses. Secret tests do NOT award bonus. Max hw grade is 30+2 bonus efficiency

Do you need help?

Code coverage

andrea.sterbini (207920 points)
750 1267 2373
in Programming in Python by (208k points)
edited by

To help you discovering if some part of your code has NOT been executed by tests (and should be hand-checked) I will add a code-coverage report to the correctness log.

To do this check locally, you can:

  • install the plugin pytest-cov (conda install pytest-cov)
  • run tests with coverage active ( pytest test_01.py --cov=program01 --cov-report=html )
  • read the report (firefox htmlcov/index.html)
  • the lines highlighted in red have not been executed by any test but could be in a future test. Check these lines carefully for errors.

3 Answers

gianluca5539 (9820 points)
4 6 44
by (9.8k points)
Thank you very much!
gabrimat (5630 points)
2 4 25
by (5.6k points)
When trying, the terminal answers back by telling me: no data to report. Anyone in the same situation?
rokshana03 (16750 points)
1 4 35
by (16.8k points)
so, I tried doing "pytest test_01" at first and it tells me that I pass 9 tests, so no timeout exceptions and the VM also says 9 tests passed. However when I do pytest with the coverage active, it says that I pass only 8 and the one that fails is because of "testlib.TimeoutError: Timeout! (1.116 > 1)". I'm not really sure what to think since the VM passes 9 tests but when I apply the coverage, it says 8 tests passed (in my PC)...is my code wrong maybe? I don't know what to think
andrea.sterbini (207920 points)
750 1267 2373
by (208k points)
The test coverage possibly adds some time to the execution.

Perhaps it's better I leave it as is and you know how to check for it locally.
rokshana03 (16750 points)
1 4 35
by (16.8k points)
Okay, thankss!