Example #1
0
    def report(
        self, morfs=None, show_missing=None, ignore_errors=None,
        file=None,                  # pylint: disable=redefined-builtin
        omit=None, include=None, skip_covered=None,
    ):
        """Write a textual summary report to `file`.

        Each module in `morfs` is listed, with counts of statements, executed
        statements, missing statements, and a list of lines missed.

        If `show_missing` is true, then details of which lines or branches are
        missing will be included in the report.  If `ignore_errors` is true,
        then a failure while reporting a single file will not stop the entire
        report.

        `file` is a file-like object, suitable for writing.

        `include` is a list of file name patterns.  Files that match will be
        included in the report. Files matching `omit` will not be included in
        the report.

        If `skip_covered` is true, don't report on files with 100% coverage.

        All of the arguments default to the settings read from the
        :ref:`configuration file <config>`.

        Returns a float, the total percentage covered.

        """
        self.config.from_args(
            ignore_errors=ignore_errors, report_omit=omit, report_include=include,
            show_missing=show_missing, skip_covered=skip_covered,
            )
        reporter = SummaryReporter(self, self.config)
        return reporter.report(morfs, outfile=file)
Example #2
0
    def report(
        self, morfs=None, show_missing=None, ignore_errors=None,
        file=None,                  # pylint: disable=redefined-builtin
        omit=None, include=None, skip_covered=None,
    ):
        """Write a summary report to `file`.

        Each module in `morfs` is listed, with counts of statements, executed
        statements, missing statements, and a list of lines missed.

        `include` is a list of file name patterns.  Files that match will be
        included in the report. Files matching `omit` will not be included in
        the report.

        If `skip_covered` is True, don't report on files with 100% coverage.

        Returns a float, the total percentage covered.

        """
        self.get_data()
        self.config.from_args(
            ignore_errors=ignore_errors, report_omit=omit, report_include=include,
            show_missing=show_missing, skip_covered=skip_covered,
            )
        reporter = SummaryReporter(self, self.config)
        return reporter.report(morfs, outfile=file)
Example #3
0
    def report(
        self,
        morfs=None,
        show_missing=True,
        ignore_errors=None,
        file=None,  # pylint: disable=W0622
        omit=None,
        include=None,
    ):
        """Write a summary report to `file`.

        Each module in `morfs` is listed, with counts of statements, executed
        statements, missing statements, and a list of lines missed.

        `include` is a list of filename patterns.  Modules whose filenames
        match those patterns will be included in the report. Modules matching
        `omit` will not be included in the report.

        Returns a float, the total percentage covered.

        """
        self._harvest_data()
        self.config.from_args(ignore_errors=ignore_errors, omit=omit, include=include, show_missing=show_missing)
        reporter = SummaryReporter(self, self.config)
        return reporter.report(morfs, outfile=file)
Example #4
0
    def report(
        self,
        morfs=None,
        show_missing=True,
        ignore_errors=None,
        file=None,  # pylint: disable=redefined-builtin
        omit=None,
        include=None,
        skip_covered=False,
    ):
        """Write a summary report to `file`.

        Each module in `morfs` is listed, with counts of statements, executed
        statements, missing statements, and a list of lines missed.

        `include` is a list of file name patterns.  Files that match will be
        included in the report. Files matching `omit` will not be included in
        the report.

        Returns a float, the total percentage covered.

        """
        self.get_data()
        self.config.from_args(
            ignore_errors=ignore_errors,
            omit=omit,
            include=include,
            show_missing=show_missing,
            skip_covered=skip_covered,
        )
        reporter = SummaryReporter(self, self.config)
        return reporter.report(morfs, outfile=file)
Example #5
0
 def report(self,
            morfs=None,
            show_missing=True,
            ignore_errors=None,
            file=None,
            omit=None,
            include=None):
     """Write a summary report to `file`.
     
     Each module in `morfs` is listed, with counts of statements, executed
     statements, missing statements, and a list of lines missed.
     
     `include` is a list of filename patterns.  Modules whose filenames
     match those patterns will be included in the report. Modules matching
     `omit` will not be included in the report.
     
     Returns a float, the total percentage covered.
     
     """
     self._harvest_data()
     self.config.from_args(ignore_errors=ignore_errors,
                           omit=omit,
                           include=include,
                           show_missing=show_missing)
     reporter = SummaryReporter(self, self.config)
     return reporter.report(morfs, outfile=file)
Example #6
0
    def report(
        self, morfs=None, show_missing=None, ignore_errors=None,
        file=None, omit=None, include=None, skip_covered=None,
    ):
        """Write a textual summary report to `file`.

        Each module in `morfs` is listed, with counts of statements, executed
        statements, missing statements, and a list of lines missed.

        If `show_missing` is true, then details of which lines or branches are
        missing will be included in the report.  If `ignore_errors` is true,
        then a failure while reporting a single file will not stop the entire
        report.

        `file` is a file-like object, suitable for writing.

        `include` is a list of file name patterns.  Files that match will be
        included in the report. Files matching `omit` will not be included in
        the report.

        If `skip_covered` is true, don't report on files with 100% coverage.

        All of the arguments default to the settings read from the
        :ref:`configuration file <config>`.

        Returns a float, the total percentage covered.

        """
        self.config.from_args(
            ignore_errors=ignore_errors, report_omit=omit, report_include=include,
            show_missing=show_missing, skip_covered=skip_covered,
            )
        reporter = SummaryReporter(self, self.config)
        return reporter.report(morfs, outfile=file)
