コード例 #1
0
ファイル: cli.py プロジェクト: z4y4ts/pycobertura
def diff(cobertura_file1, cobertura_file2, color, format, output, source1,
         source2, source_prefix1, source_prefix2, source):
    """compare coverage of two Cobertura reports"""
    cobertura1 = Cobertura(cobertura_file1,
                           source=source1,
                           source_prefix=source_prefix1)
    cobertura2 = Cobertura(cobertura_file2,
                           source=source2,
                           source_prefix=source_prefix2)

    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')

    click.echo(report, file=output, nl=isatty, color=color)

    exit_code = get_exit_code(reporter.differ, source)
    raise SystemExit(exit_code)
コード例 #2
0
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
コード例 #3
0
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
コード例 #4
0
ファイル: cli.py プロジェクト: smortvedt/pycobertura
def diff(
    cobertura_file1,
    cobertura_file2,
    color,
    format,
    output,
    source1,
    source2,
    source_prefix1,
    source_prefix2,
    source,
):
    """compare coverage of two Cobertura reports"""
    # Assume that the source is located in the same directory as the provided
    # coverage files if no source directories are provided.
    if not source1:
        source1 = get_dir_from_file_path(cobertura_file1)

    if not source2:
        source2 = get_dir_from_file_path(cobertura_file2)

    filesystem1 = filesystem_factory(source1, source_prefix=source_prefix1)
    cobertura1 = Cobertura(cobertura_file1, filesystem=filesystem1)

    filesystem2 = filesystem_factory(source2, source_prefix=source_prefix2)
    cobertura2 = Cobertura(cobertura_file2, filesystem=filesystem2)

    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")

    click.echo(report, file=output, nl=isatty, color=color)

    exit_code = get_exit_code(reporter.differ, source)
    raise SystemExit(exit_code)
コード例 #5
0
ファイル: cli.py プロジェクト: z4y4ts/pycobertura
def show(cobertura_file, format, output, source, source_prefix):
    """show coverage summary of a Cobertura report"""
    cobertura = Cobertura(cobertura_file, source=source)
    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)
コード例 #6
0
ファイル: cli.py プロジェクト: smortvedt/pycobertura
def show(cobertura_file, format, output, source, source_prefix):
    """show coverage summary of a Cobertura report"""
    if not source:
        source = get_dir_from_file_path(cobertura_file)

    cobertura = Cobertura(
        cobertura_file,
        filesystem=filesystem_factory(source, source_prefix=source_prefix),
    )
    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)