def buildProtocol(self, addr):
        """
        Create the protocol instance, keeps track of it, and makes it use
        C{clientFactoryInstance} as client factory.
        """
        proto = portforward.ProxyFactory.buildProtocol(self, addr)
        self.clientFactoryInstance = TestableProxyClientFactory()
        # Force the use of this specific instance
        proto.clientProtocolFactory = lambda: self.clientFactoryInstance
        self.protoInstance = proto
        return proto

        Create the protocol instance, keeps track of it, and makes it use
        C{clientFactoryInstance} as client factory.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_protocols.py