From a39aaf08066e6970f4d0e049b6b6658a114e9b57 Mon Sep 17 00:00:00 2001 From: Vladimir Chebotarev Date: Sun, 4 Sep 2022 16:12:39 +0300 Subject: [PATCH] Better. --- tests/test_match.py | 63 ++++++++++++--------------------------------- 1 file changed, 17 insertions(+), 46 deletions(-) diff --git a/tests/test_match.py b/tests/test_match.py index afcc43e..eb06b6d 100644 --- a/tests/test_match.py +++ b/tests/test_match.py @@ -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)) @@ -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")