Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bpo-40014: Skip os.getgrouplist related test if OSError is raised. #19075

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions Lib/test/pythoninfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,9 +333,13 @@ def collect_pwd(info_add):
return

if hasattr(os, 'getgrouplist'):
groups = os.getgrouplist(entry.pw_name, entry.pw_gid)
groups = ', '.join(map(str, groups))
info_add('os.getgrouplist', groups)
try:
groups = os.getgrouplist(entry.pw_name, entry.pw_gid)
groups = ', '.join(map(str, groups))
except OSError:
pass
else:
info_add('os.getgrouplist', groups)


def collect_readline(info_add):
Expand Down
6 changes: 4 additions & 2 deletions Lib/test/test_posix.py
Original file line number Diff line number Diff line change
Expand Up @@ -1025,8 +1025,10 @@ def _create_and_do_getcwd(dirname, current_path_length = 0):
def test_getgrouplist(self):
user = pwd.getpwuid(os.getuid())[0]
group = pwd.getpwuid(os.getuid())[3]
self.assertIn(group, posix.getgrouplist(user, group))

try:
self.assertIn(group, posix.getgrouplist(user, group))
except OSError:
raise unittest.SkipTest("os.getgrouplist() is not available")
corona10 marked this conversation as resolved.
Show resolved Hide resolved

@unittest.skipUnless(hasattr(os, 'getegid'), "test needs os.getegid()")
def test_getgroups(self):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Skip :func:`~os.getgrouplist` related tests, if :exc:`OSError` is raised.
Patch by Dong-hee Na.