Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_diff__has_not_better_coverage():
from pycobertura.cobertura import Cobertura, CoberturaDiff
cobertura1 = Cobertura('tests/dummy.zeroexit2/coverage.xml')
cobertura2 = Cobertura('tests/dummy.zeroexit1/coverage.xml')
differ = CoberturaDiff(cobertura1, cobertura2)
assert differ.has_better_coverage() is False
def test_diff__has_better_coverage():
from pycobertura.cobertura import Cobertura, CoberturaDiff
cobertura1 = Cobertura('tests/dummy.zeroexit1/coverage.xml')
cobertura2 = Cobertura('tests/dummy.zeroexit2/coverage.xml')
differ = CoberturaDiff(cobertura1, cobertura2)
assert differ.has_better_coverage() is True
def test_diff__has_better_coverage():
from pycobertura.cobertura import Cobertura, CoberturaDiff
cobertura1 = Cobertura('tests/dummy.zeroexit1/coverage.xml')
cobertura2 = Cobertura('tests/dummy.zeroexit2/coverage.xml')
differ = CoberturaDiff(cobertura1, cobertura2)
assert differ.has_better_coverage() is True
def test_diff__has_not_better_coverage():
from pycobertura.cobertura import Cobertura, CoberturaDiff
cobertura1 = Cobertura('tests/dummy.zeroexit2/coverage.xml')
cobertura2 = Cobertura('tests/dummy.zeroexit1/coverage.xml')
differ = CoberturaDiff(cobertura1, cobertura2)
assert differ.has_better_coverage() is False
def test_diff__has_all_changes_covered__some_changed_code_is_still_uncovered():
from pycobertura.cobertura import Cobertura, CoberturaDiff
cobertura1 = Cobertura('tests/dummy.zeroexit1/coverage.xml')
cobertura2 = Cobertura('tests/dummy.zeroexit2/coverage.xml')
differ = CoberturaDiff(cobertura1, cobertura2)
assert differ.has_all_changes_covered() is False
def test_diff__has_all_changes_covered__some_changed_code_is_still_uncovered():
from pycobertura.cobertura import Cobertura, CoberturaDiff
cobertura1 = Cobertura('tests/dummy.zeroexit1/coverage.xml')
cobertura2 = Cobertura('tests/dummy.zeroexit2/coverage.xml')
differ = CoberturaDiff(cobertura1, cobertura2)
assert differ.has_all_changes_covered() is False
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)
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)
report = reporter.generate()
if not isinstance(report, bytes):
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)
report = reporter.generate()
if not isinstance(report, bytes):
report = report.encode("utf-8")