[Python-checkins] cpython (3.3): Issue #16661: Fix the os.getgrouplist() test by not assuming that it

ross.lagerwall python-checkins at python.org
Thu Dec 13 16:24:56 CET 2012


http://hg.python.org/cpython/rev/ce85fe971e0a
changeset:   80838:ce85fe971e0a
branch:      3.3
parent:      80832:bdd4ec5eb621
user:        Ross Lagerwall <rosslagerwall at gmail.com>
date:        Thu Dec 13 15:20:26 2012 +0000
summary:
  Issue #16661: Fix the os.getgrouplist() test by not assuming that it
gives the same output as "id -G".

files:
  Lib/test/test_posix.py |  13 +++----------
  Misc/NEWS              |   3 +++
  2 files changed, 6 insertions(+), 10 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
@@ -647,17 +647,10 @@
     @unittest.skipUnless(hasattr(pwd, 'getpwuid'), "test needs pwd.getpwuid()")
     @unittest.skipUnless(hasattr(os, 'getuid'), "test needs os.getuid()")
     def test_getgrouplist(self):
-        with os.popen('id -G') as idg:
-            groups = idg.read().strip()
-            ret = idg.close()
+        user = pwd.getpwuid(os.getuid())[0]
+        group = pwd.getpwuid(os.getuid())[3]
+        self.assertIn(group, posix.getgrouplist(user, group))
 
-        if ret is not None or not groups:
-            raise unittest.SkipTest("need working 'id -G'")
-
-        self.assertEqual(
-            set([int(x) for x in groups.split()]),
-            set(posix.getgrouplist(pwd.getpwuid(os.getuid())[0],
-                pwd.getpwuid(os.getuid())[3])))
 
     @unittest.skipUnless(hasattr(os, 'getegid'), "test needs os.getegid()")
     def test_getgroups(self):
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -301,6 +301,9 @@
 - Issue #16559: Add more tests for the json module, including some from the
   official test suite at json.org.  Patch by Serhiy Storchaka.
 
+- Issue #16661: Fix the `os.getgrouplist()` test by not assuming that it gives
+  the same output as :command:`id -G`.
+
 - Issue #16115: Add some tests for the executable argument to
   subprocess.Popen().  Initial patch by Kushal Das.
 

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list