def test_connectFailure(self):
        """
        In case of failure, L{ProcessEndpoint.connect} returns a Deferred that
        fails.
        """

        def testSpawnProcess(pp, executable, args, env, path,
                             uid, gid, usePTY, childFDs):
            raise Exception()

        self.ep._spawnProcess = testSpawnProcess
        d = self.ep.connect(self.factory)
        error = self.failureResultOf(d)
        error.trap(Exception)

        In case of failure, L{ProcessEndpoint.connect} returns a Deferred that
        fails.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/internet/test/test_endpoints.py