Example #1
0
 def test_initgroupsForcePython(self):
     """
     If we fake the absence of the C extension, the Python implementation is
     called instead, calling C{os.setgroups}.
     """
     util._c_initgroups = None
     calls = []
     util.setgroups = calls.append
     util.initgroups(os.getuid(), os.getgid())
     # Something should be in the calls, we don't really care what
     self.assertTrue(calls)
Example #2
0
 def test_initgroupsForcePython(self):
     """
     If we fake the absence of the C extension, the Python implementation is
     called instead, calling C{os.setgroups}.
     """
     util._c_initgroups = None
     calls = []
     util.setgroups = calls.append
     util.initgroups(os.getuid(), os.getgid())
     # Something should be in the calls, we don't really care what
     self.assertTrue(calls)
Example #3
0
 def test_initgroupsInC(self):
     """
     If the C extension is present, it's called instead of the Python
     version.  We check that by making sure C{os.setgroups} is not called.
     """
     calls = []
     util.setgroups = calls.append
     try:
         util.initgroups(os.getuid(), os.getgid())
     except OSError:
         pass
     self.assertFalse(calls)
Example #4
0
 def test_initgroupsInC(self):
     """
     If the C extension is present, it's called instead of the Python
     version.  We check that by making sure C{os.setgroups} is not called.
     """
     calls = []
     util.setgroups = calls.append
     try:
         util.initgroups(os.getuid(), os.getgid())
     except OSError:
         pass
     self.assertFalse(calls)
Example #5
0
    def test_initgroupsForceC(self):
        """
        If we fake the presence of the C extension, it's called instead of the
        Python implementation.
        """
        calls = []
        util._c_initgroups = lambda x, y: calls.append((x, y))
        setgroupsCalls = []
        util.setgroups = calls.append

        util.initgroups(os.getuid(), 4)
        self.assertEquals(calls, [(pwd.getpwuid(os.getuid())[0], 4)])
        self.assertFalse(setgroupsCalls)
Example #6
0
    def test_initgroupsForceC(self):
        """
        If we fake the presence of the C extension, it's called instead of the
        Python implementation.
        """
        calls = []
        util._c_initgroups = lambda x, y: calls.append((x, y))
        setgroupsCalls = []
        util.setgroups = calls.append

        util.initgroups(os.getuid(), 4)
        self.assertEquals(calls, [(pwd.getpwuid(os.getuid())[0], 4)])
        self.assertFalse(setgroupsCalls)