Example #7
0
    def report(
            self,
            morfs=None,
            show_missing=True,
            ignore_errors=None,
            file=None,  # pylint: disable-msg=W0622
            omit=None,
            include=None):
        """Write a summary report to `file`.

        Each module in `morfs` is listed, with counts of statements, executed
        statements, missing statements, and a list of lines missed.

        `include` is a list of filename patterns.  Modules whose filenames
        match those patterns will be included in the report. Modules matching
        `omit` will not be included in the report.

        """
        self.config.from_args(ignore_errors=ignore_errors,
                              omit=omit,
                              include=include)
        reporter = SummaryReporter(self, show_missing,
                                   self.config.ignore_errors)
        reporter.report(morfs,
                        outfile=file,
                        omit=self.config.omit,
                        include=self.config.include)
Example #8
0
    def report(
        self, morfs=None, show_missing=None, ignore_errors=None,
        file=None, omit=None, include=None, skip_covered=None,
        contexts=None, skip_empty=None, precision=None, sort=None
    ):
        """Write a textual summary report to `file`.

        Each module in `morfs` is listed, with counts of statements, executed
        statements, missing statements, and a list of lines missed.

        If `show_missing` is true, then details of which lines or branches are
        missing will be included in the report.  If `ignore_errors` is true,
        then a failure while reporting a single file will not stop the entire
        report.

        `file` is a file-like object, suitable for writing.

        `include` is a list of file name patterns.  Files that match will be
        included in the report. Files matching `omit` will not be included in
        the report.

        If `skip_covered` is true, don't report on files with 100% coverage.

        If `skip_empty` is true, don't report on empty files (those that have
        no statements).

        `contexts` is a list of regular expressions.  Only data from
        :ref:`dynamic contexts <dynamic_contexts>` that match one of those
        expressions (using :func:`re.search <python:re.search>`) will be
        included in the report.

        `precision` is the number of digits to display after the decimal
        point for percentages.

        All of the arguments default to the settings read from the
        :ref:`configuration file <config>`.

        Returns a float, the total percentage covered.

        .. versionadded:: 4.0
            The `skip_covered` parameter.

        .. versionadded:: 5.0
            The `contexts` and `skip_empty` parameters.

        .. versionadded:: 5.2
            The `precision` parameter.

        """
        with override_config(
            self,
            ignore_errors=ignore_errors, report_omit=omit, report_include=include,
            show_missing=show_missing, skip_covered=skip_covered,
            report_contexts=contexts, skip_empty=skip_empty, precision=precision,
            sort=sort
        ):
            reporter = SummaryReporter(self)
            return reporter.report(morfs, outfile=file)
Example #9
0
 def report(self, morfs=None, show_missing=True, ignore_errors=False,
             file=None, omit_prefixes=None):     # pylint: disable-msg=W0622
     """Write a summary report to `file`.
     
     Each module in `morfs` is listed, with counts of statements, executed
     statements, missing statements, and a list of lines missed.
     
     """
     reporter = SummaryReporter(self, show_missing, ignore_errors)
     reporter.report(morfs, outfile=file, omit_prefixes=omit_prefixes)
Example #10
0
 def get_summary_text(self, coverage_data, options):
     """Get text output from the SummaryReporter."""
     cov = Coverage()
     cov.start()
     cov.stop()              # pragma: nested
     cov.data = coverage_data
     printer = SummaryReporter(cov, options)
     destination = StringIO()
     printer.report([], destination)
     return destination.getvalue()
Example #11
0
 def get_summary_text(self, coverage_data, options):
     """Get text output from the SummaryReporter."""
     cov = Coverage()
     cov.start()
     cov.stop()  # pragma: nested
     cov.data = coverage_data
     printer = SummaryReporter(cov, options)
     destination = StringIO()
     printer.report([], destination)
     return destination.getvalue()
Example #12
0
 def report(self,
            morfs=None,
            show_missing=True,
            ignore_errors=None,
            file=None,
            omit=None,
            include=None):
     self._harvest_data()
     self.config.from_args(ignore_errors=ignore_errors,
                           omit=omit,
                           include=include,
                           show_missing=show_missing)
     reporter = SummaryReporter(self, self.config)
     return reporter.report(morfs, outfile=file)
Example #13
0
    def get_summary_text(self, options):
        """Get text output from the SummaryReporter."""
        self.make_rigged_file("file1.py", 339, 155)
        self.make_rigged_file("file2.py", 13, 3)
        self.make_rigged_file("file3.py", 234, 228)
        self.make_file("doit.py", "import file1, file2, file3")

        cov = Coverage(source=["."], omit=["doit.py"])
        cov.start()
        import doit  # pragma: nested # pylint: disable=import-error, unused-import
        cov.stop()  # pragma: nested
        printer = SummaryReporter(cov, options)
        destination = StringIO()
        printer.report([], destination)
        return destination.getvalue()
