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)
| 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 |