From 789fa6ff8998abf5fae20f14793139b6fd94f303 Mon Sep 17 00:00:00 2001 From: cpburnz Date: Sat, 12 Jun 2021 11:50:52 -0400 Subject: [PATCH] Expand some tests --- pathspec/tests/test_gitwildmatch.py | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/pathspec/tests/test_gitwildmatch.py b/pathspec/tests/test_gitwildmatch.py index f410363..682ad02 100644 --- a/pathspec/tests/test_gitwildmatch.py +++ b/pathspec/tests/test_gitwildmatch.py @@ -184,6 +184,7 @@ def test_03_inner_double_asterisk(self): This should match: + left/right left/bar/right left/foo/bar/right left/bar/right/foo @@ -198,12 +199,14 @@ def test_03_inner_double_asterisk(self): pattern = GitWildMatchPattern(re.compile(regex), include) results = set(pattern.match([ + 'left/right', 'left/bar/right', 'left/foo/bar/right', 'left/bar/right/foo', 'foo/left/bar/right', ])) self.assertEqual(results, { + 'left/right', 'left/bar/right', 'left/foo/bar/right', 'left/bar/right/foo', @@ -223,6 +226,7 @@ def test_03_parent_double_asterisk(self): This should match: + spam foo/spam foo/spam/bar """ @@ -232,10 +236,12 @@ def test_03_parent_double_asterisk(self): pattern = GitWildMatchPattern(re.compile(regex), include) results = set(pattern.match([ + 'spam', 'foo/spam', 'foo/spam/bar', ])) self.assertEqual(results, { + 'spam', 'foo/spam', 'foo/spam/bar', }) @@ -264,6 +270,17 @@ def test_03_duplicate_leading_double_asterisk_edge_case(self): self.assertTrue(include) self.assertEqual(equivalent_regex, regex) + regex, include = GitWildMatchPattern.pattern_to_regex('**/api/') + self.assertTrue(include) + self.assertEqual(regex, '^(?:.+/)?api/.*$') + + equivalent_regex, include = GitWildMatchPattern.pattern_to_regex('**/api/**') + self.assertTrue(include) + self.assertEqual(equivalent_regex, regex) + + equivalent_regex, include = GitWildMatchPattern.pattern_to_regex('**/**/api/**/**') + self.assertTrue(include) + self.assertEqual(equivalent_regex, regex) def test_03_double_asterisk_trailing_slash_edge_case(self): """ @@ -273,9 +290,7 @@ def test_03_double_asterisk_trailing_slash_edge_case(self): """ regex, include = GitWildMatchPattern.pattern_to_regex('**/') self.assertTrue(include) - # FIXME: currently failing - # REVIEW: I believe this is the correct regex for this case - # self.assertEqual(regex, '^(?:.+/).*$') + self.assertEqual(regex, '^.+/.*$') equivalent_regex, include = GitWildMatchPattern.pattern_to_regex('**/**/') self.assertTrue(include)