def test_callbackSpooledToDisk(self):
        """
        A L{imap4.LiteralFile} whose size exceeds the maximum
        in-memory size spools its content to disk, and invoking its
        L{callback} with a line fires the instance's L{Deferred} with
        a 2-L{tuple} whose first element is the spooled file and whose second
        is the provided line.
        """
        data = b"data"
        extra = b"extra"

        self.patch(imap4.LiteralFile, "_memoryFileLimit", 1)

        literal = imap4.LiteralFile(len(data), self.deferred)

        for c in iterbytes(data):
            literal.write(c)

        literal.callback(b"extra")

        result = self.successResultOf(self.deferred)
        self.assertEqual(len(result), 2)

        dataFile, extra = result
        self.assertEqual(dataFile.read(), b"data")

        A L{imap4.LiteralFile} whose size exceeds the maximum
        in-memory size spools its content to disk, and invoking its
        L{callback} with a line fires the instance's L{Deferred} with
        a 2-L{tuple} whose first element is the spooled file and whose second
        is the provided line.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/mail/test/test_imap.py