def test_unsolicitedResponseMixedWithSolicitedResponse(self):
        """
        If unsolicited data is received along with solicited data in the
        response to a I{FETCH} command issued by L{IMAP4Client.fetchSpecific},
        the unsolicited data is passed to the appropriate callback and not
        included in the result with which the L{Deferred} returned by
        L{IMAP4Client.fetchSpecific} fires.
        """
        transport = StringTransport()
        c = StillSimplerClient()
        c.makeConnection(transport)
        c.lineReceived(b'* OK [IMAP4rev1]')

        def login():
            d = c.login(b'blah', b'blah')
            c.dataReceived(b'0001 OK LOGIN\r\n')
            return d
        def select():
            d = c.select('inbox')
            c.lineReceived(b'0002 OK SELECT')
            return d
        def fetch():
            d = c.fetchSpecific('1:*',
                headerType = 'HEADER.FIELDS',
                headerArgs = ['SUBJECT'])
            c.dataReceived(b'* 1 FETCH (BODY[HEADER.FIELDS ("SUBJECT")] {38}\r\n')
            c.dataReceived(b'Subject: Suprise for your woman...\r\n')
            c.dataReceived(b'\r\n')
            c.dataReceived(b')\r\n')
            c.dataReceived(b'* 1 FETCH (FLAGS (\Seen))\r\n')
            c.dataReceived(b'* 2 FETCH (BODY[HEADER.FIELDS ("SUBJECT")] {75}\r\n')
            c.dataReceived(b'Subject: What you been doing. Order your meds here . ,. handcuff madsen\r\n')
            c.dataReceived(b'\r\n')
            c.dataReceived(b')\r\n')
            c.dataReceived(b'0003 OK FETCH completed\r\n')
            return d
        def test(res):
            self.assertEqual(
                transport.value().splitlines()[-1],
                b"0003 FETCH 1:* BODY[HEADER.FIELDS (SUBJECT)]",
            )

            self.assertEqual(res, {
                1: [['BODY', ['HEADER.FIELDS', ['SUBJECT']],
                    'Subject: Suprise for your woman...\r\n\r\n']],
                2: [['BODY', ['HEADER.FIELDS', ['SUBJECT']],
                    'Subject: What you been doing. Order your meds here . ,. handcuff madsen\r\n\r\n']]
            })

            self.assertEqual(c.flags, {1: ['\\Seen']})

        return login(
            ).addCallback(strip(select)
            ).addCallback(strip(fetch)
            ).addCallback(test)

        If unsolicited data is received along with solicited data in the
        response to a I{FETCH} command issued by L{IMAP4Client.fetchSpecific},
        the unsolicited data is passed to the appropriate callback and not
        included in the result with which the L{Deferred} returned by
        L{IMAP4Client.fetchSpecific} fires.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/mail/test/test_imap.py