[Python-checkins] cpython (3.2): Issue #14698: Make test_posix more robust when the current UID doesn't have an
charles-francois.natali
python-checkins at python.org
Wed May 2 20:05:29 CEST 2012
http://hg.python.org/cpython/rev/93424b084d08
changeset: 76714:93424b084d08
branch: 3.2
parent: 76709:d17ecee3f752
user: Charles-François Natali <neologix at free.fr>
date: Wed May 02 20:01:38 2012 +0200
summary:
Issue #14698: Make test_posix more robust when the current UID doesn't have an
associated pwd entry.
files:
Lib/test/test_posix.py | 9 +++++++--
1 files changed, 7 insertions(+), 2 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
@@ -107,7 +107,11 @@
# If a non-privileged user invokes it, it should fail with OSError
# EPERM.
if os.getuid() != 0:
- name = pwd.getpwuid(posix.getuid()).pw_name
+ try:
+ name = pwd.getpwuid(posix.getuid()).pw_name
+ except KeyError:
+ # the current UID may not have a pwd entry
+ raise unittest.SkipTest("need a pwd entry")
try:
posix.initgroups(name, 13)
except OSError as e:
@@ -421,8 +425,9 @@
def test_getgroups(self):
with os.popen('id -G') as idg:
groups = idg.read().strip()
+ ret = idg.close()
- if not groups:
+ if ret != 0 or not groups:
raise unittest.SkipTest("need working 'id -G'")
# 'id -G' and 'os.getgroups()' should return the same
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list