1. Armin Rigo
  2. cpython-withatomic


Johannes Gijsbers  committed bdd14ab

Bug #1071513: don't test on Cygwin, as chmod doesn't work reliably there

Also check whether onerror has actually been called so this test will
fail on assertion instead of on trying to chmod a non-existent file.

  • Participants
  • Parent commits 6bd8021
  • Branches legacy-trunk

Comments (0)

Files changed (1)

File Lib/test/test_shutil.py

View file
  • Ignore whitespace
 import unittest
 import shutil
 import tempfile
+import sys
 import stat
 import os
 import os.path
         filename = tempfile.mktemp()
         self.assertRaises(OSError, shutil.rmtree, filename)
-    if hasattr(os, 'chmod'):
+    if hasattr(os, 'chmod') and sys.platform[:6] != 'cygwin':
         def test_on_error(self):
             self.errorState = 0
             os.chmod(TESTFN, stat.S_IREAD)
             shutil.rmtree(TESTFN, onerror=self.check_args_to_onerror)
+            # Test whether onerror has actually been called.
+            self.assertEqual(self.errorState, 2)
             # Make writable again.
             os.chmod(TESTFN, old_dir_mode)
             self.assertEqual(func, os.rmdir)
             self.assertEqual(arg, TESTFN)
             self.assertEqual(exc[0], OSError)
+            self.errorState = 2
     def test_rmtree_dont_delete_file(self):
         # When called on a file instead of a directory, don't delete it.