From: Charles-François Natali Date: Wed, 2 May 2012 18:04:40 +0000 (+0200) Subject: Issue #14698: Make test_posix more robust when the current UID doesn't have an X-Git-Tag: v3.3.0a4~313 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d59240de8311a493ead948f382cc07e0d70fb1c1;p=thirdparty%2FPython%2Fcpython.git Issue #14698: Make test_posix more robust when the current UID doesn't have an associated pwd entry. --- d59240de8311a493ead948f382cc07e0d70fb1c1 diff --cc Lib/test/test_posix.py index 142dddd09b62,26b8d81a6436..5ed2a0ffc514 --- a/Lib/test/test_posix.py +++ b/Lib/test/test_posix.py @@@ -618,21 -421,6 +622,22 @@@ class PosixTester(unittest.TestCase) os.chdir(curdir) support.rmtree(base_path) + @unittest.skipUnless(hasattr(posix, 'getgrouplist'), "test needs posix.getgrouplist()") + @unittest.skipUnless(hasattr(pwd, 'getpwuid'), "test needs pwd.getpwuid()") + @unittest.skipUnless(hasattr(os, 'getuid'), "test needs os.getuid()") + def test_getgrouplist(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'") + + self.assertEqual( + set([int(x) for x in groups.split()]), + set(posix.getgrouplist(pwd.getpwuid(os.getuid())[0], + pwd.getpwuid(os.getuid())[3]))) + @unittest.skipUnless(hasattr(os, 'getegid'), "test needs os.getegid()") def test_getgroups(self): with os.popen('id -G') as idg: