summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--coverage/files.py1
-rw-r--r--coverage/misc.py2
-rw-r--r--tests/test_api.py6
-rw-r--r--tests/test_files.py6
4 files changed, 12 insertions, 3 deletions
diff --git a/coverage/files.py b/coverage/files.py
index 08ce1e84..80b69572 100644
--- a/coverage/files.py
+++ b/coverage/files.py
@@ -188,6 +188,7 @@ class FnmatchMatcher(object):
def match(self, fpath):
"""Does `fpath` match one of our filename patterns?"""
+ #print("Matching %r against %r" % (self.re.pattern, fpath))
return self.re.match(fpath) is not None
diff --git a/coverage/misc.py b/coverage/misc.py
index c88d4ecd..4b1dccb2 100644
--- a/coverage/misc.py
+++ b/coverage/misc.py
@@ -87,7 +87,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)
+ return "|".join("(?:%s)" % r for r in regexes)
elif regexes:
return regexes[0]
else:
diff --git a/tests/test_api.py b/tests/test_api.py
index c1e9294f..31bfc57f 100644
--- a/tests/test_api.py
+++ b/tests/test_api.py
@@ -221,7 +221,7 @@ class ApiTest(CoverageTest):
self.assertEqual(cov.get_exclude_list(), ["foo"])
cov.exclude("bar")
self.assertEqual(cov.get_exclude_list(), ["foo", "bar"])
- self.assertEqual(cov._exclude_regex('exclude'), "(foo)|(bar)")
+ self.assertEqual(cov._exclude_regex('exclude'), "(?:foo)|(?:bar)")
cov.clear_exclude()
self.assertEqual(cov.get_exclude_list(), [])
@@ -233,7 +233,9 @@ class ApiTest(CoverageTest):
self.assertEqual(cov.get_exclude_list(which='partial'), ["foo"])
cov.exclude("bar", which='partial')
self.assertEqual(cov.get_exclude_list(which='partial'), ["foo", "bar"])
- self.assertEqual(cov._exclude_regex(which='partial'), "(foo)|(bar)")
+ self.assertEqual(
+ cov._exclude_regex(which='partial'), "(?:foo)|(?:bar)"
+ )
cov.clear_exclude(which='partial')
self.assertEqual(cov.get_exclude_list(which='partial'), [])
diff --git a/tests/test_files.py b/tests/test_files.py
index 991c2b15..ea1c494c 100644
--- a/tests/test_files.py
+++ b/tests/test_files.py
@@ -93,6 +93,12 @@ class MatcherTest(CoverageTest):
for filepath, matches in matches_to_try:
self.assertMatches(fnm, filepath, matches)
+ def test_fnmatch_matcher_overload(self):
+ fnm = FnmatchMatcher(["*x%03d*.txt" % i for i in range(500)])
+ self.assertMatches(fnm, "x007foo.txt", True)
+ self.assertMatches(fnm, "x123foo.txt", True)
+ self.assertMatches(fnm, "x798bar.txt", False)
+
class PathAliasesTest(CoverageTest):
"""Tests for coverage/files.py:PathAliases"""