diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2021-11-28 14:33:50 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-28 14:33:50 (GMT) |
commit | 209cec8a2a2e845df5af764a9171af05a2a4c8e3 (patch) | |
tree | 0bda7654be71e501f9fe2544d02a8a50758dd842 | |
parent | 86c1265cdc64030c8921e0da5fcae2ac64299c26 (diff) | |
download | cpython-209cec8a2a2e845df5af764a9171af05a2a4c8e3.zip cpython-209cec8a2a2e845df5af764a9171af05a2a4c8e3.tar.gz cpython-209cec8a2a2e845df5af764a9171af05a2a4c8e3.tar.bz2 |
[3.9] bpo-19460: Add test for MIMENonMultipart (GH-29817) (#29819)
* bpo-19460: Add test for MIMENonMultipart (GH-29817)
(cherry picked from commit 46c8d915715aa2bd4d697482aa051fe974d440e1)
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>
-rw-r--r-- | Lib/test/test_email/test_email.py | 14 | ||||
-rw-r--r-- | Misc/NEWS.d/next/Tests/2021-11-28-15-25-02.bpo-19460.lr0aWs.rst | 1 |
2 files changed, 15 insertions, 0 deletions
diff --git a/Lib/test/test_email/test_email.py b/Lib/test/test_email/test_email.py index bc062b5..489cd05 100644 --- a/Lib/test/test_email/test_email.py +++ b/Lib/test/test_email/test_email.py @@ -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 diff --git a/Misc/NEWS.d/next/Tests/2021-11-28-15-25-02.bpo-19460.lr0aWs.rst b/Misc/NEWS.d/next/Tests/2021-11-28-15-25-02.bpo-19460.lr0aWs.rst new file mode 100644 index 0000000..b082d6d --- /dev/null +++ b/Misc/NEWS.d/next/Tests/2021-11-28-15-25-02.bpo-19460.lr0aWs.rst @@ -0,0 +1 @@ +Add new Test for :class:`email.mime.nonmultipart.MIMENonMultipart`. |