Skip to content

Commit 2c398a5

Browse files
miss-islington180909asvetlov
authored
[3.10] bpo-19460: Add test for MIMENonMultipart (GH-29817) (GH-29818)
Co-authored-by: 180909 <[email protected]> Co-authored-by: Andrew Svetlov <[email protected]>
1 parent 545aebd commit 2c398a5

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
@@ -2743,6 +2743,20 @@ def test_multipart_custom_policy(self):
27432743
self.assertEqual(str(cm.exception),
27442744
'There may be at most 1 To headers in a message')
27452745

2746+
2747+
# Test the NonMultipart class
2748+
class TestNonMultipart(TestEmailBase):
2749+
def test_nonmultipart_is_not_multipart(self):
2750+
msg = MIMENonMultipart('text', 'plain')
2751+
self.assertFalse(msg.is_multipart())
2752+
2753+
def test_attach_raises_exception(self):
2754+
msg = Message()
2755+
msg['Subject'] = 'subpart 1'
2756+
r = MIMENonMultipart('text', 'plain')
2757+
self.assertRaises(errors.MultipartConversionError, r.attach, msg)
2758+
2759+
27462760
# A general test of parser->model->generator idempotency. IOW, read a message
27472761
# in, parse it into a message object tree, then without touching the tree,
27482762
# 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)