lcov_cobertura package

Module contents

Converts lcov line coverage output to Cobertura-compatible XML for CI

class lcov_cobertura.Demangler[source]

Bases: object

demangle(name)[source]
class lcov_cobertura.LcovCobertura(lcov_data, base_dir='.', excludes=None, demangle=False)[source]

Bases: object

Converts code coverage report files in lcov format to Cobertura’s XML report format so that CI servers like Jenkins can aggregate results and determine build stability etc.

>>> from lcov_cobertura import LcovCobertura
>>> LCOV_INPUT = 'your lcov input'
>>> converter = LcovCobertura(LCOV_INPUT)
>>> cobertura_xml = converter.convert()
>>> print(cobertura_xml)
<?xml version="1.0" ?>
<!DOCTYPE coverage
  SYSTEM 'http://cobertura.sourceforge.net/xml/coverage-04.dtd'>
  ...
convert()[source]

Convert lcov file to cobertura XML using options from this instance.

generate_cobertura_xml(coverage_data, **kwargs)[source]

Given parsed coverage data, return a String cobertura XML representation.

Parameters

coverage_data (dict) – Nested dict representing coverage information.

parse(**kwargs)[source]

Generate a data structure representing it that can be serialized in any logical format.

lcov_cobertura.main(argv=None)[source]

Converts LCOV coverage data to Cobertura-compatible XML for reporting.

Usage:

lcov_cobertura.py lcov-file.dat lcov_cobertura.py lcov-file.dat -b src/dir -e test.lib -o path/out.xml

By default, XML output will be written to ./coverage.xml