3. Code Coverage using pytest‐cov - jcmwright80/work-experience GitHub Wiki
In this step we will introduce the concept of testing code coverage which helps ensure we have written sufficient tests for our code.
Step 1. Read about unit testing code coverage tools and best practice and make sure you understand what sort of test coverage you should aim for and why 100% is not always best. Read about pytest-cov and its basic usage and output.
Step 2. Use pip to install pytest-cov again ensuring that its in your requirements.txt after installation.
Step 3. Run your unit test with coverage enabled
pytest --cov=.
Step 4. Add a new function in your maths_utils.py class and rerun your test with coverage and see that it shows your new function is not tested.
Step 5. Add a new test for your new function and check that the code coverage stats are improved.