diff options
author | Anton Khirnov <anton@khirnov.net> | 2018-11-29 20:05:57 +0100 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2020-02-03 13:00:02 +0100 |
commit | 11c5995ff803850d41eb93e5bfe7488722b11892 (patch) | |
tree | ffca85c217316c434829e7c4c381e6c85974de4c /tests | |
parent | c96eb5766496a050cea2f350bf5ef24b066888cd (diff) |
Let python decode the message transfer encoding.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/db/test_utils.py | 24 |
1 files changed, 5 insertions, 19 deletions
diff --git a/tests/db/test_utils.py b/tests/db/test_utils.py index 98a8247c..5622ff4b 100644 --- a/tests/db/test_utils.py +++ b/tests/db/test_utils.py @@ -732,35 +732,21 @@ class TestRemoveCte(unittest.TestCase): with open('tests/static/mail/broken-utf8.eml') as fp: mail = email.message_from_file(fp) # This should not raise an UnicodeDecodeError. - with self.assertLogs(level='DEBUG') as cm: # keep logs - utils.remove_cte(mail, as_string=True) - # We expect no Exceptions but a complaint in the log - logmsg = 'DEBUG:root:Decoding failure: \'utf-8\' codec can\'t decode '\ - 'byte 0xa1 in position 14: invalid start byte' - self.assertIn(logmsg, cm.output) + payload = utils.remove_cte(mail, as_string=True) + expected = '¡This works!\n\\xa1This doesn\'t!\n' + self.assertEqual(payload, expected) def test_malformed_cte_value(self): with open('tests/static/mail/malformed-header-CTE.eml') as fp: mail = email.message_from_file(fp) - with self.assertLogs(level='INFO') as cm: # keep logs - utils.remove_cte(mail, as_string=True) - - # We expect no Exceptions but a complaint in the log - logmsg = 'INFO:root:Unknown Content-Transfer-Encoding: "7bit;"' - self.assertEqual(cm.output, [logmsg]) + payload = utils.remove_cte(mail, as_string=True) def test_unknown_cte_value(self): with open('tests/static/mail/malformed-header-CTE-2.eml') as fp: mail = email.message_from_file(fp) - with self.assertLogs(level='DEBUG') as cm: # keep logs - utils.remove_cte(mail, as_string=True) - - # We expect no Exceptions but a complaint in the log - logmsg = 'DEBUG:root:failed to interpret Content-Transfer-Encoding: '\ - '"normal"' - self.assertIn(logmsg, cm.output) + payload = utils.remove_cte(mail, as_string=True) class Test_ensure_unique_address(unittest.TestCase): |