Skip to content

Commit

Permalink
Better.
Browse files Browse the repository at this point in the history
  • Loading branch information
excitoon committed Sep 4, 2022
1 parent 223cf6b commit a39aaf0
Showing 1 changed file with 17 additions and 46 deletions.
63 changes: 17 additions & 46 deletions tests/test_match.py
Original file line number Diff line number Diff line change
Expand Up @@ -491,9 +491,8 @@ def test_robert_parse_rule_files(self):
self.assertFalse(matches("/home/robert/.test_venv", is_dir=False))
self.assertTrue(matches("/home/robert/.test_venv", is_dir=True))

def test_caleb_test_1_match_file(self):
def test_caleb_1_match_file(self):
matches = self.__parse_gitignore_string(["*.txt", "!b.txt"], mock_base_path="/home/caleb")

for is_dir in (False, True):
with self.subTest(i=is_dir):
self.assertTrue(matches("/home/caleb/X/a.txt", is_dir=is_dir))
Expand All @@ -505,53 +504,25 @@ def test_caleb_test_1_match_file(self):

def test_caleb_01_absolute_dir_paths_1(self):
matches = self.__parse_gitignore_string(["foo"], mock_base_path="/home/caleb")
results = set(
spec.match_files(
[
"/a.py",
"/foo/a.py",
"/x/a.py",
"/x/foo/a.py",
"a.py",
"foo/a.py",
"x/a.py",
"x/foo/a.py",
]
)
)
self.assertEqual(
results,
{
"/foo/a.py",
"/x/foo/a.py",
"foo/a.py",
"x/foo/a.py",
},
)
for is_dir in (False, True):
with self.subTest(i=is_dir):
self.assertFalse(matches("/home/caleb/a.py", is_dir=is_dir))
self.assertTrue(matches("/home/caleb/foo/a.py", is_dir=is_dir))
self.assertFalse(matches("/home/caleb/x/a.py", is_dir=is_dir))
self.assertTrue(matches("/home/caleb/x/foo/a.py", is_dir=is_dir))
self.assertTrue(matches("/home/caleb/foo", is_dir=is_dir))
self.assertTrue(matches("/home/caleb/x/foo", is_dir=is_dir))

def test_caleb_01_absolute_dir_paths_2(self):
matches = self.__parse_gitignore_string(["/foo"], mock_base_path="/home/caleb")
results = set(
spec.match_files(
[
"/a.py",
"/foo/a.py",
"/x/a.py",
"/x/foo/a.py",
"a.py",
"foo/a.py",
"x/a.py",
"x/foo/a.py",
]
)
)
self.assertEqual(
results,
{
"/foo/a.py",
"foo/a.py",
},
)
for is_dir in (False, True):
with self.subTest(i=is_dir):
self.assertFalse(matches("/home/caleb/a.py", is_dir=is_dir))
self.assertTrue(matches("/home/caleb/foo/a.py", is_dir=is_dir))
self.assertFalse(matches("/home/caleb/x/a.py", is_dir=is_dir))
self.assertFalse(matches("/home/caleb/x/foo/a.py", is_dir=is_dir))
self.assertTrue(matches("/home/caleb/foo", is_dir=is_dir))
self.assertFalse(matches("/home/caleb/x/foo", is_dir=is_dir))

def test_caleb_01_current_dir_paths(self):
matches = self.__parse_gitignore_string(["*.txt", "!test1/"], mock_base_path="/home/caleb")
Expand Down

0 comments on commit a39aaf0

Please sign in to comment.