Commit c474c4e7 authored by Hynek Schlawack's avatar Hynek Schlawack

#15872: Some more Windows related tuning to shutil.rmtree tests

Turns out, the snakebite bots behave also their peculiarities.

I'm really not proud of this stream of commits. :(
parents f29b4937 87f9b46f
......@@ -171,11 +171,10 @@ class TestShutil(unittest.TestCase):
filename = os.path.join(tmpdir, "tstfile")
with self.assertRaises(NotADirectoryError) as cm:
shutil.rmtree(filename)
if cm.exception.filename.endswith('*.*'):
rm_name = os.path.join(filename, '*.*')
else:
rm_name = filename
self.assertEqual(cm.exception.filename, rm_name)
# The reason for this rather odd construct is that Windows sprinkles
# a \*.* at the end of file names. But only sometimes on some buildbots
possible_args = [filename, os.path.join(filename, '*.*')]
self.assertIn(cm.exception.filename, possible_args)
self.assertTrue(os.path.exists(filename))
# test that ignore_errors option is honored
shutil.rmtree(filename, ignore_errors=True)
......@@ -188,11 +187,12 @@ class TestShutil(unittest.TestCase):
self.assertIs(errors[0][0], os.listdir)
self.assertEqual(errors[0][1], filename)
self.assertIsInstance(errors[0][2][1], NotADirectoryError)
self.assertEqual(errors[0][2][1].filename, rm_name)
self.assertIn(errors[0][2][1].filename, possible_args)
self.assertIs(errors[1][0], os.rmdir)
self.assertEqual(errors[1][1], filename)
self.assertIsInstance(errors[1][2][1], NotADirectoryError)
self.assertEqual(errors[1][2][1].filename, rm_name)
self.assertIn(errors[1][2][1].filename, possible_args)
# See bug #1071513 for why we don't run this on cygwin
# and bug #1076467 for why we don't run this as root.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment