Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e5a9101

Browse files
committed
Issue #9581: Fix non-working PosixGroupsTester test case
(it only runs as root, which is why nobody bothered about the failure)
1 parent d3ccde8 commit e5a9101

1 file changed

Lines changed: 2 additions & 8 deletions

File tree

Lib/test/test_posix.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -409,21 +409,15 @@ def tearDown(self):
409409
def test_initgroups(self):
410410
# find missing group
411411

412-
groups = sorted(self.saved_groups)
413-
for g1,g2 in zip(groups[:-1], groups[1:]):
414-
g = g1 + 1
415-
if g < g2:
416-
break
417-
else:
418-
g = g2 + 1
412+
g = max(self.saved_groups) + 1
419413
name = pwd.getpwuid(posix.getuid()).pw_name
420414
posix.initgroups(name, g)
421415
self.assertIn(g, posix.getgroups())
422416

423417
@unittest.skipUnless(hasattr(posix, 'setgroups'),
424418
"test needs posix.setgroups()")
425419
def test_setgroups(self):
426-
for groups in [[0], range(16)]:
420+
for groups in [[0], list(range(16))]:
427421
posix.setgroups(groups)
428422
self.assertListEqual(groups, posix.getgroups())
429423

0 commit comments

Comments
 (0)