def test_decode_error(self):
"""
Tests the get_email_value function when a UnicodeDecodeError is
raised.
"""
error = UnicodeDecodeError('funnycodec', b'\x00\x00', 1, 2,
'Something went wrong!')
with patch('sifter.mailsifter.accessors.bleach.clean',
side_effect=error):
with LogCapture() as log_capture:
actual = accessors.get_email_value('Subject', {'Subject': 'test'})
expected = 'The Subject of this email could not be displayed ' + \
'due to an error.'
self.assertEqual(actual, expected)
msg = ('An error was encountered while parsing the '
'Subject field of an email.')
log_capture.check(
('sifter.mailsifter.accessors', 'ERROR', msg),
)
评论列表
文章目录