diff options
author | Danny Allen <danny.allen@pennantplc.co.uk> | 2014-09-22 12:10:53 +0100 |
---|---|---|
committer | Danny Allen <danny.allen@pennantplc.co.uk> | 2014-09-22 12:10:53 +0100 |
commit | 945aba067acd336f87e7d94cd8a1ab602fdacb4a (patch) | |
tree | 09146e7eb8ae2f75148bf3a3982e73b1e5d5deae /coverage/files.py | |
parent | e7b771868e1348c6f2b775a347efdee5504930e0 (diff) | |
parent | db7911c6a6687e75eb8c4fdd61a019641b88862b (diff) | |
download | python-coveragepy-945aba067acd336f87e7d94cd8a1ab602fdacb4a.tar.gz |
* Merge changes from head.
Diffstat (limited to 'coverage/files.py')
-rw-r--r-- | coverage/files.py | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/coverage/files.py b/coverage/files.py index 08ce1e8..1ed7276 100644 --- a/coverage/files.py +++ b/coverage/files.py @@ -147,7 +147,7 @@ def prep_patterns(patterns): class TreeMatcher(object): """A matcher for files in a tree.""" def __init__(self, directories): - self.dirs = directories[:] + self.dirs = list(directories) def __repr__(self): return "<TreeMatcher %r>" % self.dirs @@ -177,7 +177,17 @@ 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) + if sys.platform == 'win32': + # Windows is also case-insensitive. BTW: the regex docs say that + # flags like (?i) have to be at the beginning, but fnmatch puts + # them at the end, and have two there seems to work fine. + fnpats = (p + "(?i)" for p in fnpats) + self.re = re.compile(join_regex(fnpats)) def __repr__(self): return "<FnmatchMatcher %r>" % self.pats |