@@ -1588,6 +1588,18 @@ def test_run_with_shell_timeout_and_capture_output(self):
1588
1588
f"{ stacks } ```" )
1589
1589
1590
1590
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
+
1591
1603
@unittest .skipIf (mswindows , "POSIX specific tests" )
1592
1604
class POSIXProcessTestCase (BaseTestCase ):
1593
1605
@@ -1762,8 +1774,10 @@ def test_user(self):
1762
1774
[sys .executable , "-c" ,
1763
1775
"import os; print(os.getuid())" ],
1764
1776
user = user )
1777
+ except PermissionError : # errno.EACCES
1778
+ pass
1765
1779
except OSError as e :
1766
- if e .errno != errno .EPERM :
1780
+ if e .errno not in ( errno .EACCES , errno . EPERM ) :
1767
1781
raise
1768
1782
else :
1769
1783
if isinstance (user , str ):
@@ -1789,7 +1803,7 @@ def test_user_error(self):
1789
1803
def test_group (self ):
1790
1804
gid = os .getegid ()
1791
1805
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 ()
1793
1807
1794
1808
if grp is not None :
1795
1809
group_list .append (name_group )
@@ -1830,7 +1844,7 @@ def test_group_error(self):
1830
1844
def test_extra_groups (self ):
1831
1845
gid = os .getegid ()
1832
1846
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 ()
1834
1848
perm_error = False
1835
1849
1836
1850
if grp is not None :
0 commit comments