[Python-checkins] cpython (3.6): Issue #26944: Fix test_posix for Android where 'id -G' is entirely wrong
xavier.degaye
python-checkins at python.org
Wed Oct 19 05:08:59 EDT 2016
https://hg.python.org/cpython/rev/fb3e65aff225
changeset: 104550:fb3e65aff225
branch: 3.6
parent: 104547:5c21df505684
user: Xavier de Gaye <xdegaye at users.sourceforge.net>
date: Wed Oct 19 11:00:26 2016 +0200
summary:
Issue #26944: Fix test_posix for Android where 'id -G' is entirely wrong
or missing the effective gid.
files:
Lib/test/test_posix.py | 17 ++++++++++-------
Misc/NEWS | 3 +++
2 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/Lib/test/test_posix.py b/Lib/test/test_posix.py
--- a/Lib/test/test_posix.py
+++ b/Lib/test/test_posix.py
@@ -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()
@@ -810,12 +814,11 @@
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
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -35,6 +35,9 @@
Tests
-----
+- Issue #26944: Fix test_posix for Android where 'id -G' is entirely wrong or
+ missing the effective gid.
+
- Issue #28409: regrtest: fix the parser of command line arguments.
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list