예제 #1
0
 def test_whitelisted_lines(self, mock_open, _):
     configs = [
         ('foo.c', '*.c'),
         ('.c', '*.c'),
         ('foo/foo.c', '*.c'),
         ('foo/foo.c', 'foo.c'),
         ('foo.c', '/*.c'),
         ('foo.c', '/foo.c'),
         ('foo.c', 'foo.c'),
         ('foo.c', 'foo.[ch]'),
         ('foo/bar/bla.c', 'foo/**'),
         ('foo/bar/bla/blie.c', 'foo/**/blie.c'),
         ('foo/bar/bla.c', '**/bla.c'),
         ('bla.c', '**/bla.c'),
         ('foo/bar', 'foo/**/bar'),
         ('foo/bla/bar', 'foo/**/bar'),
         ('foo/bar/', 'bar/'),
         ('foo/bar/', 'bar'),
         ('foo/bar/something', 'foo/bar/*'),
     ]
     for (path, pattern) in configs:
         mock_open.return_value.__iter__.return_value = [pattern]
         patterns = IgnoreManager.get_config()
         self.assertEqual(
             (self.get_ignored(patterns), self.get_whitelisted(patterns)),
             ([pattern], []))
         assert len(list(IgnoreManager.find_matching(path, patterns))) == 1
예제 #2
0
 def test_ignored_lines(self, mock_open, _):
     configs = [('foo.c', 'foo.[dh]'), ('foo/foo.c', '/foo.c'),
                ('foo/foo.c', '/*.c'), ('foo/bar/', '/bar/'),
                ('foo/bar/', 'foo/bar/*'), ('foo/bar', 'foo?bar')]
     for (path, pattern) in configs:
         mock_open.return_value.__iter__.return_value = [pattern]
         patterns = IgnoreManager.get_config()
         self.assertEqual(
             (self.get_ignored(patterns), self.get_whitelisted(patterns)),
             ([pattern], []))
         assert list(IgnoreManager.find_matching(path, patterns)) == []