Skip to content

bpo-19460: Add test for MIMENonMultipart #29817

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions Lib/test/test_email/test_email.py
Original file line number Diff line number Diff line change
Expand Up @@ -2743,6 +2743,20 @@ def test_multipart_custom_policy(self):
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
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add new Test for ``Lib/email/mime/nonmultipart.py::MIMENonMultipart``.