def buildProtocol(self, addr):
        """
        Create a L{AccumulatingProtocol} and set it up to be able to perform
        callbacks.
        """
        self.peerAddresses.append(addr)
        self.called += 1
        p = self.protocolFactory()
        p.factory = self
        p.closedDeferred = self.protocolConnectionLost
        self.protocolConnectionLost = None
        self.protocol = p
        return p

        Create a L{AccumulatingProtocol} and set it up to be able to perform
        callbacks.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_tcp.py