Skip to content

Commit 209cec8

Browse files
miss-islington180909asvetlov
authored
[3.9] bpo-19460: Add test for MIMENonMultipart (GH-29817) (#29819)
* bpo-19460: Add test for MIMENonMultipart (GH-29817) (cherry picked from commit 46c8d91) Co-authored-by: 180909 <wjh180909@gmail.com> * Update 2021-11-28-15-25-02.bpo-19460.lr0aWs.rst Co-authored-by: 180909 <wjh180909@gmail.com> Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
1 parent 86c1265 commit 209cec8

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

Lib/test/test_email/test_email.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2742,6 +2742,20 @@ def test_multipart_custom_policy(self):
27422742
self.assertEqual(str(cm.exception),
27432743
'There may be at most 1 To headers in a message')
27442744

2745+
2746+
# Test the NonMultipart class
2747+
class TestNonMultipart(TestEmailBase):
2748+
def test_nonmultipart_is_not_multipart(self):
2749+
msg = MIMENonMultipart('text', 'plain')
2750+
self.assertFalse(msg.is_multipart())
2751+
2752+
def test_attach_raises_exception(self):
2753+
msg = Message()
2754+
msg['Subject'] = 'subpart 1'
2755+
r = MIMENonMultipart('text', 'plain')
2756+
self.assertRaises(errors.MultipartConversionError, r.attach, msg)
2757+
2758+
27452759
# A general test of parser->model->generator idempotency. IOW, read a message
27462760
# in, parse it into a message object tree, then without touching the tree,
27472761
# regenerate the plain text. The original text and the transformed text
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add new Test for :class:`email.mime.nonmultipart.MIMENonMultipart`.

0 commit comments

Comments
 (0)