cpython: de2cd04e5101 (original) (raw)
Mercurial > cpython
changeset 68617:de2cd04e5101
Merge #9298 fix. [#9298]
R David Murray rdmurray@bitdance.com | |
---|---|
date | Wed, 16 Mar 2011 16:14:43 -0400 |
parents | 8d13741a3b83(current diff)c34320d9095e(diff) |
children | 84b7a68445aa |
files | Lib/email/test/test_email.py Misc/ACKS Misc/NEWS |
diffstat | 4 files changed, 21 insertions(+), 6 deletions(-)[+] [-] Lib/email/encoders.py 2 Lib/email/test/test_email.py 20 Misc/ACKS 1 Misc/NEWS 4 |
line wrap: on
line diff
--- a/Lib/email/encoders.py +++ b/Lib/email/encoders.py @@ -12,7 +12,7 @@ ] -from base64 import b64encode as _bencode +from base64 import encodebytes as _bencode from quopri import encodestring as _encodestring
--- a/Lib/email/test/test_email.py +++ b/Lib/email/test/test_email.py @@ -573,9 +573,18 @@ class TestMessageAPI(TestEmailBase): msg['Dummy'] = 'dummy\nX-Injected-Header: test' self.assertRaises(errors.HeaderParseError, msg.as_string) -
Test the email.encoders module
class TestEncoders(unittest.TestCase): +
- def test_EncodersEncode_base64(self):
with openfile('PyBanner048.gif', 'rb') as fp:[](#l2.12)
bindata = fp.read()[](#l2.13)
mimed = email.mime.image.MIMEImage(bindata)[](#l2.14)
base64ed = mimed.get_payload()[](#l2.15)
# the transfer-encoded body lines should all be <=76 characters[](#l2.16)
lines = base64ed.split('\n')[](#l2.17)
self.assertLessEqual(max([ len(x) for x in lines ]), 76)[](#l2.18)
+ def test_encode_empty_payload(self): eq = self.assertEqual msg = Message() @@ -1141,10 +1150,11 @@ class TestMIMEApplication(unittest.TestC def test_body(self): eq = self.assertEqual
bytes = b'\xfa\xfb\xfc\xfd\xfe\xff'[](#l2.27)
msg = MIMEApplication(bytes)[](#l2.28)
eq(msg.get_payload(), '+vv8/f7/')[](#l2.29)
eq(msg.get_payload(decode=True), bytes)[](#l2.30)
bytesdata = b'\xfa\xfb\xfc\xfd\xfe\xff'[](#l2.31)
msg = MIMEApplication(bytesdata)[](#l2.32)
# whitespace in the cte encoded block is RFC-irrelevant.[](#l2.33)
eq(msg.get_payload().strip(), '+vv8/f7/')[](#l2.34)
eq(msg.get_payload(decode=True), bytesdata)[](#l2.35)
--- a/Misc/ACKS +++ b/Misc/ACKS @@ -227,6 +227,7 @@ Jaromir Dolecek Ismail Donmez Marcos Donolo Dima Dorfman +Yves Dorfsman Cesar Douady Dean Draayer Fred L. Drake, Jr.
--- a/Misc/NEWS +++ b/Misc/NEWS @@ -72,6 +72,10 @@ Core and Builtins Library ------- +- Issue #9298: base64 bodies weren't being folded to line lengths less than 78,