Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b8b09d0

Browse files
author
Johannes Gijsbers
committed
SF bug #1076467: don't run test_on_error as root, as the permission
errors don't get provoked that way. Also add a bunch of cross-references to bugs.
1 parent a32d22a commit b8b09d0

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

Lib/test/test_shutil.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ def test_rmtree_errors(self):
1616
filename = tempfile.mktemp()
1717
self.assertRaises(OSError, shutil.rmtree, filename)
1818

19-
if hasattr(os, 'chmod') and sys.platform[:6] != 'cygwin':
19+
# See bug #1071513 for why we don't run this on cygwin
20+
# and bug #1076467 for why we don't run this as root.
21+
if (hasattr(os, 'chmod') and sys.platform[:6] != 'cygwin'
22+
and os.getenv('USER') != 'root'):
2023
def test_on_error(self):
2124
self.errorState = 0
2225
os.mkdir(TESTFN)
@@ -31,7 +34,8 @@ def test_on_error(self):
3134

3235
shutil.rmtree(TESTFN, onerror=self.check_args_to_onerror)
3336
# Test whether onerror has actually been called.
34-
self.assertEqual(self.errorState, 2)
37+
self.assertEqual(self.errorState, 2,
38+
"Expected call to onerror function did not happen.")
3539

3640
# Make writable again.
3741
os.chmod(TESTFN, old_dir_mode)

0 commit comments

Comments
 (0)