summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--coverage/files.py8
-rw-r--r--tests/test_files.py9
2 files changed, 15 insertions, 2 deletions
diff --git a/coverage/files.py b/coverage/files.py
index 4c55151..8d154c6 100644
--- a/coverage/files.py
+++ b/coverage/files.py
@@ -144,6 +144,10 @@ class TreeMatcher(object):
def __repr__(self):
return "<TreeMatcher %r>" % self.dirs
+ def info(self):
+ """A list of strings for displaying when dumping state."""
+ return self.dirs
+
def add(self, directory):
"""Add another directory to the list we match for."""
self.dirs.append(directory)
@@ -169,6 +173,10 @@ class FnmatchMatcher(object):
def __repr__(self):
return "<FnmatchMatcher %r>" % self.pats
+ def info(self):
+ """A list of strings for displaying when dumping state."""
+ return self.pats
+
def match(self, fpath):
"""Does `fpath` match one of our filename patterns?"""
for pat in self.pats:
diff --git a/tests/test_files.py b/tests/test_files.py
index 509c23b..eeb2264 100644
--- a/tests/test_files.py
+++ b/tests/test_files.py
@@ -58,16 +58,19 @@ class MatcherTest(CoverageTest):
file4 = self.make_file("sub3/file4.py")
file5 = self.make_file("sub3/file5.c")
fl = FileLocator()
- tm = TreeMatcher([
+ trees = [
fl.canonical_filename("sub"),
fl.canonical_filename(file4),
- ])
+ ]
+ tm = TreeMatcher(trees)
self.assertTrue(tm.match(fl.canonical_filename(file1)))
self.assertTrue(tm.match(fl.canonical_filename(file2)))
self.assertFalse(tm.match(fl.canonical_filename(file3)))
self.assertTrue(tm.match(fl.canonical_filename(file4)))
self.assertFalse(tm.match(fl.canonical_filename(file5)))
+ self.assertEqual(tm.info(), trees)
+
def test_fnmatch_matcher(self):
file1 = self.make_file("sub/file1.py")
file2 = self.make_file("sub/file2.c")
@@ -82,6 +85,8 @@ class MatcherTest(CoverageTest):
self.assertTrue(fnm.match(fl.canonical_filename(file4)))
self.assertFalse(fnm.match(fl.canonical_filename(file5)))
+ self.assertEqual(fnm.info(), ["*.py", "*/sub2/*"])
+
class PathAliasesTest(CoverageTest):
"""Tests for coverage/files.py:PathAliases"""