]> granicus.if.org Git - python/commitdiff
Fix for issue 9367: the test code for os.getgroups
authorRonald Oussoren <ronaldoussoren@mac.com>
Sat, 24 Jul 2010 14:15:19 +0000 (14:15 +0000)
committerRonald Oussoren <ronaldoussoren@mac.com>
Sat, 24 Jul 2010 14:15:19 +0000 (14:15 +0000)
assumes that the result of getgroups and the output
of the id(1) command return groups in the same
order.  That assumption is both fragile and false.

Lib/test/test_posix.py

index 6708aeb89644710f3fada3e548e7deb2026a5558..b6322b4137f951be6256838a9c8974e3bbf9440e 100644 (file)
@@ -357,7 +357,11 @@ class PosixTester(unittest.TestCase):
         if not groups:
             raise unittest.SkipTest("need working 'id -G'")
 
-        self.assertEqual([int(x) for x in groups.split()], posix.getgroups())
+        # The order of groups isn't important, hence the calls
+        # to sorted.
+        self.assertEqual(
+                list(sorted([int(x) for x in groups.split()])),
+                list(sorted(posix.getgroups())))
 
 class PosixGroupsTester(unittest.TestCase):