From ccdc804b232ac9b17df569e5f02d1b7ea0ae69c1 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Tue, 19 Aug 2014 08:41:54 -0400 Subject: Use a set where a set is appropriate --- coverage/files.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'coverage/files.py') diff --git a/coverage/files.py b/coverage/files.py index 08ce1e8..72c0bf9 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 "" % self.dirs -- cgit v1.2.1 From a4c441bd2a112d9f5832e212040d7ed533837f9c 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 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 "" % self.pats -- cgit v1.2.1 From 093b886e2ed7a424aca018b3261a4e38ea4f4216 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sun, 21 Sep 2014 21:45:53 -0400 Subject: On Windows, we need file matching to be case-insensitive. --- coverage/files.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'coverage/files.py') diff --git a/coverage/files.py b/coverage/files.py index 40c126e..1ed7276 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): -- cgit v1.2.1