diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2014-09-21 11:32:43 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2014-09-21 11:32:43 -0400 |
commit | a4c441bd2a112d9f5832e212040d7ed533837f9c (patch) | |
tree | e647031aa788ad750e9557a84e49efe53e278280 /coverage/files.py | |
parent | dd83d87cecb28ef014be663829f9d5849086ab85 (diff) | |
download | python-coveragepy-a4c441bd2a112d9f5832e212040d7ed533837f9c.tar.gz |
Make the Fnmatcher work right on Windows.
Diffstat (limited to 'coverage/files.py')
-rw-r--r-- | coverage/files.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/coverage/files.py b/coverage/files.py index 72c0bf9..40c126e 100644 --- a/coverage/files.py +++ b/coverage/files.py @@ -177,7 +177,12 @@ class FnmatchMatcher(object): """A matcher for files by filename pattern.""" def __init__(self, pats): self.pats = pats[:] - self.re = re.compile(join_regex([fnmatch.translate(p) for p in pats])) + # fnmatch is platform-specific. On Windows, it does the Windows thing + # of treating / and \ as equivalent. But on other platforms, we need to + # take care of that ourselves. + fnpats = [fnmatch.translate(p) for p in pats] + fnpats = [p.replace(r"\/", r"[\\/]") for p in fnpats] + self.re = re.compile(join_regex(fnpats)) def __repr__(self): return "<FnmatchMatcher %r>" % self.pats |