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