summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorCharles-François Natali <neologix@free.fr>2012-05-02 18:01:38 (GMT)
committerCharles-François Natali <neologix@free.fr>2012-05-02 18:01:38 (GMT)
commite8a255a5a28f3d0cecf2bcd411ac959937cde40d (patch)
tree80c45ccae930480d4eff90f02dee3d6ac83bad97 /Lib/test
parentcb172041d356b1a61588b8176985303c7a7d2c98 (diff)
downloadcpython-e8a255a5a28f3d0cecf2bcd411ac959937cde40d.zip
cpython-e8a255a5a28f3d0cecf2bcd411ac959937cde40d.tar.gz
cpython-e8a255a5a28f3d0cecf2bcd411ac959937cde40d.tar.bz2
Issue #14698: Make test_posix more robust when the current UID doesn't have an
associated pwd entry.
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_posix.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/Lib/test/test_posix.py b/Lib/test/test_posix.py
index 7612634..26b8d81 100644
--- a/Lib/test/test_posix.py
+++ b/Lib/test/test_posix.py
@@ -107,7 +107,11 @@ class PosixTester(unittest.TestCase):
# 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 @@ class PosixTester(unittest.TestCase):
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