Registry / testing / covdefaults

covdefaults

JSON →
library2.3.0pypypiunverified

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 covdefaults
INSTALL
IMPORT
SIG · COVDEFAULTS
C
covdefaults
testingpythonv2.3.0
Install
2.2s avg
Import
Disk
17MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v2.3.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.000s · 19.3MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 2.2s · import 0.000s · 20MB
17MB installed
● package 17MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

covdefaults
This library is a coverage.py plugin and is configured via coverage's configuration files (e.g., pyproject.toml, .coveragerc), not directly imported into Python code.
covdefaults is enabled by adding its name to the `plugins` list under the `[run]` section of your coverage configuration.

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.

pyproject.toml [tool.poetry] name = "my-project" version = "0.1.0" description = "" authors = ["Your Name <you@example.com>"] readme = "README.md" [tool.poetry.dependencies] python = ">=3.7,<4.0" coverage = {extras = ["toml"], version = ">=6.0.2"} [tool.poetry.group.dev.dependencies] pip = "*" pytest = "*" covdefaults = "*" [tool.coverage.run] plugins = ["covdefaults"] # Optional: Customize or override specific defaults # source = ["."] # omit = [".venv/*"] # Optional: Customize reporting # [tool.coverage.report] # fail_under = 90
Debug
Known issues
gotchaOverriding default options in coverage.py configuration files (e.g., `pyproject.toml`, `.coveragerc`) behaves differently for various settings. Some options, like `run:source` and `report:fail_under`, will entirely prevent `covdefaults` from applying its default if you set them manually. Other options, like `run:omit` and `report:exclude_lines`, will extend the defaults provided by `covdefaults` rather than overwriting them.
fix
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.
affects: All versions
gotchaThe `[covdefaults] subtract_omit` option, when used in your configuration, removes specific patterns from `covdefaults`'s default `omit` list. Users sometimes mistakenly believe it adds to the `omit` list, leading to files being included in coverage that they intended to exclude.
fix
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.
affects: All versions
gotchaWhen using `pytest-cov`, its command-line options (e.g., `--cov=something`, `--cov-branch`) can override the `source` and `branch` settings provided by `coverage.py` or `covdefaults`. This can lead to unexpected coverage behavior if not managed carefully.
fix
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.
affects: All versions
gotchaCoverage.py, and by extension `covdefaults`, respects a specific order of precedence for configuration files: `.coveragerc`, `.coveragerc.toml`, `setup.cfg`, `tox.ini`, and `pyproject.toml`. If multiple files are present, only the first one found that contains `coverage.py` settings will be used. This can cause confusion if you expect settings from one file to be merged or to override settings in another.
fix
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.
affects: All versions
Upgrade
Version history
2.3.0latest on PyPI · released Mar 5, 2023
Audit
Dependencies
coveragerequiredcovdefaults is a plugin for coverage.py and requires it to function.
Agent activity
21 hits · last 30 days
node
20
OpenAI (training)
1
Resources
covdefaults — pip install covdefaults · libregistry