diff options
-rw-r--r-- | coverage/files.py | 4 | ||||
-rw-r--r-- | tests/test_files.py | 10 |
2 files changed, 10 insertions, 4 deletions
diff --git a/coverage/files.py b/coverage/files.py index c9afefd8..154954d6 100644 --- a/coverage/files.py +++ b/coverage/files.py @@ -293,7 +293,9 @@ class PathAliases(object): in the alias. Returns: - The mapped path. This is always a canonical filename. + The mapped path. If a mapping has happened, this is a + canonical path. If no mapping has happened, it is the + original value of `path` unchanged. """ for regex, result, pattern_sep, result_sep in self.aliases: diff --git a/tests/test_files.py b/tests/test_files.py index 6549c0ad..e5dafdf6 100644 --- a/tests/test_files.py +++ b/tests/test_files.py @@ -156,14 +156,18 @@ class PathAliasesTest(CoverageTest): """ self.assertEqual(aliases.map(inp), files.canonical_filename(out)) + def assert_not_mapped(self, aliases, inp): + """Assert that `inp` mapped through `aliases` is unchanged.""" + self.assertEqual(aliases.map(inp), inp) + def test_noop(self): aliases = PathAliases() - self.assert_mapped(aliases, '/ned/home/a.py', '/ned/home/a.py') + self.assert_not_mapped(aliases, '/ned/home/a.py') def test_nomatch(self): aliases = PathAliases() aliases.add('/home/*/src', './mysrc') - self.assert_mapped(aliases, '/home/foo/a.py', '/home/foo/a.py') + self.assert_not_mapped(aliases, '/home/foo/a.py') def test_wildcard(self): aliases = PathAliases() @@ -177,7 +181,7 @@ class PathAliasesTest(CoverageTest): def test_no_accidental_match(self): aliases = PathAliases() aliases.add('/home/*/src', './mysrc') - self.assert_mapped(aliases, '/home/foo/srcetc', '/home/foo/srcetc') + self.assert_not_mapped(aliases, '/home/foo/srcetc') def test_multiple_patterns(self): aliases = PathAliases() |