From fdac378674a3e90413fcfba3dd2c9cc0debbb9cc Mon Sep 17 00:00:00 2001 From: Patrick Totzke Date: Wed, 5 Dec 2018 09:33:25 +0000 Subject: refactor test_issue_1291 this is now test_char_vs_cte_mismatch; It checks if a mime part contains a character which is not encoded in the encoding declared in the Content-Transfer-Encoding header --- tests/db/utils_test.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/db/utils_test.py b/tests/db/utils_test.py index 6656aae5..463d1075 100644 --- a/tests/db/utils_test.py +++ b/tests/db/utils_test.py @@ -732,13 +732,16 @@ class TestMessageFromString(unittest.TestCase): class TestRemoveCte(unittest.TestCase): - @unittest.expectedFailure - def test_issue_1291(self): + def test_char_vs_cte_mismatch(self): # #1291 with open('tests/static/mail/broken-utf8.eml') as fp: mail = email.message_from_file(fp) # This should not raise an UnicodeDecodeError. - utils.remove_cte(mail, as_string=True) - self.assertTrue(True) + 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) def test_malformed_cte_value(self): with open('tests/static/mail/malformed-header-CTE.eml') as fp: -- cgit v1.2.3