MCPcopy Index your code
hub / github.com/python/cpython / write_results

Method write_results

Lib/trace.py:203–297  ·  view source on GitHub ↗

Write the coverage results. :param show_missing: Show lines that had no hits. :param summary: Include coverage summary per module. :param coverdir: If None, the results of each module are placed in its directory, otherwise it is included in

(self, show_missing=True, summary=False, coverdir=None, *,
                      ignore_missing_files=False)

Source from the content-addressed store, hash-verified

201 callers[key] = 1
202
203 def write_results(self, show_missing=True, summary=False, coverdir=None, *,
204 ignore_missing_files=False):
205 """
206 Write the coverage results.
207
208 :param show_missing: Show lines that had no hits.
209 :param summary: Include coverage summary per module.
210 :param coverdir: If None, the results of each module are placed in its
211 directory, otherwise it is included in the directory
212 specified.
213 :param ignore_missing_files: If True, counts for files that no longer
214 exist are silently ignored. Otherwise, a missing file
215 will raise a FileNotFoundError.
216 """
217 if self.calledfuncs:
218 print()
219 print("functions called:")
220 calls = self.calledfuncs
221 for filename, modulename, funcname in sorted(calls):
222 print(("filename: %s, modulename: %s, funcname: %s"
223 % (filename, modulename, funcname)))
224
225 if self.callers:
226 print()
227 print("calling relationships:")
228 lastfile = lastcfile = ""
229 for ((pfile, pmod, pfunc), (cfile, cmod, cfunc)) \
230 in sorted(self.callers):
231 if pfile != lastfile:
232 print()
233 print("***", pfile, "***")
234 lastfile = pfile
235 lastcfile = ""
236 if cfile != pfile and lastcfile != cfile:
237 print(" -->", cfile)
238 lastcfile = cfile
239 print(" %s.%s -> %s.%s" % (pmod, pfunc, cmod, cfunc))
240
241 # turn the counts data ("(filename, lineno) = count") into something
242 # accessible on a per-file basis
243 per_file = {}
244 for filename, lineno in self.counts:
245 lines_hit = per_file[filename] = per_file.get(filename, {})
246 lines_hit[lineno] = self.counts[(filename, lineno)]
247
248 # accumulate summary info, if needed
249 sums = {}
250
251 for filename, count in per_file.items():
252 if self.is_ignored_filename(filename):
253 continue
254
255 if filename.endswith(".pyc"):
256 filename = filename[:-1]
257
258 if ignore_missing_files and not os.path.isfile(filename):
259 continue
260

Callers 3

mainFunction · 0.95
_coverageMethod · 0.80
finalize_testsMethod · 0.80

Calls 14

is_ignored_filenameMethod · 0.95
write_results_fileMethod · 0.95
_modnameFunction · 0.85
_fullmodnameFunction · 0.85
_find_executable_linenosFunction · 0.85
openFunction · 0.70
getMethod · 0.45
itemsMethod · 0.45
endswithMethod · 0.45
isfileMethod · 0.45
dirnameMethod · 0.45
abspathMethod · 0.45

Tested by 1

_coverageMethod · 0.64