How to use the pycobertura.Cobertura function in pycobertura

To help you get started, we’ve selected a few pycobertura examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aconrad / pycobertura / tests / utils.py View on Github external
def make_cobertura(xml=SOURCE_FILE, *args, **kwargs):
    from pycobertura import Cobertura
    cobertura = Cobertura(xml, *args, **kwargs)
    return cobertura
github aconrad / pycobertura / tests / test_cobertura.py View on Github external
def test_parse_path():
    from pycobertura import Cobertura

    xml_path = 'foo.xml'

    with mock.patch('pycobertura.cobertura.os.path.exists', return_value=True):
        with mock.patch('pycobertura.cobertura.ET.parse') as mock_parse:
            cobertura = Cobertura(xml_path)

    assert cobertura.xml is mock_parse.return_value.getroot.return_value
github dhermes / bezier / scripts / report_lcov.py View on Github external
def report_coverage(lcov_filename):
    with open(lcov_filename, "r") as file_obj:
        contents = file_obj.read()
    converter = lcov_cobertura.LcovCobertura(contents)
    cobertura_xml = converter.convert()

    with tempfile.NamedTemporaryFile(mode="w+") as file_obj:
        file_obj.write(cobertura_xml)
        file_obj.seek(0)
        report = file_obj.name
        cobertura = pycobertura.Cobertura(report)

    reporter = pycobertura.TextReporter(cobertura)
    print(reporter.generate())
    # The status code will be the number of files under the
    # threshold.
    return sum(
        cobertura.line_rate(source_file) < THRESHOLD
        for source_file in cobertura.files()
    )