25 def report(self, morfs, outfile=None): |
26 def report(self, morfs, outfile=None): |
26 """Generate a json report for `morfs`. |
27 """Generate a json report for `morfs`. |
27 |
28 |
28 `morfs` is a list of modules or file names. |
29 `morfs` is a list of modules or file names. |
29 |
30 |
30 `outfile` is a file object to write the json to |
31 `outfile` is a file object to write the json to. |
31 |
32 |
32 """ |
33 """ |
33 outfile = outfile or sys.stdout |
34 outfile = outfile or sys.stdout |
34 coverage_data = self.coverage.get_data() |
35 coverage_data = self.coverage.get_data() |
35 coverage_data.set_query_contexts(self.config.report_contexts) |
36 coverage_data.set_query_contexts(self.config.report_contexts) |
73 ) |
74 ) |
74 |
75 |
75 return self.total.n_statements and self.total.pc_covered |
76 return self.total.n_statements and self.total.pc_covered |
76 |
77 |
77 def report_one_file(self, coverage_data, analysis): |
78 def report_one_file(self, coverage_data, analysis): |
78 """Extract the relevant report data for a single file""" |
79 """Extract the relevant report data for a single file.""" |
79 nums = analysis.numbers |
80 nums = analysis.numbers |
80 self.total += nums |
81 self.total += nums |
81 summary = { |
82 summary = { |
82 'covered_lines': nums.n_executed, |
83 'covered_lines': nums.n_executed, |
83 'num_statements': nums.n_statements, |
84 'num_statements': nums.n_statements, |