diff options
author | R David Murray <rdmurray@bitdance.com> | 2014-02-07 15:44:16 (GMT) |
---|---|---|
committer | R David Murray <rdmurray@bitdance.com> | 2014-02-07 15:44:16 (GMT) |
commit | aa21297457ef0e5647602e19a89c4b797183c16e (patch) | |
tree | c670249e97be11f526b9df3c5443dfd7f8e39f53 /Lib/test/test_email | |
parent | 11c5afd1383656e78d35a8405729c207d2287bdd (diff) | |
download | cpython-aa21297457ef0e5647602e19a89c4b797183c16e.zip cpython-aa21297457ef0e5647602e19a89c4b797183c16e.tar.gz cpython-aa21297457ef0e5647602e19a89c4b797183c16e.tar.bz2 |
#20476: use EmailMessage as factory if non-compat32 policy is used.
In 3.5 I will fix this right by adding a message_factory attribute
to the policy.
Diffstat (limited to 'Lib/test/test_email')
-rw-r--r-- | Lib/test/test_email/test_message.py | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/Lib/test/test_email/test_message.py b/Lib/test/test_email/test_message.py index e0ebb8a..c761c62 100644 --- a/Lib/test/test_email/test_message.py +++ b/Lib/test/test_email/test_message.py @@ -1,6 +1,6 @@ import unittest import textwrap -from email import policy +from email import policy, message_from_string from email.message import EmailMessage, MIMEPart from test.test_email import TestEmailBase, parameterize @@ -20,6 +20,20 @@ class Test(TestEmailBase): with self.assertRaises(ValueError): m['To'] = 'xyz@abc' + def test_rfc2043_auto_decoded_and_emailmessage_used(self): + m = message_from_string(textwrap.dedent("""\ + Subject: Ayons asperges pour le =?utf-8?q?d=C3=A9jeuner?= + From: =?utf-8?q?Pep=C3=A9?= Le Pew <pepe@example.com> + To: "Penelope Pussycat" <"penelope@example.com"> + MIME-Version: 1.0 + Content-Type: text/plain; charset="utf-8" + + sample text + """), policy=policy.default) + self.assertEqual(m['subject'], "Ayons asperges pour le déjeuner") + self.assertEqual(m['from'], "Pepé Le Pew <pepe@example.com>") + self.assertIsInstance(m, EmailMessage) + @parameterize class TestEmailMessageBase: |