diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/db/utils_test.py | 5 | ||||
-rw-r--r-- | tests/helper_test.py | 22 |
2 files changed, 3 insertions, 24 deletions
diff --git a/tests/db/utils_test.py b/tests/db/utils_test.py index 23885067..7d50d888 100644 --- a/tests/db/utils_test.py +++ b/tests/db/utils_test.py @@ -8,6 +8,7 @@ import codecs import email import email.header import email.mime.application +import email.policy import io import os import os.path @@ -465,7 +466,7 @@ class TestMessageFromFile(TestCaseClassCleanup): text = b'This is some text' t = email.mime.text.MIMEText(text, 'plain', 'utf-8') _, sig = crypto.detached_signature_for( - helper.email_as_bytes(t), self.keys) + t.as_bytes(policy=email.policy.SMTP), self.keys) s = email.mime.application.MIMEApplication( sig, 'pgp-signature', email.encoders.encode_7or8bit) m = email.mime.multipart.MIMEMultipart('signed', None, [t, s]) @@ -555,7 +556,7 @@ class TestMessageFromFile(TestCaseClassCleanup): else: text = b'This is some text' t = email.mime.text.MIMEText(text, 'plain', 'utf-8') - enc = crypto.encrypt(helper.email_as_bytes(t), self.keys) + enc = crypto.encrypt(t.as_bytes(policy=email.policy.SMTP), self.keys) e = email.mime.application.MIMEApplication( enc, 'octet-stream', email.encoders.encode_7or8bit) diff --git a/tests/helper_test.py b/tests/helper_test.py index b47e5eff..b87d77af 100644 --- a/tests/helper_test.py +++ b/tests/helper_test.py @@ -383,28 +383,6 @@ class TestCallCmd(unittest.TestCase): self.assertEqual(code, 42) -class TestEmailAsString(unittest.TestCase): - - def test_empty_message(self): - message = email.message.Message() - actual = helper.email_as_string(message) - expected = '\r\n' - self.assertEqual(actual, expected) - - def test_empty_message_with_unicode_header(self): - """Test if unicode header keys can be used in an email that is - converted to string with email_as_string().""" - # This is what alot.db.envelope.Envelope.construct_mail() currently - # does: It constructs a message object and then copies all headers from - # the envelope to the message object. Some header names are stored as - # unicode in the envelope. - message = email.message.Message() - message[u'X-Unicode-Header'] = 'dummy value' - actual = helper.email_as_string(message) - expected = 'X-Unicode-Header: dummy value\r\n\r\n' - self.assertEqual(actual, expected) - - class TestShorten(unittest.TestCase): def test_lt_maxlen(self): |