Example #1
0
 def dump_cov_info(self, cov, first_trial=False):
     json_rep = JsonReporter(cov)
     with open(self.cov_json_file, "w") as f:
         json_rep.report(morfs=[self.config.get_file_path()], outfile=f)
     cov_rate_before = self.coverage_val
     self.coverage_val = json_rep.report_data["totals"]["percent_covered"]
     if first_trial:
         self.coverage_init = self.coverage_val
     return self.coverage_val > cov_rate_before
    def json_report(self,
                    morfs=None,
                    outfile=None,
                    ignore_errors=None,
                    omit=None,
                    include=None,
                    contexts=None,
                    pretty_print=None,
                    show_contexts=None):
        """Generate a JSON report of coverage results.

        Each module in `morfs` is included in the report.  `outfile` is the
        path to write the file to, "-" will write to stdout.

        See :meth:`report` for other arguments.

        Returns a float, the total percentage covered.

        .. versionadded:: 5.0

        """
        with override_config(self,
                             ignore_errors=ignore_errors,
                             report_omit=omit,
                             report_include=include,
                             json_output=outfile,
                             report_contexts=contexts,
                             json_pretty_print=pretty_print,
                             json_show_contexts=show_contexts):
            return render_report(self.config.json_output, JsonReporter(self),
                                 morfs)