diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2018-08-01 11:14:52 -0700 |
---|---|---|
committer | Dylan Baker <dylan@pnwbakers.com> | 2018-08-02 10:51:09 -0700 |
commit | 293bf7ad89c837d6a2ee9e08443c00703172d953 (patch) | |
tree | 8927a34a5b8aca0287e385f834457258cadfc8c4 /tests/helper_test.py | |
parent | 834a658dfbe25707eebed34d5f5fdd10e1fddd60 (diff) |
helper: replace email_as_* with email builtins
Python 3.3 added a new feature to the email module, policies
(https://docs.python.org/3.5/library/email.policy.html). Policy objects
allow precise control over how numerous features work when converting to
and from str or bytes. With the `email.policy.SMTP` the behavior of
email_as_bytes and email_as_string can be achieved using the builtin
`.as_string()` and `.as_bytes()` methods, without custom code or the
need to test it. Additionally these methods handle corner cases that we
don't currently handle, such as multi-part messages with different
encodings.
Fixes #1257
Diffstat (limited to 'tests/helper_test.py')
-rw-r--r-- | tests/helper_test.py | 22 |
1 files changed, 0 insertions, 22 deletions
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): |