MCPcopy
hub / github.com/celery/celery / test_without_initgroups

Method test_without_initgroups

t/unit/utils/test_platforms.py:390–410  ·  view source on GitHub ↗
(self, getpwuid, getgrall, setgroups)

Source from the content-addressed store, hash-verified

388 @patch('grp.getgrall')
389 @patch('pwd.getpwuid')
390 def test_without_initgroups(self, getpwuid, getgrall, setgroups):
391 prev = getattr(os, 'initgroups', None)
392 try:
393 delattr(os, 'initgroups')
394 except AttributeError:
395 pass
396 try:
397 getpwuid.return_value = ['user']
398
399 class grent:
400 gr_mem = ['user']
401
402 def __init__(self, gid):
403 self.gr_gid = gid
404
405 getgrall.return_value = [grent(1), grent(2), grent(3)]
406 initgroups(5001, 50001)
407 setgroups.assert_called_with([1, 2, 3])
408 finally:
409 if prev:
410 os.initgroups = prev
411
412
413@t.skip.if_win32

Callers

nothing calls this directly

Calls 2

initgroupsFunction · 0.90
grentClass · 0.70

Tested by

no test coverage detected