diff options
author | R. David Murray <rdmurray@bitdance.com> | 2010-10-23 22:19:56 (GMT) |
---|---|---|
committer | R. David Murray <rdmurray@bitdance.com> | 2010-10-23 22:19:56 (GMT) |
commit | 8451c4b6e044f83efc2298a79af58c3e56d946a2 (patch) | |
tree | edaad1a89627de27ad30b465b7a416c468850653 /Lib/email/test/test_email.py | |
parent | 29aad0005dd56634363dabd74cf6708c9a255b43 (diff) | |
download | cpython-8451c4b6e044f83efc2298a79af58c3e56d946a2.zip cpython-8451c4b6e044f83efc2298a79af58c3e56d946a2.tar.gz cpython-8451c4b6e044f83efc2298a79af58c3e56d946a2.tar.bz2 |
#1349106: add linesep argument to generator.flatten and header.encode.
Diffstat (limited to 'Lib/email/test/test_email.py')
-rw-r--r-- | Lib/email/test/test_email.py | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/Lib/email/test/test_email.py b/Lib/email/test/test_email.py index e5e51c6..f40d770 100644 --- a/Lib/email/test/test_email.py +++ b/Lib/email/test/test_email.py @@ -77,7 +77,7 @@ class TestMessageAPI(TestEmailBase): eq(msg.get_all('cc'), ['ccc@zzz.org', 'ddd@zzz.org', 'eee@zzz.org']) eq(msg.get_all('xx', 'n/a'), 'n/a') - def test_getset_charset(self): + def TEst_getset_charset(self): eq = self.assertEqual msg = Message() eq(msg.get_charset(), None) @@ -2600,6 +2600,18 @@ Here's the message body part2 = msg.get_payload(1) eq(part2.get_content_type(), 'application/riscos') + def test_crlf_flatten(self): + # Using newline='\n' preserves the crlfs in this input file. + with openfile('msg_26.txt', newline='\n') as fp: + text = fp.read() + msg = email.message_from_string(text) + s = StringIO() + g = Generator(s) + g.flatten(msg, linesep='\r\n') + self.assertEqual(s.getvalue(), text) + + maxDiff = None + def test_multipart_digest_with_extra_mime_headers(self): eq = self.assertEqual neq = self.ndiffAssertEqual @@ -2931,6 +2943,16 @@ class Test8BitBytesHandling(unittest.TestCase): m = bfp.close() self.assertEqual(str(m), self.latin_bin_msg_as7bit) + def test_crlf_flatten(self): + with openfile('msg_26.txt', 'rb') as fp: + text = fp.read() + msg = email.message_from_bytes(text) + s = BytesIO() + g = email.generator.BytesGenerator(s) + g.flatten(msg, linesep='\r\n') + self.assertEqual(s.getvalue(), text) + maxDiff = None + class TestBytesGeneratorIdempotent(TestIdempotent): |