[3.10] bpo-19460: Add test for MIMENonMultipart (GH-29817) (GH-29818)

Co-authored-by: 180909 <wjh180909@gmail.com>
Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
This commit is contained in:
Miss Islington (bot) 2021-11-28 02:57:10 -08:00 committed by GitHub
parent 545aebd2ec
commit 2c398a5acf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 0 deletions

View file

@ -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

View file

@ -0,0 +1 @@
Add new Test for :class:`email.mime.nonmultipart.MIMENonMultipart`.