Back to index

python3.2  3.2.2
Public Member Functions | Static Public Attributes
email.test.test_email.TestLongHeaders Class Reference
Inheritance diagram for email.test.test_email.TestLongHeaders:
Inheritance graph
[legend]
Collaboration diagram for email.test.test_email.TestLongHeaders:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def test_split_long_continuation
def test_another_long_almost_unsplittable_header
def test_long_nonstring
def test_long_header_encode
def test_long_header_encode_with_tab_continuation_is_just_a_hint
def test_long_header_encode_with_tab_continuation
def test_header_encode_with_different_output_charset
def test_long_header_encode_with_different_output_charset
def test_header_splitter
def test_no_semis_header_splitter
def test_last_split_chunk_does_not_fit
def test_splittable_leading_char_followed_by_overlong_unsplitable
def test_multiple_splittable_leading_char_followed_by_overlong_unsplitable
def test_trailing_splitable_on_overlong_unsplitable
def test_trailing_splitable_on_overlong_unsplitable_with_leading_splitable
def test_long_header_with_multiple_sequential_split_chars
def test_splitter_split_on_punctuation_only_if_fws
def test_leading_splittable_in_the_middle_just_before_overlong_last_part
def test_overlong_last_part_followed_by_split_point
def test_multiline_with_overlong_parts_separated_by_two_split_points
def test_multiline_with_overlong_last_part_followed_by_split_point
def test_long_header_with_whitespace_runs
def test_long_run_with_semi_header_splitter
def test_splitter_split_on_punctuation_only_if_fws
def test_no_split_long_header
def test_splitting_multiple_long_lines
def test_splitting_first_line_only_is_long
def test_long_8bit_header
def test_long_8bit_header_no_charset
def test_long_to_header
def test_long_line_after_append
def test_shorter_line_with_append
def test_long_field_name
def test_long_received_header
def test_string_headerinst_eq
def test_long_unbreakable_lines_with_continuation
def test_another_long_multiline_header
def test_long_lines_with_different_header
def test_long_rfc2047_header_with_embedded_fws
def ndiffAssertEqual

Static Public Attributes

 maxDiff = None

Detailed Description

Definition at line 662 of file test_email.py.


Member Function Documentation

def email.test.test_email.TestEmailBase.ndiffAssertEqual (   self,
  first,
  second 
) [inherited]
Like assertEqual except use ndiff for readable output.

Definition at line 57 of file test_email.py.

00057 
00058     def ndiffAssertEqual(self, first, second):
00059         """Like assertEqual except use ndiff for readable output."""
00060         if first != second:
00061             sfirst = str(first)
00062             ssecond = str(second)
00063             rfirst = [repr(line) for line in sfirst.splitlines()]
00064             rsecond = [repr(line) for line in ssecond.splitlines()]
00065             diff = difflib.ndiff(rfirst, rsecond)
00066             raise self.failureException(NL + NL.join(diff))

Here is the call graph for this function:

Definition at line 686 of file test_email.py.

00686 
00687     def test_another_long_almost_unsplittable_header(self):
00688         eq = self.ndiffAssertEqual
00689         hstr = """\
00690 bug demonstration
00691 \t12345678911234567892123456789312345678941234567895123456789612345678971234567898112345678911234567892123456789112345678911234567892123456789
00692 \tmore text"""
00693         h = Header(hstr, continuation_ws='\t')
00694         eq(h.encode(), """\
00695 bug demonstration
00696 \t12345678911234567892123456789312345678941234567895123456789612345678971234567898112345678911234567892123456789112345678911234567892123456789
00697 \tmore text""")
00698         h = Header(hstr.replace('\t', ' '))
00699         eq(h.encode(), """\
00700 bug demonstration
00701  12345678911234567892123456789312345678941234567895123456789612345678971234567898112345678911234567892123456789112345678911234567892123456789
00702  more text""")

Here is the call graph for this function:

Definition at line 1183 of file test_email.py.

01183 
01184     def test_another_long_multiline_header(self):
01185         eq = self.ndiffAssertEqual
01186         m = ('Received: from siimage.com '
01187              '([172.25.1.3]) by zima.siliconimage.com with '
01188              'Microsoft SMTPSVC(5.0.2195.4905); '
01189              'Wed, 16 Oct 2002 07:41:11 -0700')
01190         msg = email.message_from_string(m)
01191         eq(msg.as_string(maxheaderlen=78), '''\
01192 Received: from siimage.com ([172.25.1.3]) by zima.siliconimage.com with
01193  Microsoft SMTPSVC(5.0.2195.4905); Wed, 16 Oct 2002 07:41:11 -0700
01194 
01195 ''')

Here is the call graph for this function:

Definition at line 786 of file test_email.py.

00786 
00787     def test_header_encode_with_different_output_charset(self):
00788         h = Header('文', 'euc-jp')
00789         self.assertEqual(h.encode(), "=?iso-2022-jp?b?GyRCSjgbKEI=?=")

Here is the call graph for this function:

Definition at line 800 of file test_email.py.

00800 
00801     def test_header_splitter(self):
00802         eq = self.ndiffAssertEqual
00803         msg = MIMEText('')
00804         # It'd be great if we could use add_header() here, but that doesn't
00805         # guarantee an order of the parameters.
00806         msg['X-Foobar-Spoink-Defrobnit'] = (
00807             'wasnipoop; giraffes="very-long-necked-animals"; '
00808             'spooge="yummy"; hippos="gargantuan"; marshmallows="gooey"')
00809         sfp = StringIO()
00810         g = Generator(sfp)
00811         g.flatten(msg)
00812         eq(sfp.getvalue(), '''\
00813 Content-Type: text/plain; charset="us-ascii"
00814 MIME-Version: 1.0
00815 Content-Transfer-Encoding: 7bit
00816 X-Foobar-Spoink-Defrobnit: wasnipoop; giraffes="very-long-necked-animals";
00817  spooge="yummy"; hippos="gargantuan"; marshmallows="gooey"
00818 
00819 ''')

Here is the call graph for this function:

Definition at line 836 of file test_email.py.

00836 
00837     def test_last_split_chunk_does_not_fit(self):
00838         eq = self.ndiffAssertEqual
00839         h = Header('Subject: the first part of this is short, but_the_second'
00840             '_part_does_not_fit_within_maxlinelen_and_thus_should_be_on_a_line'
00841             '_all_by_itself')
00842         eq(h.encode(), """\
00843 Subject: the first part of this is short,
00844  but_the_second_part_does_not_fit_within_maxlinelen_and_thus_should_be_on_a_line_all_by_itself""")

Here is the call graph for this function:

Definition at line 894 of file test_email.py.

00894 
00895     def test_leading_splittable_in_the_middle_just_before_overlong_last_part(self):
00896         eq = self.ndiffAssertEqual
00897         h = Header('this is a  test where we need to have more than one line '
00898             'before; our final line that is just too big to fit;; '
00899             'this_part_does_not_fit_within_maxlinelen_and_thus_should_'
00900             'be_on_a_line_all_by_itself;')
00901         eq(h.encode(), """\
00902 this is a  test where we need to have more than one line before;
00903  our final line that is just too big to fit;;
00904  this_part_does_not_fit_within_maxlinelen_and_thus_should_be_on_a_line_all_by_itself;""")

Here is the call graph for this function:

Definition at line 1036 of file test_email.py.

01036 
01037     def test_long_8bit_header(self):
01038         eq = self.ndiffAssertEqual
01039         msg = Message()
01040         h = Header('Britische Regierung gibt', 'iso-8859-1',
01041                     header_name='Subject')
01042         h.append('gr\xfcnes Licht f\xfcr Offshore-Windkraftprojekte')
01043         eq(h.encode(maxlinelen=76), """\
01044 =?iso-8859-1?q?Britische_Regierung_gibt_gr=FCnes_Licht_f=FCr_Offs?=
01045  =?iso-8859-1?q?hore-Windkraftprojekte?=""")
01046         msg['Subject'] = h
01047         eq(msg.as_string(maxheaderlen=76), """\
01048 Subject: =?iso-8859-1?q?Britische_Regierung_gibt_gr=FCnes_Licht_f=FCr_Offs?=
01049  =?iso-8859-1?q?hore-Windkraftprojekte?=
01050 
01051 """)
01052         eq(msg.as_string(maxheaderlen=0), """\
01053 Subject: =?iso-8859-1?q?Britische_Regierung_gibt_gr=FCnes_Licht_f=FCr_Offshore-Windkraftprojekte?=
01054 
01055 """)

Here is the call graph for this function:

Definition at line 1056 of file test_email.py.

01056 
01057     def test_long_8bit_header_no_charset(self):
01058         eq = self.ndiffAssertEqual
01059         msg = Message()
01060         header_string = ('Britische Regierung gibt gr\xfcnes Licht '
01061                          'f\xfcr Offshore-Windkraftprojekte '
01062                          '<a-very-long-address@example.com>')
01063         msg['Reply-To'] = header_string
01064         self.assertRaises(UnicodeEncodeError, msg.as_string)
01065         msg = Message()
01066         msg['Reply-To'] = Header(header_string, 'utf-8',
01067                                  header_name='Reply-To')
01068         eq(msg.as_string(maxheaderlen=78), """\
01069 Reply-To: =?utf-8?q?Britische_Regierung_gibt_gr=C3=BCnes_Licht_f=C3=BCr_Offs?=
01070  =?utf-8?q?hore-Windkraftprojekte_=3Ca-very-long-address=40example=2Ecom=3E?=
01071 
01072 """)

Here is the call graph for this function:

Definition at line 1107 of file test_email.py.

01107 
01108     def test_long_field_name(self):
01109         eq = self.ndiffAssertEqual
01110         fn = 'X-Very-Very-Very-Long-Header-Name'
01111         gs = ('Die Mieter treten hier ein werden mit einem Foerderband '
01112               'komfortabel den Korridor entlang, an s\xfcdl\xfcndischen '
01113               'Wandgem\xe4lden vorbei, gegen die rotierenden Klingen '
01114               'bef\xf6rdert. ')
01115         h = Header(gs, 'iso-8859-1', header_name=fn)
01116         # BAW: this seems broken because the first line is too long
01117         eq(h.encode(maxlinelen=76), """\
01118 =?iso-8859-1?q?Die_Mieter_treten_hier_e?=
01119  =?iso-8859-1?q?in_werden_mit_einem_Foerderband_komfortabel_den_Korridor_e?=
01120  =?iso-8859-1?q?ntlang=2C_an_s=FCdl=FCndischen_Wandgem=E4lden_vorbei=2C_ge?=
01121  =?iso-8859-1?q?gen_die_rotierenden_Klingen_bef=F6rdert=2E_?=""")

Here is the call graph for this function:

Definition at line 757 of file test_email.py.

00757 
00758     def test_long_header_encode(self):
00759         eq = self.ndiffAssertEqual
00760         h = Header('wasnipoop; giraffes="very-long-necked-animals"; '
00761                    'spooge="yummy"; hippos="gargantuan"; marshmallows="gooey"',
00762                    header_name='X-Foobar-Spoink-Defrobnit')
00763         eq(h.encode(), '''\
00764 wasnipoop; giraffes="very-long-necked-animals";
00765  spooge="yummy"; hippos="gargantuan"; marshmallows="gooey"''')

Here is the call graph for this function:

Definition at line 790 of file test_email.py.

00790 
00791     def test_long_header_encode_with_different_output_charset(self):
00792         h = Header(b'test-ja \xa4\xd8\xc5\xea\xb9\xc6\xa4\xb5\xa4\xec\xa4'
00793             b'\xbf\xa5\xe1\xa1\xbc\xa5\xeb\xa4\xcf\xbb\xca\xb2\xf1\xbc\xd4'
00794             b'\xa4\xce\xbe\xb5\xc7\xa7\xa4\xf2\xc2\xd4\xa4\xc3\xa4\xc6\xa4'
00795             b'\xa4\xa4\xde\xa4\xb9'.decode('euc-jp'), 'euc-jp')
00796         res = """\
00797 =?iso-2022-jp?b?dGVzdC1qYSAbJEIkWEVqOUYkNSRsJD8lYSE8JWskTztKMnE8VCROPjUbKEI=?=
00798  =?iso-2022-jp?b?GyRCRyckckJUJEMkRiQkJF4kORsoQg==?="""
00799         self.assertEqual(h.encode(), res)

Here is the call graph for this function:

Definition at line 776 of file test_email.py.

00776 
00777     def test_long_header_encode_with_tab_continuation(self):
00778         eq = self.ndiffAssertEqual
00779         h = Header('wasnipoop; giraffes="very-long-necked-animals";\t'
00780                    'spooge="yummy"; hippos="gargantuan"; marshmallows="gooey"',
00781                    header_name='X-Foobar-Spoink-Defrobnit',
00782                    continuation_ws='\t')
00783         eq(h.encode(), '''\
00784 wasnipoop; giraffes="very-long-necked-animals";
00785 \tspooge="yummy"; hippos="gargantuan"; marshmallows="gooey"''')

Here is the call graph for this function:

Definition at line 766 of file test_email.py.

00766 
00767     def test_long_header_encode_with_tab_continuation_is_just_a_hint(self):
00768         eq = self.ndiffAssertEqual
00769         h = Header('wasnipoop; giraffes="very-long-necked-animals"; '
00770                    'spooge="yummy"; hippos="gargantuan"; marshmallows="gooey"',
00771                    header_name='X-Foobar-Spoink-Defrobnit',
00772                    continuation_ws='\t')
00773         eq(h.encode(), '''\
00774 wasnipoop; giraffes="very-long-necked-animals";
00775  spooge="yummy"; hippos="gargantuan"; marshmallows="gooey"''')

Here is the call graph for this function:

Definition at line 879 of file test_email.py.

00879 
00880     def test_long_header_with_multiple_sequential_split_chars(self):
00881         eq = self.ndiffAssertEqual
00882         h = Header('This is a long line that has two whitespaces  in a row.  '
00883             'This used to cause truncation of the header when folded')
00884         eq(h.encode(), """\
00885 This is a long line that has two whitespaces  in a row.  This used to cause
00886  truncation of the header when folded""")

Here is the call graph for this function:

Definition at line 934 of file test_email.py.

00934 
00935     def test_long_header_with_whitespace_runs(self):
00936         eq = self.ndiffAssertEqual
00937         msg = Message()
00938         msg['From'] = 'test@dom.ain'
00939         msg['References'] = SPACE.join(['<foo@dom.ain>  '] * 10)
00940         msg.set_payload('Test')
00941         sfp = StringIO()
00942         g = Generator(sfp)
00943         g.flatten(msg)
00944         eq(sfp.getvalue(), """\
00945 From: test@dom.ain
00946 References: <foo@dom.ain>   <foo@dom.ain>   <foo@dom.ain>   <foo@dom.ain>
00947    <foo@dom.ain>   <foo@dom.ain>   <foo@dom.ain>   <foo@dom.ain>
00948    <foo@dom.ain>   <foo@dom.ain>\x20\x20
00949 
00950 Test""")

