From aac8f658b4ae955b241e4cb54ca61690a19df418 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Tue, 16 Jun 2015 16:17:24 -0400 Subject: Be more specific with PathAliases tests. --- coverage/files.py | 4 +++- 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() -- cgit v1.2.1