From 33c2881b63b15d332fb5ca5a8711ab3c1d6a12e0 Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Wed, 1 Apr 2009 23:07:29 +0000 Subject: #5656: detect correct encoding of files when reporting coverage in trace.py, and ignore files in the temporary directory when reporting. --- Lib/test/regrtest.py | 5 +++-- Lib/trace.py | 26 +++++++++++++++++--------- Misc/NEWS | 3 +++ 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/Lib/test/regrtest.py b/Lib/test/regrtest.py index f970404..0408a02 100755 --- a/Lib/test/regrtest.py +++ b/Lib/test/regrtest.py @@ -404,8 +404,9 @@ def main(tests=None, testdir=None, verbose=0, quiet=False, generate=False, print("Using random seed", random_seed) random.shuffle(tests) if trace: - import trace - tracer = trace.Trace(ignoredirs=[sys.prefix, sys.exec_prefix], + import trace, tempfile + tracer = trace.Trace(ignoredirs=[sys.prefix, sys.exec_prefix, + tempfile.gettempdir()], trace=False, count=True) test_times = [] support.verbose = verbose # Tell tests to be moderately quiet diff --git a/Lib/trace.py b/Lib/trace.py index a272683..9ce240f 100644 --- a/Lib/trace.py +++ b/Lib/trace.py @@ -48,6 +48,7 @@ Sample use, programmatically r.write_results(show_missing=True, coverdir="/tmp") """ +import io import linecache import os import re @@ -224,6 +225,13 @@ class CoverageResults: print(("Skipping counts file %r: %s" % (self.infile, err)), file=sys.stderr) + def is_ignored_filename(self, filename): + """Return True if the filename does not refer to a file + we want to have reported. + """ + return (filename == "" or + filename.startswith("": - continue - if filename.startswith("