Skip to content

danger-python plugin for displaying code coverage changes

License

Notifications You must be signed in to change notification settings

elpassion/danger-py-cov

Repository files navigation

PyPI Python versions Build Status

danger-py-cov

The plugin parses the .xml coverage report and visualizes how the pull request affects the results.

Example output

Current coverage is 100.00%

Files changed Coverage -
calculations.py 100.00%
cobertura.py 100.00%
models.py 100.00%
plugin.py 100.00%
report.py 100.00%

Usage

Run the tests using the runner that supports XML reporting. For pytest and pytest-cov add following to the setup.cfg:

[tool:pytest]
addopts = --cov --cov-report xml:cov.xml --cov-report term

[coverage:run]
branch = True

Installation

# install danger-js
npm install -g danger
# install danger-python
pip install danger-python
# install danger-py-cov
pip install danger-py-cov
# modify dangerfile.py to include plugin
# run the tests with coverage report enabled
pytest --cov --cov-report xml:cov.xml --cov-report term
# run danger-python
danger-python pr https://github.com/elpassion/danger-py-cov/pull/2

Add following to the dangerfile.py:

import danger_py_cov

danger_py_cov.report_coverage("cov.xml", minimum_coverage=95.0)

Make sure to run pytest before running danger-python.

Development

To develop the new features, clone the repository and then run:

# install dependencies
poetry install 
# activate virtual environment
poetry shell 
# add pre-commit checks
pre-commit install -f -t pre-commit 
# run the test suite
pytest 

License

danger-py-cov is released under an MIT license. See LICENSE for more information.