Here is the call graph for this function:

Definition at line 1090 of file test_email.py.

01090 
01091     def test_long_line_after_append(self):
01092         eq = self.ndiffAssertEqual
01093         s = 'This is an example of string which has almost the limit of header length.'
01094         h = Header(s)
01095         h.append('Add another line.')
01096         eq(h.encode(maxlinelen=76), """\
01097 This is an example of string which has almost the limit of header length.
01098  Add another line.""")

Here is the call graph for this function:

Definition at line 1196 of file test_email.py.

01196 
01197     def test_long_lines_with_different_header(self):
01198         eq = self.ndiffAssertEqual
01199         h = ('List-Unsubscribe: '
01200              '<http://lists.sourceforge.net/lists/listinfo/spamassassin-talk>,'
01201              '        <mailto:spamassassin-talk-request@lists.sourceforge.net'
01202              '?subject=unsubscribe>')
01203         msg = Message()
01204         msg['List'] = h
01205         msg['List'] = Header(h, header_name='List')
01206         eq(msg.as_string(maxheaderlen=78), """\
01207 List: List-Unsubscribe:
01208  <http://lists.sourceforge.net/lists/listinfo/spamassassin-talk>,
01209         <mailto:spamassassin-talk-request@lists.sourceforge.net?subject=unsubscribe>
01210 List: List-Unsubscribe:
01211  <http://lists.sourceforge.net/lists/listinfo/spamassassin-talk>,
01212         <mailto:spamassassin-talk-request@lists.sourceforge.net?subject=unsubscribe>
01213 
01214 """)

Here is the call graph for this function:

Definition at line 703 of file test_email.py.

00703 
00704     def test_long_nonstring(self):
00705         eq = self.ndiffAssertEqual
00706         g = Charset("iso-8859-1")
00707         cz = Charset("iso-8859-2")
00708         utf8 = Charset("utf-8")
00709         g_head = (b'Die Mieter treten hier ein werden mit einem Foerderband '
00710                   b'komfortabel den Korridor entlang, an s\xfcdl\xfcndischen '
00711                   b'Wandgem\xe4lden vorbei, gegen die rotierenden Klingen '
00712                   b'bef\xf6rdert. ')
00713         cz_head = (b'Finan\xe8ni metropole se hroutily pod tlakem jejich '
00714                    b'd\xf9vtipu.. ')
00715         utf8_head = ('\u6b63\u78ba\u306b\u8a00\u3046\u3068\u7ffb\u8a33\u306f'
00716                      '\u3055\u308c\u3066\u3044\u307e\u305b\u3093\u3002\u4e00'
00717                      '\u90e8\u306f\u30c9\u30a4\u30c4\u8a9e\u3067\u3059\u304c'
00718                      '\u3001\u3042\u3068\u306f\u3067\u305f\u3089\u3081\u3067'
00719                      '\u3059\u3002\u5b9f\u969b\u306b\u306f\u300cWenn ist das '
00720                      'Nunstuck git und Slotermeyer? Ja! Beiherhund das Oder '
00721                      'die Flipperwaldt gersput.\u300d\u3068\u8a00\u3063\u3066'
00722                      '\u3044\u307e\u3059\u3002')
00723         h = Header(g_head, g, header_name='Subject')
00724         h.append(cz_head, cz)
00725         h.append(utf8_head, utf8)
00726         msg = Message()
00727         msg['Subject'] = h
00728         sfp = StringIO()
00729         g = Generator(sfp)
00730         g.flatten(msg)
00731         eq(sfp.getvalue(), """\
00732 Subject: =?iso-8859-1?q?Die_Mieter_treten_hier_ein_werden_mit_einem_Foerderb?=
00733  =?iso-8859-1?q?and_komfortabel_den_Korridor_entlang=2C_an_s=FCdl=FCndischen?=
00734  =?iso-8859-1?q?_Wandgem=E4lden_vorbei=2C_gegen_die_rotierenden_Klingen_bef?=
00735  =?iso-8859-1?q?=F6rdert=2E_?= =?iso-8859-2?q?Finan=E8ni_metropole_se_hrouti?=
00736  =?iso-8859-2?q?ly_pod_tlakem_jejich_d=F9vtipu=2E=2E_?= =?utf-8?b?5q2j56K6?=
00737  =?utf-8?b?44Gr6KiA44GG44Go57+76Kiz44Gv44GV44KM44Gm44GE44G+44Gb44KT44CC5LiA?=
00738  =?utf-8?b?6YOo44Gv44OJ44Kk44OE6Kqe44Gn44GZ44GM44CB44GC44Go44Gv44Gn44Gf44KJ?=
00739  =?utf-8?b?44KB44Gn44GZ44CC5a6f6Zqb44Gr44Gv44CMV2VubiBpc3QgZGFzIE51bnN0dWNr?=
00740  =?utf-8?b?IGdpdCB1bmQgU2xvdGVybWV5ZXI/IEphISBCZWloZXJodW5kIGRhcyBPZGVyIGRp?=
00741  =?utf-8?b?ZSBGbGlwcGVyd2FsZHQgZ2Vyc3B1dC7jgI3jgajoqIDjgaPjgabjgYTjgb7jgZk=?=
00742  =?utf-8?b?44CC?=
00743 
00744 """)
00745         eq(h.encode(maxlinelen=76), """\
00746 =?iso-8859-1?q?Die_Mieter_treten_hier_ein_werden_mit_einem_Foerde?=
00747  =?iso-8859-1?q?rband_komfortabel_den_Korridor_entlang=2C_an_s=FCdl=FCndis?=
00748  =?iso-8859-1?q?chen_Wandgem=E4lden_vorbei=2C_gegen_die_rotierenden_Klinge?=
00749  =?iso-8859-1?q?n_bef=F6rdert=2E_?= =?iso-8859-2?q?Finan=E8ni_metropole_se?=
00750  =?iso-8859-2?q?_hroutily_pod_tlakem_jejich_d=F9vtipu=2E=2E_?=
00751  =?utf-8?b?5q2j56K644Gr6KiA44GG44Go57+76Kiz44Gv44GV44KM44Gm44GE44G+44Gb?=
00752  =?utf-8?b?44KT44CC5LiA6YOo44Gv44OJ44Kk44OE6Kqe44Gn44GZ44GM44CB44GC44Go?=
00753  =?utf-8?b?44Gv44Gn44Gf44KJ44KB44Gn44GZ44CC5a6f6Zqb44Gr44Gv44CMV2VubiBp?=
00754  =?utf-8?b?c3QgZGFzIE51bnN0dWNrIGdpdCB1bmQgU2xvdGVybWV5ZXI/IEphISBCZWlo?=
00755  =?utf-8?b?ZXJodW5kIGRhcyBPZGVyIGRpZSBGbGlwcGVyd2FsZHQgZ2Vyc3B1dC7jgI0=?=
00756  =?utf-8?b?44Go6KiA44Gj44Gm44GE44G+44GZ44CC?=""")

