diff options
Diffstat (limited to 'coverage/files.py')
-rw-r--r-- | coverage/files.py | 12 |
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. |