def test_exception_handler_exception(self):
handler = ErroringErrorHandler()
controller = ErrorController(handler)
controller.start()
self.addCleanup(controller.stop)
with ExitStack() as resources:
# Suppress logging to the console during the tests. Depending on
# timing, the exception may or may not be logged.
resources.enter_context(patch('aiosmtpd.smtp.log.exception'))
client = resources.enter_context(
SMTP(controller.hostname, controller.port))
code, response = client.helo('example.com')
self.assertEqual(code, 500)
self.assertEqual(response,
b'Error: (ValueError) ErroringErrorHandler test')
self.assertIsInstance(handler.error, ValueError)
评论列表
文章目录