diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2009-06-02 22:23:34 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2009-06-02 22:23:34 -0400 |
commit | 9440a64774ce4b374890dce8ae6f69d81069c43c (patch) | |
tree | 637c5c1c9bc3f4f8db43e8a05721501a4e5c4beb /coverage/control.py | |
parent | 245dda4e8f9afce61505e311d6577ce33ca49fbd (diff) | |
download | python-coveragepy-9440a64774ce4b374890dce8ae6f69d81069c43c.tar.gz |
Better way to figure out if a file is installed with Python.
Diffstat (limited to 'coverage/control.py')
-rw-r--r-- | coverage/control.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/coverage/control.py b/coverage/control.py index f9d2306..b564819 100644 --- a/coverage/control.py +++ b/coverage/control.py @@ -61,6 +61,11 @@ class coverage: # The default exclude pattern. self.exclude('# *pragma[: ]*[nN][oO] *[cC][oO][vV][eE][rR]') + # The prefix for files considered "installed with the interpreter". + if not self.cover_pylib: + os_file = self.file_locator.canonical_filename(os.__file__) + self.pylib_prefix = os.path.split(os_file)[0] + def _should_trace(self, filename, frame): """Decide whether to trace execution in `filename` @@ -89,9 +94,9 @@ class coverage: canonical = self.file_locator.canonical_filename(filename) # If we aren't supposed to trace installed code, then check if this is - # near the Python interpreter and skip it if so. + # near the Python standard library and skip it if so. if not self.cover_pylib: - if canonical.startswith(self.sysprefix): + if canonical.startswith(self.pylib_prefix): return False return canonical |