test_accessors.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:cyphon 作者: dunbarcyber 项目源码 文件源码
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),
                )
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号