diff options
author | R David Murray <rdmurray@bitdance.com> | 2013-06-27 22:38:36 (GMT) |
---|---|---|
committer | R David Murray <rdmurray@bitdance.com> | 2013-06-27 22:38:36 (GMT) |
commit | c723da361a8d5129ec9bd336e6327a65b4e92148 (patch) | |
tree | 2dca9621ff0ad08f1463735ff97e7e369ad2125c /Lib/test/test_email | |
parent | cd83fa8c3e8509418215c55b89e52160dc38e50d (diff) | |
parent | f6069f9f22a81a0b9f81a1cc43fb0896e70f5379 (diff) | |
download | cpython-c723da361a8d5129ec9bd336e6327a65b4e92148.zip cpython-c723da361a8d5129ec9bd336e6327a65b4e92148.tar.gz cpython-c723da361a8d5129ec9bd336e6327a65b4e92148.tar.bz2 |
Merge #14360: make encoders.encode_quopri work.
Diffstat (limited to 'Lib/test/test_email')
-rw-r--r-- | Lib/test/test_email/test_email.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/Lib/test/test_email/test_email.py b/Lib/test/test_email/test_email.py index eaed26f..78b86b8 100644 --- a/Lib/test/test_email/test_email.py +++ b/Lib/test/test_email/test_email.py @@ -1474,6 +1474,35 @@ class TestMIMEApplication(unittest.TestCase): self.assertEqual(msg.get_payload(), '\uFFFD' * len(bytesdata)) self.assertEqual(msg2.get_payload(decode=True), bytesdata) + def test_binary_body_with_encode_quopri(self): + # Issue 14360. + bytesdata = b'\xfa\xfb\xfc\xfd\xfe\xff ' + msg = MIMEApplication(bytesdata, _encoder=encoders.encode_quopri) + self.assertEqual(msg.get_payload(), '=FA=FB=FC=FD=FE=FF=20') + self.assertEqual(msg.get_payload(decode=True), bytesdata) + self.assertEqual(msg['Content-Transfer-Encoding'], 'quoted-printable') + s = BytesIO() + g = BytesGenerator(s) + g.flatten(msg) + wireform = s.getvalue() + msg2 = email.message_from_bytes(wireform) + self.assertEqual(msg.get_payload(), '=FA=FB=FC=FD=FE=FF=20') + self.assertEqual(msg2.get_payload(decode=True), bytesdata) + self.assertEqual(msg2['Content-Transfer-Encoding'], 'quoted-printable') + + def test_binary_body_with_encode_base64(self): + bytesdata = b'\xfa\xfb\xfc\xfd\xfe\xff' + msg = MIMEApplication(bytesdata, _encoder=encoders.encode_base64) + self.assertEqual(msg.get_payload(), '+vv8/f7/\n') + self.assertEqual(msg.get_payload(decode=True), bytesdata) + s = BytesIO() + g = BytesGenerator(s) + g.flatten(msg) + wireform = s.getvalue() + msg2 = email.message_from_bytes(wireform) + self.assertEqual(msg.get_payload(), '+vv8/f7/\n') + self.assertEqual(msg2.get_payload(decode=True), bytesdata) + # Test the basic MIMEText class class TestMIMEText(unittest.TestCase): |