Example #14
0
    def get_summary_text(self, options):
        """Get text output from the SummaryReporter."""
        self.make_rigged_file("file1.py", 339, 155)
        self.make_rigged_file("file2.py", 13, 3)
        self.make_rigged_file("file3.py", 234, 228)
        self.make_file("doit.py", "import file1, file2, file3")

        cov = Coverage(source=["."], omit=["doit.py"])
        cov.start()
        import doit             # pragma: nested # pylint: disable=import-error, unused-import
        cov.stop()              # pragma: nested
        printer = SummaryReporter(cov, options)
        destination = StringIO()
        printer.report([], destination)
        return destination.getvalue()
Example #15
0
class ProgressionReporter(CoverageReporter):
    """A reporter for testing whether your coverage is improving or degrading. """

    def __init__(self, coverage, show_missing=False, ignore_errors=False):
        super(ProgressionReporter, self).__init__(coverage, ignore_errors)
        self.summary_reporter = CoverageSummaryReporter(coverage, show_missing=show_missing, ignore_errors=ignore_errors)

    def coverage_progressed(self):
        """ Returns 0 if coverage has regressed, 1 if there was no
        existing best-coverage summary, 2 if coverage is the same as
        the existing best-coverage summary, 3 if coverage is improved
        compared to the existing best-coverage summary. """
        if not hasattr(self, 'bestunc'):
            return 1

        if (self.curtot == self.besttot) and (self.curunc == self.bestunc):
            return 2

        if (self.curtot <= self.besttot) and (self.curunc <= self.bestunc):
            return 3
        else:
            return 0

    def report(self, morfs, omit=None, outfile=None, include=None):
        """Writes a report summarizing progression/regression."""
        # First we use our summary_reporter to generate a text summary of the current version.
        if outfile is None:
            outfile = SUMMARY_FNAME
        outfileobj = open(outfile, "w")
        self.summary_reporter.report(morfs, omit=omit, outfile=outfileobj, include=include)
        outfileobj.close()

        self.curunc, self.curpart = parse_out_unc_and_part(fileutil.read_file(SUMMARY_FNAME, mode='rU'))
        self.curtot = self.curunc + self.curpart

        # Then we see if there is a previous best version and if so what its count of uncovered and partially covered lines was.
        try:
            self.bestunc, self.bestpart = parse_out_unc_and_part(fileutil.read_file(BEST_SUMMARY_FNAME, mode='rU'))
        except IOError, le:
            # Ignore "No such file or directory", report and ignore any other error.
            if (le.args[0] != 2 and le.args[0] != 3) or (le.args[0] != errno.ENOENT):
                sys.stderr.write("WARNING, got unexpected IOError from attempt to read best-ever summary file: %s\n" % (le,))
            pass
        except SummaryTextParseError, le:
            sys.stderr.write("WARNING, got unexpected SummaryTextParseError from attempt to read best-ever summary file: %s\n" % (le,))
            pass
Example #16
0
    def get_summary_text(self, *options):
        """Get text output from the SummaryReporter.

        The arguments are tuples: (name, value) for Coverage.set_option.
        """
        self.make_rigged_file("file1.py", 339, 155)
        self.make_rigged_file("file2.py", 13, 3)
        self.make_rigged_file("file10.py", 234, 228)
        self.make_file("doit.py", "import file1, file2, file10")

        cov = Coverage(source=["."], omit=["doit.py"])
        self.start_import_stop(cov, "doit")
        for name, value in options:
            cov.set_option(name, value)
        printer = SummaryReporter(cov)
        destination = io.StringIO()
        printer.report([], destination)
        return destination.getvalue()
    def report(self, morfs=None, show_missing=True, ignore_errors=None,
                file=None,                          # pylint: disable-msg=W0622
                omit=None, include=None
                ):
        """Write a summary report to `file`.

        Each module in `morfs` is listed, with counts of statements, executed
        statements, missing statements, and a list of lines missed.

        `include` is a list of filename patterns.  Modules whose filenames
        match those patterns will be included in the report. Modules matching
        `omit` will not be included in the report.

        """
        self.config.from_args(
            ignore_errors=ignore_errors, omit=omit, include=include
            )
        reporter = SummaryReporter(
            self, show_missing, self.config.ignore_errors
            )
        reporter.report(morfs, outfile=file, config=self.config)
Example #18
0
 def __init__(self, coverage, show_missing=False, ignore_errors=False):
     super(ProgressionReporter, self).__init__(coverage, ignore_errors)
     self.summary_reporter = CoverageSummaryReporter(coverage, show_missing=show_missing, ignore_errors=ignore_errors)
Example #19
0
 def report(self, morfs = None, show_missing = True, ignore_errors = None, file = None, omit = None, include = None):
     self._harvest_data()
     self.config.from_args(ignore_errors=ignore_errors, omit=omit, include=include, show_missing=show_missing)
     reporter = SummaryReporter(self, self.config)
     return reporter.report(morfs, outfile=file)