MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_getgroups

Method test_getgroups

Lib/test/test_posix.py:1260–1284  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1258 @unittest.skipUnless(hasattr(os, 'popen'), "test needs os.popen()")
1259 @support.requires_subprocess()
1260 def test_getgroups(self):
1261 with os.popen('id -G 2>/dev/null') as idg:
1262 groups = idg.read().strip()
1263 ret = idg.close()
1264
1265 try:
1266 idg_groups = set(int(g) for g in groups.split())
1267 except ValueError:
1268 idg_groups = set()
1269 if ret is not None or not idg_groups:
1270 raise unittest.SkipTest("need working 'id -G'")
1271
1272 # Issues 16698: OS X ABIs prior to 10.6 have limits on getgroups()
1273 if sys.platform == 'darwin':
1274 import sysconfig
1275 dt = sysconfig.get_config_var('MACOSX_DEPLOYMENT_TARGET') or '10.3'
1276 if tuple(int(n) for n in dt.split('.')[0:2]) < (10, 6):
1277 raise unittest.SkipTest("getgroups(2) is broken prior to 10.6")
1278
1279 # 'id -G' and 'os.getgroups()' should return the same
1280 # groups, ignoring order, duplicates, and the effective gid.
1281 # #10822/#26944 - It is implementation defined whether
1282 # posix.getgroups() includes the effective gid.
1283 symdiff = idg_groups.symmetric_difference(posix.getgroups())
1284 self.assertTrue(not symdiff or symdiff == {posix.getegid()})
1285
1286 @unittest.skipUnless(hasattr(signal, 'SIGCHLD'), 'CLD_XXXX be placed in si_code for a SIGCHLD signal')
1287 @unittest.skipUnless(hasattr(os, 'waitid_result'), "test needs os.waitid_result")

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected