diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2014-09-21 21:45:53 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2014-09-21 21:45:53 -0400 |
commit | d68b95f7a0a201b2e8e830b6d4769005ef0223fa (patch) | |
tree | 25eee2671f68dcc391ebcf2127578f4443475bf2 | |
parent | eff5f72064a0577fd0b61a634c4196271dc19308 (diff) | |
download | python-coveragepy-git-d68b95f7a0a201b2e8e830b6d4769005ef0223fa.tar.gz |
On Windows, we need file matching to be case-insensitive.
-rw-r--r-- | coverage/files.py | 9 | ||||
-rw-r--r-- | coverage/misc.py | 7 |
2 files changed, 8 insertions, 8 deletions
diff --git a/coverage/files.py b/coverage/files.py index 40c126e9..1ed7276e 100644 --- a/coverage/files.py +++ b/coverage/files.py @@ -180,8 +180,13 @@ class FnmatchMatcher(object): # 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] + 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): diff --git a/coverage/misc.py b/coverage/misc.py index 48727478..6962ae32 100644 --- a/coverage/misc.py +++ b/coverage/misc.py @@ -86,12 +86,7 @@ def bool_or_none(b): def join_regex(regexes): """Combine a list of regexes into one that matches any of them.""" - if len(regexes) > 1: - return "|".join("(?:%s)" % r for r in regexes) - elif regexes: - return regexes[0] - else: - return "" + return "|".join("(?:%s)" % r for r in regexes) def file_be_gone(path): |