@@ -132,13 +132,12 @@ def test_rmtree_errors(self):
132132 filename = os .path .join (tmpdir , "tstfile" )
133133 with self .assertRaises (OSError ) as cm :
134134 shutil .rmtree (filename )
135- if cm .exception .filename .endswith ('*.*' ):
136- rm_name = os .path .join (filename , '*.*' )
137- else :
138- rm_name = filename
139- self .assertEqual (cm .exception .filename , rm_name )
135+ # The reason for this rather odd construct is that Windows sprinkles
136+ # a \*.* at the end of file names. But only sometimes on some buildbots
137+ possible_args = [filename , os .path .join (filename , '*.*' )]
138+ self .assertIn (cm .exception .filename , possible_args )
140139 self .assertTrue (os .path .exists (filename ))
141- # test that ignore_errors option is honoured
140+ # test that ignore_errors option is honored
142141 shutil .rmtree (filename , ignore_errors = True )
143142 self .assertTrue (os .path .exists (filename ))
144143 errors = []
@@ -149,11 +148,11 @@ def onerror(*args):
149148 self .assertIs (errors [0 ][0 ], os .listdir )
150149 self .assertEqual (errors [0 ][1 ], filename )
151150 self .assertIsInstance (errors [0 ][2 ][1 ], OSError )
152- self .assertEqual (errors [0 ][2 ][1 ].filename , rm_name )
151+ self .assertIn (errors [0 ][2 ][1 ].filename , possible_args )
153152 self .assertIs (errors [1 ][0 ], os .rmdir )
154153 self .assertEqual (errors [1 ][1 ], filename )
155154 self .assertIsInstance (errors [1 ][2 ][1 ], OSError )
156- self .assertEqual (errors [1 ][2 ][1 ].filename , rm_name )
155+ self .assertIn (errors [1 ][2 ][1 ].filename , possible_args )
157156
158157 # See bug #1071513 for why we don't run this on cygwin
159158 # and bug #1076467 for why we don't run this as root.
0 commit comments