From ab2d58eefa222cdc439bef8eb02b3620bc991164 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charles-Fran=C3=A7ois=20Natali?= Date: Tue, 17 Apr 2012 19:48:35 +0200 Subject: Issue #5113: Fix a test_posix failure on HP-UX, where non-root users can chown() to root under certain circumstances. --- Lib/test/test_posix.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_posix.py b/Lib/test/test_posix.py index 09f04ec..7612634 100644 --- a/Lib/test/test_posix.py +++ b/Lib/test/test_posix.py @@ -9,6 +9,7 @@ import errno import sys import time import os +import platform import pwd import shutil import stat @@ -229,6 +230,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 @@ -240,12 +244,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): -- cgit v0.12