Test Overview
This test checks that pytest-cov is correctly set up to measure code coverage during pytest test runs. It verifies that coverage data is collected and reported.
This test checks that pytest-cov is correctly set up to measure code coverage during pytest test runs. It verifies that coverage data is collected and reported.
import pytest def add(a, b): return a + b def test_add(): assert add(2, 3) == 5 # Run this test with coverage using: # pytest --cov=.
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test runner starts pytest with coverage option '--cov=.' | Terminal shows pytest starting and coverage plugin initializing | — | PASS |
| 2 | Pytest discovers test_add function and runs it | Test function executes in Python environment | assert add(2, 3) == 5 | PASS |
| 3 | pytest-cov collects coverage data for the add function | Coverage data is recorded in memory | — | PASS |
| 4 | pytest finishes and outputs coverage report to terminal | Terminal displays coverage summary showing 100% coverage for add function | Coverage report shows 100% lines covered | PASS |
pytest-cov in testing?pytest --cov=my_module if all code in my_module is covered by tests?pytest --cov=my_module --cov-report=html but no HTML report is generated. What is the most likely cause?mod1 and mod2 and generate both terminal and HTML reports. Which command is correct?Pass the test and this pattern moves unknown