Here is the call graph for this function:

Definition at line 1122 of file test_email.py.

01122 
01123     def test_long_received_header(self):
01124         h = ('from FOO.TLD (vizworld.acl.foo.tld [123.452.678.9]) '
01125              'by hrothgar.la.mastaler.com (tmda-ofmipd) with ESMTP; '
01126              'Wed, 05 Mar 2003 18:10:18 -0700')
01127         msg = Message()
01128         msg['Received-1'] = Header(h, continuation_ws='\t')
01129         msg['Received-2'] = h
01130         # This should be splitting on spaces not semicolons.
01131         self.ndiffAssertEqual(msg.as_string(maxheaderlen=78), """\
01132 Received-1: from FOO.TLD (vizworld.acl.foo.tld [123.452.678.9]) by
01133  hrothgar.la.mastaler.com (tmda-ofmipd) with ESMTP;
01134  Wed, 05 Mar 2003 18:10:18 -0700
01135 Received-2: from FOO.TLD (vizworld.acl.foo.tld [123.452.678.9]) by
01136  hrothgar.la.mastaler.com (tmda-ofmipd) with ESMTP;
01137  Wed, 05 Mar 2003 18:10:18 -0700
01138 
01139 """)

Here is the call graph for this function:

Definition at line 1215 of file test_email.py.

01215 
01216     def test_long_rfc2047_header_with_embedded_fws(self):
01217         h = Header(textwrap.dedent("""\
01218             We're going to pretend this header is in a non-ascii character set
01219             \tto see if line wrapping with encoded words and embedded
01220                folding white space works"""),
01221                    charset='utf-8',
01222                    header_name='Test')
01223         self.assertEqual(h.encode()+'\n', textwrap.dedent("""\
01224             =?utf-8?q?We=27re_going_to_pretend_this_header_is_in_a_non-ascii_chara?=
01225              =?utf-8?q?cter_set?=
01226              =?utf-8?q?_to_see_if_line_wrapping_with_encoded_words_and_embedded?=
01227              =?utf-8?q?_folding_white_space_works?=""")+'\n')
01228 
01229 
01230 
# Test mangling of "From " lines in the body of a message

Here is the call graph for this function:

Definition at line 951 of file test_email.py.

00951 
00952     def test_long_run_with_semi_header_splitter(self):
00953         eq = self.ndiffAssertEqual
00954         msg = Message()
00955         msg['From'] = 'test@dom.ain'
00956         msg['References'] = SPACE.join(['<foo@dom.ain>'] * 10) + '; abc'
00957         msg.set_payload('Test')
00958         sfp = StringIO()
00959         g = Generator(sfp)
00960         g.flatten(msg)
00961         eq(sfp.getvalue(), """\
00962 From: test@dom.ain
00963 References: <foo@dom.ain> <foo@dom.ain> <foo@dom.ain> <foo@dom.ain>
00964  <foo@dom.ain> <foo@dom.ain> <foo@dom.ain> <foo@dom.ain> <foo@dom.ain>
00965  <foo@dom.ain>; abc
00966 
00967 Test""")

Here is the call graph for this function:

Definition at line 1073 of file test_email.py.

01073 
01074     def test_long_to_header(self):
01075         eq = self.ndiffAssertEqual
01076         to = ('"Someone Test #A" <someone@eecs.umich.edu>,'
01077               '<someone@eecs.umich.edu>, '
01078               '"Someone Test #B" <someone@umich.edu>, '
01079               '"Someone Test #C" <someone@eecs.umich.edu>, '
01080               '"Someone Test #D" <someone@eecs.umich.edu>')
01081         msg = Message()
01082         msg['To'] = to
01083         eq(msg.as_string(maxheaderlen=78), '''\
01084 To: "Someone Test #A" <someone@eecs.umich.edu>,<someone@eecs.umich.edu>,
01085  "Someone Test #B" <someone@umich.edu>,
01086  "Someone Test #C" <someone@eecs.umich.edu>,
01087  "Someone Test #D" <someone@eecs.umich.edu>
01088 
01089 ''')

Here is the call graph for this function:

Definition at line 1159 of file test_email.py.

01159 
01160     def test_long_unbreakable_lines_with_continuation(self):
01161         eq = self.ndiffAssertEqual
01162         msg = Message()
01163         t = """\
01164 iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAGFBMVEUAAAAkHiJeRUIcGBi9
01165  locQDQ4zJykFBAXJfWDjAAACYUlEQVR4nF2TQY/jIAyFc6lydlG5x8Nyp1Y69wj1PN2I5gzp"""
01166         msg['Face-1'] = t
01167         msg['Face-2'] = Header(t, header_name='Face-2')
01168         msg['Face-3'] = ' ' + t
01169         # XXX This splitting is all wrong.  It the first value line should be
01170         # snug against the field name or the space after the header not there.
01171         eq(msg.as_string(maxheaderlen=78), """\
01172 Face-1:\x20
01173  iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAGFBMVEUAAAAkHiJeRUIcGBi9
01174  locQDQ4zJykFBAXJfWDjAAACYUlEQVR4nF2TQY/jIAyFc6lydlG5x8Nyp1Y69wj1PN2I5gzp
01175 Face-2:\x20
01176  iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAGFBMVEUAAAAkHiJeRUIcGBi9
01177  locQDQ4zJykFBAXJfWDjAAACYUlEQVR4nF2TQY/jIAyFc6lydlG5x8Nyp1Y69wj1PN2I5gzp
01178 Face-3:\x20
01179  iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAGFBMVEUAAAAkHiJeRUIcGBi9
01180  locQDQ4zJykFBAXJfWDjAAACYUlEQVR4nF2TQY/jIAyFc6lydlG5x8Nyp1Y69wj1PN2I5gzp
01181 
01182 """)

Here is the call graph for this function:

Definition at line 923 of file test_email.py.

00923 
00924     def test_multiline_with_overlong_last_part_followed_by_split_point(self):
00925         eq = self.ndiffAssertEqual
00926         h = Header('this is a test where we need to have more than one line '
00927             'before our final line; ; '
00928             'this_part_does_not_fit_within_maxlinelen_and_thus_should_'
00929             'be_on_a_line_all_by_itself; ')
00930         eq(h.encode(), """\
00931 this is a test where we need to have more than one line before our final line;
00932  ;
00933  this_part_does_not_fit_within_maxlinelen_and_thus_should_be_on_a_line_all_by_itself; """)

Here is the call graph for this function:

Definition at line 912 of file test_email.py.

00912 
00913     def test_multiline_with_overlong_parts_separated_by_two_split_points(self):
00914         eq = self.ndiffAssertEqual
00915         h = Header('this_is_a__test_where_we_need_to_have_more_than_one_line_'
00916             'before_our_final_line_; ; '
00917             'this_part_does_not_fit_within_maxlinelen_and_thus_should_'
00918             'be_on_a_line_all_by_itself; ')
00919         eq(h.encode(), """\
00920 this_is_a__test_where_we_need_to_have_more_than_one_line_before_our_final_line_;
00921  ;
00922  this_part_does_not_fit_within_maxlinelen_and_thus_should_be_on_a_line_all_by_itself; """)

Here is the call graph for this function:

Definition at line 854 of file test_email.py.

00854 
00855     def test_multiple_splittable_leading_char_followed_by_overlong_unsplitable(self):
00856         eq = self.ndiffAssertEqual
00857         h = Header(', , but_the_second'
00858             '_part_does_not_fit_within_maxlinelen_and_thus_should_be_on_a_line'
00859             '_all_by_itself')
00860         eq(h.encode(), """\
00861 , ,
00862  but_the_second_part_does_not_fit_within_maxlinelen_and_thus_should_be_on_a_line_all_by_itself""")

Here is the call graph for this function:

Definition at line 820 of file test_email.py.

