'L{UnixApplicationRunner.startApplication} calls
L{UnixApplicationRunner.setupEnvironment} with the chroot, rundir,
nodaemon, umask, and pidfile parameters from the configuration it is
constructed with.'

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))
    if _PY3:
        setupEnvironmentParameters = inspect.signature(self.runner.setupEnvironment).parameters
        fakeSetupEnvironmentParameters = inspect.signature(fakeSetupEnvironment).parameters
        fakeSetupEnvironmentParameters = fakeSetupEnvironmentParameters.copy()
        fakeSetupEnvironmentParameters.pop('self')
        self.assertEqual(setupEnvironmentParameters, fakeSetupEnvironmentParameters)
    else:
        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'])
