]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-149879: Fix test_grp on Cygwin (#150495) main
authorVictor Stinner <vstinner@python.org>
Tue, 26 May 2026 21:16:16 +0000 (23:16 +0200)
committerGitHub <noreply@github.com>
Tue, 26 May 2026 21:16:16 +0000 (21:16 +0000)
Lib/test/test_grp.py

index ed86802f069e0f88e0f2253755322d5bc7d583a7..f08b9328a9ff04295d4e0f00bd4adcc9489862bd 100644 (file)
@@ -2,6 +2,7 @@
 
 import random
 import string
+import sys
 import unittest
 from test.support import import_helper
 
@@ -35,7 +36,15 @@ class GroupDatabaseTestCase(unittest.TestCase):
             self.skipTest('huge group file, extended test skipped')
 
         for e in entries:
-            e2 = grp.getgrgid(e.gr_gid)
+            try:
+                e2 = grp.getgrgid(e.gr_gid)
+            except KeyError:
+                # On Cygwin, some groups returned by getgrall() cannot be
+                # retrieved by getgrgid()
+                if sys.platform == 'cygwin':
+                    continue
+                raise
+
             self.check_value(e2)
             self.assertEqual(e2.gr_gid, e.gr_gid)
             name = e.gr_name