mirror of https://github.com/python/cpython
Issue #16661: Fix the os.getgrouplist() test by not assuming that it
gives the same output as "id -G".
This commit is contained in:
parent
954ac03a44
commit
a0b315f5f7
|
@ -647,17 +647,10 @@ class PosixTester(unittest.TestCase):
|
||||||
@unittest.skipUnless(hasattr(pwd, 'getpwuid'), "test needs pwd.getpwuid()")
|
@unittest.skipUnless(hasattr(pwd, 'getpwuid'), "test needs pwd.getpwuid()")
|
||||||
@unittest.skipUnless(hasattr(os, 'getuid'), "test needs os.getuid()")
|
@unittest.skipUnless(hasattr(os, 'getuid'), "test needs os.getuid()")
|
||||||
def test_getgrouplist(self):
|
def test_getgrouplist(self):
|
||||||
with os.popen('id -G') as idg:
|
user = pwd.getpwuid(os.getuid())[0]
|
||||||
groups = idg.read().strip()
|
group = pwd.getpwuid(os.getuid())[3]
|
||||||
ret = idg.close()
|
self.assertIn(group, posix.getgrouplist(user, group))
|
||||||
|
|
||||||
if ret is not None 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()")
|
@unittest.skipUnless(hasattr(os, 'getegid'), "test needs os.getegid()")
|
||||||
def test_getgroups(self):
|
def test_getgroups(self):
|
||||||
|
|
|
@ -301,6 +301,9 @@ Tests
|
||||||
- Issue #16559: Add more tests for the json module, including some from the
|
- Issue #16559: Add more tests for the json module, including some from the
|
||||||
official test suite at json.org. Patch by Serhiy Storchaka.
|
official test suite at json.org. Patch by Serhiy Storchaka.
|
||||||
|
|
||||||
|
- Issue #16661: Fix the `os.getgrouplist()` test by not assuming that it gives
|
||||||
|
the same output as :command:`id -G`.
|
||||||
|
|
||||||
- Issue #16115: Add some tests for the executable argument to
|
- Issue #16115: Add some tests for the executable argument to
|
||||||
subprocess.Popen(). Initial patch by Kushal Das.
|
subprocess.Popen(). Initial patch by Kushal Das.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue