File tree Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -1791,7 +1791,12 @@ def test_user(self):
1791
1791
name_uid = "nobody" if sys .platform != 'darwin' else "unknown"
1792
1792
1793
1793
if pwd is not None :
1794
- test_users .append (name_uid )
1794
+ try :
1795
+ pwd .getpwnam (name_uid )
1796
+ test_users .append (name_uid )
1797
+ except KeyError :
1798
+ # unknown user name
1799
+ name_uid = None
1795
1800
1796
1801
for user in test_users :
1797
1802
# posix_spawn() may be used with close_fds=False
@@ -1819,7 +1824,7 @@ def test_user(self):
1819
1824
with self .assertRaises (ValueError ):
1820
1825
subprocess .check_call (ZERO_RETURN_CMD , user = - 1 )
1821
1826
1822
- if pwd is None :
1827
+ if pwd is None and name_uid is not None :
1823
1828
with self .assertRaises (ValueError ):
1824
1829
subprocess .check_call (ZERO_RETURN_CMD , user = name_uid )
1825
1830
Original file line number Diff line number Diff line change
1
+ test_subprocess.test_user() now skips the test on an user name if the user
2
+ name doesn't exist. For example, skip the test if the user "nobody" doesn't
3
+ exist on Linux.
You can’t perform that action at this time.
0 commit comments