diff options
| author | R David Murray <rdmurray@bitdance.com> | 2011-03-16 20:13:07 (GMT) |
|---|---|---|
| committer | R David Murray <rdmurray@bitdance.com> | 2011-03-16 20:13:07 (GMT) |
| commit | 78099bb153c2b8399f80cb32798dda7215945157 (patch) | |
| tree | fe4693ce1f16c2e5a81de70ea1a42b401ef3c339 /Lib/email/test/test_email.py | |
| parent | 3137d25b43ad52905a22158112bff4b0fa488b3b (diff) | |
| parent | 6d94bd470e3f4aa1dc7295b034553509ace2c654 (diff) | |
| download | cpython-78099bb153c2b8399f80cb32798dda7215945157.zip cpython-78099bb153c2b8399f80cb32798dda7215945157.tar.gz cpython-78099bb153c2b8399f80cb32798dda7215945157.tar.bz2 | |
Merge #9298 fix.
Diffstat (limited to 'Lib/email/test/test_email.py')
| -rw-r--r-- | Lib/email/test/test_email.py | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/Lib/email/test/test_email.py b/Lib/email/test/test_email.py index a6ea1d1..b9fd8d0 100644 --- 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: + bindata = fp.read() + mimed = email.mime.image.MIMEImage(bindata) + base64ed = mimed.get_payload() + # the transfer-encoded body lines should all be <=76 characters + lines = base64ed.split('\n') + self.assertLessEqual(max([ len(x) for x in lines ]), 76) + def test_encode_empty_payload(self): eq = self.assertEqual msg = Message() @@ -1141,10 +1150,11 @@ class TestMIMEApplication(unittest.TestCase): def test_body(self): eq = self.assertEqual - bytes = b'\xfa\xfb\xfc\xfd\xfe\xff' - msg = MIMEApplication(bytes) - eq(msg.get_payload(), '+vv8/f7/') - eq(msg.get_payload(decode=True), bytes) + bytesdata = b'\xfa\xfb\xfc\xfd\xfe\xff' + msg = MIMEApplication(bytesdata) + # whitespace in the cte encoded block is RFC-irrelevant. + eq(msg.get_payload().strip(), '+vv8/f7/') + eq(msg.get_payload(decode=True), bytesdata) |
