summaryrefslogtreecommitdiff
path: root/Lib/test/test_email
diff options
context:
space:
mode:
authorR David Murray <rdmurray@bitdance.com>2016-09-07 21:15:59 -0400
committerR David Murray <rdmurray@bitdance.com>2016-09-07 21:15:59 -0400
commit29d1bc0842e5b086813aa7de4ab18f1c192d2291 (patch)
treeb812609f72f860adb5203ba9cbb1d0c4299e39af /Lib/test/test_email
parent23e863378124229928e12b72c22df33f1428c61e (diff)
downloadcpython-git-29d1bc0842e5b086813aa7de4ab18f1c192d2291.tar.gz
#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')
-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 434516226c..f3a57df9e9 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