Registry / testing / pytest-codecov

pytest-codecov

JSON →
library0.7.0pypypi✓ verified 86d ago

Pytest plugin for uploading pytest-cov results (coverage reports) to codecov.io. Current version 0.7.0, released 2025-01-26, with support for Python >=3.8. Release cadence is irregular, with major updates every few years.

pip install pytest-codecov
INSTALL
IMPORT
SIG · PYTEST-CODECOV
P
pytest-codecov
testingpythonv0.7.0
Install
3.9s avg
Import
886ms
Disk
34MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.7.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.95 runs
installs and imports cleanly · install 0.0s · import 0.934s · 35.6MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 3.9s · import 0.838s · 36MB
34MB installed
● package 34MB
Code
Verified usage

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

pytest_codecov
import pytest_codecov
This is a pytest plugin; it is automatically discovered after installation. Direct import is not required but works for configuration.

Minimal setup: install pytest-cov and pytest-codecov, then run pytest with --cov and --cov-report=xml. The plugin uploads coverage to Codecov automatically.

import pytest import os # Run pytest with coverage and upload to Codecov # Set CODECOV_TOKEN as environment variable or in .codecov.yml os.environ['CODECOV_TOKEN'] = os.environ.get('CODECOV_TOKEN', '') # Run tests with coverage and JUnit XML (optional) retcode = pytest.main([ '--cov=my_package', '--cov-report=xml', '--junit-xml=test-results.xml', 'tests/' ]) # The plugin automatically uploads to Codecov after tests finish
Debug
Known issues
breakingIn pytest-codecov 0.6.0+, the plugin uses the new Codecov upload endpoint. If you have a firewall or proxy, you may need to allow upload to upload.codecov.io instead of codecov.io.
fix
Update network rules to allow connections to upload.codecov.io.
affects: >=0.6.0
gotchaThe plugin only uploads when tests are run with pytest (not via other test runners). Ensure you are using pytest to execute tests.
fix
Run your tests using pytest command or pytest.main() in code.
affects: all
gotchaIf you use --cov-report= and set it to a value other than xml, the coverage report may not be uploaded. The plugin expects an XML report by default.
fix
Use --cov-report=xml or ensure cov-report is set to xml in pytest configuration.
affects: >=0.6.0
deprecatedThe legacy Codecov uploader is deprecated. Consider migrating to codecov-cli for future-proofing.
fix
Install codecov-cli and follow its configuration; or use the --codecov-cli flag if available.
affects: all
Errors
Common errors & fixes
ValueError: Missing repository slug. Please set CODECOV_SLUG environment variable or provide it via --codecov-slug.
The plugin cannot determine the repository slug automatically when running outside a git repo (e.g., in CI without git info).
fix
Set the environment variable CODECOV_SLUG to 'owner/repo' or use the --codecov-slug command-line option.
pytest: error: unrecognized arguments: --cov
pytest-cov is not installed or not activated.
fix
Install pytest-cov: pip install pytest-cov
Upgrade
Version history
0.7.0latest on PyPI · released Mar 25, 2025
Audit
Dependencies
pytest-covrequiredRequired for coverage collection; pytest-codecov uploads the coverage results generated by pytest-cov.
codecov-clioptionalAlternative upload method; pytest-codecov uses the legacy Codecov uploader by default, but can be configured to use the CLI.
Agent activity
12 hits · last 30 days
node
10
Resources
pytest-codecov — pip install pytest-codecov · libregistry