diff -r 829117ae2e55 Lib/test/test_posix.py --- a/Lib/test/test_posix.py Tue Jul 19 16:46:09 2016 -0500 +++ b/Lib/test/test_posix.py Thu Jul 21 17:42:13 2016 +0200 @@ -15,6 +15,7 @@ import tempfile import unittest import warnings +from test.support import is_android _DUMMY_SYMLINK = os.path.join(tempfile.gettempdir(), support.TESTFN + '-dummy-symlink') @@ -797,7 +798,11 @@ groups = idg.read().strip() ret = idg.close() - if ret is not None or not groups: + try: + idg_groups = [int(g) for g in groups.split()] + except ValueError: + idg_groups = [] + 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() @@ -807,13 +812,17 @@ 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 = posix.getgroups() + # #10822 - it is implementation defined whether posix.getgroups() + # includes the effective gid so we include it anyway, since id -G + # does. Except on Android where the effective group id is not + # included in 'id -G' and not in posix.getgroups() either. + if not is_android: + posix_groups.append(posix.getegid()) + # '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()])) + self.assertEqual(set(idg_groups), set(posix_groups)) # tests for the posix *at functions follow