def test_setupEnvironment(self):
        options = twistd.ServerOptions()
        options.parseOptions([
            '--nodaemon',
            '--umask', '0070',
            '--chroot', '/foo/chroot',
            '--rundir', '/foo/rundir',
            '--pidfile', '/foo/pidfile'])
        application = service.Application("test_setupEnvironment")
        self.runner = UnixApplicationRunner(options)

        args = []
        def fakeSetupEnvironment(self, chroot, rundir, nodaemon, umask,
                                 pidfile):
            args.extend((chroot, rundir, nodaemon, umask, pidfile))

        # Sanity check
        self.assertEqual(
            inspect.getargspec(self.runner.setupEnvironment),
            inspect.getargspec(fakeSetupEnvironment))

        self.patch(UnixApplicationRunner, 'setupEnvironment',
                   fakeSetupEnvironment)
        self.patch(UnixApplicationRunner, 'shedPrivileges',
                   lambda *a, **kw: None)
        self.patch(app, 'startApplication', lambda *a, **kw: None)
        self.runner.startApplication(application)

        self.assertEqual(
            args,
            ['/foo/chroot', '/foo/rundir', True, 56, '/foo/pidfile'])
L{UnixApplicationRunner.startApplication} calls
dataset/ETHPy150Open twisted/twisted/twisted/test/test_twistd.py/UnixApplicationRunnerStartApplicationTests.test_setupEnvironment