summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_email
diff options
context:
space:
mode:
authorMark Sapiro <mark@msapiro.net>2020-07-08 21:00:35 (GMT)
committerGitHub <noreply@github.com>2020-07-08 21:00:35 (GMT)
commit4fa61a7732923f92de0f7830c12da48c4cec937f (patch)
treed30bb0fc4c447bab77c7d376886ff23fb3e90e47 /Lib/test/test_email
parent61fc23ca106bc82955b0e59d1ab42285b94899e2 (diff)
downloadcpython-4fa61a7732923f92de0f7830c12da48c4cec937f.zip
cpython-4fa61a7732923f92de0f7830c12da48c4cec937f.tar.gz
cpython-4fa61a7732923f92de0f7830c12da48c4cec937f.tar.bz2
bpo-40597: Allow email.contextmanager set_content() to set a null string. (GH-20542)
Diffstat (limited to 'Lib/test/test_email')
-rw-r--r--Lib/test/test_email/test_contentmanager.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/Lib/test/test_email/test_contentmanager.py b/Lib/test/test_email/test_contentmanager.py
index 64dca2d..f4f6bb7 100644
--- a/Lib/test/test_email/test_contentmanager.py
+++ b/Lib/test/test_email/test_contentmanager.py
@@ -303,6 +303,19 @@ class TestRawDataManager(TestEmailBase):
self.assertEqual(m.get_payload(decode=True).decode('utf-8'), content)
self.assertEqual(m.get_content(), content)
+ def test_set_text_plain_null(self):
+ m = self._make_message()
+ content = ''
+ raw_data_manager.set_content(m, content)
+ self.assertEqual(str(m), textwrap.dedent("""\
+ Content-Type: text/plain; charset="utf-8"
+ Content-Transfer-Encoding: 7bit
+
+
+ """))
+ self.assertEqual(m.get_payload(decode=True).decode('utf-8'), '\n')
+ self.assertEqual(m.get_content(), '\n')
+
def test_set_text_html(self):
m = self._make_message()
content = "<p>Simple message.</p>\n"