In this exercise you will work with your group to get to full code coverage and fix any bugs that you find.
- Clone a copy of this exercise. This command makes a new folder called
code-coverage-exercise
, and then puts the exercise into this new folder. You do not need to fork the repository.
git clone ...
Use ls
to confirm there's a new project folder
- Move your location into this project folder
cd code-coverage-exercise
- Create a virtual environment named
venv
for this project:
python3 -m venv venv
- Activate this environment:
source venv/bin/activate
Verify that you're in a python3 virtual environment by running:
$ python --version
should output a Python 3 version$ pip --version
should output that it is working with Python 3
- Install dependencies once at the beginning of this exercise with
# Must be in activated virtual environment
pip install -r requirements.txt
- Exit and re-enter the virtual enviornment with the following command. This is needed to ensure the correct version of pytest is used in the terminal.
deactivate && source venv/bin/activate
To check the code coverage you can run:
pytest --cov=student --cov-report html --cov-report term
To see the detailed report (after running the above) you can open it in your default browser with:
open htmlcov/index.html
The above commands need to be run from the root folder of the project.
Once you've loaded the detailed report you can click on the file names to see information about what lines are missing code coverage.
To read more about pytest-cov you can consult the pytest-cov documentation.