diff -r 7dab8fd016c5 Lib/test/regrtest.py --- a/Lib/test/regrtest.py Thu Apr 16 01:42:19 2009 -0700 +++ b/Lib/test/regrtest.py Thu Apr 16 02:17:15 2009 -0700 @@ -663,6 +663,7 @@ def cleanup_test_droppings(testname, verbose): import shutil + import stat # Try to clean up junk commonly left behind. While tests shouldn't leave # any files or directories behind, when a test fails that can be tedious @@ -687,6 +688,10 @@ if verbose: print("%r left behind %s %r" % (testname, kind, name)) try: + # if we have chmod, fix possible permissions problems + # that might prevent cleanup + if (hasattr(os, 'chmod')): + os.chmod(name, stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO) nuker(name) except Exception as msg: print(("%r left behind %s %r and it couldn't be " diff -r 7dab8fd016c5 Lib/test/test_shutil.py --- a/Lib/test/test_shutil.py Thu Apr 16 01:42:19 2009 -0700 +++ b/Lib/test/test_shutil.py Thu Apr 16 02:17:15 2009 -0700 @@ -45,9 +45,22 @@ shutil.rmtree(TESTFN) def check_args_to_onerror(self, func, arg, exc): + # test_rmtree_errors deliberately runs rmtree + # on a directory that is chmod 400, which will fail. + # This function is run when shutil.rmtree fails. + # 99.9% of the time it initially fails to remove + # a file in the directory, so the first time through + # func is os.remove. + # However, some Linux machines running ZFS on + # FUSE experienced a failure earlier in the process + # at os.listdir. The first failure may legally + # be either. if self.errorState == 0: - self.assertEqual(func, os.remove) - self.assertEqual(arg, self.childpath) + if func is os.remove: + self.assertEqual(arg, self.childpath) + else: + self.assertEqual(func, os.listdir, "func must be either os.remove or os.listdir") + self.assertEqual(arg, TESTFN) self.failUnless(issubclass(exc[0], OSError)) self.errorState = 1 else: