From 134b27ee390d5bb5c524e2fd6a1902eb2002ae2a Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sun, 21 Sep 2014 11:32:43 -0400 Subject: Make the Fnmatcher work right on Windows. --- coverage/files.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'coverage/files.py') diff --git a/coverage/files.py b/coverage/files.py index 72c0bf92..40c126e9 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 "" % self.pats -- cgit v1.2.1