diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2011-09-03 15:43:51 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2011-09-03 15:43:51 -0400 |
commit | d9b1cc04cde71e2f830dfa91f9a8fa3bcee09b34 (patch) | |
tree | c2f5a924abdb0605eb11c392f4428b42bcf528ed /coverage | |
parent | d27b5891587ca85a8fe878bb7c74f198e3ba9db7 (diff) | |
download | python-coveragepy-git-d9b1cc04cde71e2f830dfa91f9a8fa3bcee09b34.tar.gz |
Fix the [paths] feature to actually work for reporting.
Diffstat (limited to 'coverage')
-rw-r--r-- | coverage/control.py | 2 | ||||
-rw-r--r-- | coverage/files.py | 8 |
2 files changed, 8 insertions, 2 deletions
diff --git a/coverage/control.py b/coverage/control.py index a77d805d..d83e11b8 100644 --- a/coverage/control.py +++ b/coverage/control.py @@ -469,7 +469,7 @@ class coverage(object): """ aliases = None if self.config.paths: - aliases = PathAliases() + aliases = PathAliases(self.file_locator) for paths in self.config.paths.values(): result = paths[0] for pattern in paths[1:]: diff --git a/coverage/files.py b/coverage/files.py index 7258acca..53dc0999 100644 --- a/coverage/files.py +++ b/coverage/files.py @@ -139,9 +139,12 @@ class PathAliases(object): A `PathAliases` object tracks a list of pattern/result pairs, and can map a path through those aliases to produce a unified path. + `locator` is a FileLocator that is used to canonicalize the results. + """ - def __init__(self): + def __init__(self, locator=None): self.aliases = [] + self.locator = locator def add(self, pattern, result): """Add the `pattern`/`result` pair to the list of aliases. @@ -191,12 +194,15 @@ class PathAliases(object): in the alias. """ + opath = path for regex, result, pattern_sep, result_sep in self.aliases: m = regex.match(path) if m: new = path.replace(m.group(0), result) if pattern_sep != result_sep: new = new.replace(pattern_sep, result_sep) + if self.locator: + new = self.locator.canonical_filename(new) return new return path |