Skip to main content

A Cobertura coverage report parser written in Python.

Project description

pycobertura

A Cobertura coverage report parser written in Python.

Features:

  • show coverage summary of a cobertura file

  • diff two cobertura files and show relative progress

  • output in plain text or HTML

  • colorized diff output

CLI usage

pycobertura provides a command line interface to report on coverage files:

$ pycobertura show coverage.xml
Name                     Stmts    Miss  Cover    Missing
---------------------  -------  ------  -------  ---------
pycobertura/__init__         1       0  100.00%
pycobertura/cli             18       0  100.00%
pycobertura/cobertura       93       0  100.00%
pycobertura/reports        129       0  100.00%
pycobertura/utils           12       0  100.00%
TOTAL                      253       0  100.00%

You can also use the diff command to show the difference between two coverage files:

$ pycobertura diff coverage.old.xml coverage.new.xml
Name          Stmts    Miss    Cover     Missing
------------  -------  ------  --------  ---------
dummy/dummy   -        -2      +50.00%   -2, -5
dummy/dummy2  +2       -       +100.00%
TOTAL         +2       -2      +50.00%

The column Missing will show line numbers prefixed with either a plus sign + or a minus sign -. When prefixed with a plus sign, the line was introduced as uncovered, when prefixed as a minus sign, the line is no longer uncovered.

Library usage

Using it as a library in your Python application is easy:

from pycobertura import Cobertura
cobertura = Cobertura('coverage.xml')

cobertura.version == '3.7.1'
cobertura.line_rate() == 1.0  # 100%
cobertura.classes() == [
    'pycobertura/__init__',
    'pycobertura/cli',
    'pycobertura/cobertura',
    'pycobertura/reports',
    'pycobertura/utils',
]
cobertura.line_rate('pycobertura/cli') == 1.0

from pycobertura import TextReporter
tr = TextReporter(cobertura)
tr.generate() == """\
Name                     Stmts    Miss  Cover    Missing
---------------------  -------  ------  -------  ---------
pycobertura/__init__         1       0  100.00%
pycobertura/cli             18       0  100.00%
pycobertura/cobertura       93       0  100.00%
pycobertura/reports        129       0  100.00%
pycobertura/utils           12       0  100.00%
TOTAL                      253       0  100.00%"""

from pycobertura import TextReporterDelta

coverage1 = Cobertura('coverage1.xml')
coverage2 = Cobertura('coverage2.xml')
delta = TextReporterDelta(coverage1, coverage2)
delta.generate() == """\
Name          Stmts    Miss    Cover     Missing
------------  -------  ------  --------  ---------
dummy/dummy   -        -2      +50.00%   -2, -5
dummy/dummy2  +2       -       +100.00%
TOTAL         +2       -2      +50.00%"""

Release Notes

Unreleased

0.2.1 (2014-12-10)

  • fix py26 compatibility by switching the XML parser to lxml which has a more predictible behavior when used across all Python versions.

  • add Travis CI

0.2.0 (2014-12-10)

  • apply Skeleton 2.0 theme to html output

  • add -o / --output option to write reports to a file.

  • known issue: diffing 2 files with options --format text, --color and --output does not render color under PY2.

0.1.0 (2014-12-03)

  • add --color and --no-color options to pycobertura diff.

  • add option -f and --format with output of text (default) and html.

  • change class naming from report to reporter

0.0.2 (2014-11-27)

  • MIT license

  • use pypandoc to convert the long_description in setup.py from Markdown to reStructuredText so pypi can digest and format the pycobertura page properly.

0.0.1 (2014-11-24)

  • Initial version

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pycobertura-0.2.1.tar.gz (21.5 kB view details)

Uploaded Source

File details

Details for the file pycobertura-0.2.1.tar.gz.

File metadata

  • Download URL: pycobertura-0.2.1.tar.gz
  • Upload date:
  • Size: 21.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pycobertura-0.2.1.tar.gz
Algorithm Hash digest
SHA256 2a2b280f9ed41d20fcfb46889b440d3d5342eb12bd6681fd813cc1d84c4bbc90
MD5 abef74a3ec65dc6861adaa9ec0a7180c
BLAKE2b-256 ac50fa395198c79fecd6a58200098f0bacc52869e68b67462ca83c1a58ea6f4a

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page