diff options
-rw-r--r-- | CHANGES.txt | 4 | ||||
-rw-r--r-- | coverage/files.py | 2 | ||||
-rw-r--r-- | test/test_files.py | 7 |
3 files changed, 12 insertions, 1 deletions
diff --git a/CHANGES.txt b/CHANGES.txt index 4ec429ab..79f404ce 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -21,6 +21,9 @@ Version 3.5.3b1 - Optimized .pyo files may not have been handled correctly, `issue 195`_. Thanks, Marius Gedminas. +- Certain unusually named file paths could have been mangled during reporting, + `issue 194`_. Thanks, Marius Gedminas. + - Try to do a better job of the impossible task of detecting when we can't build the C extension, fixing `issue 183`_. @@ -29,6 +32,7 @@ Version 3.5.3b1 .. _issue 82: https://bitbucket.org/ned/coveragepy/issue/82/tokenerror-when-generating-html-report .. _issue 179: https://bitbucket.org/ned/coveragepy/issue/179/htmlreporter-fails-when-source-file-is .. _issue 183: https://bitbucket.org/ned/coveragepy/issue/183/install-fails-for-python-23 +.. _issue 194: https://bitbucket.org/ned/coveragepy/issue/194/filelocatorrelative_filename-could-mangle .. _issue 195: https://bitbucket.org/ned/coveragepy/issue/195/pyo-file-handling-in-codeunit .. _tox: http://tox.readthedocs.org/ diff --git a/coverage/files.py b/coverage/files.py index e07c5766..13f43930 100644 --- a/coverage/files.py +++ b/coverage/files.py @@ -27,7 +27,7 @@ class FileLocator(object): """ if filename.startswith(self.relative_dir): - filename = filename.replace(self.relative_dir, "") + filename = filename.replace(self.relative_dir, "", 1) return filename def canonical_filename(self, filename): diff --git a/test/test_files.py b/test/test_files.py index d45f5973..ba8a06ba 100644 --- a/test/test_files.py +++ b/test/test_files.py @@ -37,6 +37,13 @@ class FileLocatorTest(CoverageTest): self.assertEqual(fl.relative_filename(a1), "file1.py") self.assertEqual(fl.relative_filename(a2), a2) + def test_filepath_contains_absolute_prefix_twice(self): + # https://bitbucket.org/ned/coveragepy/issue/194/filelocatorrelative_filename-could-mangle + fl = FileLocator() + d = fl.abs_file(os.curdir) + rel = os.path.join('sub', d.lstrip(os.path.sep), 'file1.py') + self.assertEqual(fl.relative_filename(fl.abs_file(rel)), rel) + class MatcherTest(CoverageTest): """Tests of file matchers.""" |