summaryrefslogtreecommitdiff
path: root/coverage
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2017-10-26 07:09:11 -0400
committerNed Batchelder <ned@nedbatchelder.com>2017-10-26 07:09:11 -0400
commite1d414f035829bedd4d06a8dbc9bd638080332fb (patch)
tree51685d62516274a280b6dc2024fca2b824be94b3 /coverage
parent26821ed8e6ea20925ab859bf5e06607f0861bb4c (diff)
downloadpython-coveragepy-e1d414f035829bedd4d06a8dbc9bd638080332fb.tar.gz
Root is acceptable as a combining path (the manylinux tests end up with one of these)
Diffstat (limited to 'coverage')
-rw-r--r--coverage/files.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/coverage/files.py b/coverage/files.py
index 346043d..04ce9cb 100644
--- a/coverage/files.py
+++ b/coverage/files.py
@@ -302,6 +302,11 @@ class PathAliases(object):
def __init__(self):
self.aliases = []
+ def pprint(self): # pragma: debugging
+ """Dump the important parts of the PathAliases, for debugging."""
+ for regex, result, _, _ in self.aliases:
+ print("{0!r} --> {1!r}".format(regex.pattern, result))
+
def add(self, pattern, result):
"""Add the `pattern`/`result` pair to the list of aliases.
@@ -315,8 +320,10 @@ class PathAliases(object):
match an entire tree, and not just its root.
"""
+ if len(pattern) > 1:
+ pattern = pattern.rstrip(r"\/")
+
# The pattern can't end with a wildcard component.
- pattern = pattern.rstrip(r"\/")
if pattern.endswith("*"):
raise CoverageException("Pattern must not end with wildcards.")
pattern_sep = sep(pattern)
@@ -325,7 +332,8 @@ class PathAliases(object):
# unless it already is, or is meant to match any prefix.
if not pattern.startswith('*') and not isabs_anywhere(pattern):
pattern = abs_file(pattern)
- pattern += pattern_sep
+ if not pattern.endswith(pattern_sep):
+ pattern += pattern_sep
# Make a regex from the pattern. fnmatch always adds a \Z to
# match the whole string, which we don't want, so we remove the \Z.