MCPcopy Index your code
hub / github.com/python/cpython / test_getgroups

Method test_getgroups

Lib/test/test_os/test_posix.py:1320–1344  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1318 @unittest.skipUnless(hasattr(os, 'popen'), "test needs os.popen()")
1319 @support.requires_subprocess()
1320 def test_getgroups(self):
1321 with os.popen('id -G 2>/dev/null') as idg:
1322 groups = idg.read().strip()
1323 ret = idg.close()
1324
1325 try:
1326 idg_groups = set(int(g) for g in groups.split())
1327 except ValueError:
1328 idg_groups = set()
1329 if ret is not None or not idg_groups:
1330 raise unittest.SkipTest("need working 'id -G'")
1331
1332 # Issues 16698: OS X ABIs prior to 10.6 have limits on getgroups()
1333 if sys.platform == 'darwin':
1334 import sysconfig
1335 dt = sysconfig.get_config_var('MACOSX_DEPLOYMENT_TARGET') or '10.3'
1336 if tuple(int(n) for n in dt.split('.')[0:2]) < (10, 6):
1337 raise unittest.SkipTest("getgroups(2) is broken prior to 10.6")
1338
1339 # 'id -G' and 'os.getgroups()' should return the same
1340 # groups, ignoring order, duplicates, and the effective gid.
1341 # #10822/#26944 - It is implementation defined whether
1342 # posix.getgroups() includes the effective gid.
1343 symdiff = idg_groups.symmetric_difference(posix.getgroups())
1344 self.assertTrue(not symdiff or symdiff == {posix.getegid()})
1345
1346 @unittest.skipUnless(hasattr(signal, 'SIGCHLD'), 'CLD_XXXX be placed in si_code for a SIGCHLD signal')
1347 @unittest.skipUnless(hasattr(os, 'waitid_result'), "test needs os.waitid_result")

Callers

nothing calls this directly

Calls 7

setFunction · 0.85
symmetric_differenceMethod · 0.80
assertTrueMethod · 0.80
stripMethod · 0.45
readMethod · 0.45
closeMethod · 0.45
splitMethod · 0.45

Tested by

no test coverage detected