]> granicus.if.org Git - python/commitdiff
Issue #16661: Fix the os.getgrouplist() test by not assuming that it
authorRoss Lagerwall <rosslagerwall@gmail.com>
Thu, 13 Dec 2012 15:20:26 +0000 (15:20 +0000)
committerRoss Lagerwall <rosslagerwall@gmail.com>
Thu, 13 Dec 2012 15:20:26 +0000 (15:20 +0000)
gives the same output as "id -G".

Lib/test/test_posix.py
Misc/NEWS

index f59607b4f53da9ca9a6729f66cc1ef57c0c6a2e8..4ad735055d0de490e0bf2d7705de9cf92ad1197c 100644 (file)
@@ -647,17 +647,10 @@ class PosixTester(unittest.TestCase):
     @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):
index 58675e86bf16872f9d9de8422d805268754e1d54..604e6fa8cee612c907c812b03f8a83de78fb99ad 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -301,6 +301,9 @@ Tests
 - 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.