summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_email
diff options
context:
space:
mode:
authorR David Murray <rdmurray@bitdance.com>2013-08-22 01:13:51 (GMT)
committerR David Murray <rdmurray@bitdance.com>2013-08-22 01:13:51 (GMT)
commitb8c537094d52dc07434df757c4c29c0f6c6e76d4 (patch)
tree749de3324b11d8af63dbda2e096b6e8a7a9dc329 /Lib/test/test_email
parentcba2e3c2e9f219043ddef0a896748f50691b3c47 (diff)
parent00ae435deef434f471e39bea3f3ab3a3e3cd90fe (diff)
downloadcpython-b8c537094d52dc07434df757c4c29c0f6c6e76d4.zip
cpython-b8c537094d52dc07434df757c4c29c0f6c6e76d4.tar.gz
cpython-b8c537094d52dc07434df757c4c29c0f6c6e76d4.tar.bz2
Merge #18324: set_payload now correctly handles binary input.
Diffstat (limited to 'Lib/test/test_email')
-rw-r--r--Lib/test/test_email/test_email.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/Lib/test/test_email/test_email.py b/Lib/test/test_email/test_email.py
index b2c8b7d..202cee8 100644
--- a/Lib/test/test_email/test_email.py
+++ b/Lib/test/test_email/test_email.py
@@ -620,6 +620,42 @@ class TestMessageAPI(TestEmailBase):
"attachment; filename*=utf-8''Fu%C3%9Fballer%20%5Bfilename%5D.ppt",
msg['Content-Disposition'])
+ def test_binary_quopri_payload(self):
+ for charset in ('latin-1', 'ascii'):
+ msg = Message()
+ msg['content-type'] = 'text/plain; charset=%s' % charset
+ msg['content-transfer-encoding'] = 'quoted-printable'
+ msg.set_payload(b'foo=e6=96=87bar')
+ self.assertEqual(
+ msg.get_payload(decode=True),
+ b'foo\xe6\x96\x87bar',
+ 'get_payload returns wrong result with charset %s.' % charset)
+
+ def test_binary_base64_payload(self):
+ for charset in ('latin-1', 'ascii'):
+ msg = Message()
+ msg['content-type'] = 'text/plain; charset=%s' % charset
+ msg['content-transfer-encoding'] = 'base64'
+ msg.set_payload(b'Zm9v5paHYmFy')
+ self.assertEqual(
+ msg.get_payload(decode=True),
+ b'foo\xe6\x96\x87bar',
+ 'get_payload returns wrong result with charset %s.' % charset)
+
+ def test_binary_uuencode_payload(self):
+ for charset in ('latin-1', 'ascii'):
+ for encoding in ('x-uuencode', 'uuencode', 'uue', 'x-uue'):
+ msg = Message()
+ msg['content-type'] = 'text/plain; charset=%s' % charset
+ msg['content-transfer-encoding'] = encoding
+ msg.set_payload(b"begin 666 -\n)9F]OYI:'8F%R\n \nend\n")
+ self.assertEqual(
+ msg.get_payload(decode=True),
+ b'foo\xe6\x96\x87bar',
+ str(('get_payload returns wrong result ',
+ 'with charset {0} and encoding {1}.')).\
+ format(charset, encoding))
+
def test_add_header_with_name_only_param(self):
msg = Message()
msg.add_header('Content-Disposition', 'inline', foo_bar=None)