Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion coverage/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ class ModuleMatcher(object):
"""A matcher for modules in a tree."""
def __init__(self, module_names):
self.modules = list(module_names)
self.pattern = fnmatches_to_regex(module_names)

def __repr__(self):
return "<ModuleMatcher %r>" % (self.modules)
Expand All @@ -263,7 +264,7 @@ def match(self, module_name):
# This is a module in the package
return True

return False
return bool(self.pattern.match(module_name))


class FnmatchMatcher(object):
Expand Down
6 changes: 5 additions & 1 deletion tests/test_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,12 @@ def test_module_matcher(self):
('__main__', False),
('mymain', True),
('yourmain', False),
('pkg', True),
('pkg.main', True),
('pkg2', True),
('apkg', False),
]
modules = ['test', 'py.test', 'mymain']
modules = ['test', 'py.test', 'mymain', 'pkg*']
mm = ModuleMatcher(modules)
self.assertEqual(
mm.info(),
Expand Down