Skip to content

Commit

Permalink
Added test for excluding from subdirectories. cpburnz/python-pathspec#39
Browse files Browse the repository at this point in the history
  • Loading branch information
excitoon committed Aug 28, 2022
1 parent 6f760f8 commit e42f590
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tests/test_match.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit e42f590

Please sign in to comment.