@@ -117,10 +117,30 @@ def test_basic(tmpdir, capsys):
117117 assert cs .main (d ) == 0
118118
119119 # empty directory
120- os .mkdir (op .join (d , 'test ' ))
120+ os .mkdir (op .join (d , 'empty ' ))
121121 assert cs .main (d ) == 0
122122
123123
124+ def test_bad_glob (tmpdir , capsys ):
125+ # disregard invalid globs, properly handle escaped globs
126+ g = op .join (tmpdir , 'glob' )
127+ os .mkdir (g )
128+ fname = op .join (g , '[b-a].txt' )
129+ with open (fname , 'a' ) as f :
130+ f .write ('abandonned\n ' )
131+ assert cs .main (g ) == 1
132+ # bad glob is invalid
133+ code , _ , stderr = cs .main ('--skip' , '[b-a].txt' ,
134+ g , std = True )
135+ if sys .hexversion < 0x030A05F0 : # Python < 3.10.5 raises re.error
136+ assert code == EX_USAGE , 'invalid glob'
137+ assert 'invalid glob' in stderr
138+ else : # Python >= 3.10.5 does not match
139+ assert code == 1
140+ # properly escaped glob is valid, and matches glob-like file name
141+ assert cs .main ('--skip' , '[[]b-a[]].txt' , g ) == 0
142+
143+
124144@pytest .mark .skipif (
125145 not sys .platform == 'linux' , reason = 'Only supported on Linux' )
126146def test_permission_error (tmp_path , capsys ):
0 commit comments