{"library":"pytest-cov","title":"pytest-cov: Coverage Plugin for pytest","description":"pytest-cov is a pytest plugin that provides comprehensive code coverage functionality, integrating seamlessly with `coverage.py`. It extends pytest with features like automatic erasing and combination of `.coverage` data files, support for detailed coverage contexts, and compatibility with `pytest-xdist` for distributed testing. It is actively maintained by the pytest-dev team.","language":"python","status":"active","last_verified":"Wed Apr 15","install":{"commands":["pip install pytest-cov"],"cli":null},"imports":[],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import pytest\n\n# app.py\ndef greet(name):\n    if name:\n        return f\"Hello, {name}!\"\n    return \"Hello, World!\"\n\n# test_app.py\ndef test_greet_with_name():\n    assert greet(\"Alice\") == \"Hello, Alice!\"\n\ndef test_greet_without_name():\n    assert greet(None) == \"Hello, World!\"\n\n# To run this, save as app.py and test_app.py, then:\n# pytest --cov=app test_app.py\n# You'll see a coverage report in your terminal.\n# For an HTML report: pytest --cov=app --cov-report=html test_app.py","lang":"python","description":"Create a simple Python module (`app.py`) and a test file (`test_app.py`). Run pytest with the `--cov` flag, pointing to the module or directory you want to measure coverage for. This will output a summary to the terminal. You can specify different report formats like HTML, XML, or JSON using `--cov-report`.","tag":"verified","tag_description":"quickstart runs on critical runtimes, recently tested","last_tested":"2026-04-23","results":[{"runtime":"python:3.10-alpine","exit_code":0},{"runtime":"python:3.10-slim","exit_code":0},{"runtime":"python:3.11-alpine","exit_code":0},{"runtime":"python:3.11-slim","exit_code":0},{"runtime":"python:3.12-alpine","exit_code":0},{"runtime":"python:3.12-slim","exit_code":0},{"runtime":"python:3.13-alpine","exit_code":0},{"runtime":"python:3.13-slim","exit_code":0},{"runtime":"python:3.9-alpine","exit_code":0},{"runtime":"python:3.9-slim","exit_code":0}]},"compatibility":null}