[Python-checkins] cpython (3.2): #15872: Some more Windows related tuning to shutil.rmtree tests

hynek.schlawack python-checkins at python.org
Mon Dec 10 16:37:11 CET 2012


http://hg.python.org/cpython/rev/cb8274e1ebfa
changeset:   80812:cb8274e1ebfa
branch:      3.2
parent:      80809:2d953d47d634
user:        Hynek Schlawack <hs at ox.cx>
date:        Mon Dec 10 16:29:57 2012 +0100
summary:
  #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. :(

files:
  Lib/test/test_shutil.py |  15 +++++++--------
  1 files changed, 7 insertions(+), 8 deletions(-)


diff --git a/Lib/test/test_shutil.py b/Lib/test/test_shutil.py
--- a/Lib/test/test_shutil.py
+++ b/Lib/test/test_shutil.py
@@ -132,13 +132,12 @@
         filename = os.path.join(tmpdir, "tstfile")
         with self.assertRaises(OSError) 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 honoured
+        # test that ignore_errors option is honored
         shutil.rmtree(filename, ignore_errors=True)
         self.assertTrue(os.path.exists(filename))
         errors = []
@@ -149,11 +148,11 @@
         self.assertIs(errors[0][0], os.listdir)
         self.assertEqual(errors[0][1], filename)
         self.assertIsInstance(errors[0][2][1], OSError)
-        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], OSError)
-        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.

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list