summaryrefslogtreecommitdiffstats
path: root/contrib/tools/python3/Lib/trace.py
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/tools/python3/Lib/trace.py')
-rwxr-xr-xcontrib/tools/python3/Lib/trace.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/contrib/tools/python3/Lib/trace.py b/contrib/tools/python3/Lib/trace.py
index a50a310e6a9..64fc8037e35 100755
--- a/contrib/tools/python3/Lib/trace.py
+++ b/contrib/tools/python3/Lib/trace.py
@@ -202,7 +202,8 @@ class CoverageResults:
for key in other_callers:
callers[key] = 1
- def write_results(self, show_missing=True, summary=False, coverdir=None):
+ def write_results(self, show_missing=True, summary=False, coverdir=None, *,
+ ignore_missing_files=False):
"""
Write the coverage results.
@@ -211,6 +212,9 @@ class CoverageResults:
:param coverdir: If None, the results of each module are placed in its
directory, otherwise it is included in the directory
specified.
+ :param ignore_missing_files: If True, counts for files that no longer
+ exist are silently ignored. Otherwise, a missing file
+ will raise a FileNotFoundError.
"""
if self.calledfuncs:
print()
@@ -253,6 +257,9 @@ class CoverageResults:
if filename.endswith(".pyc"):
filename = filename[:-1]
+ if ignore_missing_files and not os.path.isfile(filename):
+ continue
+
if coverdir is None:
dir = os.path.dirname(os.path.abspath(filename))
modulename = _modname(filename)
@@ -277,7 +284,6 @@ class CoverageResults:
percent = int(100 * n_hits / n_lines)
sums[modulename] = n_lines, percent, modulename, filename
-
if summary and sums:
print("lines cov% module (path)")
for m in sorted(sums):