diff -r dda25c37d02b Lib/test/test_posix.py --- a/Lib/test/test_posix.py Sat Aug 13 14:47:54 2016 -0400 +++ b/Lib/test/test_posix.py Thu Aug 18 20:08:36 2016 -0400 @@ -799,7 +799,11 @@ groups = idg.read().strip() ret = idg.close() - if ret is not None or not groups: + try: + idg_groups = set(int(g) for g in groups.split()) + except ValueError: + idg_groups = set() + if ret is not None or not idg_groups: raise unittest.SkipTest("need working 'id -G'") # Issues 16698: OS X ABIs prior to 10.6 have limits on getgroups() @@ -809,13 +813,19 @@ if tuple(int(n) for n in dt.split('.')[0:2]) < (10, 6): raise unittest.SkipTest("getgroups(2) is broken prior to 10.6") + posix_groups = set(posix.getgroups()) + # #10822/#26944 - it is implementation defined whether + # posix.getgroups() and the 'id -G' command include the effective gid, + # so we eliminate it from the match sets. + egid = posix.getegid() + if egid in idg_groups: + idg_groups.remove(egid) + if egid in posix_groups: + posix_groups.remove(egid) + # 'id -G' and 'os.getgroups()' should return the same - # groups, ignoring order and duplicates. - # #10822 - it is implementation defined whether posix.getgroups() - # includes the effective gid so we include it anyway, since id -G does - self.assertEqual( - set([int(x) for x in groups.split()]), - set(posix.getgroups() + [posix.getegid()])) + # groups, ignoring order, duplicates, and the egid. + self.assertEqual(idg_groups, posix_groups) # tests for the posix *at functions follow