covdefaults is a coverage.py plugin that provides sensible, opinionated default settings to streamline test coverage configuration. It automatically sets defaults for aspects like branch coverage, source directory, common file omission patterns, and reporting options (e.g., `show_missing=True`, `fail_under=100`). The current version is 2.3.0, released on March 5, 2023, and it maintains an active release cadence.
pip install covdefaultsVerified import paths — ran on the pinned version, not inferred.
To enable covdefaults, add it to the `plugins` list in your `pyproject.toml` (or `.coveragerc`, `setup.cfg`, `tox.ini`). This example assumes a Poetry project with pytest and coverage installed. covdefaults will then apply its default settings for coverage measurement and reporting. You can override specific defaults by explicitly setting them in your coverage configuration.
Always consult the `covdefaults` documentation or source for the exact behavior of specific settings when overriding. Test your coverage configuration thoroughly to ensure the desired defaults are applied or overridden correctly.
Use `[covdefaults] subtract_omit` only when you explicitly want to un-omit a file that `covdefaults` would normally omit. To add new patterns to the `omit` list, use the standard `[run] omit` option in your coverage configuration.
For consistent coverage behavior, prefer to define your `coverage.py` configuration (including `covdefaults` activation and overrides) in a configuration file (like `pyproject.toml`) rather than relying heavily on `pytest-cov` command-line arguments that duplicate configuration file settings. This ensures a single source of truth for your coverage setup.
Consolidate your coverage configuration into a single file, preferably `pyproject.toml`, to avoid ambiguity. If using multiple files is unavoidable, be mindful of the precedence order and clearly document where your primary coverage settings reside.