Registry / devops / coverage-badge

coverage-badge

JSON →
library1.1.2pypypiunverified

coverage-badge is a Python utility that generates SVG coverage badges based on data produced by the `Coverage.py` tool. While it currently stands at version 1.1.2, the project is in maintenance mode, meaning it will receive only occasional updates and fixes, but no new features. Users seeking more advanced features or active development are encouraged to explore alternatives like `genbadge`.

pip install coverage-badge
INSTALL
IMPORT
SIG · COVERAGE-BADGE
C
coverage-badge
devopspythonv1.1.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

To generate a coverage badge, first run `Coverage.py` (e.g., via `pytest --cov`) to produce coverage data. Then, execute `coverage-badge` in the same directory as the `.coverage` data file to generate the SVG image.

# 1. Run Coverage.py to generate coverage data # (Example with pytest, ensure pytest-cov is installed if using pytest) # pip install coverage pytest pytest-cov coverage run -m pytest # 2. Generate the coverage badge SVG file # Ensure you run this command from the directory where the .coverage data file is located. coverage-badge -o coverage.svg # The coverage.svg file is now generated and can be embedded in your README.md # Example markdown: ![Coverage](coverage.svg)
coverage-badge --version
Debug
Known issues
deprecatedThe `coverage-badge` project is in maintenance mode and will not receive new features. It is recommended to use `genbadge` for more features and active development.
fix
Consider migrating to `genbadge` for new projects or if advanced features are required.
affects: All versions
gotchaThe `coverage-badge` command must be run from the directory where the `.coverage` data file (generated by `Coverage.py`) is located.
fix
Navigate to the correct directory using `cd` before running `coverage-badge`, or specify the path to the `.coverage` file if the tool supported it (which it doesn't currently, based on documentation).
affects: All versions
gotcha`coverage-badge` requires `Coverage.py` to have been run previously to generate a `.coverage` data file. Without this file, the badge cannot be generated.
fix
Always run `coverage run ...` (e.g., `coverage run -m pytest`) before attempting to generate the badge with `coverage-badge`.
affects: All versions
Errors
Common errors & fixes
coverage-badge: command not found
The `coverage-badge` executable is not found in the system's PATH, usually because the package was not installed or the Python environment's scripts directory is not configured correctly.
fix
Ensure `coverage-badge` is installed in your active Python environment: `pip install coverage-badge`. If using a virtual environment, make sure it's activated.
No coverage data found.
The `coverage-badge` utility could not find the `.coverage` data file generated by `Coverage.py` in the current working directory, or the file was empty/corrupted.
fix
First, run `Coverage.py` to generate the coverage data (e.g., `coverage run -m pytest`). Then, execute `coverage-badge` from the same directory where the `.coverage` file was created.
coverage unknown
The coverage badge displays 'unknown' because the underlying coverage data could not be generated, parsed, or was not successfully picked up by the CI/CD system's badge mechanism. While not a direct error from `coverage-badge` itself, it's a common symptom when `coverage-badge`'s output (or its input) is misconfigured in a CI/CD pipeline.
fix
Verify that `Coverage.py` runs successfully and generates valid data. Ensure `coverage-badge` is executed correctly to produce the SVG. In your CI/CD configuration (e.g., GitLab CI, GitHub Actions), confirm the badge's URL points to the correct SVG, the pipeline successfully generates the coverage artifact, and any regex patterns for parsing coverage are correct.
ModuleNotFoundError: No module named 'coverage-badge'
The `coverage-badge` Python package is not installed or is not accessible in the Python environment where the script is being executed.
fix
Install the package using pip: `pip install coverage-badge`. If you are in a virtual environment, ensure it is activated before installation.
Upgrade
Version history
1.1.2latest on PyPI · released Aug 2, 2024
Audit
Dependencies
coveragerequiredThe core functionality of coverage-badge relies on coverage.py to generate test coverage data (.coverage file). It is not a direct Python dependency but a prerequisite for operation.
Agent activity
4 hits · last 30 days
node
2
Resources
coverage-badge — pip install coverage-badge · libregistry