mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
Issue #9344: Add os.getgrouplist().
This commit is contained in:
parent
10c30d6764
commit
b0ae53d8a0
6 changed files with 368 additions and 252 deletions
|
@ -569,6 +569,21 @@ 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()
|
||||
|
||||
if 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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue