@@ -1588,6 +1588,18 @@ def test_run_with_shell_timeout_and_capture_output(self):
15881588 f"{ stacks } ```" )
15891589
15901590
1591+ def _get_test_grp_name ():
1592+ for name_group in ('staff' , 'nogroup' , 'grp' ):
1593+ if grp :
1594+ try :
1595+ grp .getgrnam (name_group )
1596+ except KeyError :
1597+ continue
1598+ return name_group
1599+ else :
1600+ raise unittest .SkipTest ('No identified group name to use for this test on this platform.' )
1601+
1602+
15911603@unittest .skipIf (mswindows , "POSIX specific tests" )
15921604class POSIXProcessTestCase (BaseTestCase ):
15931605
@@ -1762,8 +1774,10 @@ def test_user(self):
17621774 [sys .executable , "-c" ,
17631775 "import os; print(os.getuid())" ],
17641776 user = user )
1777+ except PermissionError : # errno.EACCES
1778+ pass
17651779 except OSError as e :
1766- if e .errno != errno .EPERM :
1780+ if e .errno not in ( errno .EACCES , errno . EPERM ) :
17671781 raise
17681782 else :
17691783 if isinstance (user , str ):
@@ -1789,7 +1803,7 @@ def test_user_error(self):
17891803 def test_group (self ):
17901804 gid = os .getegid ()
17911805 group_list = [65534 if gid != 65534 else 65533 ]
1792- name_group = "nogroup" if sys . platform != 'darwin' else "staff"
1806+ name_group = _get_test_grp_name ()
17931807
17941808 if grp is not None :
17951809 group_list .append (name_group )
@@ -1830,7 +1844,7 @@ def test_group_error(self):
18301844 def test_extra_groups (self ):
18311845 gid = os .getegid ()
18321846 group_list = [65534 if gid != 65534 else 65533 ]
1833- name_group = "nogroup" if sys . platform != 'darwin' else "staff"
1847+ name_group = _get_test_grp_name ()
18341848 perm_error = False
18351849
18361850 if grp is not None :
0 commit comments