@@ -171,11 +171,10 @@ def test_rmtree_errors(self):
171171 filename = os .path .join (tmpdir , "tstfile" )
172172 with self .assertRaises (NotADirectoryError ) as cm :
173173 shutil .rmtree (filename )
174- if cm .exception .filename .endswith ('*.*' ):
175- rm_name = os .path .join (filename , '*.*' )
176- else :
177- rm_name = filename
178- self .assertEqual (cm .exception .filename , rm_name )
174+ # The reason for this rather odd construct is that Windows sprinkles
175+ # a \*.* at the end of file names. But only sometimes on some buildbots
176+ possible_args = [filename , os .path .join (filename , '*.*' )]
177+ self .assertIn (cm .exception .filename , possible_args )
179178 self .assertTrue (os .path .exists (filename ))
180179 # test that ignore_errors option is honored
181180 shutil .rmtree (filename , ignore_errors = True )
@@ -188,11 +187,12 @@ def onerror(*args):
188187 self .assertIs (errors [0 ][0 ], os .listdir )
189188 self .assertEqual (errors [0 ][1 ], filename )
190189 self .assertIsInstance (errors [0 ][2 ][1 ], NotADirectoryError )
191- self .assertEqual (errors [0 ][2 ][1 ].filename , rm_name )
190+ self .assertIn (errors [0 ][2 ][1 ].filename , possible_args )
192191 self .assertIs (errors [1 ][0 ], os .rmdir )
193192 self .assertEqual (errors [1 ][1 ], filename )
194193 self .assertIsInstance (errors [1 ][2 ][1 ], NotADirectoryError )
195- self .assertEqual (errors [1 ][2 ][1 ].filename , rm_name )
194+ self .assertIn (errors [1 ][2 ][1 ].filename , possible_args )
195+
196196
197197 # See bug #1071513 for why we don't run this on cygwin
198198 # and bug #1076467 for why we don't run this as root.
0 commit comments