@@ -101,67 +101,25 @@ def sep(stream, s, txt):
101
101
def summary (self , cov_fail_under , stream ):
102
102
"""Produce coverage reports."""
103
103
104
- def _get_total (cfu ):
105
- with _backup (self .cov , "config" ):
106
- return self .cov .report (show_missing = True , ignore_errors = True , include = cfu .include , omit = cfu .omit , file = _NullFile )
107
-
108
- totals = {cfu : _get_total (cfu ) for cfu in cov_fail_under }
109
-
110
- if not self .cov_report :
111
- return totals
112
-
113
- # Output coverage section header.
114
- if len (self .node_descs ) == 1 :
115
- self .sep (stream , '-' , 'coverage: %s' % '' .join (self .node_descs ))
116
- else :
117
- self .sep (stream , '-' , 'coverage' )
118
- for node_desc in sorted (self .node_descs ):
119
- self .sep (stream , ' ' , '%s' % node_desc )
120
-
121
- # Produce terminal report if wanted.
122
- if any (x in self .cov_report for x in ['term' , 'term-missing' ]):
123
- options = {
124
- 'show_missing' : ('term-missing' in self .cov_report ) or None ,
125
- 'ignore_errors' : True ,
126
- 'file' : stream ,
127
- }
128
- skip_covered = isinstance (self .cov_report , dict ) and 'skip-covered' in self .cov_report .values ()
129
- if hasattr (coverage , 'version_info' ) and coverage .version_info [0 ] >= 4 :
130
- options .update ({'skip_covered' : skip_covered or None })
131
- with _backup (self .cov , "config" ):
132
- self .cov .report (** options )
133
-
134
- # Produce annotated source code report if wanted.
135
- if 'annotate' in self .cov_report :
136
- annotate_dir = self .cov_report ['annotate' ]
137
- with _backup (self .cov , "config" ):
138
- self .cov .annotate (ignore_errors = True , directory = annotate_dir )
139
- if annotate_dir :
140
- stream .write ('Coverage annotated source written to dir %s\n ' % annotate_dir )
104
+ if self .cov_report :
105
+ # Output coverage section header.
106
+ if len (self .node_descs ) == 1 :
107
+ self .sep (stream , '-' , 'coverage: %s' % '' .join (self .node_descs ))
141
108
else :
142
- stream .write ('Coverage annotated source written next to source\n ' )
143
-
144
- # Produce html report if wanted.
145
- if 'html' in self .cov_report :
146
- output = self .cov_report ['html' ]
147
- with _backup (self .cov , "config" ):
148
- self .cov .html_report (ignore_errors = True , directory = output )
149
- stream .write ('Coverage HTML written to dir %s\n ' % (self .cov .config .html_dir if output is None else output ))
150
-
151
- # Produce xml report if wanted.
152
- if 'xml' in self .cov_report :
153
- output = self .cov_report ['xml' ]
154
- with _backup (self .cov , "config" ):
155
- self .cov .xml_report (ignore_errors = True , outfile = output )
156
- stream .write ('Coverage XML written to file %s\n ' % (self .cov .config .xml_output if output is None else output ))
157
-
158
- # Report on any failed workers.
159
- if self .failed_workers :
160
- self .sep (stream , '-' , 'coverage: failed workers' )
161
- stream .write ('The following workers failed to return coverage data, '
162
- 'ensure that pytest-cov is installed on these workers.\n ' )
163
- for node in self .failed_workers :
164
- stream .write ('%s\n ' % node .gateway .id )
109
+ self .sep (stream , '-' , 'coverage' )
110
+ for node_desc in sorted (self .node_descs ):
111
+ self .sep (stream , ' ' , '%s' % node_desc )
112
+
113
+ totals = self .cov .summary (self .cov_report , cov_fail_under , stream )
114
+
115
+ if self .cov_report :
116
+ # Report on any failed workers.
117
+ if self .failed_workers :
118
+ self .sep (stream , '-' , 'coverage: failed workers' )
119
+ stream .write ('The following workers failed to return coverage data, '
120
+ 'ensure that pytest-cov is installed on these workers.\n ' )
121
+ for node in self .failed_workers :
122
+ stream .write ('%s\n ' % node .gateway .id )
165
123
166
124
return totals
167
125
0 commit comments