def test_loginBeforeSTARTTLS(self):
        """
        A client that attempts to log in before issuing the
        C{STARTTLS} command receives a C{NO} response.
        """
        # Prevent the client from issuing STARTTLS.
        self.client.startTLS = lambda: defer.succeed(
            ([], 'OK Begin TLS negotiation now')
        )
        self.connected.addCallback(
            lambda _: self.client.login(b"wrong", b"time"),
        )

        self.connected.addErrback(
            self.assertClientFailureMessage,
            b"LOGIN is disabled before STARTTLS",
        )

        self.connected.addCallback(self._cbStopClient)
        self.connected.addErrback(self._ebGeneral)

        return defer.gatherResults([self.loopback(), self.connected])

        A client that attempts to log in before issuing the
        C{STARTTLS} command receives a C{NO} response.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/mail/test/test_imap.py