diff options
author | Patrick Totzke <patricktotzke@gmail.com> | 2018-12-05 09:33:25 +0000 |
---|---|---|
committer | Patrick Totzke <patricktotzke@gmail.com> | 2018-12-07 20:13:38 +0000 |
commit | fdac378674a3e90413fcfba3dd2c9cc0debbb9cc (patch) | |
tree | b405714c1a66345ab51501c2cbe6b6d74b7dfc00 /tests | |
parent | e7b29f53e9928ddb7b467fcf1bdd1bb650668cba (diff) |
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
Diffstat (limited to 'tests')
-rw-r--r-- | tests/db/utils_test.py | 11 |
1 files changed, 7 insertions, 4 deletions
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: |