예제 #1
0
 def test_is_ignored_dir(self):
     from kanayure.filelist import FileList
     testcases = ((set(), set(), r"a\b", False),
                  (set(), {'a'}, r"a\b", False),
                  (set(), {'b'}, r"a\b", True),
                  (set(), {'a', 'b'}, r"a\b", True),
                  (set(), {'*'}, r"a\b", True),
                  (set(), {'a', '*'}, r"a\b", True),
                  (set(), {'b', '*'}, r"a\b", True),
                  ({'a'}, set(), r"a\b", True),
                  ({'b'}, set(), r"a\b", False),
                  ({'a', 'b'}, set(), r"a\b", False),
                  ({'*'}, set(), r"a\b", False),
                  ({'a', '*'}, set(), r"a\b", False),
                  ({'b', '*'}, set(), r"a\b", False),
                  ({'*', 'a'}, set(), r"a\b", False),
                  ({'*', 'b'}, set(), r"a\b", False),
                  ({'a'}, {'b'}, r"a\b", True),
                  ({'b'}, {'a'}, r"a\b", False),
                  ({'a'}, {'a'}, r"a\b", True),
                  ({'b'}, {'b'}, r"a\b", True),
                  ({'*'}, {'*'}, r"a\b", True))
     message = ("\n" +
                "include_dirs = {}\n" +
                "exclude_dirs = {}\n" +
                "dirpath = {}\n" +
                "ignore = {}\n")
     for testcase in testcases:
         include_dirs, exclude_dirs, dirpath, ignore = testcase
         filelist = FileList(include_dirs=include_dirs,
                             exclude_dirs=exclude_dirs)
         if ignore:
             self.assertTrue(filelist.is_ignored_dir(dirpath),
                             message.format(*testcase) +
                             repr(testcase))
         else:
             self.assertFalse(filelist.is_ignored_dir(dirpath),
                              message.format(*testcase) +
                              repr(testcase))
예제 #2
0
 def test_is_ignored_file(self):
     from kanayure.filelist import FileList
     testcases = ((set(), set(), 'a', False),
                  (set(), {'a'}, 'a', True),
                  (set(), {'b'}, 'a', False),
                  (set(), {'a', 'b'}, 'a', True),
                  (set(), {'*'}, 'a', True),
                  (set(), {'a', '*'}, 'a', True),
                  (set(), {'b', '*'}, 'a', True),
                  ({'a'}, set(), 'a', False),
                  ({'b'}, set(), 'a', True),
                  ({'a', 'b'}, set(), 'a', False),
                  ({'*'}, set(), 'a', False),
                  ({'a', '*'}, set(), 'a', False),
                  ({'b', '*'}, set(), 'a', False),
                  ({'*', 'a'}, set(), 'a', False),
                  ({'*', 'b'}, set(), 'a', False),
                  ({'a'}, {'b'}, 'a', False),
                  ({'b'}, {'a'}, 'a', True),
                  ({'a'}, {'a'}, 'a', True),
                  ({'b'}, {'b'}, 'a', True),
                  ({'*'}, {'*'}, 'a', True))
     message = ("\n" +
                "include_files = {}\n" +
                "exclude_files = {}\n" +
                "filename = {}\n" +
                "ignore = {}\n")
     for testcase in testcases:
         include_files, exclude_files, filename, ignore = testcase
         filelist = FileList(include_files=include_files,
                             exclude_files=exclude_files,)
         if ignore:
             self.assertTrue(filelist.is_ignored_file(filename),
                             message.format(*testcase) +
                             repr(testcase))
         else:
             self.assertFalse(filelist.is_ignored_file(filename),
                              message.format(*testcase) +
                              repr(testcase))
예제 #3
0
 def test_compile_globs(self):
     from kanayure.filelist import FileList
     filelist = FileList()
     self.assertIsNone(filelist.compile_globs(set()))
     self.assertIsNotNone(filelist.compile_globs({'a'}))