From 07227d1ec027b8a6b189fecf4ac9eb555e2b0ec7 Mon Sep 17 00:00:00 2001 From: Barry Warsaw Date: Wed, 17 Oct 2001 20:52:26 +0000 Subject: Two merges from the mimelib project: test_no_semis_header_splitter(): This actually should still split. test_no_split_long_header(): An example of an unsplittable line. test_no_semis_header_splitter(): Test for SF bug # 471918, Generator splitting long headers. --- Lib/test/test_email.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/Lib/test/test_email.py b/Lib/test/test_email.py index fe6ffd2..e0180f7 100644 --- a/Lib/test/test_email.py +++ b/Lib/test/test_email.py @@ -28,6 +28,7 @@ from test_support import findfile NL = '\n' EMPTYSTRING = '' +SPACE = ' ' @@ -276,6 +277,39 @@ class TestLongHeaders(unittest.TestCase): g(msg) self.assertEqual(sfp.getvalue(), openfile('msg_18.txt').read()) + def test_no_semis_header_splitter(self): + msg = Message() + msg['From'] = 'test@dom.ain' + refparts = [] + for i in range(10): + refparts.append('<%d@dom.ain>' % i) + msg['References'] = SPACE.join(refparts) + msg.set_payload('Test') + sfp = StringIO() + g = Generator(sfp) + g(msg) + self.assertEqual(sfp.getvalue(), """\ +From: test@dom.ain +References: <0@dom.ain> <1@dom.ain> <2@dom.ain> <3@dom.ain> <4@dom.ain> + <5@dom.ain> <6@dom.ain> <7@dom.ain> <8@dom.ain> <9@dom.ain> + +Test""") + + def test_no_split_long_header(self): + msg = Message() + msg['From'] = 'test@dom.ain' + refparts = [] + msg['References'] = 'x' * 80 + msg.set_payload('Test') + sfp = StringIO() + g = Generator(sfp) + g(msg) + self.assertEqual(sfp.getvalue(), """\ +From: test@dom.ain +References: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + +Test""") + # Test mangling of "From " lines in the body of a message -- cgit v0.12