def test_literalWithoutPrecedingWhitespace(self):
        """
        Literals should be recognized even when they are not preceded by
        whitespace.
        """
        transport = StringTransport()
        protocol = imap4.IMAP4Client()

        protocol.makeConnection(transport)
        protocol.lineReceived(b'* OK [IMAP4rev1]')

        def login():
            d = protocol.login(b'blah', b'blah')
            protocol.dataReceived(b'0001 OK LOGIN\r\n')
            return d
        def select():
            d = protocol.select(b'inbox')
            protocol.lineReceived(b'0002 OK SELECT')
            return d
        def fetch():
            d = protocol.fetchSpecific('1:*',
                headerType='HEADER.FIELDS',
                headerArgs=['SUBJECT'])
            protocol.dataReceived(
                b'* 1 FETCH (BODY[HEADER.FIELDS ({7}\r\nSUBJECT)] "Hello")\r\n')
            protocol.dataReceived(b'0003 OK FETCH completed\r\n')
            return d
        def test(result):
            self.assertEqual(
                transport.value().splitlines()[-1],
                b"0003 FETCH 1:* BODY[HEADER.FIELDS (SUBJECT)]",
            )
            self.assertEqual(
                result,  {1: [['BODY', ['HEADER.FIELDS', ['SUBJECT']], 'Hello']]})

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

        Literals should be recognized even when they are not preceded by
        whitespace.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/mail/test/test_imap.py