Skip to content

Commit

Permalink
refactor test_issue_1291
Browse files Browse the repository at this point in the history
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
  • Loading branch information
pazz committed Dec 7, 2018
1 parent e7b29f5 commit fdac378
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions tests/db/utils_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -732,13 +732,16 @@ def test(self):

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:
Expand Down

0 comments on commit fdac378

Please sign in to comment.