summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/db/test_utils.py24
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):