@@ -905,27 +905,56 @@ def test_15_issue_93_b_2_double(self):
905905 self .assertFalse (pattern .match_file (' foo' ))
906906 self .assertTrue (pattern .match_file (' foo' ))
907907
908- def test_15_issue_93_c_1 (self ):
908+ def test_15_issue_93_c_1_valid (self ):
909909 """
910- Test patterns with invalid range notation .
910+ Test patterns with valid range notations .
911911 """
912- # TODO BUG: This test is a placeholder for the current behavior. Git behaves
913- # differently for this scenario.
912+ for raw_pattern , regex in [
913+ ('[a-z]' , f'^(?:.+/)?[a-z]{ _DIR_OPT } ' ),
914+ ('a[a-z]' , f'^(?:.+/)?a[a-z]{ _DIR_OPT } ' ),
915+ ]:
916+ with self .subTest (f"p={ raw_pattern !r} " ):
917+ pattern = GitIgnoreBasicPattern (raw_pattern )
918+ self .assertIs (pattern .include , True )
919+ self .assertEqual (pattern .regex .pattern , regex )
920+
921+ def test_15_issue_93_c_2_invalid (self ):
922+ """
923+ Test patterns with invalid range notations.
924+ """
925+ # TODO BUG: These tests need to pass.
914926 # - See <https://github.com/cpburnz/python-pathspec/issues/93>.
915- pattern = GitIgnoreBasicPattern ('[' )
916- self .assertIs (pattern .include , True )
917- self .assertEqual (pattern .regex .pattern , f'^(?:.+/)?\\ [{ _DIR_OPT } ' )
927+ for raw_pattern in [
928+ '[!]' ,
929+ '[z-a]' ,
930+ 'a[z-a]' ,
931+ ]:
932+ with self .subTest (f"p={ raw_pattern !r} " ):
933+ pattern = GitIgnoreBasicPattern (raw_pattern )
934+ self .assertIs (pattern .include , None )
935+ self .assertIs (pattern .regex .pattern , None )
918936
919- def test_15_issue_93_c_2 (self ):
937+ def test_15_issue_93_c_3_unclosed (self ):
920938 """
921- Test patterns with invalid range notation .
939+ Test patterns with unclosed range notations .
922940 """
923- # TODO BUG: This test is a placeholder for the current behavior. Git behaves
924- # differently for this scenario.
941+ # TODO BUG: These tests need to pass.
925942 # - See <https://github.com/cpburnz/python-pathspec/issues/93>.
926- pattern = GitIgnoreBasicPattern ('[!]' )
927- self .assertIs (pattern .include , True )
928- self .assertEqual (pattern .regex .pattern , f'^(?:.+/)?\\ [!\\ ]{ _DIR_OPT } ' )
943+ for raw_pattern in [
944+ '[!' ,
945+ '[-' ,
946+ '[a' ,
947+ '[a-' ,
948+ '[a-z' ,
949+ 'a[' ,
950+ 'a[-' ,
951+ 'a[a-' ,
952+ 'a[a-z' ,
953+ ]:
954+ with self .subTest (f"p={ raw_pattern !r} " ):
955+ pattern = GitIgnoreBasicPattern (raw_pattern )
956+ self .assertIs (pattern .include , None )
957+ self .assertIs (pattern .regex .pattern , None )
929958
930959 def test_16_repr_str (self ):
931960 """
0 commit comments