@@ -19,6 +19,7 @@ def __init__(self, coverage):
19
19
self .config = self .coverage .config
20
20
self .branches = coverage .get_data ().has_arcs ()
21
21
self .outfile = None
22
+ self .output_format = self .config .format or "text"
22
23
self .fr_analysis = []
23
24
self .skipped_count = 0
24
25
self .empty_count = 0
@@ -159,6 +160,15 @@ def report(self, morfs, outfile=None):
159
160
if not self .total .n_files and not self .skipped_count :
160
161
raise NoDataError ("No data to report." )
161
162
163
+ if self .output_format == "total" :
164
+ self .write (self .total .pc_covered_str )
165
+ else :
166
+ self .tabular_report ()
167
+
168
+ return self .total .n_statements and self .total .pc_covered
169
+
170
+ def tabular_report (self ):
171
+ """Writes tabular report formats."""
162
172
# Prepare the header line and column sorting.
163
173
header = ["Name" , "Stmts" , "Miss" ]
164
174
if self .branches :
@@ -221,15 +231,12 @@ def report(self, morfs, outfile=None):
221
231
file_suffix = 's' if self .empty_count > 1 else ''
222
232
end_lines .append (f"\n { self .empty_count } empty file{ file_suffix } skipped." )
223
233
224
- text_format = self .config .format or "text"
225
- if text_format == "markdown" :
234
+ if self .output_format == "markdown" :
226
235
formatter = self ._report_markdown
227
236
else :
228
237
formatter = self ._report_text
229
238
formatter (header , lines_values , total_line , end_lines )
230
239
231
- return self .total .n_statements and self .total .pc_covered
232
-
233
240
def report_one_file (self , fr , analysis ):
234
241
"""Report on just one file, the callback from report()."""
235
242
nums = analysis .numbers
0 commit comments