summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
author180909 <wjh180909@gmail.com>2021-11-28 09:24:41 (GMT)
committerGitHub <noreply@github.com>2021-11-28 09:24:41 (GMT)
commit46c8d915715aa2bd4d697482aa051fe974d440e1 (patch)
tree4d406314b10f5ef1ecbb295679b47020f176b52f /Lib
parent4dfae6f38e1720ddafcdd68043e476ecb41cb4d5 (diff)
downloadcpython-46c8d915715aa2bd4d697482aa051fe974d440e1.zip
cpython-46c8d915715aa2bd4d697482aa051fe974d440e1.tar.gz
cpython-46c8d915715aa2bd4d697482aa051fe974d440e1.tar.bz2
bpo-19460: Add test for MIMENonMultipart (GH-29817)
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_email/test_email.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/Lib/test/test_email/test_email.py b/Lib/test/test_email/test_email.py
index 54ffcdc..a3ccbbb 100644
--- a/Lib/test/test_email/test_email.py
+++ b/Lib/test/test_email/test_email.py
@@ -2743,6 +2743,20 @@ message 2
self.assertEqual(str(cm.exception),
'There may be at most 1 To headers in a message')
+
+# Test the NonMultipart class
+class TestNonMultipart(TestEmailBase):
+ def test_nonmultipart_is_not_multipart(self):
+ msg = MIMENonMultipart('text', 'plain')
+ self.assertFalse(msg.is_multipart())
+
+ def test_attach_raises_exception(self):
+ msg = Message()
+ msg['Subject'] = 'subpart 1'
+ r = MIMENonMultipart('text', 'plain')
+ self.assertRaises(errors.MultipartConversionError, r.attach, msg)
+
+
# A general test of parser->model->generator idempotency. IOW, read a message
# in, parse it into a message object tree, then without touching the tree,
# regenerate the plain text. The original text and the transformed text