[Python-checkins] cpython (2.7): Issue #5113: Fix a test_posix failure on HP-UX, where non-root users can

charles-francois.natali python-checkins at python.org
Tue Apr 17 19:59:29 CEST 2012


http://hg.python.org/cpython/rev/8a4c9a168d09
changeset:   76376:8a4c9a168d09
branch:      2.7
parent:      76351:de27fedaeb25
user:        Charles-François Natali <neologix at free.fr>
date:        Tue Apr 17 19:46:06 2012 +0200
summary:
  Issue #5113: Fix a test_posix failure on HP-UX, where non-root users can
chown() to root under certain circumstances.

files:
  Lib/test/test_posix.py |  12 +++++++++---
  1 files changed, 9 insertions(+), 3 deletions(-)


diff --git a/Lib/test/test_posix.py b/Lib/test/test_posix.py
--- a/Lib/test/test_posix.py
+++ b/Lib/test/test_posix.py
@@ -9,6 +9,7 @@
 import sys
 import time
 import os
+import platform
 import pwd
 import shutil
 import stat
@@ -219,6 +220,9 @@
 
     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
@@ -230,14 +234,16 @@
                 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):
         # raise an OSError if the file does not exist

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list