diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2014-11-24 21:30:04 -0500 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2014-11-24 21:30:04 -0500 |
commit | 2b369aa719d2a4b4e755c9030f1d0cc1dfeeeacb (patch) | |
tree | 361d0a995b5360a0170aff07cc87aa5afbc7562a /tests/test_files.py | |
parent | 8fa9db9f86de0b7cbce45e0a5fe87e38e47212b7 (diff) | |
parent | b3ccb75241566c1e1a814ae99a84637fd0ac2b44 (diff) | |
download | python-coveragepy-git-2b369aa719d2a4b4e755c9030f1d0cc1dfeeeacb.tar.gz |
Merged pull request 42, fixing issue #328.
Diffstat (limited to 'tests/test_files.py')
-rw-r--r-- | tests/test_files.py | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/tests/test_files.py b/tests/test_files.py index 648c76a9..f6976a81 100644 --- a/tests/test_files.py +++ b/tests/test_files.py @@ -2,7 +2,9 @@ import os, os.path -from coverage.files import FileLocator, TreeMatcher, FnmatchMatcher +from coverage.files import ( + FileLocator, TreeMatcher, FnmatchMatcher, ModuleMatcher +) from coverage.files import PathAliases, find_python_files, abs_file from coverage.misc import CoverageException @@ -80,6 +82,37 @@ class MatcherTest(CoverageTest): for filepath, matches in matches_to_try: self.assertMatches(tm, filepath, matches) + def test_module_matcher(self): + matches_to_try = [ + ('test', True), + ('test', True), + ('trash', False), + ('testing', False), + ('test.x', True), + ('test.x.y.z', True), + ('py', False), + ('py.t', False), + ('py.test', True), + ('py.testing', False), + ('py.test.buz', True), + ('py.test.buz.baz', True), + ('__main__', False), + ('mymain', True), + ('yourmain', False), + ] + modules = ['test', 'py.test', 'mymain'] + mm = ModuleMatcher(modules) + self.assertEqual( + mm.info(), + modules + ) + for modulename, matches in matches_to_try: + self.assertEqual( + mm.match(modulename), + matches, + modulename, + ) + def test_fnmatch_matcher(self): matches_to_try = [ (self.make_file("sub/file1.py"), True), |