Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Recall & Review
beginner
What is pytest-cov used for?
pytest-cov is a plugin for pytest that measures code coverage during test runs. It shows which parts of your code were tested and which were not.
Click to reveal answer
beginner
How do you install pytest-cov?
You install pytest-cov using pip with the command: pip install pytest-cov.
Click to reveal answer
beginner
How do you run pytest with coverage reporting?
Run tests with coverage by using: pytest --cov=your_package_name. Replace your_package_name with the folder or module you want to check coverage for.
Click to reveal answer
intermediate
What does the option --cov-report=term do?
It shows the coverage report directly in the terminal after tests finish, so you can quickly see which lines were covered.
Click to reveal answer
intermediate
How can you generate an HTML coverage report with pytest-cov?
Use the command: pytest --cov=your_package_name --cov-report=html. This creates a folder named htmlcov with a detailed, easy-to-read coverage report you can open in a browser.
Click to reveal answer
Which command installs pytest-cov?
Apytest --install-cov
Bpip install pytest-cov
Cpip install coverage
Dpip install pytest
✗ Incorrect
The correct command to install pytest-cov is pip install pytest-cov.
What does pytest --cov=myapp do?
ARuns tests only for the 'myapp' package
BGenerates an HTML report only
CRuns tests and measures coverage for the 'myapp' package
DInstalls coverage for 'myapp'
✗ Incorrect
This command runs all tests and measures how much of 'myapp' code is covered by tests.