def test_removeCurrentProtocolWhenClientConnectionFailed(self):
        """
        L{smtp.SMTPSenderFactory} removes the current protocol when the client
        connection is failed.
        """
        reactor = MemoryReactor()
        sentDeferred = defer.Deferred()
        clientFactory = smtp.SMTPSenderFactory(
            "source@address", "recipient@address",
            BytesIO(b"message"), sentDeferred)
        connector = reactor.connectTCP("localhost", 25, clientFactory)
        clientFactory.buildProtocol(None)
        clientFactory.clientConnectionFailed(connector,
                                             error.ConnectionDone("Bye."))
        self.assertEqual(clientFactory.currentProtocol, None)

        L{smtp.SMTPSenderFactory} removes the current protocol when the client
        connection is failed.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/mail/test/test_smtp.py