diff options
author | Xavier de Gaye <xdegaye@users.sourceforge.net> | 2016-10-19 09:00:26 (GMT) |
---|---|---|
committer | Xavier de Gaye <xdegaye@users.sourceforge.net> | 2016-10-19 09:00:26 (GMT) |
commit | 24c3b4928eb3046a02b55ab4317cee28aa1c56ba (patch) | |
tree | 36cf2574850f648f5845e6c7c5b3659339f864cc /Lib | |
parent | 8166a5db5b5470384103a70f59d51b417f94e5ca (diff) | |
download | cpython-24c3b4928eb3046a02b55ab4317cee28aa1c56ba.zip cpython-24c3b4928eb3046a02b55ab4317cee28aa1c56ba.tar.gz cpython-24c3b4928eb3046a02b55ab4317cee28aa1c56ba.tar.bz2 |
Issue #26944: Fix test_posix for Android where 'id -G' is entirely wrong
or missing the effective gid.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_posix.py | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/Lib/test/test_posix.py b/Lib/test/test_posix.py index d2f58ba..63c74cd 100644 --- a/Lib/test/test_posix.py +++ b/Lib/test/test_posix.py @@ -799,7 +799,11 @@ class PosixTester(unittest.TestCase): 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() @@ -810,12 +814,11 @@ class PosixTester(unittest.TestCase): raise unittest.SkipTest("getgroups(2) is broken prior to 10.6") # '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 effective gid. + # #10822/#26944 - It is implementation defined whether + # posix.getgroups() includes the effective gid. + symdiff = idg_groups.symmetric_difference(posix.getgroups()) + self.assertTrue(not symdiff or symdiff == {posix.getegid()}) # tests for the posix *at functions follow |