summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_posix.py
diff options
context:
space:
mode:
authorCharles-François Natali <neologix@free.fr>2012-04-17 17:58:50 (GMT)
committerCharles-François Natali <neologix@free.fr>2012-04-17 17:58:50 (GMT)
commitfba807ac44ff6804dd1be7c3962fc3455c8e7763 (patch)
tree1257a06aa8af5e2c2c7c4252e187f628257179ea /Lib/test/test_posix.py
parentc8ce715a82fd8034ef1d809b262346c15f2490c4 (diff)
parentab2d58eefa222cdc439bef8eb02b3620bc991164 (diff)
downloadcpython-fba807ac44ff6804dd1be7c3962fc3455c8e7763.zip
cpython-fba807ac44ff6804dd1be7c3962fc3455c8e7763.tar.gz
cpython-fba807ac44ff6804dd1be7c3962fc3455c8e7763.tar.bz2
Issue #5113: Fix a test_posix failure on HP-UX, where non-root users can
chown() to root under certain circumstances.
Diffstat (limited to 'Lib/test/test_posix.py')
-rw-r--r--Lib/test/test_posix.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/Lib/test/test_posix.py b/Lib/test/test_posix.py
index c3dfffb..142dddd 100644
--- a/Lib/test/test_posix.py
+++ b/Lib/test/test_posix.py
@@ -10,6 +10,7 @@ import sys
import time
import os
import fcntl
+import platform
import pwd
import shutil
import stat
@@ -390,6 +391,9 @@ class PosixTester(unittest.TestCase):
def _test_all_chown_common(self, chown_func, first_param):
"""Common code for chown, fchown and lchown tests."""
+ # test a successful chown call
+ chown_func(first_param, os.getuid(), os.getgid())
+
if os.getuid() == 0:
try:
# Many linux distros have a nfsnobody user as MAX_UID-2
@@ -401,12 +405,15 @@ class PosixTester(unittest.TestCase):
chown_func(first_param, ent.pw_uid, ent.pw_gid)
except KeyError:
pass
+ elif platform.system() in ('HP-UX', 'SunOS'):
+ # HP-UX and Solaris can allow a non-root user to chown() to root
+ # (issue #5113)
+ raise unittest.SkipTest("Skipping because of non-standard chown() "
+ "behavior")
else:
# non-root cannot chown to root, raises OSError
self.assertRaises(OSError, chown_func,
first_param, 0, 0)
- # test a successful chown call
- chown_func(first_param, os.getuid(), os.getgid())
@unittest.skipUnless(hasattr(posix, 'chown'), "test needs os.chown()")
def test_chown(self):