diff options
author | Ross Lagerwall <rosslagerwall@gmail.com> | 2011-06-10 05:30:30 (GMT) |
---|---|---|
committer | Ross Lagerwall <rosslagerwall@gmail.com> | 2011-06-10 05:30:30 (GMT) |
commit | b0ae53d8a09731a51be48f9e84a71d09d0f90657 (patch) | |
tree | c4aed090ed5d29da17d008e3aa8d47b076146f1b /Lib/test/test_posix.py | |
parent | 10c30d676432b995d19308855a5ed40f87353074 (diff) | |
download | cpython-b0ae53d8a09731a51be48f9e84a71d09d0f90657.zip cpython-b0ae53d8a09731a51be48f9e84a71d09d0f90657.tar.gz cpython-b0ae53d8a09731a51be48f9e84a71d09d0f90657.tar.bz2 |
Issue #9344: Add os.getgrouplist().
Diffstat (limited to 'Lib/test/test_posix.py')
-rw-r--r-- | Lib/test/test_posix.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Lib/test/test_posix.py b/Lib/test/test_posix.py index 70a47b0..438634e 100644 --- a/Lib/test/test_posix.py +++ b/Lib/test/test_posix.py @@ -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: |