diff --git a/tests/test_match.py b/tests/test_match.py index d8555e1..78e8769 100644 --- a/tests/test_match.py +++ b/tests/test_match.py @@ -215,6 +215,17 @@ def test_exclude_directories(self): self.assertFalse(matches("/home/michael/file.yaml", is_dir=True)) self.assertFalse(matches("/home/michael/dir.yaml/file.sql", is_dir=False)) + def test_exclude_from_subdirectory(self): + matches = self.__parse_gitignore_string(["*.log", "!important/*.log", "trace.*"], fake_base_dir="/home/michael") + for is_dir in (False, True): + with self.subTest(i=is_dir): + self.assertTrue(matches("/home/michael/a.log", is_dir=is_dir)) + self.assertFalse(matches("/home/michael/b.txt", is_dir=is_dir)) + self.assertFalse(matches("/home/michael/important", is_dir=is_dir)) + self.assertFalse(matches("/home/michael/important/d.log", is_dir=is_dir)) + self.assertFalse(matches("/home/michael/important/e.txt", is_dir=is_dir)) + self.assertTrue(matches("/home/michael/trace.c", is_dir=is_dir)) + def test_ignore_all_subdirectories(self): matches = self.__parse_gitignore_string(["**/"], fake_base_dir="/home/michael") for is_dir in (False, True):