diff -r b11b71aaf864 Lib/test/test_posix.py --- a/Lib/test/test_posix.py Sat May 21 14:56:53 2016 +0300 +++ b/Lib/test/test_posix.py Sun May 22 13:28:00 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: + idgroups = [int(g) for g in groups.split()] + except ValueError: + idgroups = [] + if ret is not None or not idgroups: 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") + getgroups = 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: + getgroups += [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(idgroups), set(getgroups)) # tests for the posix *at functions follow