Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
"""
Initialize a Cobertura report given a coverage report `report`. It can
be either a file object or the path to an XML file that is in the
Cobertura format.
The optional argument `filesystem` describes how to retrieve the source
files referenced in the report. Please check the pycobertura.filesystem
module in order to discover more about filesystems.
"""
self.xml = ET.parse(report).getroot()
self.report = report if isinstance(report, basestring) else None
if filesystem:
self.filesystem = filesystem
else:
self.filesystem = filesystem_factory(self.report)
def diff(
cobertura_file1,
cobertura_file2,
color,
format,
output,
source1,
source2,
source_prefix1,
source_prefix2,
source,
):
"""compare coverage of two Cobertura reports"""
fs1 = filesystem_factory(
report=cobertura_file1, source=source1, source_prefix=source_prefix1
)
fs2 = filesystem_factory(
report=cobertura_file2, source=source2, source_prefix=source_prefix2
)
cobertura1 = Cobertura(cobertura_file1, filesystem=fs1)
cobertura2 = Cobertura(cobertura_file2, filesystem=fs2)
Reporter = delta_reporters[format]
reporter_args = [cobertura1, cobertura2]
reporter_kwargs = {"show_source": source}
isatty = True if output is None else output.isatty()
if format == "text":
color = isatty if color is None else color is True
cobertura_file1,
cobertura_file2,
color,
format,
output,
source1,
source2,
source_prefix1,
source_prefix2,
source,
):
"""compare coverage of two Cobertura reports"""
fs1 = filesystem_factory(
report=cobertura_file1, source=source1, source_prefix=source_prefix1
)
fs2 = filesystem_factory(
report=cobertura_file2, source=source2, source_prefix=source_prefix2
)
cobertura1 = Cobertura(cobertura_file1, filesystem=fs1)
cobertura2 = Cobertura(cobertura_file2, filesystem=fs2)
Reporter = delta_reporters[format]
reporter_args = [cobertura1, cobertura2]
reporter_kwargs = {"show_source": source}
isatty = True if output is None else output.isatty()
if format == "text":
color = isatty if color is None else color is True
reporter_kwargs["color"] = color
reporter = Reporter(*reporter_args, **reporter_kwargs)
def show(cobertura_file, format, output, source, source_prefix):
"""show coverage summary of a Cobertura report"""
fs = filesystem_factory(cobertura_file, source=source)
cobertura = Cobertura(cobertura_file, filesystem=fs)
Reporter = reporters[format]
reporter = Reporter(cobertura)
report = reporter.generate()
if not isinstance(report, bytes):
report = report.encode("utf-8")
isatty = True if output is None else output.isatty()
click.echo(report, file=output, nl=isatty)