mirror of
https://github.com/python/cpython.git
synced 2025-07-24 03:35:53 +00:00
#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.
This commit is contained in:
parent
11c5afd138
commit
aa21297457
4 changed files with 37 additions and 10 deletions
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue