def test_setupEnvironment(self):
        """
        L{UnixApplicationRunner.startApplication} calls
        L{UnixApplicationRunner.setupEnvironment} with the chroot, rundir,
        nodaemon, umask, and pidfile parameters from the configuration it is
        constructed with.
        """
        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
        if _PY3:
            setupEnvironmentParameters = \
                inspect.signature(self.runner.setupEnvironment).parameters
            fakeSetupEnvironmentParameters = \
                inspect.signature(fakeSetupEnvironment).parameters

            # inspect.signature() does not return "self" in the signature of
            # a class method, so we need to omit  it when comparing the
            # the signature of a plain method
            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'])

        L{UnixApplicationRunner.startApplication} calls
        L{UnixApplicationRunner.setupEnvironment} with the chroot, rundir,
        nodaemon, umask, and pidfile parameters from the configuration it is
        constructed with.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_twistd.py