pytest-cover is a pytest plugin for measuring code coverage, which was forked from pytest-cov. The project was officially merged back into pytest-cov in January 2019, and its GitHub repository explicitly states to use pytest-cov instead. This library (version 3.0.0) is effectively abandoned and users are strongly advised to use the actively maintained `pytest-cov` for coverage reporting with pytest.
pip install pytest-coverNo compatibility data collected yet for this library.
Since `pytest-cover` is abandoned, the quickstart illustrates usage for its successor, `pytest-cov`. It involves creating a simple Python module and a corresponding test file. The plugin integrates directly with `pytest` via command-line options. Running `pytest --cov=your_module` will execute tests and show a coverage report in the terminal. You can also generate an HTML report with `--cov-report=html`.
Migrate to `pytest-cov`. Uninstall `pytest-cover` (`pip uninstall pytest-cover`) and install `pytest-cov` (`pip install pytest-cov`). Review `pytest-cov`'s documentation for any specific migration steps or differences in configuration.
If encountering unexpected coverage behavior related to subprocesses, ensure all remnants of `pytest-cover` (and older `pytest-cov` versions) are uninstalled. `pytest-cov` version 7+ replaced the `.pth` file approach with `coverage`'s patch options (e.g., `[run] concurrency = multiprocessing` and `patch = subprocess` in `.coveragerc`).
Use `pytest-cov` instead, which is actively maintained and supports modern Python versions (currently Python 3.9+ for `pytest-cov` 6.0.0+, and has dropped support for Python 3.8 in `pytest-cov` 6.0.0). Refer to `pytest-cov`'s changelog for specific Python and `pytest` version compatibility.
When using distributed testing with `pytest-xdist`, ensure `pytest-cov` (the recommended alternative) and `coverage` are installed in all worker environments. Configure `coverage` for parallel execution (e.g., `[run] parallel = true` in `.coveragerc`) to correctly combine results.