summaryrefslogtreecommitdiff
path: root/coverage/files.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2010-03-13 20:12:05 -0500
committerNed Batchelder <ned@nedbatchelder.com>2010-03-13 20:12:05 -0500
commita2a9f18bce8c7999c4f048bc7c44ab2d89b9268c (patch)
tree2cd81fbe59dc761366f7982cd20983aaeb74b916 /coverage/files.py
parentc3abd04da6c4ecc5d9464261c5c30d3eb527b04f (diff)
parentf3ed4653b327d5dbd71d7e9f646b0a3ab067cb13 (diff)
downloadpython-coveragepy-git-a2a9f18bce8c7999c4f048bc7c44ab2d89b9268c.tar.gz
Merged Ben Finney's use-os-path-module fixes (again?)
Diffstat (limited to 'coverage/files.py')
-rw-r--r--coverage/files.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/coverage/files.py b/coverage/files.py
index bf60f8b4..ace47c1f 100644
--- a/coverage/files.py
+++ b/coverage/files.py
@@ -6,7 +6,7 @@ class FileLocator(object):
"""Understand how filenames work."""
def __init__(self):
- self.relative_dir = self.abs_file(os.curdir) + os.sep
+ self.relative_dir = self.abs_file(os.curdir)
# Cache of results of calling the canonical_filename() method, to
# avoid duplicating work.
@@ -23,7 +23,9 @@ class FileLocator(object):
FileLocator was constructed.
"""
- return filename.replace(self.relative_dir, "")
+ common_prefix = os.path.commonprefix(
+ [filename, self.relative_dir + os.sep])
+ return filename[len(common_prefix):]
def canonical_filename(self, filename):
"""Return a canonical filename for `filename`.