From: Barry Warsaw Date: Fri, 22 Mar 2002 16:19:30 +0000 (+0000) Subject: test_no_parts_in_a_multipart(): A test for the layout of a X-Git-Tag: v2.2.1c2~57 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=25cf603523bf7bf715589fdcf2911e0be7552172;p=thirdparty%2FPython%2Fcpython.git test_no_parts_in_a_multipart(): A test for the layout of a multipart/mixed message with no attachments. test_one_part_in_a_multipart(): A test for the layout of a multipart/mixed message with a single attachment. test_seq_parts_in_a_multipart(): A test for the layout of a multipart/mixed message with a single attachment that happens to be a sequence of length one. These tests ensure no regressions on the fix for SF bug #531966. I will merge these into the standalone email package and Python 2.3 trunk separately. --- diff --git a/Lib/test/test_email.py b/Lib/test/test_email.py index 7105f7d4b31b..5155680bfc41 100644 --- a/Lib/test/test_email.py +++ b/Lib/test/test_email.py @@ -539,6 +539,82 @@ This is the dingus fish. unless(not m0.is_multipart()) unless(not m1.is_multipart()) + def test_no_parts_in_a_multipart(self): + outer = MIMEBase('multipart', 'mixed') + outer['Subject'] = 'A subject' + outer['To'] = 'aperson@dom.ain' + outer['From'] = 'bperson@dom.ain' + outer.preamble = '' + outer.epilogue = '' + outer.set_boundary('BOUNDARY') + msg = MIMEText('hello world') + self.assertEqual(outer.as_string(), '''\ +Content-Type: multipart/mixed; boundary="BOUNDARY" +MIME-Version: 1.0 +Subject: A subject +To: aperson@dom.ain +From: bperson@dom.ain + +--BOUNDARY + + +--BOUNDARY-- +''') + + def test_one_part_in_a_multipart(self): + outer = MIMEBase('multipart', 'mixed') + outer['Subject'] = 'A subject' + outer['To'] = 'aperson@dom.ain' + outer['From'] = 'bperson@dom.ain' + outer.preamble = '' + outer.epilogue = '' + outer.set_boundary('BOUNDARY') + msg = MIMEText('hello world') + outer.attach(msg) + self.assertEqual(outer.as_string(), '''\ +Content-Type: multipart/mixed; boundary="BOUNDARY" +MIME-Version: 1.0 +Subject: A subject +To: aperson@dom.ain +From: bperson@dom.ain + +--BOUNDARY +Content-Type: text/plain; charset="us-ascii" +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit + +hello world + +--BOUNDARY-- +''') + + def test_seq_parts_in_a_multipart(self): + outer = MIMEBase('multipart', 'mixed') + outer['Subject'] = 'A subject' + outer['To'] = 'aperson@dom.ain' + outer['From'] = 'bperson@dom.ain' + outer.preamble = '' + outer.epilogue = '' + msg = MIMEText('hello world') + outer.attach([msg]) + outer.set_boundary('BOUNDARY') + self.assertEqual(outer.as_string(), '''\ +Content-Type: multipart/mixed; boundary="BOUNDARY" +MIME-Version: 1.0 +Subject: A subject +To: aperson@dom.ain +From: bperson@dom.ain + +--BOUNDARY +Content-Type: text/plain; charset="us-ascii" +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit + +hello world + +--BOUNDARY-- +''') + # Test some badly formatted messages