00820 
00821     def test_no_semis_header_splitter(self):
00822         eq = self.ndiffAssertEqual
00823         msg = Message()
00824         msg['From'] = 'test@dom.ain'
00825         msg['References'] = SPACE.join('<%d@dom.ain>' % i for i in range(10))
00826         msg.set_payload('Test')
00827         sfp = StringIO()
00828         g = Generator(sfp)
00829         g.flatten(msg)
00830         eq(sfp.getvalue(), """\
00831 From: test@dom.ain
00832 References: <0@dom.ain> <1@dom.ain> <2@dom.ain> <3@dom.ain> <4@dom.ain>
00833  <5@dom.ain> <6@dom.ain> <7@dom.ain> <8@dom.ain> <9@dom.ain>
00834 
00835 Test""")

Here is the call graph for this function:

Definition at line 986 of file test_email.py.

00986 
00987     def test_no_split_long_header(self):
00988         eq = self.ndiffAssertEqual
00989         hstr = 'References: ' + 'x' * 80
00990         h = Header(hstr)
00991         # These come on two lines because Headers are really field value
00992         # classes and don't really know about their field names.
00993         eq(h.encode(), """\
00994 References:
00995  xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx""")
00996         h = Header('x' * 80)
00997         eq(h.encode(), 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx')

Here is the call graph for this function:

Definition at line 905 of file test_email.py.

00905 
00906     def test_overlong_last_part_followed_by_split_point(self):
00907         eq = self.ndiffAssertEqual
00908         h = Header('this_part_does_not_fit_within_maxlinelen_and_thus_should_'
00909             'be_on_a_line_all_by_itself ')
00910         eq(h.encode(), "this_part_does_not_fit_within_maxlinelen_and_thus_"
00911                         "should_be_on_a_line_all_by_itself ")

Here is the call graph for this function:

Definition at line 1099 of file test_email.py.

01099 
01100     def test_shorter_line_with_append(self):
01101         eq = self.ndiffAssertEqual
01102         s = 'This is a shorter line.'
01103         h = Header(s)
01104         h.append('Add another sentence. (Surprise?)')
01105         eq(h.encode(),
01106            'This is a shorter line. Add another sentence. (Surprise?)')

Here is the call graph for this function:

Definition at line 666 of file test_email.py.

00666 
00667     def test_split_long_continuation(self):
00668         eq = self.ndiffAssertEqual
00669         msg = email.message_from_string("""\
00670 Subject: bug demonstration
00671 \t12345678911234567892123456789312345678941234567895123456789612345678971234567898112345678911234567892123456789112345678911234567892123456789
00672 \tmore text
00673 
00674 test
00675 """)
00676         sfp = StringIO()
00677         g = Generator(sfp)
00678         g.flatten(msg)
00679         eq(sfp.getvalue(), """\
00680 Subject: bug demonstration
00681 \t12345678911234567892123456789312345678941234567895123456789612345678971234567898112345678911234567892123456789112345678911234567892123456789
00682 \tmore text
00683 
00684 test
00685 """)

Here is the call graph for this function:

Definition at line 845 of file test_email.py.

00845 
00846     def test_splittable_leading_char_followed_by_overlong_unsplitable(self):
00847         eq = self.ndiffAssertEqual
00848         h = Header(', but_the_second'
00849             '_part_does_not_fit_within_maxlinelen_and_thus_should_be_on_a_line'
00850             '_all_by_itself')
00851         eq(h.encode(), """\
00852 ,
00853  but_the_second_part_does_not_fit_within_maxlinelen_and_thus_should_be_on_a_line_all_by_itself""")

Here is the call graph for this function:

Definition at line 887 of file test_email.py.

00887 
00888     def test_splitter_split_on_punctuation_only_if_fws(self):
00889         eq = self.ndiffAssertEqual
00890         h = Header('thisverylongheaderhas;semicolons;and,commas,but'
00891             'they;arenotlegal;fold,points')
00892         eq(h.encode(), "thisverylongheaderhas;semicolons;and,commas,butthey;"
00893                         "arenotlegal;fold,points")

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 968 of file test_email.py.

00968 
00969     def test_splitter_split_on_punctuation_only_if_fws(self):
00970         eq = self.ndiffAssertEqual
00971         msg = Message()
00972         msg['From'] = 'test@dom.ain'
00973         msg['References'] = ('thisverylongheaderhas;semicolons;and,commas,but'
00974             'they;arenotlegal;fold,points')
00975         msg.set_payload('Test')
00976         sfp = StringIO()
00977         g = Generator(sfp)
00978         g.flatten(msg)
00979         # XXX the space after the header should not be there.
00980         eq(sfp.getvalue(), """\
00981 From: test@dom.ain
00982 References:\x20
00983  thisverylongheaderhas;semicolons;and,commas,butthey;arenotlegal;fold,points
00984 
00985 Test""")

Here is the call graph for this function:

Definition at line 1020 of file test_email.py.

01020 
01021     def test_splitting_first_line_only_is_long(self):
01022         eq = self.ndiffAssertEqual
01023         hstr = """\
01024 from modemcable093.139-201-24.que.mc.videotron.ca ([24.201.139.93] helo=cthulhu.gerg.ca)
01025 \tby kronos.mems-exchange.org with esmtp (Exim 4.05)
01026 \tid 17k4h5-00034i-00
01027 \tfor test@mems-exchange.org; Wed, 28 Aug 2002 11:25:20 -0400"""
01028         h = Header(hstr, maxlinelen=78, header_name='Received',
01029                    continuation_ws='\t')
01030         eq(h.encode(), """\
01031 from modemcable093.139-201-24.que.mc.videotron.ca ([24.201.139.93]
01032  helo=cthulhu.gerg.ca)
01033 \tby kronos.mems-exchange.org with esmtp (Exim 4.05)
01034 \tid 17k4h5-00034i-00
01035 \tfor test@mems-exchange.org; Wed, 28 Aug 2002 11:25:20 -0400""")

Here is the call graph for this function:

Definition at line 998 of file test_email.py.

00998 
00999     def test_splitting_multiple_long_lines(self):
01000         eq = self.ndiffAssertEqual
01001         hstr = """\
01002 from babylon.socal-raves.org (localhost [127.0.0.1]); by babylon.socal-raves.org (Postfix) with ESMTP id B570E51B81; for <mailman-admin@babylon.socal-raves.org>; Sat, 2 Feb 2002 17:00:06 -0800 (PST)
01003 \tfrom babylon.socal-raves.org (localhost [127.0.0.1]); by babylon.socal-raves.org (Postfix) with ESMTP id B570E51B81; for <mailman-admin@babylon.socal-raves.org>; Sat, 2 Feb 2002 17:00:06 -0800 (PST)
01004 \tfrom babylon.socal-raves.org (localhost [127.0.0.1]); by babylon.socal-raves.org (Postfix) with ESMTP id B570E51B81; for <mailman-admin@babylon.socal-raves.org>; Sat, 2 Feb 2002 17:00:06 -0800 (PST)
01005 """
01006         h = Header(hstr, continuation_ws='\t')
01007         eq(h.encode(), """\
01008 from babylon.socal-raves.org (localhost [127.0.0.1]);
01009  by babylon.socal-raves.org (Postfix) with ESMTP id B570E51B81;
01010  for <mailman-admin@babylon.socal-raves.org>;
01011  Sat, 2 Feb 2002 17:00:06 -0800 (PST)
01012 \tfrom babylon.socal-raves.org (localhost [127.0.0.1]);
01013  by babylon.socal-raves.org (Postfix) with ESMTP id B570E51B81;
01014  for <mailman-admin@babylon.socal-raves.org>;
01015  Sat, 2 Feb 2002 17:00:06 -0800 (PST)
01016 \tfrom babylon.socal-raves.org (localhost [127.0.0.1]);
01017  by babylon.socal-raves.org (Postfix) with ESMTP id B570E51B81;
01018  for <mailman-admin@babylon.socal-raves.org>;
01019  Sat, 2 Feb 2002 17:00:06 -0800 (PST)""")

Here is the call graph for this function:

Definition at line 1140 of file test_email.py.

01140 
01141     def test_string_headerinst_eq(self):
01142         h = ('<15975.17901.207240.414604@sgigritzmann1.mathematik.'
01143              'tu-muenchen.de> (David Bremner\'s message of '
01144              '"Thu, 6 Mar 2003 13:58:21 +0100")')
01145         msg = Message()
01146         msg['Received-1'] = Header(h, header_name='Received-1',
01147                                    continuation_ws='\t')
01148         msg['Received-2'] = h
01149         # XXX The space after the ':' should not be there.
01150         self.ndiffAssertEqual(msg.as_string(maxheaderlen=78), """\
01151 Received-1:\x20
01152  <15975.17901.207240.414604@sgigritzmann1.mathematik.tu-muenchen.de> (David
01153  Bremner's message of \"Thu, 6 Mar 2003 13:58:21 +0100\")
01154 Received-2:\x20
01155  <15975.17901.207240.414604@sgigritzmann1.mathematik.tu-muenchen.de> (David
01156  Bremner's message of \"Thu, 6 Mar 2003 13:58:21 +0100\")
01157 
01158 """)

Here is the call graph for this function:

Definition at line 863 of file test_email.py.

00863 
00864     def test_trailing_splitable_on_overlong_unsplitable(self):
00865         eq = self.ndiffAssertEqual
00866         h = Header('this_part_does_not_fit_within_maxlinelen_and_thus_should_'
00867             'be_on_a_line_all_by_itself;')
00868         eq(h.encode(), "this_part_does_not_fit_within_maxlinelen_and_thus_should_"
00869             "be_on_a_line_all_by_itself;")

Here is the call graph for this function:

Definition at line 870 of file test_email.py.

00870 
00871     def test_trailing_splitable_on_overlong_unsplitable_with_leading_splitable(self):
00872         eq = self.ndiffAssertEqual
00873         h = Header('; '
00874             'this_part_does_not_fit_within_maxlinelen_and_thus_should_'
00875             'be_on_a_line_all_by_itself; ')
00876         eq(h.encode(), """\
00877 ;
00878  this_part_does_not_fit_within_maxlinelen_and_thus_should_be_on_a_line_all_by_itself; """)

Here is the call graph for this function:


Member Data Documentation

Definition at line 664 of file test_email.py.


The documentation for this class was generated from the following file: