diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2010-03-13 19:59:48 -0500 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2010-03-13 19:59:48 -0500 |
commit | f3ed4653b327d5dbd71d7e9f646b0a3ab067cb13 (patch) | |
tree | 99f2ca08f258eca288c599c246d40d52f77b536b /coverage/files.py | |
parent | 0182926a873072d7062b8db17c15d345e8054193 (diff) | |
parent | 24bdb1797bc8a29f28d5f7796fc0ffed1cf5c668 (diff) | |
download | python-coveragepy-git-f3ed4653b327d5dbd71d7e9f646b0a3ab067cb13.tar.gz |
Merge Ben Finney's use-os-path-module fixes.
Diffstat (limited to 'coverage/files.py')
-rw-r--r-- | coverage/files.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/coverage/files.py b/coverage/files.py index ba228c23..fb597329 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`. |