'Launch a child process, using either the C{uid} or C{gid} argument to
L{IReactorProcess.spawnProcess} to change either its UID or GID to a
different value.  If the child process reports this hasn\'t happened,
raise an exception to fail the test.
@param which: Either C{b"uid"} or C{b"gid"}.'

def _changeIDTest(self, which):

    program = ['import    os', ('raise    SystemExit(os.get%s()    !=    1)' % (which,))]
    container = []
    class CaptureExitStatus(ProcessProtocol, ):
        def processEnded(self, reason):
            container.append(reason)
            reactor.stop()
    reactor = self.buildReactor()
    protocol = CaptureExitStatus()
    reactor.callWhenRunning(reactor.spawnProcess, protocol, pyExe, [pyExe, '-c', '\n'.join(program)], **{which: 1})
    self.runReactor(reactor)
    self.assertEqual(0, container[0].value.exitCode)
