diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2009-04-29 21:50:23 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2009-04-29 21:50:23 -0400 |
commit | 62ab88a1a06e712427c1f57c561e2afb7aa7b21d (patch) | |
tree | 8c076d984bbca191d14b2d780caaab85a1e1a78d /coverage/control.py | |
parent | 89d2c9dc416949ca9e3181f8367de1e5dd8e3fde (diff) | |
download | python-coveragepy-62ab88a1a06e712427c1f57c561e2afb7aa7b21d.tar.gz |
Python stdlib is now not measured by default. If needed, turn it on with the -L switch.coverage-3.0b2
Diffstat (limited to 'coverage/control.py')
-rw-r--r-- | coverage/control.py | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/coverage/control.py b/coverage/control.py index d03c69b..6d3187d 100644 --- a/coverage/control.py +++ b/coverage/control.py @@ -1,6 +1,6 @@ """Core control stuff for coverage.py""" -import os, socket +import os, socket, sys from coverage.annotate import AnnotateReporter from coverage.codeunit import code_unit_factory @@ -17,11 +17,13 @@ class coverage: self.parallel_mode = False self.exclude_re = '' + self.cover_stdlib = False self.nesting = 0 + self.file_locator = FileLocator() + self.sysprefix = self.file_locator.abs_file(sys.prefix) self.collector = Collector(self.should_trace) - self.data = CoverageData(collector="coverage.py v%s" % __version__) # The default exclude pattern. @@ -36,14 +38,20 @@ class coverage: Returns a canonicalized filename if it should be traced, False if it should not. + """ if filename == '<string>': # There's no point in ever tracing string executions, we can't do # anything with the data later anyway. return False - # TODO: flag: ignore std lib? + + canonical = self.file_locator.canonical_filename(filename) + if not self.cover_stdlib: + if canonical.startswith(self.sysprefix): + return False + # TODO: ignore by module as well as file? - return self.file_locator.canonical_filename(filename) + return canonical def use_cache(self, usecache): """Control the use of a data file (incorrectly called a cache). |