summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_email/test_message.py
diff options
context:
space:
mode:
authorR David Murray <rdmurray@bitdance.com>2016-09-08 01:15:59 (GMT)
committerR David Murray <rdmurray@bitdance.com>2016-09-08 01:15:59 (GMT)
commit29d1bc0842e5b086813aa7de4ab18f1c192d2291 (patch)
treeb812609f72f860adb5203ba9cbb1d0c4299e39af /Lib/test/test_email/test_message.py
parent23e863378124229928e12b72c22df33f1428c61e (diff)
downloadcpython-29d1bc0842e5b086813aa7de4ab18f1c192d2291.zip
cpython-29d1bc0842e5b086813aa7de4ab18f1c192d2291.tar.gz
cpython-29d1bc0842e5b086813aa7de4ab18f1c192d2291.tar.bz2
#24277: The new email API is no longer provisional.
This is a wholesale reorganization and editing of the email documentation to make the new API the standard one, and the old API the 'legacy' one. The default is still the compat32 policy, for backward compatibility. We will change that eventually.
Diffstat (limited to 'Lib/test/test_email/test_message.py')
-rw-r--r--Lib/test/test_email/test_message.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/Lib/test/test_email/test_message.py b/Lib/test/test_email/test_message.py
index 4345162..f3a57df 100644
--- a/Lib/test/test_email/test_message.py
+++ b/Lib/test/test_email/test_message.py
@@ -764,6 +764,26 @@ class TestEmailMessage(TestEmailMessageBase, TestEmailBase):
m.set_content(content_manager=cm)
self.assertEqual(m['MIME-Version'], '1.0')
+ def test_as_string_uses_max_header_length_by_default(self):
+ m = self._str_msg('Subject: long line' + ' ab'*50 + '\n\n')
+ self.assertEqual(len(m.as_string().strip().splitlines()), 3)
+
+ def test_as_string_allows_maxheaderlen(self):
+ m = self._str_msg('Subject: long line' + ' ab'*50 + '\n\n')
+ self.assertEqual(len(m.as_string(maxheaderlen=0).strip().splitlines()),
+ 1)
+ self.assertEqual(len(m.as_string(maxheaderlen=34).strip().splitlines()),
+ 6)
+
+ def test_str_defaults_to_policy_max_line_length(self):
+ m = self._str_msg('Subject: long line' + ' ab'*50 + '\n\n')
+ self.assertEqual(len(str(m).strip().splitlines()), 3)
+
+ def test_str_defaults_to_utf8(self):
+ m = EmailMessage()
+ m['Subject'] = 'unicöde'
+ self.assertEqual(str(m), 'Subject: unicöde\n\n')
+
class TestMIMEPart(TestEmailMessageBase, TestEmailBase):
# Doing the full test run here may seem a bit redundant, since the two