{"id":24419,"library":"pytest-codecov","title":"pytest-codecov","description":"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.","status":"active","version":"0.7.0","language":"python","source_language":"en","source_url":"https://github.com/seantis/pytest-codecov","tags":["pytest","plugin","coverage","codecov","testing"],"install":[{"cmd":"pip install pytest-codecov","lang":"bash","label":"pip install"}],"dependencies":[{"reason":"Required for coverage collection; pytest-codecov uploads the coverage results generated by pytest-cov.","package":"pytest-cov","optional":false},{"reason":"Alternative upload method; pytest-codecov uses the legacy Codecov uploader by default, but can be configured to use the CLI.","package":"codecov-cli","optional":true}],"imports":[{"note":"This is a pytest plugin; it is automatically discovered after installation. Direct import is not required but works for configuration.","wrong":"","symbol":"pytest_codecov","correct":"import pytest_codecov"}],"quickstart":{"code":"import pytest\nimport os\n\n# Run pytest with coverage and upload to Codecov\n# Set CODECOV_TOKEN as environment variable or in .codecov.yml\nos.environ['CODECOV_TOKEN'] = os.environ.get('CODECOV_TOKEN', '')\n\n# Run tests with coverage and JUnit XML (optional)\nretcode = pytest.main([\n    '--cov=my_package',\n    '--cov-report=xml',\n    '--junit-xml=test-results.xml',\n    'tests/'\n])\n\n# The plugin automatically uploads to Codecov after tests finish","lang":"python","description":"Minimal setup: install pytest-cov and pytest-codecov, then run pytest with --cov and --cov-report=xml. The plugin uploads coverage to Codecov automatically."},"warnings":[{"fix":"Update network rules to allow connections to upload.codecov.io.","message":"In 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.","severity":"breaking","affected_versions":">=0.6.0"},{"fix":"Run your tests using pytest command or pytest.main() in code.","message":"The plugin only uploads when tests are run with pytest (not via other test runners). Ensure you are using pytest to execute tests.","severity":"gotcha","affected_versions":"all"},{"fix":"Use --cov-report=xml or ensure cov-report is set to xml in pytest configuration.","message":"If 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.","severity":"gotcha","affected_versions":">=0.6.0"},{"fix":"Install codecov-cli and follow its configuration; or use the --codecov-cli flag if available.","message":"The legacy Codecov uploader is deprecated. Consider migrating to codecov-cli for future-proofing.","severity":"deprecated","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Set the environment variable CODECOV_SLUG to 'owner/repo' or use the --codecov-slug command-line option.","cause":"The plugin cannot determine the repository slug automatically when running outside a git repo (e.g., in CI without git info).","error":"ValueError: Missing repository slug. Please set CODECOV_SLUG environment variable or provide it via --codecov-slug."},{"fix":"Install pytest-cov: pip install pytest-cov","cause":"pytest-cov is not installed or not activated.","error":"pytest: error: unrecognized arguments: --cov"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}