How to use the pycobertura.reporters.TextReporter 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 / test_reporters.py View on Github external
def test_text_report__with_missing_range():
    from pycobertura.reporters import TextReporter

    cobertura = make_cobertura('tests/dummy.with-dummy2-no-cov.xml')
    report = TextReporter(cobertura)

    assert report.generate() == """\
Filename             Stmts    Miss  Cover    Missing
github aconrad / pycobertura / tests / test_reporters.py View on Github external
def test_text_report():
    from pycobertura.reporters import TextReporter

    cobertura = make_cobertura()
    report = TextReporter(cobertura)

    assert report.generate() == """\
Filename                          Stmts    Miss  Cover    Missing
github aconrad / pycobertura / pycobertura / reporters.py View on Github external
def generate(self):
        lines = self.get_report_lines()

        formatted_lines = []
        for row in lines:
            formatted_row = self.format_row(row)
            formatted_lines.append(formatted_row)

        report = tabulate(
            formatted_lines, headers=["Filename", "Stmts", "Miss", "Cover", "Missing"]
        )

        return report


class HtmlReporter(TextReporter):
    def __init__(self, *args, **kwargs):
        self.title = kwargs.pop("title", "pycobertura report")
        self.render_file_sources = kwargs.pop("render_file_sources", True)
        self.no_file_sources_message = kwargs.pop(
            "no_file_sources_message", "Rendering of source files was disabled."
        )
        super(HtmlReporter, self).__init__(*args, **kwargs)

    def get_source(self, filename):
        lines = self.cobertura.file_source(filename)
        return lines

    def generate(self):
        lines = self.get_report_lines()

        formatted_lines = []
github aconrad / pycobertura / pycobertura / cli.py View on Github external
from pycobertura.cobertura import Cobertura
from pycobertura.reporters import (
    HtmlReporter,
    TextReporter,
    HtmlReporterDelta,
    TextReporterDelta,
)
from pycobertura.filesystem import filesystem_factory

pycobertura = click.Group()


reporters = {
    "html": HtmlReporter,
    "text": TextReporter,
}


class ExitCodes:
    OK = 0
    EXCEPTION = 1
    COVERAGE_WORSENED = 2
    NOT_ALL_CHANGES_COVERED = 3


def get_exit_code(differ, source):
    # Compute the non-zero exit code. This is a 2-step process which involves
    # checking whether code coverage is any better first and then check if all
    # changes are covered (stricter) which can only be done if the source code
    # is available (and enabled via the --source option).