mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
[3.9] bpo-19460: Add test for MIMENonMultipart (GH-29817) (#29819)
* bpo-19460: Add test for MIMENonMultipart (GH-29817)
(cherry picked from commit 46c8d91571
)
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>
This commit is contained in:
parent
86c1265cdc
commit
209cec8a2a
2 changed files with 15 additions and 0 deletions
|
@ -2742,6 +2742,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
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Add new Test for :class:`email.mime.nonmultipart.MIMENonMultipart`.
|
Loading…
Add table
Add a link
Reference in a new issue