def test_checkFail(self):
        """
        Trigger the L{imap.IMAP4Server._ebSelectWork} errback
        by failing when we select an mbox.
        """
        def failSelect(self, name, rw=1):
            raise imap4.IllegalMailboxEncoding("encoding")

        def checkResponse(ignore):
            failures = self.flushLoggedErrors()
            self.assertEqual(failures[1].value.args[0],
                             b'SELECT failed: Server error')

        self.patch(Account, "select", failSelect)
        d = self._testCheck()
        return d.addCallback(checkResponse)

        Trigger the L{imap.IMAP4Server._ebSelectWork} errback
        by failing when we select an mbox.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/mail/test/test_imap.py