def test_setgroups_raises_ESRCH(self, hack, sysconf, getgroups): sysconf.side_effect = ValueError() esrch = OSError() esrch.errno = errno.ESRCH hack.side_effect = esrch with self.assertRaises(OSError): setgroups(list(range(400)))
def test_setgroups_raises_ESRCH(self, hack, getgroups): with patch('os.sysconf') as sysconf: sysconf.side_effect = ValueError() esrch = OSError() esrch.errno = errno.ESRCH hack.side_effect = esrch with pytest.raises(OSError): setgroups(list(range(400)))
def test_setgroups_raises_EPERM(self, hack, sysconf, getgroups): sysconf.side_effect = ValueError() eperm = OSError() eperm.errno = errno.EPERM hack.side_effect = eperm getgroups.return_value = list(range(400)) setgroups(list(range(400))) getgroups.assert_called_with() getgroups.return_value = [1000] with self.assertRaises(OSError): setgroups(list(range(400))) getgroups.assert_called_with()
def test_setgroups_sysconf_raises(self, hack, sysconf): sysconf.side_effect = ValueError() setgroups(list(range(400))) hack.assert_called_with(list(range(400)))
def test_setgroups(self, hack, sysconf): sysconf.return_value = 100 setgroups(list(range(400))) hack.assert_called_with(list(range(100)))
def test_setgroups_sysconf_raises(self, hack): with patch('os.sysconf') as sysconf: sysconf.side_effect = ValueError() setgroups(list(range(400))) hack.assert_called_with(list(range(400)))
def test_setgroups(self, hack): with patch('os.sysconf') as sysconf: sysconf.return_value = 100 setgroups(list(range(400))) hack.assert_called_with(list(range(100)))