a  ze;@sddlZddlZddlZddlZddlZddlmZmZddlm Z ddl m Z ddl m Z ddlmZddlZddlZddlmZddlmZmZmZdd lmZmZdd lmZmZmZdd lm Z dd l!m"Z"dd l#m$Z$ddl%m&Z&ddl'm(Z(ddl)m*Z*ddl+m,Z,ddl-m.Z.ddl/m0Z0ddlm1Z1ddlm2Z2ddlm3Z3ddlm4Z4ddlm5Z5ddlm6Z6ddl7m8Z8m9Z9ddl:m;Z;mZ>dZ?dZ@dZAGd d!d!e<ZBGd"d#d#ejCZDGd$d%d%e<ZEGd&d'd'ejCZFGd(d)d)ejCZGGd*d+d+ejCZHGd,d-d-ejCZIGd.d/d/ejCZJGd0d1d1e<ZKGd2d3d3e<ZLGd4d5d5e<ZMGd6d7d7e<ZNGd8d9d9e<ZOGd:d;d;e<ZPGdd?d?e<ZRGd@dAdAe<ZSGdBdCdCe<ZTGdDdEdEZUGdFdGdGeUeOZVGdHdIdIeUeOZWGdJdKdKejCZXGdLdMdMejCZYGdNdOdOejCZZGdPdQdQe<Z[GdRdSdSe<Z\GdTdUdUe<Z]e^dVkre_dS)WN)StringIOBytesIO)chainchoice)Thread)patch)Charset)Header decode_header make_header)Parser HeaderParser) GeneratorDecodedGeneratorBytesGenerator)Message)MIMEApplication) MIMEAudio)MIMEText) MIMEImage)MIMEBase) MIMEMessage) MIMEMultipart)MIMENonMultipart)utilserrors)encoders) iterators) base64mime) quoprimime)unlink start_threads)openfile TestEmailBase) FeedParserBytesFeedParser  c@seZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZddZddZdd Zd!d"Zd#d$Zd%d&Zd'd(Zd)d*Zd+d,Zd-d.Zd/d0Zd1d2Zd3d4Zd5d6Zd7d8Zd9d:Zd;d<Z d=d>Z!d?d@Z"dAdBZ#dCdDZ$dEdFZ%dGdHZ&dIdJZ'dKdLZ(dMdNZ)dOdPZ*dQdRZ+dSdTZ,dUdVZ-dWdXZ.dYdZZ/d[d\Z0d]d^Z1d_d`Z2dadbZ3dcddZ4dedfZ5dgdhZ6didjZ7dkdlZ8dmdnZ9dodpZ:dqdrZ;dsdtZdydzZ?d{d|Z@d}d~ZAddZBddZCddZDddZEddZFddZGddZHddZIddZJddZKddZLddZMddZNddZOddZPddZQddZRddZSddZTddZUddZVddZWdS)TestMessageAPIcCs:|j}|d}||dgd||ddddS)Nz msg_20.txtZcc)z ccc@zzz.orgz ddd@zzz.orgz eee@zzz.orgxxzn/a) assertEqual_msgobjget_allselfeqmsgr4N/opt/bitninja-python-dojo/embedded/lib/python3.9/test/test_email/test_email.py test_get_all6s zTestMessageAPI.test_get_allcCs|j}t}||dtd}||||dd||d||dd||dd||dd ||jd|d||d||ddt}d |d <d |d <d|d<||||dd ||dd||dddS)N iso-8859-1 mime-versionz1.0 text/plain content-typez text/plain; charset="iso-8859-1"charsetcontent-transfer-encodingquoted-printablez2.0z MIME-Versionz text/x-weird Content-Typezquinted-puntableContent-Transfer-Encodingz"text/x-weird; charset="iso-8859-1")r-r get_charsetr set_charsetget_content_type get_param input_charsetr1r2r3r;r4r4r5test_getset_charset<s,   z"TestMessageAPI.test_getset_charsetcCs8|j}t}|d||jd||dddS)Nus-asciir:text/plain; charset="us-ascii")r-rrAr@rDr0r4r4r5test_set_charset_from_stringVs  z+TestMessageAPI.test_set_charset_from_stringcCs0t}td}|d|||jddS)Nr7zThis is a string payload)rr set_payloadr-r@rD)r1r3r;r4r4r5test_set_payload_with_charset]s z,TestMessageAPI.test_set_payload_with_charsetcCsVd}td}t}|||||dd||jdd|||ddS)NАБВutf-8r<base64Tdecodez 0JDQkdCS )r rrJr- get_payloadr1datar;r3r4r4r5+test_set_payload_with_8bit_data_and_charsetcs z:TestMessageAPI.test_set_payload_with_8bit_data_and_charsetcCsRd}td}d|_t}||d|||dd||jdd|dSNrLrMr<8bitTrO)r body_encodingrrJrPr-rQrRr4r4r5>test_set_payload_with_non_ascii_and_charset_body_encoding_nonelszMTestMessageAPI.test_set_payload_with_non_ascii_and_charset_body_encoding_nonecCsLd}td}d|_t}|||||dd||jdd|dSrU)r rWrrJr-rQrRr4r4r5>test_set_payload_with_8bit_data_and_charset_body_encoding_noneus zMTestMessageAPI.test_set_payload_with_8bit_data_and_charset_body_encoding_nonecCs$t}|g||gdSNrrJr-rQr1r3r4r4r5test_set_payload_to_list~s z'TestMessageAPI.test_set_payload_to_listcCs8t}d|d<|dtt}|td|j|dS)Nmultipart/mixedr>zstring payloadz[Aa]ttach.*non-multipart)rrJrZassertRaisesRegex TypeErrorattach)r1r3Zsub_msgr4r4r5"test_attach_when_payload_is_strings  z1TestMessageAPI.test_attach_when_payload_is_stringcCsl|j}|d}|}||gd|d}|d}||gd|d}|}||gddS)Nz msg_08.txt)NrGr7 iso-8859-2koi8-rz msg_09.txtdingbat)rdrGr7rdrcz msg_12.txt)NrGr7Nrbz iso-8859-3rGrc)r-r. get_charsets)r1r2r3charsetsr4r4r5test_get_charsetss    z TestMessageAPI.test_get_charsetscCsV|j}|d}dd|D}||ddg|d}|d}||ddS)N msg_04.txtcSsg|] }|qSr4 get_filename.0pr4r4r5 z4TestMessageAPI.test_get_filename..msg.txt msg_07.txtdingusfish.gif)r-r.rQrj)r1r2r3 filenamessubpartr4r4r5test_get_filenames   z TestMessageAPI.test_get_filenamecCs4|j}|d}dd|D}||ddgdS)Nz msg_44.txtcSsg|] }|qSr4rirkr4r4r5rnrozHTestMessageAPI.test_get_filename_with_name_parameter..rpr-r.rQ)r1r2r3rtr4r4r5%test_get_filename_with_name_parameters z4TestMessageAPI.test_get_filename_with_name_parametercCs"|j}|d}||ddS)NrqBOUNDARY)r-r. get_boundaryr0r4r4r5test_get_boundarys z TestMessageAPI.test_get_boundarycCs|j}|d}|d|d\}}||d||d|d}|d|d\}}||d||d|d}|tj|jddS) N msg_01.txtryr:z3text/plain; charset="us-ascii"; boundary="BOUNDARY"rhz$multipart/mixed; boundary="BOUNDARY" msg_03.txt)r-r. set_boundaryitemslower assertRaisesrHeaderParseError)r1r2r3headervaluer4r4r5test_set_boundarys       z TestMessageAPI.test_set_boundarycCsLtd}||ddd|||ddddddS)Nz form-datarrrzmultipart/form-data!z!multipart/form-data; boundary="==)rr-r as_stringr\r4r4r5test_make_boundarys z!TestMessageAPI.test_make_boundarycCsrtd}|}Wdn1s&0Yt}||}t}t|dd}||d|||dS)N msg_46.txtTrF) r$readrparsestrrrflattenr-getvaluer1fpZmsgdataparserr3outgenr4r4r5test_message_rfc822_onlys &   z'TestMessageAPI.test_message_rfc822_onlycCsztd}|d}Wdn1s,0Ytj}||}t}tj |}| || | |dS)Nrascii) r$rencodeemailrBytesHeaderParserZ parsebytesr generatorrrr-rrr4r4r5test_byte_message_rfc822_onlys ,    z,TestMessageAPI.test_byte_message_rfc822_onlycCs|j}|d}||jddd||djddd||djddd||djddd ||d jddd ||d jddd dS)Nz msg_10.txtTrOrs This is a 7bit encoded message. rrs-This is a Quoted Printable encoded message! s!This is a Base64 encoded message.s"This is a Base64 encoded message. r}s/This has no Content-Transfer-Encoding: header. rwr0r4r4r5test_get_decoded_payloads$ z'TestMessageAPI.test_get_decoded_payloadcCsZ|j}t}|ddD]}||d<||jdddq|d||jddddS) Nz$begin 666 - +:&5L;&\@=V]R;&0 end z x-uuencodeuuencodeZuuezx-uuer<TrO hello worldfoosfoo)r-rrJrQ)r1r2r3cter4r4r5test_get_decoded_uu_payloads  z*TestMessageAPI.test_get_decoded_uu_payloadcCst}|t|jddS)Nrr)rrr_rQr\r4r4r5*test_get_payload_n_raises_on_non_multipart sz9TestMessageAPI.test_get_payload_n_raises_on_non_multipartcCsj|j}|d}td}|}Wdn1s60Yt}t|}|||||dS)Nrqz msg_17.txt)r-r.r$rrrrr)r1r2r3rtextsgr4r4r5test_decoded_generators  & z%TestMessageAPI.test_decoded_generatorcCsbt}d|d<d|d<|d||d||d||d||d||d|dS) NZMeFromZYoutofromZFROMToZTO)rassertInr\r4r4r5test__contains__s     zTestMessageAPI.test__contains__cCs|d}td}|}Wdn1s00Y||t||jdd}|d}||dd||t |dddS)Nr|Tunixfromr(rzFrom rr) r.r$rr-strrsplit assertTrue startswithNLjoin)r1r3rrfullreprlinesr4r4r5test_as_string's  &  zTestMessageAPI.test_as_stringcCsT|d}|jjdd}|j|d}t}t||d}|||||dSNr| lineseppolicy) r.rclonerrrrr-rr1r3Z newpolicyrrrr4r4r5test_as_string_policy1s    z$TestMessageAPI.test_as_string_policycCs<td}|d}td}t|}|||dS)Nu MIME-Version: 1.0 Content-type: text/plain; charset="iso-8859-1" Test if non-ascii messages with no Content-Transfer-Encoding set can be as_string'd: Föö bär r7a% MIME-Version: 1.0 Content-type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Test if non-ascii messages with no Content-Transfer-Encoding set can be as_string'd: F=F6=F6 b=E4r )textwrapdedentrrmessage_from_bytesr-rr1msourceexpectedr3r4r4r5#test_nonascii_as_string_without_cte:s    z2TestMessageAPI.test_nonascii_as_string_without_ctecCs>td}|d}|dd}t|}|||dS)Nu MIME-Version: 1.0 Test if non-ascii messages with no Content-Type nor Content-Transfer-Encoding set can be as_string'd: Föö bär r7rreplace)rrrrPrrr-rrr4r4r54test_nonascii_as_string_without_content_type_and_ctePs     zCTestMessageAPI.test_nonascii_as_string_without_content_type_and_ctecCs|d}td}|d}Wdn1s60Y||t||jdd}|d}||d d||d |dddS) Nr|rTr rsFrom rr) r.r$rrr-bytesas_bytesrrrr)r1r3rrSrrr4r4r5 test_as_bytes]s  ,  zTestMessageAPI.test_as_bytescCsT|d}|jjdd}|j|d}t}t||d}|||||dSr) r.rrrrrrr-rrr4r4r5test_as_bytes_policygs    z#TestMessageAPI.test_as_bytes_policycCs td}||dddS)NzContent-Type: blarg; baz; boo bazr)rmessage_from_stringr-rCr\r4r4r5test_bad_paramqs zTestMessageAPI.test_bad_paramcCstd}||ddSNz From: foo rrr-rjr\r4r4r5test_missing_filenameus z$TestMessageAPI.test_missing_filenamecCstd}||ddS)Nz%Content-Disposition: blarg; filename r)rr\r4r4r5test_bogus_filenameysz"TestMessageAPI.test_bogus_filenamecCstd}||ddSrrrr-rzr\r4r4r5test_missing_boundary~s z$TestMessageAPI.test_missing_boundarycCsx|j}td}||jddgdtd}||jddgd||dtd}||jddgddS)N&X-Header: foo=one; bar=two; baz=three x-headerr))rone)bartworZthreez X-Header: foo; bar=one; baz=two ))rr))rr)rr"X-Header: foo; bar="one"; baz=two )r-rr get_paramsr0r4r4r5test_get_paramss(   zTestMessageAPI.test_get_paramscCs$t}d|d<||dddS)Nz>Content-Type: Multipart/mixed; boundary = "CPIMSSMTPC06p5f3tG"r>boundaryZCPIMSSMTPC06p5f3tG)rr-rCr\r4r4r5test_get_param_liberalsz%TestMessageAPI.test_get_param_liberalcCs|j}td}||jdddd||jdddd||ddtd}||jdddd ||jdddd ||jd ddddS) NrrrrrZquuzrrr)rrr-rrrCr0r4r4r5test_get_paramszTestMessageAPI.test_get_paramcCs&|d}||ddddS)Nz msg_22.txtrrnamez wibble.JPG)r.r-rQrCr\r4r4r5'test_get_param_funky_continuation_liness z6TestMessageAPI.test_get_param_funky_continuation_linescCs6td}||dd||jdddddS)Nz4Content-Type: image/pjpeg; name="Jim&&Jill" rzJim&&JillFunquotez"Jim&&Jill"rr\r4r4r5#test_get_param_with_semis_in_quotessz2TestMessageAPI.test_get_param_with_semis_in_quotescCs<td}||ddtd}||dddS)Nz5Content-Type: foo; bar*0="baz\"foobar"; bar*1="\"baz"rzbaz"foobar"bazrr\r4r4r5test_get_param_with_quotessz)TestMessageAPI.test_get_param_with_quotescCs>td}|d||d||d||d|dS)NzHeader: existsrr ZHEADERZheaderx)rrrZ assertNotInr\r4r4r5test_field_containments     z%TestMessageAPI.test_field_containmentcCs|j}t}|dd||dd|dd||dd||jdddd||gd||jddgd |jdd d d ||jdd d d dS) Nr; iso-2022-jp importance high valueFr "high value")r9r))r;r)rr)r)r;z "iso-2022-jp")rrz iso-9999-xxzX-Jimmyr)r-r set_paramrCrr0r4r4r5test_set_params  zTestMessageAPI.test_set_paramcCsp|j}|d}||gd|d}|d||ddg|d|||ddd|fgdS)N msg_05.txt)multipart/reportr)) report-typedelivery-statusr%D1690A7AC1.996856090/mail.example.comrrr)r-r.rrC del_paramr)r1r2r3Zold_valr4r4r5test_del_params&    zTestMessageAPI.test_del_paramcCs6t}|jdddd|dd||dddS)NContent-Disposition attachmentbud.giffilenamercontent-dispositionr add_headerrr-r\r4r4r5test_del_param_on_other_headers z-TestMessageAPI.test_del_param_on_other_headercCst}|dddS)Nrr)rrr\r4r4r5$test_del_param_on_nonexistent_headersz3TestMessageAPI.test_del_param_on_nonexistent_headercCs@t}|jdddd|d}|jddd||d|dS)Nr>r9rMr;foobarrr)r1r3Zexisting_headerr4r4r5test_del_nonexistent_params z)TestMessageAPI.test_del_nonexistent_paramcCsj|j}t}|t|jd|d||dd|dd||dd|d||dddS) Nrr9r:r;rGrHz text/htmlztext/html; charset="us-ascii")r-rr ValueErrorset_typerr0r4r4r5 test_set_types   zTestMessageAPI.test_set_typecCs.t}d|d<|dd||dddS)Nr9zX-Content-Typeapplication/octet-streamzx-content-type)rrr-r\r4r4r5test_set_type_on_other_headers z,TestMessageAPI.test_set_type_on_other_headercCst}||ddS)Nr9)rr-rBr\r4r4r5test_get_content_type_missing sz,TestMessageAPI.test_get_content_type_missingcCs$t}|d||ddS)Nmessage/rfc822)rset_default_typer-rBr\r4r4r5/test_get_content_type_missing_with_default_types z>TestMessageAPI.test_get_content_type_missing_with_default_typecCs$|d}||dddS)N msg_30.txtrrr.r-rQrBr\r4r4r5+test_get_content_type_from_message_implicits z:TestMessageAPI.test_get_content_type_from_message_implicitcCs$|d}||dddS)N msg_28.txtrrrr\r4r4r5+test_get_content_type_from_message_explicits z:TestMessageAPI.test_get_content_type_from_message_explicitcCs|d}||ddS)Nr~r9r.r-rBr\r4r4r56test_get_content_type_from_message_text_plain_implicits zETestMessageAPI.test_get_content_type_from_message_text_plain_implicitcCs|d}||ddS)Nr|r9rr\r4r4r56test_get_content_type_from_message_text_plain_explicit"s zETestMessageAPI.test_get_content_type_from_message_text_plain_explicitcCst}||ddS)Nrrr-get_content_maintyper\r4r4r5!test_get_content_maintype_missing&sz0TestMessageAPI.test_get_content_maintype_missingcCs$t}|d||ddS)Nrmessage)rrr-r r\r4r4r53test_get_content_maintype_missing_with_default_type*s zBTestMessageAPI.test_get_content_maintype_missing_with_default_typecCs$|d}||dddS)Nrrr"r.r-rQr r\r4r4r5/test_get_content_maintype_from_message_implicit/s z>TestMessageAPI.test_get_content_maintype_from_message_implicitcCs$|d}||dddS)Nrrr"r$r\r4r4r5/test_get_content_maintype_from_message_explicit3s z>TestMessageAPI.test_get_content_maintype_from_message_explicitcCs|d}||ddS)Nr~rr.r-r r\r4r4r5:test_get_content_maintype_from_message_text_plain_implicit7s zITestMessageAPI.test_get_content_maintype_from_message_text_plain_implicitcCs|d}||ddS)Nr|rr'r\r4r4r5:test_get_content_maintype_from_message_text_plain_explicit;s zITestMessageAPI.test_get_content_maintype_from_message_text_plain_explicitcCst}||ddS)Nplainrr-get_content_subtyper\r4r4r5 test_get_content_subtype_missing?sz/TestMessageAPI.test_get_content_subtype_missingcCs$t}|d||ddS)Nrrfc822)rrr-r,r\r4r4r52test_get_content_subtype_missing_with_default_typeCs zATestMessageAPI.test_get_content_subtype_missing_with_default_typecCs$|d}||dddS)Nrrr.r.r-rQr,r\r4r4r5.test_get_content_subtype_from_message_implicitHs z=TestMessageAPI.test_get_content_subtype_from_message_implicitcCs$|d}||dddS)Nrrr.r0r\r4r4r5.test_get_content_subtype_from_message_explicitLs z=TestMessageAPI.test_get_content_subtype_from_message_explicitcCs|d}||ddS)Nr~r*r.r-r,r\r4r4r59test_get_content_subtype_from_message_text_plain_implicitPs zHTestMessageAPI.test_get_content_subtype_from_message_text_plain_implicitcCs|d}||ddS)Nr|r*r3r\r4r4r59test_get_content_subtype_from_message_text_plain_explicitTs zHTestMessageAPI.test_get_content_subtype_from_message_text_plain_explicitcCs"t}d|d<||ddS)Nno-slash-in-this-stringr>rrr\r4r4r5test_get_content_maintype_errorXsz.TestMessageAPI.test_get_content_maintype_errorcCs"t}d|d<||ddS)Nr6r>r*r+r\r4r4r5test_get_content_subtype_error]sz-TestMessageAPI.test_get_content_subtype_errorcCs|j}t}|dd|dd|dd||gd||gd|dd ||gd||gd |dd |dd ||gd ||gd|t|jdddS)NFirstOneSecondTwoThirdThree)r9r;r=)r:r<r>Twenty)r:r?r>Eleven One Hundred)r9r;r=r9)rAr?r>r@ZFourthZMissing)r-rrkeysvaluesreplace_headerrKeyErrorr0r4r4r5test_replace_headerbs      z"TestMessageAPI.test_replace_headercCspt}|||jdddd||d|dd||d|dd||ddS)Nrrz random.avirinlineZInlinE)r assertIsNoneZget_content_dispositionrr-rDr\r4r4r5test_get_content_dispositionss  z+TestMessageAPI.test_get_content_dispositioncCsPd}t}d|d<d|d<||||jddd||jd tjdS) NzAwDp0P7//y6LwKEAcPa/6Q=9z audio/x-midir:rNr<TrOs.pr)rrJr-rQassertIsInstancedefectsrInvalidBase64CharactersDefectr1xr3r4r4r5test_broken_base64_payloads  z)TestMessageAPI.test_broken_base64_payloadcCsBd}t}d|d<d|d<||||jddt|ddS) Nuthis is a bröken thing to dor9r:rVr<TrOzraw-unicode-escape)rrJr-rQrrMr4r4r5test_broken_unicode_payloads z*TestMessageAPI.test_broken_unicode_payloadcCs>dd}t}d|d<d|d<||_||jdd|dS) Nu#this is a quéstionable thing to dorMtext/plain; charset="utf-8"r:rVr<TrO)rrZ_payloadr-rQrMr4r4r5test_questionable_bytes_payloads  z.TestMessageAPI.test_questionable_bytes_payloadcCs*t}|jdddd|d|ddS)Nrrrrzattachment; filename="bud.gif"rrr-r\r4r4r5test_ascii_add_headersz$TestMessageAPI.test_ascii_add_headercCs*t}|jdddd|d|ddS)NrrFußballer.pptrz/attachment; filename*=utf-8''Fu%C3%9Fballer.pptrSr\r4r4r5test_noascii_add_headersz&TestMessageAPI.test_noascii_add_headercCs*t}|jdddd|d|ddS)Nrr)r7r)rUrz1attachment; filename*=iso-8859-1''Fu%DFballer.pptrSr\r4r4r5#test_nonascii_add_header_via_triplesz2TestMessageAPI.test_nonascii_add_header_via_triplecCs*t}|jdddd|d|ddS)Nrrzwindows [filename].pptrz-attachment; filename="windows [filename].ppt"rSr\r4r4r5#test_ascii_add_header_with_tspecialsz2TestMessageAPI.test_ascii_add_header_with_tspecialcCs*t}|jdddd|d|ddS)NrruFußballer [filename].pptrz@attachment; filename*=utf-8''Fu%C3%9Fballer%20%5Bfilename%5D.pptrSr\r4r4r5&test_nonascii_add_header_with_tspecialsz5TestMessageAPI.test_nonascii_add_header_with_tspecialcCsLdD]B}t}d||d<d|d<|d||jddd d |qdS) Nlatin-1rtext/plain; charset=%sr:r=r<sfoo=e6=96=87barTrO foo文bar1get_payload returns wrong result with charset %s.r[r1r;r3r4r4r5test_binary_quopri_payloads   z)TestMessageAPI.test_binary_quopri_payloadcCsLdD]B}t}d||d<d|d<|d||jddd d |qdS) NrZr\r:rNr<s Zm9v5paHYmFyTrOr]r^r[r_r4r4r5test_binary_base64_payloads   z)TestMessageAPI.test_binary_base64_payloadc Cs^dD]T}dD]J}t}d||d<||d<|d||jddd td ||q qdS) NrZrr\r:r<s begin 666 - )9F]OYI:'8F%R end TrOr])z!get_payload returns wrong result z"with charset {0} and encoding {1}.)rrJr-rQrformat)r1r;encodingr3r4r4r5test_binary_uuencode_payloads   z+TestMessageAPI.test_binary_uuencode_payloadcCs*t}|jdddd|d|ddS)NrrG)Zfoo_barzinline; foo-barrSr\r4r4r5$test_add_header_with_name_only_paramsz3TestMessageAPI.test_add_header_with_name_only_paramcCs&t}|dd|d|ddS)NzX-Statusr)rSr\r4r4r5test_add_header_with_no_values z,TestMessageAPI.test_add_header_with_no_valuecCs&t}td|d<|tj|jdSNzdummy X-Injected-Header: testZDummy)rr rrrrr\r4r4r5(test_embedded_header_via_Header_rejecteds z7TestMessageAPI.test_embedded_header_via_Header_rejectedcCs"t}d|d<|tj|jdSrg)rrrrrr\r4r4r5(test_embedded_header_via_string_rejectedsz7TestMessageAPI.test_embedded_header_via_string_rejectedcCs*td}d|d<|t|tddS)Nzabc uÉ testSubjectz Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: =?utf-8?q?=C3=89_test?= abc rr-rrrr1rr4r4r5-test_unicode_header_defaults_to_utf8_encodingsz.L) r$rrmimeimagerrQrassertLessEqualmax)r1rbindataZmimedZbase64edrr4r4r5test_EncodersEncode_base64s  & z'TestEncoders.test_EncodersEncode_base64cCs(|j}t}|d||dddS)NrGr<7bit)r-rrAr0r4r4r5test_encode_empty_payload's z&TestEncoders.test_encode_empty_payloadcCsP|j}td}||ddtd}||ddtddd}||dddS) N hello worldr<r~uhello ø worldrNr7_charsetr=)r-rr0r4r4r5test_default_cte-s zTestEncoders.test_default_ctecCs8|j}tddd}||dd||tddS)Nu文 euc-jprr<r~z MIME-Version: 1.0 Content-Type: text/plain; charset="iso-2022-jp" Content-Transfer-Encoding: 7bit $BJ8(B )r-rrrrr0r4r4r5test_encode7or8bit9s zTestEncoders.test_encode7or8bitcCs&tddd}|t|tddS)Nuáö rz ISO-8859-1z MIME-Version: 1.0 Content-Type: text/text; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable =E1=F6 rkr\r4r4r5test_qp_encode_latin1Hs z"TestEncoders.test_qp_encode_latin1cCs&tddd}|t|tddS)Nuż rz ISO-8859-2z MIME-Version: 1.0 Content-Type: text/text; charset="iso-8859-2" Content-Transfer-Encoding: quoted-printable =BF rkr\r4r4r5test_qp_encode_non_latin1Rs z&TestEncoders.test_qp_encode_non_latin1N) rorprqr}rrrrrr4r4r4r5rrs    rrc@sHeZdZdZddZddZddZdd Zd d Zd d Z ddZ ddZ ddZ ddZ ddZddZddZddZddZd d!Zd"d#Zd$d%Zd&d'Zd(d)Zd*d+Zd,d-Zd.d/Zd0d1Zd2d3Zd4d5Zd6d7Zd8d9Zd:d;Z dd?Z"d@dAZ#dBdCZ$dDdEZ%dFdGZ&dHdIZ'dJdKZ(dLdMZ)dNdOZ*dS)PTestLongHeadersNcCs:|j}td}t}t|}||||ddS)NzSubject: bug demonstration 12345678911234567892123456789312345678941234567895123456789612345678971234567898112345678911234567892123456789112345678911234567892123456789 more text test )ndiffAssertEqualrrrrrrr1r2r3sfprr4r4r5test_split_long_continuationcs   z,TestLongHeaders.test_split_long_continuationcCsF|j}d}t|dd}||dt|dd}||ddS)Nzbug demonstration 12345678911234567892123456789312345678941234567895123456789612345678971234567898112345678911234567892123456789112345678911234567892123456789 more text continuation_wsr*zbug demonstration 12345678911234567892123456789312345678941234567895123456789612345678971234567898112345678911234567892123456789112345678911234567892123456789 more text)rr rrr1r2Zhstrhr4r4r5,test_another_long_almost_unsplittable_headerws  zNr4rlir4r4r5 roz@TestLongHeaders.test_no_semis_header_splitter.. ReferencesTestzFrom: 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) rrSPACErrangerJrrrrrr4r4r5test_no_semis_header_splitters  z-TestLongHeaders.test_no_semis_header_splittercCs |j}td}||ddS)NzSubject: the first part of this is short, but_the_second_part_does_not_fit_within_maxlinelen_and_thus_should_be_on_a_line_all_by_itselfzSubject: the first part of this is short, but_the_second_part_does_not_fit_within_maxlinelen_and_thus_should_be_on_a_line_all_by_itselfrrr4r4r5"test_last_split_chunk_does_not_fit sz2TestLongHeaders.test_last_split_chunk_does_not_fitcCs |j}td}||ddS)Nz_, but_the_second_part_does_not_fit_within_maxlinelen_and_thus_should_be_on_a_line_all_by_itselfz`, but_the_second_part_does_not_fit_within_maxlinelen_and_thus_should_be_on_a_line_all_by_itselfrrr4r4r5>test_splittable_leading_char_followed_by_overlong_unsplittableszNTestLongHeaders.test_splittable_leading_char_followed_by_overlong_unsplittablecCs |j}td}||ddS)Nza, , but_the_second_part_does_not_fit_within_maxlinelen_and_thus_should_be_on_a_line_all_by_itselfzb, , but_the_second_part_does_not_fit_within_maxlinelen_and_thus_should_be_on_a_line_all_by_itselfrrr4r4r5Gtest_multiple_splittable_leading_char_followed_by_overlong_unsplittableszWTestLongHeaders.test_multiple_splittable_leading_char_followed_by_overlong_unsplittablecCs |j}td}||ddS)NzTthis_part_does_not_fit_within_maxlinelen_and_thus_should_be_on_a_line_all_by_itself;rrr4r4r51test_trailing_splittable_on_overlong_unsplittable(szATestLongHeaders.test_trailing_splittable_on_overlong_unsplittablecCs |j}td}||ddS)NzW; this_part_does_not_fit_within_maxlinelen_and_thus_should_be_on_a_line_all_by_itself; zX; this_part_does_not_fit_within_maxlinelen_and_thus_should_be_on_a_line_all_by_itself; rrr4r4r5Itest_trailing_splittable_on_overlong_unsplittable_with_leading_splittable/szYTestLongHeaders.test_trailing_splittable_on_overlong_unsplittable_with_leading_splittablecCs |j}td}||ddS)NzpThis is a long line that has two whitespaces in a row. This used to cause truncation of the header when foldedzqThis is a long line that has two whitespaces in a row. This used to cause truncation of the header when foldedrrr4r4r55test_long_header_with_multiple_sequential_split_chars8szETestLongHeaders.test_long_header_with_multiple_sequential_split_charscCs |j}td}||ddS)NKthisverylongheaderhas;semicolons;and,commas,butthey;arenotlegal;fold,pointsrrr4r4r5:test_splitter_split_on_punctuation_only_if_fws_with_header@szJTestLongHeaders.test_splitter_split_on_punctuation_only_if_fws_with_headercCs |j}td}||ddS)Nzthis is a test where we need to have more than one line before; our final line that is just too big to fit;; this_part_does_not_fit_within_maxlinelen_and_thus_should_be_on_a_line_all_by_itself;zthis is a test where we need to have more than one line before; our final line that is just too big to fit;; this_part_does_not_fit_within_maxlinelen_and_thus_should_be_on_a_line_all_by_itself;rrr4r4r5Dtest_leading_splittable_in_the_middle_just_before_overlong_last_partGszTTestLongHeaders.test_leading_splittable_in_the_middle_just_before_overlong_last_partcCs |j}td}||ddS)NzTthis_part_does_not_fit_within_maxlinelen_and_thus_should_be_on_a_line_all_by_itself rrr4r4r5/test_overlong_last_part_followed_by_split_pointRsz?TestLongHeaders.test_overlong_last_part_followed_by_split_pointcCs |j}td}||ddS)Nzthis_is_a__test_where_we_need_to_have_more_than_one_line_before_our_final_line_; ; this_part_does_not_fit_within_maxlinelen_and_thus_should_be_on_a_line_all_by_itself; zthis_is_a__test_where_we_need_to_have_more_than_one_line_before_our_final_line_; ; this_part_does_not_fit_within_maxlinelen_and_thus_should_be_on_a_line_all_by_itself; rrr4r4r5@test_multiline_with_overlong_parts_separated_by_two_split_pointsYszPTestLongHeaders.test_multiline_with_overlong_parts_separated_by_two_split_pointscCs |j}td}||ddS)Nzthis is a test where we need to have more than one line before our final line; ; this_part_does_not_fit_within_maxlinelen_and_thus_should_be_on_a_line_all_by_itself; zthis is a test where we need to have more than one line before our final line; ; this_part_does_not_fit_within_maxlinelen_and_thus_should_be_on_a_line_all_by_itself; rrr4r4r5>test_multiline_with_overlong_last_part_followed_by_split_pointdszNTestLongHeaders.test_multiline_with_overlong_last_part_followed_by_split_pointcCs\|j}t}d|d<tdgd|d<|dt}t|}||||ddS)Nrrz rrrzFrom: test@dom.ain References: Test rrrrrJrrrrrr4r4r5%test_long_header_with_whitespace_runsos  z5TestLongHeaders.test_long_header_with_whitespace_runscCs`|j}t}d|d<tdgdd|d<|dt}t|}||||ddS) Nrrz rz; abcrrzFrom: test@dom.ain References: ; abc Testrrr4r4r5'test_long_run_with_semi_header_splitters  z7TestLongHeaders.test_long_run_with_semi_header_splittercCsP|j}t}d|d<d|d<|dt}t|}||||ddS)NrrrrrzrFrom: test@dom.ain References: thisverylongheaderhas;semicolons;and,commas,butthey;arenotlegal;fold,points Test)rrrJrrrrrr4r4r5.test_splitter_split_on_punctuation_only_if_fwss  z>TestLongHeaders.test_splitter_split_on_punctuation_only_if_fwscCs:|j}d}t|}||dtd}||ddS)Nz\References: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxz]References: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxZPxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxrrr4r4r5test_no_split_long_headers z)TestLongHeaders.test_no_split_long_headercCs(|j}d}t|dd}||ddS)NaWfrom babylon.socal-raves.org (localhost [127.0.0.1]); by babylon.socal-raves.org (Postfix) with ESMTP id B570E51B81; for ; Sat, 2 Feb 2002 17:00:06 -0800 (PST) from babylon.socal-raves.org (localhost [127.0.0.1]); by babylon.socal-raves.org (Postfix) with ESMTP id B570E51B81; for ; Sat, 2 Feb 2002 17:00:06 -0800 (PST) from babylon.socal-raves.org (localhost [127.0.0.1]); by babylon.socal-raves.org (Postfix) with ESMTP id B570E51B81; for ; Sat, 2 Feb 2002 17:00:06 -0800 (PST) rra_from babylon.socal-raves.org (localhost [127.0.0.1]); by babylon.socal-raves.org (Postfix) with ESMTP id B570E51B81; for ; Sat, 2 Feb 2002 17:00:06 -0800 (PST) from babylon.socal-raves.org (localhost [127.0.0.1]); by babylon.socal-raves.org (Postfix) with ESMTP id B570E51B81; for ; Sat, 2 Feb 2002 17:00:06 -0800 (PST) from babylon.socal-raves.org (localhost [127.0.0.1]); by babylon.socal-raves.org (Postfix) with ESMTP id B570E51B81; for ; Sat, 2 Feb 2002 17:00:06 -0800 (PST)rrr4r4r5"test_splitting_multiple_long_liness z2TestLongHeaders.test_splitting_multiple_long_linescCs,|j}d}t|dddd}||ddS)Nzfrom modemcable093.139-201-24.que.mc.videotron.ca ([24.201.139.93] helo=cthulhu.gerg.ca) by kronos.mems-exchange.org with esmtp (Exim 4.05) id 17k4h5-00034i-00 for test@mems-exchange.org; Wed, 28 Aug 2002 11:25:20 -0400NZReceivedr)rrrzfrom modemcable093.139-201-24.que.mc.videotron.ca ([24.201.139.93] helo=cthulhu.gerg.ca) by kronos.mems-exchange.org with esmtp (Exim 4.05) id 17k4h5-00034i-00 for test@mems-exchange.org; Wed, 28 Aug 2002 11:25:20 -0400rrr4r4r5&test_splitting_first_line_only_is_longs z6TestLongHeaders.test_splitting_first_line_only_is_longcCsf|j}t}tdddd}|d||jddd||d<||jdd d ||jd d d dS) NzBritische Regierung gibtr7rjru-grünes Licht für Offshore-Windkraftprojekterwrzl=?iso-8859-1?q?Britische_Regierung_gibt_gr=FCnes_Licht_f=FCr_Offs?= =?iso-8859-1?q?hore-Windkraftprojekte?=Z maxheaderlenzwSubject: =?iso-8859-1?q?Britische_Regierung_gibt_gr=FCnes_Licht_f=FCr_Offs?= =?iso-8859-1?q?hore-Windkraftprojekte?= rzdSubject: =?iso-8859-1?q?Britische_Regierung_gibt_gr=FCnes_Licht_f=FCr_Offshore-Windkraftprojekte?= )rrr rrr)r1r2r3rr4r4r5test_long_8bit_headers z%TestLongHeaders.test_long_8bit_headercCsV|j}t}d}||d<||jdddt}t|dd|d<||jddddS)NuhBritische Regierung gibt grünes Licht für Offshore-Windkraftprojekte zReply-TorrzReply-To: =?utf-8?q?Britische_Regierung_gibt_gr=C3=BCnes_Licht_f=C3=BCr_Offs?= =?utf-8?q?hore-Windkraftprojekte_=3Ca-very-long-address=40example=2Ecom=3E?= r)rrrr )r1r2r3Z header_stringr4r4r5 test_long_8bit_header_no_charsets z0TestLongHeaders.test_long_8bit_header_no_charsetcCs.|j}d}t}||d<||jddddS)Nz"Someone Test #A" ,, "Someone Test #B" , "Someone Test #C" , "Someone Test #D" rrrzTo: "Someone Test #A" ,, "Someone Test #B" , "Someone Test #C" , "Someone Test #D" )rrr)r1r2rr3r4r4r5test_long_to_headers z#TestLongHeaders.test_long_to_headercCs2|j}d}t|}|d||jddddS)NzIThis is an example of string which has almost the limit of header length.zAdd another line.rwrz\This is an example of string which has almost the limit of header length. Add another line.rr rrr1r2rrr4r4r5test_long_line_after_appends  z+TestLongHeaders.test_long_line_after_appendcCs.|j}d}t|}|d||ddS)NzThis is a shorter line.z!Add another sentence. (Surprise?)z9This is a shorter line. Add another sentence. (Surprise?)rrr4r4r5test_shorter_line_with_appends z-TestLongHeaders.test_shorter_line_with_appendcCs2|j}d}d}t|d|d}||jddddS)Nz!X-Very-Very-Very-Long-Header-NameuDie Mieter treten hier ein werden mit einem Foerderband komfortabel den Korridor entlang, an südlündischen Wandgemälden vorbei, gegen die rotierenden Klingen befördert. r7rrwra=?iso-8859-1?q?Die_Mieter_treten_hier_e?= =?iso-8859-1?q?in_werden_mit_einem_Foerderband_komfortabel_den_Korridor_e?= =?iso-8859-1?q?ntlang=2C_an_s=FCdl=FCndischen_Wandgem=E4lden_vorbei=2C_ge?= =?iso-8859-1?q?gen_die_rotierenden_Klingen_bef=F6rdert=2E_?=r)r1r2fnZgsrr4r4r5test_long_field_name s z$TestLongHeaders.test_long_field_namecCs:d}t}t|dd|d<||d<||jddddS) Nzfrom FOO.TLD (vizworld.acl.foo.tld [123.452.678.9]) by hrothgar.la.mastaler.com (tmda-ofmipd) with ESMTP; Wed, 05 Mar 2003 18:10:18 -0700rr Received-1 Received-2rra1Received-1: from FOO.TLD (vizworld.acl.foo.tld [123.452.678.9]) by hrothgar.la.mastaler.com (tmda-ofmipd) with ESMTP; Wed, 05 Mar 2003 18:10:18 -0700 Received-2: from FOO.TLD (vizworld.acl.foo.tld [123.452.678.9]) by hrothgar.la.mastaler.com (tmda-ofmipd) with ESMTP; Wed, 05 Mar 2003 18:10:18 -0700 rr rrr1rr3r4r4r5test_long_received_header/s z)TestLongHeaders.test_long_received_headercCs<d}t}t|ddd|d<||d<||jddddS) Nz<15975.17901.207240.414604@sgigritzmann1.mathematik.tu-muenchen.de> (David Bremner's message of "Thu, 6 Mar 2003 13:58:21 +0100")rrrrrra#Received-1: <15975.17901.207240.414604@sgigritzmann1.mathematik.tu-muenchen.de> (David Bremner's message of "Thu, 6 Mar 2003 13:58:21 +0100") Received-2: <15975.17901.207240.414604@sgigritzmann1.mathematik.tu-muenchen.de> (David Bremner's message of "Thu, 6 Mar 2003 13:58:21 +0100") rrr4r4r5test_string_headerinst_eqAs z)TestLongHeaders.test_string_headerinst_eqcCsJ|j}t}d}||d<t|dd|d<d||d<||jddd dS) NziVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAGFBMVEUAAAAkHiJeRUIcGBi9 locQDQ4zJykFBAXJfWDjAAACYUlEQVR4nF2TQY/jIAyFc6lydlG5x8Nyp1Y69wj1PN2I5gzpzFace-1zFace-2rr*zFace-3rraFace-1: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAGFBMVEUAAAAkHiJeRUIcGBi9 locQDQ4zJykFBAXJfWDjAAACYUlEQVR4nF2TQY/jIAyFc6lydlG5x8Nyp1Y69wj1PN2I5gzp Face-2: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAGFBMVEUAAAAkHiJeRUIcGBi9 locQDQ4zJykFBAXJfWDjAAACYUlEQVR4nF2TQY/jIAyFc6lydlG5x8Nyp1Y69wj1PN2I5gzp Face-3: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAGFBMVEUAAAAkHiJeRUIcGBi9 locQDQ4zJykFBAXJfWDjAAACYUlEQVR4nF2TQY/jIAyFc6lydlG5x8Nyp1Y69wj1PN2I5gzp rrr r)r1r2r3tr4r4r5-test_long_unbreakable_lines_with_continuationTs z=TestLongHeaders.test_long_unbreakable_lines_with_continuationcCs*|j}d}t|}||jddddS)NzReceived: from siimage.com ([172.25.1.3]) by zima.siliconimage.com with Microsoft SMTPSVC(5.0.2195.4905); Wed, 16 Oct 2002 07:41:11 -0700rrzReceived: from siimage.com ([172.25.1.3]) by zima.siliconimage.com with Microsoft SMTPSVC(5.0.2195.4905); Wed, 16 Oct 2002 07:41:11 -0700 )rrrrr1r2rr3r4r4r5"test_another_long_multiline_headerls z2TestLongHeaders.test_another_long_multiline_headercCs>|j}d}t}||d<t|dd|d<||jddddS)NzList-Unsubscribe: , Listrrra_List: List-Unsubscribe: , List: List-Unsubscribe: , r)r1r2rr3r4r4r5%test_long_lines_with_different_headerys z5TestLongHeaders.test_long_lines_with_different_headercCs6ttdddd}||dtdddS)Nz We're going to pretend this header is in a non-ascii character set to see if line wrapping with encoded words and embedded folding white space worksrMr)r;rr(z =?utf-8?q?We=27re_going_to_pretend_this_header_is_in_a_non-ascii_chara?= =?utf-8?q?cter_set?= =?utf-8?q?_to_see_if_line_wrapping_with_encoded_words_and_embedded?= =?utf-8?q?_folding_white_space_works?=)r rrr-rrr4r4r5*test_long_rfc2047_header_with_embedded_fwss z:TestLongHeaders.test_long_rfc2047_header_with_embedded_fws)+rorprqmaxDiffrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr4r4r4r5r_sP6              rc@s<eZdZddZddZddZddZd d Zd d Zd S)TestFromManglingcCs"t|_d|jd<|jddS)Nz aaa@bbb.orgrz(From the desk of A.A.A.: Blah blah blah )rr3rJr1r4r4r5setUps zTestFromMangling.setUpcCs2t}t|dd}||j||ddS)NTZ mangle_from_zFrom the desk of A.A.A.: Blah blah blah rrrr3r-rr1rrr4r4r5test_mangled_froms  z"TestFromMangling.test_mangled_fromcCs2t}t|dd}||j||ddS)NFrz;From: aaa@bbb.org From the desk of A.A.A.: Blah blah blah rrr4r4r5test_dont_mangle_froms  z&TestFromMangling.test_dont_mangle_fromcCsTt}t|dd}ttd}|||tdd| dDddS)NTra) From: foo@bar.com Mime-Version: 1.0 Content-Type: multipart/mixed; boundary=XXX From somewhere unknown --XXX Content-Type: text/plain foo --XXX-- From somewhere unknowable cSsg|]}|drdqS)z>From rr)rrvr4r4r5rns zLTestFromMangling.test_mangle_from_in_preamble_and_epilog..r(r) rrrrrrrr-rurr)r1rrr3r4r4r5'test_mangle_from_in_preamble_and_epilogs  z8TestFromMangling.test_mangle_from_in_preamble_and_epilogcCsRtdd}t|d}t}t|dd}|||| |ddS)Nz Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: aaa@bbb.org rMs From Rölli Trs >From Rölli ) rrrrrrrrr-r)r1rr3brr4r4r5 test_mangled_from_with_bad_bytess   z1TestFromMangling.test_mangled_from_with_bad_bytescCstdd}t|}dS)Nu From: aperson@example.com Content-Type: multipart/mixed; boundary="1" Content-Transfer-Encoding: È rM)rrrrr)r1rr3r4r4r5$test_multipart_with_bad_bytes_in_ctes z5TestFromMangling.test_multipart_with_bad_bytes_in_cteN) rorprqrrrrrrr4r4r4r5rs   rc@s4eZdZddZddZddZddZd d Zd S) TestMIMEAudiocCsDtdd}||_Wdn1s*0Yt|j|_dS)N audiotest.aurt)r$r _audiodatar_aur1rr4r4r5rs (zTestMIMEAudio.setUpcCs||jddS)Nz audio/basic)r-rrBrr4r4r5test_guess_minor_typesz#TestMIMEAudio.test_guess_minor_typecCs(|j}|tt|d|jdSNr)rrQr-rN decodebytesrrr1payloadr4r4r5 test_encodings zTestMIMEAudio.test_encodingcCs t|jd}||ddS)Nfishz audio/fish)rrr-rB)r1Zaur4r4r5test_checkSetMinors z TestMIMEAudio.test_checkSetMinorcCs|j}|jjdddd||jdd||jjdddd g||jjd dddg}||jjdddd ||jjd |dd |||jd||||jjd|dd|dS)Nrrrrrz#attachment; filename="audiotest.au"rrr))rrrr)rZfailobjrr )r-rrrrCassertIsr1r2missingr4r4r5test_add_headers4  zTestMIMEAudio.test_add_headerNrorprqrrrrrr4r4r4r5rs rc@s4eZdZddZddZddZddZd d Zd S) TestMIMEImagecCsDtdd}||_Wdn1s*0Yt|j|_dS)Nrsrt)r$r_imgdatar_imrr4r4r5rs (zTestMIMEImage.setUpcCs||jddS)Nz image/gif)r-r rBrr4r4r5rsz#TestMIMEImage.test_guess_minor_typecCs(|j}|tt|d|jdSr)r rQr-rNrrr rr4r4r5rs zTestMIMEImage.test_encodingcCs t|jd}||ddS)Nrz image/fish)rr r-rB)r1Zimr4r4r5r!s z TestMIMEImage.test_checkSetMinorcCs|j}|jjdddd||jdd||jjdddd g||jjd dddg}||jjdddd ||jjd |dd |||jd||||jjd|dd|dS)Nrrrsrrz%attachment; filename="dingusfish.gif"rr)rrsrr)rrr )r-r rrrCrrr4r4r5r%s4  zTestMIMEImage.test_add_headerNrr4r4r4r5r s r c@sDeZdZddZddZddZddZd d Zd d Zd dZ dS)TestMIMEApplicationcCs.|j}td}||d||dddS)Nrr<rN)r-rrBr0r4r4r5 test_headers<sz TestMIMEApplication.test_headerscCs:|j}d}t|}||d||jdd|dS)Nr z+vv8/f7/TrO)r-rrQstrip)r1r2 bytesdatar3r4r4r5 test_bodyBs zTestMIMEApplication.test_bodycCsd}t|tjd}||dt|||jdd|||ddt}t|}||| }t |}||dt|||jdd|||dddS)Nr Z_encoder�TrOr?rV) rrencode_7or8bitr-rQrurrrrrrr1rr3rrZwireformmsg2r4r4r5$test_binary_body_with_encode_7or8bitJs  z8TestMIMEApplication.test_binary_body_with_encode_7or8bitcCsd}t|tjd}||dt|||jdd|t}t|}||| }t |}||dt|||jdd|dS)Nr rrTrO) rr encode_noopr-rQrurrrrrrrr4r4r5!test_binary_body_with_encode_noop[s  z5TestMIMEApplication.test_binary_body_with_encode_noopcCshd}t|tjd}||jdd|t}t|}|||}t |}||jdd|dS)Ns rTrO) rrrr-rQrrrrrrrr4r4r50test_binary_body_with_unicode_linend_encode_noopls  zDTestMIMEApplication.test_binary_body_with_unicode_linend_encode_noopcCsd}t|tjd}||d||jdd|||ddt}t|}|||}t |}||d||jdd|||dddS)Ns rz=FA=FB=FC=FD=FE=FF=20TrOr?r=) rrZ encode_quoprir-rQrrrrrrrr4r4r5#test_binary_body_with_encode_quoprixs  z7TestMIMEApplication.test_binary_body_with_encode_quopricCsd}t|tjd}||d||jdd|t}t|}|||}t |}||d||jdd|dS)Nr rz +vv8/f7/ TrO) rrZ encode_base64r-rQrrrrrrrr4r4r5#test_binary_body_with_encode_base64s  z7TestMIMEApplication.test_binary_body_with_encode_base64N) rorprqrrrrrrrr4r4r4r5r ;s r c@sVeZdZddZddZddZddZd d Zd d Zd dZ e dddZ dS) TestMIMETextcCstd|_dSN hello there)r_msgrr4r4r5rszTestMIMEText.setUpcCs`|j}||jd||jddg}||jd||||jjd|dd|dS)Nr9r;rGr r)r-r rBrCrrr4r4r5 test_typesszTestMIMEText.test_typescCs&||jd||jdSr)r-r rQ assertFalse is_multipartrr4r4r5 test_payloadszTestMIMEText.test_payloadcCsz|j}tddd}||jd||ddtd}d|_td|d}||jd||dd||ddS)NrrGrr:rHrMrQ)r-rr@rDr rWrQrEr4r4r5 test_charsets  zTestMIMEText.test_charsetcCs4|j}tddd}||jd||dddS)NrrGrr:rH)r-rr@rDr0r4r4r5test_7bit_inputs zTestMIMEText.test_7bit_inputcCs>|j}td}||d||dd|d|dS)NrrGr:rH)r-rr@rrr0r4r4r5test_7bit_input_no_charsets z'TestMIMEText.test_7bit_input_no_charsetcCsPd}|j}t|dd}||jd||dd||jdd|ddS)NкирилицаrMrr:rQTrO)r-rr@output_charsetrQr)r1teststrr2r3r4r4r5test_utf8_inputs  zTestMIMEText.test_utf8_inputzBcan't fix because of backward compat in email5, will fix in email6cCsd}|tt|dS)Nr()rUnicodeEncodeErrorr)r1r*r4r4r5test_utf8_input_no_charsetsz'TestMIMEText.test_utf8_input_no_charsetN) rorprqrr!r$r%r&r'r+unittestskipr-r4r4r4r5rs  rc@seZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZddZddZdd Zd!d"Zd#d$Zd%d&Zd'd(Zd)S)* TestMultipartc Cs tdd}|}Wdn1s(0Ytdddd}t|dd}|jd d dd td }||||d |d<d|d<d|d<d}t|}|ddkrtj }ntj }|dkrd} nd} d| |df} t dt|| |d<||_ ||_ ||_dS)Nrsrt multipartmixedryrrs)rrrrz$Hi there, This is the dingus fish. zBarry rz)Dingus Lovers rzHere is your dingus fishrjg4FcpAr-+z %s%04d$z%a, %d %b %Y %H:%M:%SZDate)r$rrrrrr`time localtimetimezonealtzonestrftimer r _txt) r1rrS containerryZintronowZ timetupleZtzsecssignZtzoffsetr4r4r5rs> &     zTestMultipart.setUpcCs|j}|j}|j}||||d|t|d|t|jd|d}|d}| ||j | ||j ||||g| || |dS)Nr^rrrr) r-rr rr#rBrurQ IndexErrorrr=r r")r1r2raisesrZm0Zm1r4r4r5test_hierarchys  zTestMultipart.test_hierarchycCs$d}t|}|||dS)NzContent-Type: multipart/mixed; boundary="BOUNDARY" MIME-Version: 1.0 Subject: A subject To: aperson@dom.ain From: bperson@dom.ain --BOUNDARY --BOUNDARY-- )r rrr)r1rr3r4r4r5test_empty_multipart_idempotent s z-TestMultipart.test_empty_multipart_idempotentcCs@tdd}d|d<d|d<d|d<|d ||d dS) Nr1r2 A subjectrjaperson@dom.ainrbperson@dom.ainrryzContent-Type: multipart/mixed; boundary="BOUNDARY" MIME-Version: 1.0 Subject: A subject To: aperson@dom.ain From: bperson@dom.ain --BOUNDARY --BOUNDARY-- )rrrrr1outerr4r4r5/test_no_parts_in_a_multipart_with_none_epilogues   z=TestMultipart.test_no_parts_in_a_multipart_with_none_epiloguecCsLtdd}d|d<d|d<d|d<d |_d |_|d ||d dS) Nr1r2rErjrFrrGrr)ryzContent-Type: multipart/mixed; boundary="BOUNDARY" MIME-Version: 1.0 Subject: A subject To: aperson@dom.ain From: bperson@dom.ain --BOUNDARY --BOUNDARY-- )rpreambleepiloguerrrrHr4r4r50test_no_parts_in_a_multipart_with_empty_epilogue-s  z>TestMultipart.test_no_parts_in_a_multipart_with_empty_epiloguecCsV|j}tdd}d|d<d|d<d|d<|d td }||||d dS) Nr1r2rErjrFrrGrryrContent-Type: multipart/mixed; boundary="BOUNDARY" MIME-Version: 1.0 Subject: A subject To: aperson@dom.ain From: bperson@dom.ain --BOUNDARY Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit hello world --BOUNDARY-- )rrrrr`rr1r2rIr3r4r4r5test_one_part_in_a_multipartBs   z*TestMultipart.test_one_part_in_a_multipartcCs\|j}tdd}d|d<d|d<d|d<d |_td }|||d ||d dS) Nr1r2rErjrFrrGrr)rryaContent-Type: multipart/mixed; boundary="BOUNDARY" MIME-Version: 1.0 Subject: A subject To: aperson@dom.ain From: bperson@dom.ain --BOUNDARY Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit hello world --BOUNDARY-- rrrKrr`rrrOr4r4r51test_seq_parts_in_a_multipart_with_empty_preamble[s   z?TestMultipart.test_seq_parts_in_a_multipart_with_empty_preamblecCs\|j}tdd}d|d<d|d<d|d<d|_td }|||d ||d dS Nr1r2rErjrFrrGrrryrNrQrOr4r4r50test_seq_parts_in_a_multipart_with_none_preamblews   z>TestMultipart.test_seq_parts_in_a_multipart_with_none_preamblecCs\|j}tdd}d|d<d|d<d|d<d|_td }|||d ||d dSrSrrrLrr`rrrOr4r4r50test_seq_parts_in_a_multipart_with_none_epilogues   z>TestMultipart.test_seq_parts_in_a_multipart_with_none_epiloguecCs\|j}tdd}d|d<d|d<d|d<d |_td }|||d ||d dS) Nr1r2rErjrFrrGrr)rryrNrUrOr4r4r51test_seq_parts_in_a_multipart_with_empty_epilogues   z?TestMultipart.test_seq_parts_in_a_multipart_with_empty_epiloguecCs\|j}tdd}d|d<d|d<d|d<d |_td }|||d ||d dS) Nr1r2rErjrFrrGrr(rryaContent-Type: multipart/mixed; boundary="BOUNDARY" MIME-Version: 1.0 Subject: A subject To: aperson@dom.ain From: bperson@dom.ain --BOUNDARY Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit hello world --BOUNDARY-- rUrOr4r4r5.test_seq_parts_in_a_multipart_with_nl_epilogues   z ----961284236552522269-- )r.r-rr\r4r4r5test_boundary_in_non_multiparts z,TestMultipart.test_boundary_in_non_multipartcCsB|j}td}||||d|t|ddS)NzMIME-Version: 1.0 Content-Type: multipart/mixed; boundary=" XXXX" -- XXXX Content-Type: text/plain -- XXXX Content-Type: text/plain -- XXXX-- z XXXXr)r-rrrr#rzrurQr0r4r4r5 test_boundary_with_leading_space*s  z.TestMultipart.test_boundary_with_leading_spacecCs&td}||dddS)NzContent-Type: multipart/mixed; boundary="===============0012394164==" MIME-Version: 1.0 --===============0012394164== Content-Type: image/file1.jpg MIME-Version: 1.0 Content-Transfer-Encoding: base64 YXNkZg== --===============0012394164==--rzYXNkZg==)r rr-rQrlr4r4r5&test_boundary_without_trailing_newline=s z4TestMultipart.test_boundary_without_trailing_newlinecCs tdd}||jtjjdS)Nr1r2)rrrrcompat32rlr4r4r5test_mimebase_default_policyKs z*TestMultipart.test_mimebase_default_policycCs(tddtjjd}||jtjjdS)Nr1r2r)rrrdefaultrrlr4r4r5test_mimebase_custom_policyOsz)TestMultipart.test_mimebase_custom_policyN)rorprqrrCrDrJrMrPrRrTrVrWrXr\r]r`rarbrcrdrfrhr4r4r4r5r0s($ r0c@s~eZdZddZddZddZedZdd Z d d Z d d Z ddZ ddZ ddZddZddZddZddZdS)TestNonConformantcCs>|j}|d}||d||d||ddS)Nz msg_14.txtr9rr*)r-r.rBr r,r0r4r4r5test_parse_missing_minor_typeVs  z/TestNonConformant.test_parse_missing_minor_typecCsN|d}|d}|t|d|t|jd||jdtj dS)N msg_15.txtrrKrr) r.rQrhasattrr-rurKrJrStartBoundaryNotFoundDefect)r1r3innerr4r4r5test_same_boundary_inner_outer^s   z0TestNonConformant.test_same_boundary_inner_outercCsX|d}||t|t|jd||jdtj||jdtj dS)Nz msg_25.txtrrrr) r.rJrQrr-rurKrNoBoundaryInMultipartDefect!MultipartInvariantViolationDefectr\r4r4r5test_multipart_no_boundaryhs   z,TestNonConformant.test_multipart_no_boundarya^ Date: Wed, 14 Nov 2007 12:56:23 GMT From: foo@bar.invalid To: foo@bar.invalid Subject: Content-Transfer-Encoding: base64 and multipart MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============3344438784458119861=="{} --===============3344438784458119861== Content-Type: text/plain Test message --===============3344438784458119861== Content-Type: application/octet-stream Content-Transfer-Encoding: base64 YWJj --===============3344438784458119861==-- cCs<||jd}|t|jd||jdtjdS)Nz" Content-Transfer-Encoding: base64rrr) _str_msg multipart_msgrbr-rurKrJrZ-InvalidMultipartContentTransferEncodingDefectr\r4r4r5test_multipart_invalid_ctes  z,TestNonConformant.test_multipart_invalid_ctecCs(||jd}|t|jddS)Nr)rrsrtrbr-rurKr\r4r4r5test_multipart_no_cte_no_defectsz1TestNonConformant.test_multipart_no_cte_no_defectcCs8dD].}||jd|}|t|jdqdS)N)r~rVZBINaryz Content-Transfer-Encoding: {}rrv)r1rr3r4r4r5"test_multipart_valid_cte_no_defectsz4TestNonConformant.test_multipart_valid_cte_no_defectcCs|j}|j}t}d|d<||d||d||d|d=d|d<||d||d||dt}t|}|||| ddS)Nrr>r*r9r:rzContent-Type: foo ) r-rrr r,rBrrrr)r1r2neqr3rrr4r4r5test_invalid_content_types  z+TestNonConformant.test_invalid_content_typecCs"|j}|d}||ddS)N msg_31.txtzm--BOUNDARY Content-Type: text/plain message 1 --BOUNDARY Content-Type: text/plain message 2 --BOUNDARY-- )rr.rQr0r4r4r5test_no_start_boundarys z(TestNonConformant.test_no_start_boundarycCs"|j}|d}||ddS)Nz msg_35.txtzFrom: aperson@dom.ain To: bperson@dom.ain Subject: here's something interesting counter to RFC 2822, there's no separating newline here )rr.rr0r4r4r5test_no_separating_blank_lines z/TestNonConformant.test_no_separating_blank_linecCsX|d}|t|d|t|jd||jdtj||jdtj dS)Nz msg_41.txtrKrrrr) r.rrlr-rurKrJrrprqr\r4r4r5test_lying_multiparts   z&TestNonConformant.test_lying_multipartcCsD|d}|dd}|t|jd||jdtjdS)Nz msg_42.txtrrr)r.rQr-rurKrJrrm)r1rIZbadr4r4r5test_missing_start_boundarys   z-TestNonConformant.test_missing_start_boundarycCsj|j}d}t|}||dg||d|t|jd||jtj g||jdj ddS)Nz Line 1 Subject: test bodyrjbodyrrrz Line 1 ) r-rrrBrQrurKassertDefectsEqualrZ#FirstHeaderLineIsContinuationDefectlinerr4r4r5&test_first_line_is_continuation_headers z8TestNonConformant.test_first_line_is_continuation_headercCsB|d}||dg||d||jtjgdS)Nz&Subject: test not a header To: abc b rjznot a header To: abc b )rsr-rBrQrrKrZ MissingHeaderBodySeparatorDefectr\r4r4r5"test_missing_header_body_separators  z4TestNonConformant.test_missing_header_body_separatorN)rorprqrjrorrrrrtrurwrxrzr|r}r~rrrr4r4r4r5riTs     ric@seZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZddZddZdd Zd!S)" TestRFC2047cCsN|j}d}t|}||gdt|}|t|d||jddddS)NzVRe: =?mac-iceland?q?r=8Aksm=9Arg=8Cs?= baz foo bar =?mac-iceland?q?r=8Aksm=9Arg=8Cs?=))sRe: Ns rksmrgsz mac-iceland)s baz foo bar Nru+Re: räksmörgås baz foo bar räksmörgåsrwrziRe: =?mac-iceland?q?r=8Aksm=9Arg=8Cs?= baz foo bar =?mac-iceland?q?r=8Aksm?= =?mac-iceland?q?=9Arg=8Cs?=)r-r r rrrr1r2rdhrr4r4r5test_rfc2047_multiline sz"TestRFC2047.test_rfc2047_multilinecCs:|j}d}t|}||ddgtt|}||ddS)Nz0=?ISO-8859-1?Q?Andr=E9?= Pirard )sAndrr7)s Pirard NuAndré Pirard r-r rr rr4r4r5test_whitespace_keeper_unicode s z*TestRFC2047.test_whitespace_keeper_unicodecCs:|j}d}t|}||gdtt|}||ddS)NzWThe =?iso-8859-1?b?cXVpY2sgYnJvd24gZm94?= jumped over the =?iso-8859-1?b?bGF6eSBkb2c=?=))sThe N)squick brown foxr7)s jumped over the N)slazy dogr7z,The quick brown fox jumped over the lazy dogr)r1r2rrhur4r4r5 test_whitespace_keeper_unicode_2 s  z,TestRFC2047.test_whitespace_keeper_unicode_2cCs d}t|}||gddS)Nz3Sm=?ISO-8859-1?B?9g==?=rg=?ISO-8859-1?B?5Q==?=sbord))sSmNr7)srgNr7)ssbordNr r-r1rrr4r4r5test_rfc2047_missing_whitespace' sz+TestRFC2047.test_rfc2047_missing_whitespacecCs d}t|}||gddS)Nz7Sm =?ISO-8859-1?B?9g==?= rg =?ISO-8859-1?B?5Q==?= sbord))sSm Nr)s rg Nr)s sbordNrrr4r4r5test_rfc2047_with_whitespace. sz(TestRFC2047.test_rfc2047_with_whitespacecCs<d}gd}|D]&\}}t||}|||dfgqdS)Nz=?iso-8859-1?B?%s?=))zdm==v)zdm=r)Zdmr)zdmk=vi)Zdmkrr7r)r1rrSqarr4r4r5test_rfc2047_B_bad_padding5 s   z&TestRFC2047.test_rfc2047_B_bad_paddingcCsd}|t|dgdS)Nz=?iso-8859-1?Q?andr=e9=zz?=)sandr=zzr7r-r r1rr4r4r5test_rfc2047_Q_invalid_digits? s z)TestRFC2047.test_rfc2047_Q_invalid_digitscCsd}|t|gddS)Nz(=?ISO-8859-1?Q?a?=))(Nar7)Nrrr4r4r5test_rfc2047_rfc2047_1E s z"TestRFC2047.test_rfc2047_rfc2047_1cCsd}|t|gddS)Nz(=?ISO-8859-1?Q?a?= b))rr)s b)Nrrr4r4r5test_rfc2047_rfc2047_2K s z"TestRFC2047.test_rfc2047_rfc2047_2cCsd}|t|gddS)Nz'(=?ISO-8859-1?Q?a?= =?ISO-8859-1?Q?b?=)r)sabr7rrrr4r4r5test_rfc2047_rfc2047_3Q s z"TestRFC2047.test_rfc2047_rfc2047_3cCsd}|t|gddS)Nz((=?ISO-8859-1?Q?a?= =?ISO-8859-1?Q?b?=)rrrr4r4r5test_rfc2047_rfc2047_4W s z"TestRFC2047.test_rfc2047_rfc2047_4cCsd}|t|gddS)Nz,(=?ISO-8859-1?Q?a?= =?ISO-8859-1?Q?b?=)rrrr4r4r5test_rfc2047_rfc2047_5a] s z#TestRFC2047.test_rfc2047_rfc2047_5acCsd}|t|gddS)Nz+(=?ISO-8859-1?Q?a?= =?ISO-8859-1?Q?b?=)rrrr4r4r5test_rfc2047_rfc2047_5bc s z#TestRFC2047.test_rfc2047_rfc2047_5bcCsd}|t|gddS)Nz(=?ISO-8859-1?Q?a_b?=))r)sa br7rrrr4r4r5test_rfc2047_rfc2047_6i s z"TestRFC2047.test_rfc2047_rfc2047_6cCsPd}|t|gd|tt|||ttt|ddS)Nz((=?ISO-8859-1?Q?a?= =?ISO-8859-2?Q?_b?=))rr)s brbrz(a b))r-r r rrrrr4r4r5test_rfc2047_rfc2047_7o s  z"TestRFC2047.test_rfc2047_rfc2047_7cCsVd}|t|ddg|tt|d||ttt|ddS)Nz9=?windows-1252?q?=22M=FCller_T=22?= )s "Mller T"z windows-1252)sNr)u"Müller T" )r-r r rr splitlinesrrr4r4r5test_multiline_headerx s  z!TestRFC2047.test_multiline_headerN)rorprqrrrrrrrrrrrrrrrrr4r4r4r5r s     rc@seZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZddZddZdd Zd!S)"TestMIMEMessagecCs6td}||_Wdn1s(0YdS)N msg_11.txt)r$rZ_textrr4r4r5r s zTestMIMEMessage.setUpcCs|ttddS)Nza plain string)rr_rrr4r4r5test_type_error szTestMIMEMessage.test_type_errorcCsv|j}d}t}||d<t|}||d|}||t|t|d|d}|||||d|dS)Nz A sub-messagerjrrrrsubject) r-rrrBrQrJlistrur)r1r2rrrrrur4r4r5test_valid_argument s  z#TestMIMEMessage.test_valid_argumentcCs:t}d|d<t}d|d<t|}|tj|j|dS)Nz subpart 1rjz subpart 2)rrrrZMultipartConversionErrorr`)r1rZrrr4r4r5test_bad_multipart s z"TestMIMEMessage.test_bad_multipartcCsTt}d|d<|dt|}d|d<t}t|}||||ddS)NAn enclosed messagerj!Here is the body of the message. zThe enclosing messagezContent-Type: message/rfc822 MIME-Version: 1.0 Subject: The enclosing message Subject: An enclosed message Here is the body of the message. )rrJrrrrr-r)r1rrrrr4r4r5 test_generate s  zTestMIMEMessage.test_generatecCst|j}|d}||d|}||t|t|d|d}||t||dd||ddS)Nrrrrrrrr)r-r.rBrQrJrrur)r1r2r3rZsubmsgr4r4r5test_parse_message_rfc822 s   z)TestMIMEMessage.test_parse_message_rfc822cCs|j}|d}||d|||t|d|d}||d||d|d}||d|t|d |d}||t||d d ||j d d dd||j dd dd|d}||t||dd||j ddddg||j dddd|d }||d|}||t |t|d|d}||t||d||dddS)N msg_16.txtrrrr9aThis report relates to a message you sent with the following header fields: Message-id: <002001c144a6$8752e060$56104586@oxy.edu> Date: Sun, 23 Sep 2001 20:10:55 -0700 From: "Ian T. Henry" To: SoCal Raves Subject: [scr] yeah for Ians!! Your message cannot be delivered to the following recipients: Recipient address: jangel1@cougar.noc.ucla.edu Reason: recipient reached disk quota rrzmessage/delivery-statusrzoriginal-envelope-idz"0GK500B4HD0888@cougar.noc.ucla.eduZdnsz reporting-mtarr)ZnsdactionZfailedzoriginal-recipient)r.r))zjangel1@cougar.noc.ucla.edur)r.zfinal-recipientr message-idz(<002001c144a6$8752e060$56104586@oxy.edu>) r-r.rBrr#rurQrJrrCrr)r1r2r3ruZdsn1Zdsn2rr[r4r4r5test_dsn sD           zTestMIMEMessage.test_dsnc Cs|j}td}|}Wdn1s,0Yt}d|d<d|d<d|d<d|_d |_td }td }|jd d dd||||t }t |}| ||| |dS)N msg_21.txtrFrrGrrrj MIME messagezEnd of MIME message r:r<r>r^ryr3) rr$rrrKrLrrr`rrrr) r1r2rrr3rZrrrr4r4r5 test_epilogue s$ &   zTestMIMEMessage.test_epiloguecCsv|j}t}d|d<d|d<d|d<d|_d|_td }td }|jd d d d||||||ddS)NrFrrGrrrjrr)r:r<r>r^ryr3adFrom: aperson@dom.ain To: bperson@dom.ain Subject: Test Content-Type: multipart/mixed; boundary="BOUNDARY" MIME message --BOUNDARY Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit One --BOUNDARY Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Two --BOUNDARY-- )rrrKrLrrr`r)r1r2r3rZrr4r4r5test_no_nl_preamble s  z#TestMIMEMessage.test_no_nl_preamblecCs|j}td}t|}Wdn1s.0Y|d}||d||d|d}||d||d|d}||d||d|d}||d||ddS)Nrrrrrr9r-r$rmessage_from_filerQget_default_typerBr1r2rr3Z container1Z container2Z container1aZ container2ar4r4r5test_default_type2 s (    z!TestMIMEMessage.test_default_typecCs|j}td}t|}Wdn1s.0Y|d}||d||d|d}||d||d|d}||d||d|d}||d||ddS)Nrrrrrr9rrr4r4r5.test_default_type_with_explicit_container_typeC s (    z>TestMIMEMessage.test_default_type_with_explicit_container_typecCs|j}|j}tdd}d|_td}td}t|}t|}||||||d||d||d||d|| dd|d =|d =|d =|d =||d||d||d||d|| dd dS) Ndigestryr) message 1 message 2 rraContent-Type: multipart/digest; boundary="BOUNDARY" MIME-Version: 1.0 --BOUNDARY Content-Type: message/rfc822 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit message 1 --BOUNDARY Content-Type: message/rfc822 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit message 2 --BOUNDARY-- r:r8aBContent-Type: multipart/digest; boundary="BOUNDARY" MIME-Version: 1.0 --BOUNDARY Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit message 1 --BOUNDARY Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit message 2 --BOUNDARY-- ) r-rrrLrrr`rBrr)r1r2ryr>Z subpart1aZ subpart2aZsubpart1Zsubpart2r4r4r5test_default_type_non_parsedT s0   z,TestMIMEMessage.test_default_type_non_parsedcCsZ|j}td}td}t||fd}|t|d||d|||d|dS)Nr))Z _subpartsrrrr)r-rrrurQ)r1r2Ztext1Ztext2r3r4r4r5$test_mime_attachments_in_constructor sz4TestMIMEMessage.test_mime_attachments_in_constructorcCst}||dSrZ)rrr#r\r4r4r5"test_default_multipart_constructor sz2TestMIMEMessage.test_default_multipart_constructorcCs0t}d|d<d|d<||dddgdS)Na@b.comrc@d.comr)rr-r/r\r4r4r5test_multipart_default_policy sz-TestMIMEMessage.test_multipart_default_policycCs^ttjjd}d|d<|t}d|d<Wdn1s>0Y|t|jddS)Nrrrrz.There may be at most 1 To headers in a message) rrrrgrrr-r exception)r1r3cmr4r4r5test_multipart_custom_policy s & z,TestMIMEMessage.test_multipart_custom_policyN)rorprqrrrrrrrrrrrrrrrrr4r4r4r5r s  9#J rc@seZdZdZddZd4ddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZddZddZdd Zd!d"Zd#d$Zd%d&Zd'd(Zd)d*Zd+d,Zd-d.Zd/d0Zd1d2Zd3S)5TestIdempotentr(cCsBt|}|}Wdn1s&0Yt|}||fSrZr$rrrr1rrrSr3r4r4r5r. s & zTestIdempotent._msgobjFcCs8|j}t}t|dd}|j||d|||dS)Nrrr)rrrrr)r1r3rrr2rrr4r4r5 _idempotent s  zTestIdempotent._idempotentcCs|j}|d\}}||d||d||d||dd||dd||jd||jd| ||dS) Nr|r9rr*rr)r;rGr;rG) r-r.rBr r,rrCrKrLrr1r2r3rr4r4r5test_parse_text_message s  z&TestIdempotent.test_parse_text_messagecCsP|j}|d\}}||d||d||dd|||dS)Nr~r9r;)r-r.rBrrCrrr4r4r5test_parse_untyped_message s z)TestIdempotent.test_parse_untyped_messagecCs|d\}}|||dS)Nrhr.rr1r3rr4r4r5test_simple_multipart sz$TestIdempotent.test_simple_multipartcCs|d\}}|||dS)N msg_02.txtrrr4r4r5test_MIME_digest szTestIdempotent.test_MIME_digestcCs|d\}}|||dS)Nz msg_27.txtrrr4r4r5test_long_header szTestIdempotent.test_long_headercCs|d\}}|||dS)Nrrrr4r4r5"test_MIME_digest_with_part_headers sz1TestIdempotent.test_MIME_digest_with_part_headerscCs|d\}}|||dS)N msg_06.txtrrr4r4r5test_mixed_with_image sz$TestIdempotent.test_mixed_with_imagecCs|d\}}|||dS)Nrrrr4r4r5test_multipart_report sz$TestIdempotent.test_multipart_reportcCs|d\}}|||dS)Nrrrr4r4r5r szTestIdempotent.test_dsncCs|d\}}|||dS)Nrrrr4r4r5test_preamble_epilogue sz%TestIdempotent.test_preamble_epiloguecCs|d\}}|||dS)Nz msg_23.txtrrr4r4r5test_multipart_one_part sz&TestIdempotent.test_multipart_one_partcCs|d\}}|||dS)Nz msg_24.txtrrr4r4r5test_multipart_no_parts sz&TestIdempotent.test_multipart_no_partscCs|d\}}|||dS)Nr{rrr4r4r5r| sz%TestIdempotent.test_no_start_boundarycCs|d\}}|||dS)N msg_32.txtrrr4r4r5test_rfc2231_charset sz#TestIdempotent.test_rfc2231_charsetcCs|d\}}|||dS)Nz msg_33.txtrrr4r4r5test_more_rfc2231_parameters sz+TestIdempotent.test_more_rfc2231_parameterscCs|d\}}|||dS)Nz msg_34.txtrrr4r4r5%test_text_plain_in_a_multipart_digest sz4TestIdempotent.test_text_plain_in_a_multipart_digestcCs|d\}}|||dS)Nz msg_12a.txtrrr4r4r5test_nested_multipart_mixeds sz+TestIdempotent.test_nested_multipart_mixedscCs|d\}}|||dS)NrYrrr4r4r5%test_message_external_body_idempotent sz4TestIdempotent.test_message_external_body_idempotentcCs"|d\}}|j||dddS)N msg_43.txtTrrrr4r4r5test_message_delivery_status# sz+TestIdempotent.test_message_delivery_statuscCs|d\}}|||dSN msg_45.txtrrr4r4r5test_message_signed_idempotent' sz-TestIdempotent.test_message_signed_idempotentc CsX|j}|d\}}||di}|D]\}}|||<q.||dd||dd||jd|j||j|j|t|d|d }||d ||d |j|d }||d ||d |j|d } || d| | t | } | | t |t| d | d } | | t || d |jdS)Nrrrrrrz$This is a MIME-encapsulated message.rrr9zYadda yadda yaddarrrr) r-r.rBrrKrrLrurQrJrr) r1r2r3rparamsZpkZpvrZrZmsg3rZmsg4r4r4r5test_content_type+ s4       z TestIdempotent.test_content_typecCs|j}|d\}}||d|}||t|t|d|d}||t||d||t|||j dS)Nrrrrrr9) r-r.rBrQrJrrurrr)r1r2r3rrrZr4r4r5 test_parserJ s  zTestIdempotent.test_parserN)F)rorprqrr.rrrrrrrrrrrrrr|rrrrrrrrrr4r4r4r5r s2  rc@seZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZddZddZdd Zd!d"Zd#d$Zd%d&Zd'd(Zd)d*Zd+d,Zd-d.Zd/d0Zd1d2Zd3d4Zd5d6Zd7d8Zd9d:Zd;d<Z d=d>Z!d?d@Z"dAdBZ#dCdDZ$dEdFZ%dGdHZ&dIdJZ'dKdLZ(dMdNZ)dOdPZ*dQdRZ+dSdTZ,dUdVZ-dWdXZ.dYdZZ/d[d\Z0d]d^Z1d_d`Z2dadbZ3dcddZ4dedfZ5dgdhZ6diS)jTestMiscellaneouscCsjtd}|}Wdn1s&0Yt|}t}t|dd}|||||dSNr|rr r$rrrrrrr-rr1rrr3rrr4r4r5test_message_from_string^ s &   z*TestMiscellaneous.test_message_from_stringcCsttdX}|}|dt|}t}t|dd}||||| Wdn1sf0YdSr) r$rseekrrrrrr-rrr4r4r5test_message_from_filei s     z(TestMiscellaneous.test_message_from_filecCstd}|}Wdn1s&0YGdddt}t||}|||td}|}Wdn1s~0Yt||}|D]}|||qdS)Nr|c@s eZdZdS)zHTestMiscellaneous.test_message_from_string_with_class..MyMessageNrorprqr4r4r4r5 MyMessagez srr)r$rrrrrJwalk)r1rrrr3rur4r4r5#test_message_from_string_with_classu s &   &  z5TestMiscellaneous.test_message_from_string_with_classcCsGdddt}td}t||}Wdn1s:0Y|||td}t||}Wdn1sz0Y|D]}|||qdS)Nc@s eZdZdS)zFTestMiscellaneous.test_message_from_file_with_class..MyMessageNrr4r4r4r5r srr|r)rr$rrrJr)r1rrr3rur4r4r5!test_message_from_file_with_class s *  * z3TestMiscellaneous.test_message_from_file_with_classcCs,Gdddt}|d|}|||dS)NcseZdZfddZZS)zSTestMiscellaneous.test_custom_message_does_not_require_arguments..MyMessagecstdSrZ)super__init__r __class__r4r5r sz\TestMiscellaneous.test_custom_message_does_not_require_arguments..MyMessage.__init__)rorprqr __classcell__r4r4rr5r srzSubject: test test)rrsrJ)r1rr3r4r4r5.test_custom_message_does_not_require_arguments s z@TestMiscellaneous.test_custom_message_does_not_require_argumentscCs"td}|t|jgddS)Nr)r r;rr feedparserrrrr"Zmessage_from_binary_filerrrrxrr!r) __import__r-sorted__all__)r1moduler4r4r5 test__all__ szTestMiscellaneous.test__all__cCs:t}|tt|ddt|dddS)N)r8r-r parsedate formatdategmtimer1r?r4r4r5test_formatdate sz!TestMiscellaneous.test_formatdatecCs>t}|ttj|ddddt|dddS)NTr9r)r8r-rrrr9rr4r4r5test_formatdate_localtime s z+TestMiscellaneous.test_formatdate_localtimec CsVt}|tj|ddtdt||tj|dddtdt|dS)NFrz%a, %d %b %Y %H:%M:%S -0000T)r9Zusegmtz%a, %d %b %Y %H:%M:%S GMT)r8r-rrr<rrr4r4r5test_formatdate_usegmt s z(TestMiscellaneous.test_formatdate_usegmtcCs|td|td|td|td|td|td|td|td|td|td|tddS)Nr)r*0zA Complete Waste of Timez Wed, 3 Apr 2002 12.34.56.78+0800)rHrr parsedate_tzrr4r4r5/test_parsedate_returns_None_for_invalid_strings szATestMiscellaneous.test_parsedate_returns_None_for_invalid_stringscCs|tdtddS)NzWed,3 Apr 2002 14:58:26 +0800zWed, 3 Apr 2002 14:58:26 +0800)r-rrrr4r4r5test_parsedate_compact s z(TestMiscellaneous.test_parsedate_compactcCs|j}|tdddS)N25 Feb 2003 13:47:26 -0800) r /rrrr4透r-rrr1r2r4r4r5test_parsedate_no_dayofweek s z-TestMiscellaneous.test_parsedate_no_dayofweekcCs|j}|tdddS)N5 Feb 2003 13:47:26 -0800 rrrr r!rrrr4r"r#r$r4r4r5#test_parsedate_compact_no_dayofweek s z5TestMiscellaneous.test_parsedate_compact_no_dayofweekcCs|tdddS)NzWed, 3 Apr 2002 14:58:26+0800) r}r:r!rrrr4ipr#rr4r4r5.test_parsedate_no_space_before_positive_offset s z@TestMiscellaneous.test_parsedate_no_space_before_positive_offsetcCs|tdddS)NzWed, 3 Apr 2002 14:58:26-0800) r*r}rr+r,r!rrrr4r"r#rr4r4r5.test_parsedate_no_space_before_negative_offset s z@TestMiscellaneous.test_parsedate_no_space_before_negative_offsetcCs*|j}|tdd|tdddS)Nz5 Feb 2003 13.47.26 -0800r'z5 Feb 2003 13.47 -0800) rrr(rr rrrrr4r"r#r$r4r4r5%test_parsedate_accepts_time_with_dots s  z7TestMiscellaneous.test_parsedate_accepts_time_with_dotscCs|j}td}tt|}|t|dd|dd|ttd|dtd}tt|dd}|t|dd|dd|ttd|ddddS)Nr&rz%Yr ) r-rrintr8mktimer9r<r)r1r2Ztimetuprr4r4r5+test_parsedate_acceptable_to_time_functions s    z=TestMiscellaneous.test_parsedate_acceptable_to_time_functionscCs(|tdd|tdddS)N) rrrrrrrr4r4r4rr) r4rrrrrrrr4r4r4ii.)r-rZ mktime_tzrr4r4r5test_mktime_tz s   z TestMiscellaneous.test_mktime_tzcCs4|tdtd|tdtddS)Nz25 Feb 03 13:47:26 -0800rz25 Feb 71 13:47:26 -0800z25 Feb 1971 13:47:26 -0800r#rr4r4r5test_parsedate_y2k s   z$TestMiscellaneous.test_parsedate_y2kcCs.|tdd|ttdddS)Nz<>r)r)r)r-r parseaddr formataddrrr4r4r5test_parseaddr_empty sz&TestMiscellaneous.test_parseaddr_emptycCs:|tdd|tdd|tdddS)Nza@b@cr7za@b.c@cza@172.17.0.1@cr-rr9rr4r4r5test_parseaddr_multiple_domains sz1TestMiscellaneous.test_parseaddr_multiple_domainscCs|tdddS)N)zA Silly Personperson@dom.ainzA Silly Person r-rr:rr4r4r5test_noquote_dump sz#TestMiscellaneous.test_noquote_dumpcCsP|tdd|tddd}d}|tt||f||fdS)N)zA (Very) Silly Personr>z("A (Very) Silly Person" z*"A \(Very\) Silly Person" zA \(Special\) Personr>r-rr:r9r1rrr4r4r5test_escape_dump sz"TestMiscellaneous.test_escape_dumpcCs>|tddd}d}|tt||f||fdS)N)Arthur \Backslash\ Foobarr>z."Arthur \\Backslash\\ Foobar" rDr>rArBr4r4r5test_escape_backslashes( sz)TestMiscellaneous.test_escape_backslashescCsBd}d}d}d}|t||f||t||fd|dS)N Häns Würstr>-=?utf-8?b?SMOkbnMgV8O8cnN0?= z0=?iso-8859-1?q?H=E4ns_W=FCrst?= r7r?)r1raddr utf8_base64Z latin1_quoprir4r4r5test_quotes_unicode_names0 sz+TestMiscellaneous.test_quotes_unicode_namescsld}d}d}dGfddd}|}d|f}|t||f|||t||ftd|dS) NrFr>rGZFOOBARcseZdZfddZdS)zKTestMiscellaneous.test_accepts_any_charset_like_object..CharsetMockcsSrZr4)r1stringr r4r5 header_encodeA szYTestMiscellaneous.test_accepts_any_charset_like_object..CharsetMock.header_encodeN)rorprqrMr4rLr4r5 CharsetMock@ srNz%s <%s>rM)r-rr:r )r1rrHrIrNZmockZ mock_expectedr4rLr5$test_accepts_any_charset_like_object: s z6TestMiscellaneous.test_accepts_any_charset_like_objectcCs(d}d}t}|ttj||f|dS)NrFr>)objectrAttributeErrorrr:)r1rrHZ bad_charsetr4r4r5-test_invalid_charset_like_object_raises_errorI s z?TestMiscellaneous.test_invalid_charset_like_object_raises_errorcCs0d}|ttjd|f|ttjd|fdS)Nupersön@dom.inName)r UnicodeErrorrr:)r1rHr4r4r5!test_unicode_address_raises_errorR sz3TestMiscellaneous.test_unicode_address_raises_errorcCsVd}d}d\}}|t|||f|t|||f|t||f|dS)NzJohn X. Doe z"John X. Doe" )z John X. Doezjxd@example.comr8)r1rNyrrr4r4r5test_name_with_dotX s z$TestMiscellaneous.test_name_with_dotcCs:|j}|tdd|tdd|tdddS)N""example" example"@example.com)r)rX!"\"example\" example"@example.com)r)rY#"\\"example\\" example"@example.com)r)rZr<r$r4r4r52test_parseaddr_preserves_quoted_pairs_in_addressesa s    zDTestMiscellaneous.test_parseaddr_preserves_quoted_pairs_in_addressescCs^|dtd|dtd|dtd|dtd|dtd dS) N)r)merwok wok@xample.comr\)r)merwok wok@xample.comr]z merwok wok @xample.com)r)merwok"wok" wok@xample.comr^)r)zmerwok.wok.wok@xample.comzmerwok. wok . wok@xample.comr<rr4r4r5-test_parseaddr_preserves_spaces_in_local_parts sz?TestMiscellaneous.test_parseaddr_preserves_spaces_in_local_partcCs0d}d}|t|||t||dS)N)z#'foo@example.com' (foo@example.com)foo@example.comz7"'foo@example.com' (foo@example.com)" r8)r1rHZaddrstrr4r4r56test_formataddr_does_not_quote_parens_in_quoted_string szHTestMiscellaneous.test_formataddr_does_not_quote_parens_in_quoted_stringcCsd}|t|ddS)NzFoo Bar )zFoo Barr`r<)r1rNr4r4r5test_multiline_from_comment sz-TestMiscellaneous.test_multiline_from_commentcCs|tdddS)N)zA Silly; Personr>z""A Silly; Person" r?rr4r4r5test_quote_dump sz!TestMiscellaneous.test_quote_dumpcCs|j}|j}t}t}||d||d||d|d||d||d|||d||d||d|d||d||d|||||||dS)NrGUS-ASCIIzUs-AsCiIZusasciiZUSASCIIZUsAsCiI)r-ZassertNotEqualr )r1r2neZcset1Zcset2r4r4r5test_charset_richcomparisons s$             z.TestMiscellaneous.test_charset_richcomparisonscCs"|j}|tddgddgdS)Nzaperson@dom.ain (Al Person)zBud Person )z Al PersonrF)z Bud PersonrGr-r getaddressesr$r4r4r5test_getaddresses sz#TestMiscellaneous.test_getaddressescCsL|j}|tdgdg|tdggd|tddgddgdS)Nzfoo: ;r7z []*-- =~$)r7r7)r)z*--z#"Jason R. Mastaler" )zJason R. Mastalerz jason@dom.ainrgr$r4r4r5test_getaddresses_nasty sz)TestMiscellaneous.test_getaddresses_nastycCs(|j}tdg}||ddddS)Nz%User ((nested comment)) rrr foo@bar.comrg)r1r2addrsr4r4r5"test_getaddresses_embedded_comment s z4TestMiscellaneous.test_getaddresses_embedded_commentcCs(ttdg}||ddddS)NzAl Person rrrrF)rrhr r-)r1rlr4r4r5test_getaddresses_header_obj sz.TestMiscellaneous.test_getaddresses_header_objcs~GdddtfddtdD}t|Wdn1sD0Ytdd|Dg}|tt|t|dS)Nc@seZdZddZdS)zBTestMiscellaneous.test_make_msgid_collisions..MsgidsThreadcSsBg|_|jj}tj}tj}|d}||kr>||ddq$dS)Ng@testdomain-stringdomain)msgidsrr make_msgidr8 monotonic)r1rrsZclockZtfinr4r4r5run s  zFTestMiscellaneous.test_make_msgid_collisions..MsgidsThread.runN)rorprqrur4r4r4r5 MsgidsThread srvcsg|] }qSr4r4rrvr4r5rn roz@TestMiscellaneous.test_make_msgid_collisions..r(cSsg|] }|jqSr4)rr)rlrr4r4r5rn ro)rrr#sumr-ruset)r1threadsZall_idsr4rwr5test_make_msgid_collisions s   z,TestMiscellaneous.test_make_msgid_collisionscCs.|j}t}|jdddd||ddS)Nrrzfoo\wacky"namer)r-rrrjr0r4r4r5test_utils_quote_unquote s z*TestMiscellaneous.test_utils_quote_unquotecCstd}||ddS)Nz not a charsetrNr r-get_body_encodingr1r;r4r4r5)test_get_body_encoding_with_bogus_charset sz;TestMiscellaneous.test_get_body_encoding_with_bogus_charsetcCs|j}t}d|d<||dd|}|t|d||ddt|d}||d|jd|d ||d ||jd d d||d dt}d|d<|}|t|d||ddt|d}||tj |jd|d ||d||d ddS)Nztext/plain; charset=UTF-8r>r:rrrrMrNrr aGVsbG8gd29ybGQ= TrOr<ztext/plain; charset="US-ASCII"rGrr~) r-rrerur r~rJrQrr)r1r2r3rfr;r4r4r5-test_get_body_encoding_with_uppercase_charset s.  z?TestMiscellaneous.test_get_body_encoding_with_uppercase_charsetcCs(td}td}|||dS)NrGrdr})r1ZlcZucr4r4r5test_charsets_case_insensitive sz0TestMiscellaneous.test_charsets_case_insensitivecCs4|j}|d}t}t||||ddS)NraBmultipart/report text/plain message/delivery-status text/plain text/plain text/plain text/plain text/plain text/plain text/plain text/plain text/plain text/plain text/plain text/plain text/plain text/plain text/plain text/plain text/plain text/plain text/plain text/plain text/plain text/plain text/plain text/plain text/plain text/plain text/rfc822-headers r^r_r4r4r51test_partial_falls_inside_message_delivery_status s   zCTestMiscellaneous.test_partial_falls_inside_message_delivery_statuscCs"|tjjddddddS)Nrorpiz@testdomain-string>r-rrrsrr4r4r5test_make_msgid_domain0 sz(TestMiscellaneous.test_make_msgid_domaincCs$|tjjdddddddS)Nz test-idstringro)Zidstringrqiz!.test-idstring@testdomain-string>rrr4r4r5test_make_msgid_idstring5 sz*TestMiscellaneous.test_make_msgid_idstringcCsTtd8}d|_}|tjd|dWdn1sF0YdS)Nzsocket.getfqdnzpythontest.example.com@>)rZ return_valuerrrrsendswith)r1Z mock_getfqdnrqr4r4r5test_make_msgid_default_domain; s    z0TestMiscellaneous.test_make_msgid_default_domaincCsztddd}|}Wdn1s*0Y|dd}t|}t}tj|}||| | |dS)N msg_26.txtr(newliner) r$rrrrrrrrr-rr1fZmsgtxtZ msgtxt_nlr3rrr4r4r5test_Generator_linendB s&    z'TestMiscellaneous.test_Generator_linendcCstddd}|}Wdn1s*0Y|dd}t|}t}tj|}|j|dd| | d|dS)Nrr(rrrr) r$rrrrrrrrr-rrPrr4r4r5test_BytesGenerator_linendM s&   z,TestMiscellaneous.test_BytesGenerator_linendcCstdd}|}Wdn1s(0Y|dd}|dd}t|}t}tj|}|j|dd| | |dS) Nrrtswith attachmentsfo rrr) r$rrrrrrrrr-rrr4r4r5)test_BytesGenerator_linend_with_non_asciiX s &    z;TestMiscellaneous.test_BytesGenerator_linend_with_non_asciic CsFtdd}|}Wdn1s(0Ytdd}|}Wdn1sZ0Ytdft|fft|ffttfftdftdfg}|D]\}}|j |j dd*||}| |j t j jWdn1s0Y|j |j dd4||d t j ji}| |j t j jWdq1s60YqdS) Nrrtrs)r))r1r2re)clsrrgr)r$rrrrrrrrsubTestrorrrrerg)r1rZ audiodatar|classesr constructorrr4r4r5!test_mime_classes_policy_argumentd s$ & &  0z3TestMiscellaneous.test_mime_classes_policy_argumentN)7rorprqrrrrrrrrrrrr%r)r-r.r/r3r5r6r;r=r@rCrErJrOrRrUrWr[r_rarbrcrfrirjrmrnr{r|rrrrrrrrrrrr4r4r4r5r] sh            *   rc@s4eZdZddZddZddZddZd d Zd S) TestIteratorscCs|j}|j}|d}t|}t|}|t|d|t|| |d}t|}t|}|t|dt d$}|t|| Wdn1s0YdS)Nr|rr+z msg_19.txt) r-rr.rZbody_line_iteratorrru EMPTYSTRINGrrQr$r)r1r2ryr3itrrr4r4r5test_body_line_iterator| s     z%TestIterators.test_body_line_iteratorcCsb|j}|d}t|d}g}d}|D]}|d7}||q(||d|t|ddS)Nrhrrrrrz`a simple kind of mirror to reflect upon our own a simple kind of mirror to reflect upon our own r-r.rZtyped_subpart_iteratorrrQrrr1r2r3rrZsubpartsrur4r4r5test_typed_subpart_iterator s   z)TestIterators.test_typed_subpart_iteratorcCsd|j}|d}t|dd}g}d}|D]}|d7}||q*||d|t|ddS)Nr~rr*rrrz% Hi, Do you like this message? -Me rrr4r4r5(test_typed_subpart_iterator_default_type s  z6TestIterators.test_typed_subpart_iterator_default_typec Csgd}ddlm}m}|}g}d}|D]N\}}||||7}d} t|j|D]} || | d7} qT||| q*|t|||d dd|Dd |dS)N))za r)rr)zc rr)r)r)zd rr)ze r)z frr)rrrrBufferedSubFile NeedMoreDatarrr)cSsg|] \}}|qSr4r4)rlilnr4r4r5rn roz0TestIterators.test_pushCR_LF..) email.feedparserrrpushiterreadlinerr-rur) r1ZimtrrbsfZomntrrZn1Zolr4r4r5test_pushCR_LF s     zTestIterators.test_pushCR_LFc sddlm}m}d}d}ddfddt|Dd }|d }|}g}tdt||D]0} || | |} || |t |j |q`| ||dS) Nrri'r(zabcd r)c3s|]}tVqdSrZrrcharsr4r5r roz1TestIterators.test_push_random..r(T) rrrrrrrurextendrrr-) r1rrr chunksizertargetrrrchunkr4rr5test_push_random s   zTestIterators.test_push_randomN)rorprqrrrrrr4r4r4r5r{ s rc@s,eZdZddZddZddZddZd S) TestFeedParserscCs"t}|D]}||q |SrZ)r&feedclose)r1chunksr rr4r4r5parse s zTestFeedParsers.parsecCs.|d}||dd||dddS)NzFirst: val : bad Second: valr9valr;)rr-r\r4r4r5test_empty_header_name_handled s z.TestFeedParsers.test_empty_header_name_handledcCs|dg}||gd|dg}||gd|ddg}||ddg|dd g}||dd g|dd g}||dd g|d g}||d g|gd}||ddgdS)Nz a: b: c: d: )rrcdz a: b: c: d:za: bc: rZbca: zb: rz b: u a:…b:
c: )ru …b:
c:)rub:…rrr))ru…c:)rr-rBrrlr4r4r5 test_newlines s   zTestFeedParsers.test_newlinescCsd\}}|dgd|g|}||dg||d|||dgd|g|}||dg||d|||dgd|dg|}||dg||d|d||ddgd|g|}||d d d||fgdS) N)ii Nza:b rN)rrza:b …rzb: rr)rr-rrQ)r1MNrr4r4r5test_long_linesszTestFeedParsers.test_long_linesN)rorprqrrrrr4r4r4r5r src@seZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ dZ ddZddZddZddZddZd d!Zd"d#ZdS)$ TestParserscCs|j}td}t|}Wdn1s00Y||dd||dd||d||||t dS)Nrrppp-request@zzz.orgr ppp@zzz.orgr^) r-r$rrrBr"r#rJrQrr1r2rr3r4r4r5test_header_parsers *zTestParsers.test_header_parsercCs|j}tdd }tj|}Wdn1s60Y||dd||dd||d||| | t | |j dd t dS) Nrrtrrrrr^TrO) r-r$rrrrrBr"r#rJrQrrrr4r4r5test_bytes_header_parsers .z$TestParsers.test_bytes_header_parsercCsJtdd,}tj|||jWdn1s<0YdS)Nrrt)r$rr BytesParserrr"closedrr4r4r5%test_bytes_parser_does_not_close_file+s z1TestParsers.test_bytes_parser_does_not_close_filecCs`tddB}tjj}|tjj|tjjdj || |j Wdn1sR0YdS)Nrkrtr) r$rrrrrrmrstrictrr"r)r1rZ bytesParserr4r4r52test_bytes_parser_on_exception_does_not_close_file0s  z>TestParsers.test_bytes_parser_on_exception_does_not_close_filecCsJtdd,}tj|||jWdn1s<0YdS)Nrr)r$rrr rr"rrr4r4r5test_parser_does_not_close_file8s z+TestParsers.test_parser_does_not_close_filecCs`tddB}tjj}|tjj|tjjdj || |j Wdn1sR0YdS)Nrkrr) r$rrr rrrmrrrr"r)r1rrr4r4r5,test_parser_on_exception_does_not_close_file=s   z8TestParsers.test_parser_on_exception_does_not_close_filecCs>|j}td}||dd||dd||ddS)NzFrom: aperson@dom.ain To: bperson@dom.ain Subject: the next line has a space on it Date: Mon, 8 Apr 2002 15:09:19 -0400 Message-ID: spam Here's the message body r!the next line has a space on it rspamHere's the message body r-rrrQr0r4r4r5test_whitespace_continuationDs  z(TestParsers.test_whitespace_continuationcCs>|j}td}||dd||dd||ddS)NzFrom: aperson@dom.ain To: bperson@dom.ain Date: Mon, 8 Apr 2002 15:09:19 -0400 Message-ID: spam Subject: the next line has a space on it Here's the message body rrrrrrr0r4r4r5(test_whitespace_continuation_last_headerVs  z4TestParsers.test_whitespace_continuation_last_headercCs|j}tddd}t|}Wdn1s40Y|t|d|d}||d||d|d}||d dS) Nrr(rrrr9z!Simple email with attachment. rrzapplication/riscos)r-r$r rrurQrB)r1r2rr3part1part2r4r4r5test_crlf_separationhs*  z TestParsers.test_crlf_separationcCsntddd}|}Wdn1s*0Yt|}t}t|}|j|dd|||dS)Nrr(rrrrrr4r4r5test_crlf_flattenss& zTestParsers.test_crlf_flattenNc Cs:|j}|j}td}t|}Wdn1s40Y||d|t|d|d}||d||d|t|d|d}||d||d||d|d}||d||d|t|d|d}||d||d||ddS) Nrrrrrrr9rr) r-rr$rrr#rurQrB) r1r2ryrr3rZpart1arZpart2ar4r4r5-test_multipart_digest_with_extra_mime_headerss, (    z9TestParsers.test_multipart_digest_with_extra_mime_headerscCs,gd}tt|}||dddS)N)z$From: Andrew Person From: foo From: bar !"#QUX;~: zoo bodyrcss|] }|VqdSrZr4)rlZfieldr4r4r5rroz9TestParsers.test_rfc2822_header_syntax..)z!"#QUX;~z>Fromrr)r-rrrur rQrr4r4r5test_rfc2822_header_syntaxs  z&TestParsers.test_rfc2822_header_syntaxcCs*|j}d}t|}|t|ddS)Nz<>From foo@example.com 11:25:53 From: bar !"#QUX;~: zoo bodyr)r-rrrurBrr4r4r5(test_rfc2822_space_not_allowed_in_headers z4TestParsers.test_rfc2822_space_not_allowed_in_headercCsD|j}d}t|}|}|||gd||ddS)Nz7A: first header B: second header CC: third header body)ABZCCr)r-rrrBsortrQ)r1r2rr3Zheadersr4r4r5!test_rfc2822_one_character_headers z-TestParsers.test_rfc2822_one_character_headercCs,d}t|}||dddS)NzFrom: foo@bar.com To: baz Mime-Version: 1.0 Content-Type: multipart/mixed; boundary=BOUNDARY --BOUNDARY Content-Type: text/plain body ending with CRLF newline --BOUNDARY-- rr)rrrrQrr1rr3r4r4r5test_CRLFLF_at_end_of_parts z&TestParsers.test_CRLFLF_at_end_of_part)rorprqrrrrrrrrrrrrrrrrrrr4r4r4r5rs$      rc@seZdZedZddZddZddZdd Z d d Z d d Z dZ d dde DddZddZddZddZddZddZddZd d!Zd"d#Zd$d%Zd&d'Zd(d)Zed*dZd+d,Zd-d.Zed/Zd0d1Zd2d3Z d4d5Z!e"dZ#d6ge#d7d8<d e#Z#d9d:Z$ed;d<Z%ed=Z&d>d?Z'd@dAZ(dBdCZ)dDdEZ*dFdGZ+dHdIZ,dJdKZ-dLZ.dLS)MTest8BitBytesHandlingz From: foo@bar.com To: baz Mime-Version: 1.0 Content-Type: text/plain; charset={charset} Content-Transfer-Encoding: {cte} {bodyline} cCsP|jjddddd}t|}||d||jdddddS)NrMrVpöstalr;rZbodylinepöstal TrO bodytest_msgrbrrrr-rQrr4r4r5test_known_8bit_CTEs z)Test8BitBytesHandling.test_known_8bit_CTEcCsP|jjddddd}t|}||d||jddd ddS) NZnotavalidcharsetrVrrrMu p��stal TrOrrrr4r4r5test_unknown_8bit_CTEs z+Test8BitBytesHandling.test_unknown_8bit_CTEcCsP|jjddddd}t|}||d||jdddddS) NrMr= p=C3=B6stálru p=C3=B6stál TrO pöstál rrr4r4r5test_8bit_in_quopri_bodys  z.Test8BitBytesHandling.test_8bit_in_quopri_bodycCsP|jjddddd}t|}||d||jddd ddS) Nrr=rrrMup=C3=B6st��l TrOrrrr4r4r5.test_invalid_8bit_in_non_8bit_cte_uses_replaces zDTest8BitBytesHandling.test_invalid_8bit_in_non_8bit_cte_uses_replacecCsT|jjddddd}t|}||jdddd||jdt j dS) NrMrNu cMO2c3RhbAá=rTrOrr) rrbrrrr-rQrJrKrrLrr4r4r5test_8bit_in_base64_body#s  z.Test8BitBytesHandling.test_8bit_in_base64_bodycCs@|jjddddd}t|}||jdddddS)NrMru <,.Vz Yes, they are flying. rMcCs:t|j}|t|dd|t|dddS)Nrb��z)rrheadertest_msgr-rrr\r4r4r5test_get_8bit_headerHs z*Test8BitBytesHandling.test_get_8bit_headercCs8t|j}|t|tdjdd|jDdS)Nz From: {} To: {} Subject: {} From: {} Yes, they are flying. cSsg|]\}}|dqS)rrr4)rlrrr4r4r5rnWrozATest8BitBytesHandling.test_print_8bit_headers..) rrrr-rrrrbheadertest_headersr\r4r4r5test_print_8bit_headersMs   z-Test8BitBytesHandling.test_print_8bit_headerscCs.t|j}|dd|DgddS)NcSsg|] }t|qSr4rrvr4r4r5rn\rozGTest8BitBytesHandling.test_values_with_8bit_headers..)rkr]Maintenant je vous pr��sente mon coll��gue, le pouf c��l��bre Jean de Baddie g��st)rrrassertListEqualrCr\r4r4r5test_values_with_8bit_headersZs z3Test8BitBytesHandling.test_values_with_8bit_headerscCs.t|j}|dd|DgddS)NcSs g|]\}}t|t|fqSr4r)rlrNrVr4r4r5rngrozFTest8BitBytesHandling.test_items_with_8bit_headers..)r)rr)rjr)rr)rrrrrr\r4r4r5test_items_with_8bit_headerses z2Test8BitBytesHandling.test_items_with_8bit_headerscCs0t|j}|dd|dDddgdS)NcSsg|] }t|qSr4rrvr4r4r5rnsrozHTest8BitBytesHandling.test_get_all_with_8bit_headers..rrkr)rrrrr/r\r4r4r5test_get_all_with_8bit_headersqs  z4Test8BitBytesHandling.test_get_all_with_8bit_headerscCsJttdd}||d||d||ddS)NuA Content-Type: text/pl§in; charset=utf-8 r[u text/pl�inrupl�in) rrrrrr-rBr r,r\r4r4r5test_get_content_type_with_8bitws z5Test8BitBytesHandling.test_get_content_type_with_8bitcCsXtdd}||jddgd||jdddd||jdddddS) Nu(X-Header: foo=§ne; b§r=two; baz=three r[rr))r�ne)ub�rrrZFoor ub§r)rrrr-rrCr\r4r4r5test_get_params_with_8bitsz/Test8BitBytesHandling.test_get_params_with_8bitcCs,ttdd}||dddS)Nn Content-Type: text/plain; charset=us-ascii; title*=us-ascii'en'This%20is%20not%20f§nr[title)rGenuThis is not f�n)rrrrrr-rCr\r4r4r5!test_get_rfc2231_params_with_8bits  z7Test8BitBytesHandling.test_get_rfc2231_params_with_8bitcCs8ttdd}|dd||dddS)Nr r[r test)rrrrrrr-rCr\r4r4r5!test_set_rfc2231_params_with_8bits  z7Test8BitBytesHandling.test_set_rfc2231_params_with_8bitcCsFttdd}|d||dd||ddS)Nr r[r r) rrrrrrr-rCr r\r4r4r5!test_del_rfc2231_params_with_8bits  z7Test8BitBytesHandling.test_del_rfc2231_params_with_8bitcCs>ttdd}||d||jddddS)Nu Content-Transfer-Encoding: b§se64 Content-Type: text/plain; charset=latin-1 payload r[zpayload TrOspayload )rrrrrr-rQr\r4r4r5%test_get_payload_with_8bit_cte_headers z;Test8BitBytesHandling.test_get_payload_with_8bit_cte_headeru0 From: foo@bar.com To: báz Subject: Maintenant je vous présente mon collègue, le pouf célèbre Jean de Baddie Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Да, они летят. cCs:t|j}t}tj|||||jdSrZ) rrnon_latin_bin_msgrrrrr-rr1r3rr4r4r5test_bytes_generators z*Test8BitBytesHandling.test_bytes_generatorcCs6tj}t}tj||||ddS)Nr) rr"rrrrrr-rrr4r4r5&test_bytes_generator_handles_None_bodys z Subject: Aktuelles zu Japan, Klonfleisch und Smiley-System Message-ID: <76a486bee62b0d200f33dc2ca08220ad@localhost.localdomain> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="b1_76a486bee62b0d200f33dc2ca08220ad" --b1_76a486bee62b0d200f33dc2ca08220ad Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Guten Tag, , mit großer Betroffenheit verfolgen auch wir im foodwatch-Team die Nachrichten aus Japan. --b1_76a486bee62b0d200f33dc2ca08220ad Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: 8bit foodwatch - Newsletter

mit großer Betroffenheit verfolgen auch wir im foodwatch-Team die Nachrichten aus Japan.

--b1_76a486bee62b0d200f33dc2ca08220ad-- rM) rrrrrrrrrr-r)r1rr3rrr4r4r5test_8bit_multipart1s %&   z)Test8BitBytesHandling.test_8bit_multipartcCsFt}td|d<t}tj|}|j|dd||ddS)Nžluťoučký kůňrjrrs5Subject: =?utf-8?b?xb5sdcWlb3XEjWvDvSBrxa/FiA==?= ) rr rrrrrr-rr1rrrr4r4r5'test_bytes_generator_b_encoding_linesep_s  z=Test8BitBytesHandling.test_bytes_generator_b_encoding_linesepcCsFt}td|d<t}tj|}|j|dd||ddS)Nr&rjrrz5Subject: =?utf-8?b?xb5sdcWlb3XEjWvDvSBrxa/FiA==?= ) rr rrrrrr-rr'r4r4r5!test_generator_b_encoding_linesepks  z7Test8BitBytesHandling.test_generator_b_encoding_linesepN)/rorprqrrrrrrrrrrrrrrrrrrrr rrrrrrrrrrrrrrr r!r"r#r$rr%r(r)rr4r4r4r5rsd                       .  rc@s"eZdZdZddZdddZdS) BaseTestBytesGeneratorIdempotentNcCsTt|d}|}Wdn1s(0Y|j|j|}t|}||fS)Nrt)r$rnormalize_linesep_regexsubblineseprrrr4r4r5r.~s  & z(BaseTestBytesGeneratorIdempotent._msgobjFcCs<t}tjj|dd}|j|||jd|||dS)Nrr)rr)rrrrrrr-r)r1r3rSrrrr4r4r5rsz,BaseTestBytesGeneratorIdempotent._idempotent)F)rorprqrr.rr4r4r4r5r*zsr*c@seZdZdZdZedZdS)TestBytesGeneratorIdempotentNLr(rs\r\nNrorprqrr-recompiler+r4r4r4r5r.sr.c@seZdZdZdZedZdS) TestBytesGeneratorIdempotentCRLFrrs (?d}n<|dkrLd}n.|d krZd }n |d krhd }n|d krvd }nd}|td||q,dS)Nhellohellor)eolrrr}rr0 rN)r-r header_lengthru body_encoder)r1r2sizeZbsizer4r4r5test_lens  zTestBase64.test_lencCs*|j}|tdd|tdddS)Nr)rozaGVsbG8=r5)r-r rPr$r4r4r5 test_decodeszTestBase64.test_decodecCsd|j}|tdd|tdd|tdd|tjdddd |tjddd d d dS) Nror5z aGVsbG8= shello z aGVsbG8K sdxxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx (rzeHh4eCB4eHh4IHh4eHggeHh4eCB4eHh4IHh4eHgg eHh4eCB4eHh4IHh4eHggeHh4eCB4eHh4IHh4eHgg eHh4eCB4eHh4IHh4eHggeHh4eCB4eHh4IHh4eHgg eHh4eCB4eHh4IA== rrr7zeHh4eCB4eHh4IHh4eHggeHh4eCB4eHh4IHh4eHgg eHh4eCB4eHh4IHh4eHggeHh4eCB4eHh4IHh4eHgg eHh4eCB4eHh4IHh4eHggeHh4eCB4eHh4IHh4eHgg eHh4eCB4eHh4IA== )r-r r>r$r4r4r5 test_encodeszTestBase64.test_encodecCsZ|j}tj}||dd||dd||dd||dddd ||dddS) Nr4z=?iso-8859-1?b?aGVsbG8=?= hello worldz!=?iso-8859-1?b?aGVsbG8NCndvcmxk?= hello worldz!=?iso-8859-1?b?aGVsbG8Kd29ybGQ=?=rbr z=?iso-8859-2?b?aGVsbG8=?=)r-r rM)r1r2her4r4r5test_header_encodeszTestBase64.test_header_encodeN)rorprqr@rArDrHr4r4r4r5r3s r3c@s*eZdZddZddZddZddZd d Zd d ZdddZ ddZ ddZ ddZ ddZ ddZddZddZddZd d!Zd"d#Zd$d%Zdd&d'Zd(d)Zd*d+Zd,d-Zd.d/Zd0d1Zd2d3Zd4d5Zd6d7Zd8d9Zd:d;Zdd?Z!d@dAZ"dBdCZ#dDdEZ$dFdGZ%dHdIZ&dJdKZ'dLdMZ(dNdOZ)dPdQZ*dRdSZ+dTdUZ,ddVdWZ-dXdYZ.dZd[Z/d\d]Z0d^d_Z1d`daZ2dbdcZ3dddeZ4dfdgZ5dhdiZ6djdkZ7dldmZ8dndoZ9dpdqZ:drdsZ;dtduZdzd{Z?d|d}Z@d~dZAddZBddZCddZDddZEd S) TestQuopricsttttdtddttdtddttdtdddd d D_fd d td D_tttdtdd_jtdjtdfdd td D_ dS)NrzrrrZr9css|] }|VqdSrZr4rlrr4r4r5rroz#TestQuopri.setUp..s!*+-/csg|]}|jvr|qSr4)hlitrMrr4r5rnroz$TestQuopri.setUp..r*~r=csg|]}|jvr|qSr4)blitrMrr4r5rnro) rrrordrNhnonrRrremovebnonrr4rr5rs zTestQuopri.setUpcCsP|jD]}|t|dt|q|jD]}|t|dt|q,dS)Nz'Should not be header quopri encoded: %sz#Should be header quopri encoded: %s)rNr"r!Z header_checkchrrTrr1rr4r4r5test_quopri_header_checks      z#TestQuopri.test_quopri_header_checkcCsP|jD]}|t|dt|q|jD]}|t|dt|q,dS)Nz%Should not be body quopri encoded: %sz!Should be body quopri encoded: %s)rRr"r!Z body_checkrWrVrrXr4r4r5test_quopri_body_checks      z!TestQuopri.test_quopri_body_checkcCs|j}|tdd|ttjdddtdd|tdd|ttjdddtdd|jD]$}|tt|gdd t|qp|jD]2}|t d krq|tt|gd d t|q|td ddS)Nr5r(Zxxxr rs h@e@l@l@o@r<rrzexpected length 1 for %rr*rzexpected length 3 for %r ) r-r!r=rurMrNrrWrTrSr1r2rr4r4r5test_header_quopri_lens0     z!TestQuopri.test_header_quopri_lencCsN|j}|jD]}|tt|gdq |jD]}|tt|gdq.dS)Nrrr)r-rRr!Z body_lengthrrVr\r4r4r5test_body_quopri_lens   zTestQuopri.test_body_quopri_lencCs2tdD]$}t|}|tt||qdS)NrO)rrWr-r!rquote)r1rNrr4r4r5test_quote_unquote_idempotents z(TestQuopri.test_quote_unquote_idempotentNcCs0|durt|}n t||}|||dSrZ)r!rMr-)r1rZexpected_encoded_headerr;encoded_headerr4r4r5_test_header_encodes  zTestQuopri._test_header_encodecCs|dddS)Nror)rbrr4r4r5test_header_encode_null"sz"TestQuopri.test_header_encode_nullcCs|dddS)Nr5z=?iso-8859-1?q?hello?=rcrr4r4r5test_header_encode_one_word%sz&TestQuopri.test_header_encode_one_wordcCs|dddS)Ns hello worldz=?iso-8859-1?q?hello=0Aworld?=rcrr4r4r5test_header_encode_two_lines(sz'TestQuopri.test_header_encode_two_linescCs|dddS)Ns hellotherez=?iso-8859-1?q?hello=C7there?=rcrr4r4r5test_header_encode_non_ascii,sz'TestQuopri.test_header_encode_non_asciicCs|jdddddS)Nr5z=?iso-8859-2?q?hello?=rbr rcrr4r4r5test_header_encode_alt_charset0sz)TestQuopri.test_header_encode_alt_charsetcCst|}|||dSrZ)r! header_decoder-)r1raZexpected_decoded_headerZdecoded_headerr4r4r5_test_header_decode4s zTestQuopri._test_header_decodecCs|dddSNr)rjrr4r4r5test_header_decode_null8sz"TestQuopri.test_header_decode_nullcCs|dddSNr4rlrr4r4r5test_header_decode_one_word;sz&TestQuopri.test_header_decode_one_wordcCs|dddS)Nz hello=0AworldrFrlrr4r4r5test_header_decode_two_lines>sz'TestQuopri.test_header_decode_two_linescCs|dddS)Nz hello=C7thereu helloÇthererlrr4r4r5test_header_decode_non_asciiAsz'TestQuopri.test_header_decode_non_asciicCs|tdddS)Na=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30A00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000)r-r!rirr4r4r5test_header_decode_re_bug_18380Dsz*TestQuopri.test_header_decode_re_bug_18380cCs2|durt|}ntj||d}|||dS)Nr6)r!rPr-)r1encodedZexpected_decodedr7decodedr4r4r5 _test_decodeHs zTestQuopri._test_decodecCs|dddSrkrurr4r4r5test_decode_null_wordOsz TestQuopri.test_decode_null_wordcCs|dddS)Nrr(rvrr4r4r5test_decode_null_line_null_wordRsz*TestQuopri.test_decode_null_line_null_wordcCs|dddSrnrvrr4r4r5test_decode_one_wordUszTestQuopri.test_decode_one_wordcCs|jdddddS)Nr4Xr6rvrr4r4r5test_decode_one_word_eolXsz#TestQuopri.test_decode_one_word_eolcCs|dddSNhello hello rvrr4r4r5test_decode_one_line[szTestQuopri.test_decode_one_linecCs|dddSNr~rvrr4r4r5test_decode_one_line_lf^sz"TestQuopri.test_decode_one_line_lfcCs|dddS)Nzhello r~rvrr4r4r5test_decode_one_line_crasz"TestQuopri.test_decode_one_line_crcCs|jdddddS)Nr~helloXrzr6rvrr4r4r5test_decode_one_line_nldsz"TestQuopri.test_decode_one_line_nlcCs|jdddddS)Nr}rrzr6rvrr4r4r5test_decode_one_line_crnlgsz$TestQuopri.test_decode_one_line_crnlcCs|dddS)NrErFrvrr4r4r5test_decode_one_line_one_wordjsz(TestQuopri.test_decode_one_line_one_wordcCs|jdddddS)NrEZ helloXworldrzr6rvrr4r4r5!test_decode_one_line_one_word_eolmsz,TestQuopri.test_decode_one_line_one_word_eolcCs|dddS)Nhello world hello world rvrr4r4r5test_decode_two_linespsz TestQuopri.test_decode_two_linescCs|jdddddS)NrZ helloXworldXrzr6rvrr4r4r5test_decode_two_lines_eolssz$TestQuopri.test_decode_two_lines_eolcCs|dddS)NASpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamrvrr4r4r5test_decode_one_long_linevsz$TestQuopri.test_decode_one_long_linecCs|dddS)Nr*r)rvrr4r4r5test_decode_one_spaceysz TestQuopri.test_decode_one_spacecCs|dddS)Nz r)rvrr4r4r5test_decode_multiple_spaces|sz&TestQuopri.test_decode_multiple_spacescCs|dddS)Nz hello r~rvrr4r4r5$test_decode_one_line_trailing_spacessz/TestQuopri.test_decode_one_line_trailing_spacescCs|dddS)Nzhello world rrvrr4r4r5%test_decode_two_lines_trailing_spacessz0TestQuopri.test_decode_two_lines_trailing_spacescCs|dddS)Nz=22quoted=20words=22z"quoted words"rvrr4r4r5test_decode_quoted_wordsz"TestQuopri.test_decode_quoted_wordcCs|dddS)Nzab=CD=EFabÍïrvrr4r4r5test_decode_uppercase_quotingsz(TestQuopri.test_decode_uppercase_quotingcCs|dddS)Nzab=cd=efrrvrr4r4r5test_decode_lowercase_quotingsz(TestQuopri.test_decode_lowercase_quotingcCs|dddS)Nzsoft line= breakzsoft linebreakrvrr4r4r5test_decode_soft_line_breaksz&TestQuopri.test_decode_soft_line_breakcCs|dddS)NzA=1,B=A ==> A+B==2rvrr4r4r5test_decode_false_quotingsz$TestQuopri.test_decode_false_quotingcCsi}|durd}n||d<|dur(d}n||d<tj|fi|}||||dks^|dkr||D]}|t||qfdS)Nrwrr(r7r)r!r>r-rrzru)r1rZexpected_encoded_bodyrr7kwargsZ encoded_bodyrr4r4r5 _test_encodes  zTestQuopri._test_encodecCs|dddSrkrrr4r4r5test_encode_nullszTestQuopri.test_encode_nullcCs|dddS)Nz rrr4r4r5test_encode_null_linessz!TestQuopri.test_encode_null_linescCs|dddSrrrr4r4r5test_encode_one_lineszTestQuopri.test_encode_one_linecCs|dddSr|rrr4r4r5test_encode_one_line_crlfsz$TestQuopri.test_encode_one_line_crlfcCs|jdddddS)Nr~r}rr6rrr4r4r5test_encode_one_line_eolsz#TestQuopri.test_encode_one_line_eolcCs |jdddddddS)Nuhelloυ rMlatin1z hello=CF=85 rr6)rrrPrr4r4r5(test_encode_one_line_eol_after_non_asciisz3TestQuopri.test_encode_one_line_eol_after_non_asciicCs|dddS)Nr*z=20rrr4r4r5test_encode_one_spacesz TestQuopri.test_encode_one_spacecCs|dddS)Nz z=20 rrr4r4r5test_encode_one_line_one_spacesz)TestQuopri.test_encode_one_line_one_spacecCs|dddS)Nz z=20 =20 rrr4r4r5test_encode_two_lines_one_spacesz*TestQuopri.test_encode_two_lines_one_spacecCs|dddS)Nzhello z hello =20rrr4r4r5$test_encode_one_word_trailing_spacessz/TestQuopri.test_encode_one_word_trailing_spacescCs|dddS)Nz hello z hello =20 rrr4r4r5$test_encode_one_line_trailing_spacessz/TestQuopri.test_encode_one_line_trailing_spacescCs|dddS)Nzhello z hello =09rrr4r4r5!test_encode_one_word_trailing_tabsz,TestQuopri.test_encode_one_word_trailing_tabcCs|dddS)Nz hello z hello =09 rrr4r4r5!test_encode_one_line_trailing_tabsz,TestQuopri.test_encode_one_line_trailing_tabcCs|jdddddS)N abcd 1234z abcd = 1234rrrrr4r4r5,test_encode_trailing_space_before_maxlinelensz7TestQuopri.test_encode_trailing_space_before_maxlinelencCs|jdddddS)Nrzabcd= =20 1234r(rrrr4r4r5(test_encode_trailing_space_at_maxlinelensz3TestQuopri.test_encode_trailing_space_at_maxlinelencCs|jdddddS)Nrzabc= d=20 1234r}rrrr4r4r5,test_encode_trailing_space_beyond_maxlinelensz7TestQuopri.test_encode_trailing_space_beyond_maxlinelencCs|dddS)Nz z=20 =20 =20 =20 =20 rrr4r4r5test_encode_whitespace_linessz'TestQuopri.test_encode_whitespace_linescCs|dddS)Nza = bza =3D brrr4r4r5test_encode_quoted_equalssz$TestQuopri.test_encode_quoted_equalscCs|dddS)NZdxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxzfxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx= xxxxxxxxxxxxxxxxxxxxxxxxxrrr4r4r5test_encode_one_long_stringsz&TestQuopri.test_encode_one_long_stringcCs|dddS)Nzexxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx zgxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx= xxxxxxxxxxxxxxxxxxxxxxxxx rrr4r4r5test_encode_one_long_linesz$TestQuopri.test_encode_one_long_linecCs|dddS)Nzxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx zxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx= xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx= xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx rrr4r4r5test_encode_one_very_long_linesz)TestQuopri.test_encode_one_very_long_linecCs|jdddddS)Nz=====z=3D= =3D= =3D= =3D= =3Dr}rrrr4r4r5test_encode_shortest_maxlinelensz*TestQuopri.test_encode_shortest_maxlinelencCs|jt|jdddddS)Nr)rr)rrrrr4r4r5 test_encode_maxlinelen_too_smallsz+TestQuopri.test_encode_maxlinelen_too_smallcCst|j}|tdd|tdd|tdd|tjdddd|tjddd d d |td d dS) Nr)r4rErFdxxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx rBrzjxxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx= xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxx= x xxxx xxxx xxxx xxxx=20rrCzlxxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx= xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxx= x xxxx xxxx xxxx xxxx=20zone line two line)r-r!r>r$r4r4r5rDs zTestQuopri.test_encode)N)N)NN)FrorprqrrYrZr]r^r`rbrdrerfrgrhrjrmrorprqrrrurwrxryr{rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrDr4r4r4r5rIs   rIc@s,eZdZddZddZddZddZd S) TestCharsetcCs0ddlm}z |jd=Wnty*Yn0dS)Nrr fake)rr;ZCHARSETSrE)r1 CharsetModuler4r4r5tearDowns    zTestCharset.tearDowncCsN|j}td}||ddd}|t|j|td}|||ddS)NrG Hello World!u¤¢¤¤¤¦¤¨¤ªrMz(=?utf-8?b?wqTCosKkwqTCpMKmwqTCqMKkwqo=?=)r-r rMrrT)r1r2rrr4r4r5test_codec_encodeablesz!TestCharset.test_codec_encodeablecCs|j}td}|d|dtd}|d|dtd}|d|dtd }d d lm}|d |jddtd }|d|ddS) Nr7z hello w=F6rldu hello wörldrMrrrGrrrr r)r-r r>rr;Z add_charsetZQP)r1r2rrr4r4r5test_body_encode$s zTestCharset.test_body_encodecCs,td}|t|d|tjtddS)NrGuascÿii)r r-rrrZ CharsetErrorrr4r4r5test_unicode_charset_nameCsz%TestCharset.test_unicode_charset_nameN)rorprqrrrrr4r4r4r5rs rc@seZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZddZddZdd Zd!d"Zd#d$Zd%d&Zd'd(Zd)d*Zd+d,Zd-d.Zd/d0Zd1d2Zd3S)4 TestHeadercCs8|j}td}||d|d||ddS)Nrz Goodbye World!zHello World! Goodbye World!rr rrrr4r4r5 test_simpleLs  zTestHeader.test_simplecCs8|j}td}||d|d||ddS)NrzGoodbye World!zHello World! Goodbye World!rrr4r4r5test_simple_surpriseSs  zTestHeader.test_simple_surprisecCsd}|t||dfgdS)Nzno decoding neededrrr4r4r5test_header_needs_no_decodingZsz(TestHeader.test_header_needs_no_decodingcCs8tddd}|jdddD]}|t|dqdS)NaI am the very model of a modern Major-General; I've information vegetable, animal, and mineral; I know the kings of England, and I quote the fights historical from Marathon to Waterloo, in order categorical; I'm very well acquainted, too, with matters mathematical; I understand equations, both the simple and quadratical; about binomial theorem I'm teeming with a lot o' news, with many cheerful facts about the square of the hypotenuse.rwrr*)Z splitcharsz )r rrrzru)r1rlr4r4r5 test_long^s zTestHeader.test_longc Cs|j}td}td}td}d}d}d}t||}|||||||jdd} || d t| } |t| d || d |df|| d |df|| d |ddft|} || ddt t| } || |dS)Nr7rbrMrrrrwra=?iso-8859-1?q?Die_Mieter_treten_hier_ein_werden_mit_einem_Foerderband_kom?= =?iso-8859-1?q?fortabel_den_Korridor_entlang=2C_an_s=FCdl=FCndischen_Wand?= =?iso-8859-1?q?gem=E4lden_vorbei=2C_gegen_die_rotierenden_Klingen_bef=F6r?= =?iso-8859-1?q?dert=2E_?= =?iso-8859-2?q?Finan=E8ni_metropole_se_hroutily?= =?iso-8859-2?q?_pod_tlakem_jejich_d=F9vtipu=2E=2E_?= =?utf-8?b?5q2j56K6?= =?utf-8?b?44Gr6KiA44GG44Go57+76Kiz44Gv44GV44KM44Gm44GE44G+44Gb44KT44CC?= =?utf-8?b?5LiA6YOo44Gv44OJ44Kk44OE6Kqe44Gn44GZ44GM44CB44GC44Go44Gv44Gn?= =?utf-8?b?44Gf44KJ44KB44Gn44GZ44CC5a6f6Zqb44Gr44Gv44CMV2VubiBpc3QgZGFz?= =?utf-8?b?IE51bnN0dWNrIGdpdCB1bmQgU2xvdGVybWV5ZXI/IEphISBCZWloZXJodW5k?= =?utf-8?b?IGRhcyBPZGVyIGRpZSBGbGlwcGVyd2FsZHQgZ2Vyc3B1dC7jgI3jgajoqIA=?= =?utf-8?b?44Gj44Gm44GE44G+44GZ44CC?=rrrrrsDie Mieter treten hier ein werden mit einem Foerderband komfortabel den Korridor entlang, an südlündischen Wandgemälden vorbei, gegen die rotierenden Klingen befördert. Finančni metropole se hroutily pod tlakem jejich důvtipu.. 正確に言うと翻訳はされていません。一部はドイツ語ですが、あとはでたらめです。実際には「Wenn ist das Nunstuck git und Slotermeyer? Ja! Beiherhund das Oder die Flipperwaldt gersput.」と言っています。) rr r rrr rurrPr ) r1r2rrrrrrrencrtZustrZnewhr4r4r5test_multilingualds2      zTestHeader.test_multilingualcCst}||ddSrkrrr4r4r5test_empty_header_encodesz#TestHeader.test_empty_header_encodecCs4|j}t}||d|dtd||ddS)Nr)rr7)rr rr rr4r4r5test_header_ctor_default_argss  z(TestHeader.test_header_ctor_default_argscCs|j}d}t|}||d|t||t|dd}||d|t||t|ddd}||||t||dS)Nz|A very long line that must get split to something other than at the 76th character boundary to test the non-default behaviorz}A very long line that must get split to something other than at the 76th character boundary to test the non-default behaviorrjrz}A very long line that must get split to something other than at the 76th character boundary to test the non-default behaviori)rr)rr rrrr4r4r5test_explicit_maxlinelens z#TestHeader.test_explicit_maxlinelencCs|j}tddd}d}|||}||d||ttt|tddd}|d|}||d||ttt|dS)Nr7r<r;rra=?iso-8859-1?q?xxx?= =?iso-8859-1?q?x_?= =?iso-8859-1?q?xx?= =?iso-8859-1?q?xx?= =?iso-8859-1?q?_x?= =?iso-8859-1?q?xx?= =?iso-8859-1?q?x_?= =?iso-8859-1?q?xx?= =?iso-8859-1?q?xx?= =?iso-8859-1?q?_x?= =?iso-8859-1?q?xx?= =?iso-8859-1?q?x_?= =?iso-8859-1?q?xx?= =?iso-8859-1?q?xx?= =?iso-8859-1?q?_x?= =?iso-8859-1?q?xx?= =?iso-8859-1?q?x_?= =?iso-8859-1?q?xx?= =?iso-8859-1?q?xx?= =?iso-8859-1?q?_x?= =?iso-8859-1?q?xx?= =?iso-8859-1?q?x_?= =?iso-8859-1?q?xx?= =?iso-8859-1?q?xx?= =?iso-8859-1?q?_x?= =?iso-8859-1?q?xx?= =?iso-8859-1?q?x_?= =?iso-8859-1?q?xx?= =?iso-8859-1?q?xx?= =?iso-8859-1?q?_x?= =?iso-8859-1?q?xx?= =?iso-8859-1?q?x_?= =?iso-8859-1?q?xx?= =?iso-8859-1?q?xx?= =?iso-8859-1?q?_x?= =?iso-8859-1?q?xx?= =?iso-8859-1?q?x_?= =?iso-8859-1?q?xx?= =?iso-8859-1?q?xx?= =?iso-8859-1?q?_x?= =?iso-8859-1?q?xx?= =?iso-8859-1?q?x_?= =?iso-8859-1?q?xx?= =?iso-8859-1?q?xx?= =?iso-8859-1?q?_x?= =?iso-8859-1?q?xx?= =?iso-8859-1?q?x_?= =?iso-8859-1?q?xx?= =?iso-8859-1?q?xx?= =?iso-8859-1?q?_?=rBz=?iso-8859-1?q?xxxx_xxxx_xxxx_xxxx_xxx?= =?iso-8859-1?q?x_xxxx_xxxx_xxxx_xxxx_?= =?iso-8859-1?q?xxxx_xxxx_xxxx_xxxx_xx?= =?iso-8859-1?q?xx_xxxx_xxxx_xxxx_xxxx?= =?iso-8859-1?q?_xxxx_xxxx_?=rr rrrr r r1r2rrNrr4r4r5test_quopri_splittables   3   z!TestHeader.test_quopri_splittablecCs|j}tddd}d}|||}||d||ttt|tddd}|||}||d||ttt|dS)Nrcr<rra=?koi8-r?b?eHh4?= =?koi8-r?b?eCB4?= =?koi8-r?b?eHh4?= =?koi8-r?b?IHh4?= =?koi8-r?b?eHgg?= =?koi8-r?b?eHh4?= =?koi8-r?b?eCB4?= =?koi8-r?b?eHh4?= =?koi8-r?b?IHh4?= =?koi8-r?b?eHgg?= =?koi8-r?b?eHh4?= =?koi8-r?b?eCB4?= =?koi8-r?b?eHh4?= =?koi8-r?b?IHh4?= =?koi8-r?b?eHgg?= =?koi8-r?b?eHh4?= =?koi8-r?b?eCB4?= =?koi8-r?b?eHh4?= =?koi8-r?b?IHh4?= =?koi8-r?b?eHgg?= =?koi8-r?b?eHh4?= =?koi8-r?b?eCB4?= =?koi8-r?b?eHh4?= =?koi8-r?b?IHh4?= =?koi8-r?b?eHgg?= =?koi8-r?b?eHh4?= =?koi8-r?b?eCB4?= =?koi8-r?b?eHh4?= =?koi8-r?b?IHh4?= =?koi8-r?b?eHgg?= =?koi8-r?b?eHh4?= =?koi8-r?b?eCB4?= =?koi8-r?b?eHh4?= =?koi8-r?b?IA==?=rBz=?koi8-r?b?eHh4eCB4eHh4IHh4eHggeHh4?= =?koi8-r?b?eCB4eHh4IHh4eHggeHh4eCB4?= =?koi8-r?b?eHh4IHh4eHggeHh4eCB4eHh4?= =?koi8-r?b?IHh4eHggeHh4eCB4eHh4IHh4?= =?koi8-r?b?eHggeHh4eCB4eHh4IHh4eHgg?= =?koi8-r?b?eHh4eCB4eHh4IA==?=rrr4r4r5test_base64_splittables   #   z!TestHeader.test_base64_splittablecCs8|j}d}t|}||dgt|}|||dS)Nr4)r4Nr-r r r)r1r2rrNrr4r4r5test_us_ascii_header<s  zTestHeader.test_us_ascii_headercCs&|j}t}|dd||ddS)Nr4r7)r-r rrr4r4r5test_string_charsetDs zTestHeader.test_string_charsetcCs:|j}tdd}||dtdd}||ddS)NrrMz=?utf-8?q?p=C3=B6stal?=u 菊地時夫z=?utf-8?b?6I+K5Zyw5pmC5aSr?=r-r rrr4r4r5test_utf8_shortestSs   zTestHeader.test_utf8_shortestcCsr|j}|j}d}|tt|t}|t|j||dd}|tt|dd||j|dd|t||dS)N0Ynwp4dUEbay Auction Semiar- No Charge Earn BigrMrr)rr-rTr rrPr)r1rBr2rNrer4r4r5test_bad_8bit_headerZs  zTestHeader.test_bad_8bit_headercCsNd}|dd}t|tjjd}|t|d|tj||dfgdS)Nrrsurrogateescaper 2Ynwp4dUEbay Auction Semiar- No Charge � Earn Big unknown-8bit) rPr rr; UNKNOWN8BITr-rrr )r1rNrrr4r4r5test_escaped_8bit_headerfs  z#TestHeader.test_escaped_8bit_headercCsBd}t|tjjd}|t|d|tj||dfgdSNrr rr)r rr;rr-rrr )r1rNrr4r4r5&test_header_handles_binary_unknown8bitns  z1TestHeader.test_header_handles_binary_unknown8bitcCsVd}t|tjjd}tjtj|}|t|d|tj||dfgdSr) r rr;rrr r r-r)r1rNrZh2r4r4r5+test_make_header_handles_binary_unknown8bitus z6TestHeader.test_make_header_handles_binary_unknown8bitcCs2td}tj|}|d|t|ddS)Nr)rZtest2)r rrr rr-r)r1rrr4r4r50test_modify_returned_list_does_not_change_header}s  z;TestHeader.test_modify_returned_list_does_not_change_headercCsR|j}t}|dd|d|}||dtt|}|||dS)Nr4r7Zworldz=?iso-8859-1?q?hello?= world)r-r rrr r )r1r2rrr4r4r5 test_encoded_adjacent_nonencodeds    z+TestHeader.test_encoded_adjacent_nonencodedcCs:|j}d}t|}||gdt|}||ddS)NzGSubject: =?koi8-r?b?8NLP18XSy8EgzsEgxsnOwczYztk=?= =?koi8-r?q?=CA?= zz.))s Subject: N)s rc)s zz.Nz6Subject: =?koi8-r?b?8NLP18XSy8EgzsEgxsnOwczYztnK?= zz.r)r1r2rpartsZhdrr4r4r5test_whitespace_keepersz!TestHeader.test_whitespace_keepercCs|j}d}|tjt|dS)NzXSubject: =?EUC-KR?B?CSixpLDtKSC/7Liuvsax4iC6uLmwMcijIKHaILzSwd/H0SC8+LCjwLsgv7W/+Mj3I ?=)rrrr )r1rBrr4r4r5test_broken_base64_headersz$TestHeader.test_broken_base64_headercCs tddd}||ddS)Nr shift_jisr rrrr4r4r5test_shift_jis_charsets z!TestHeader.test_shift_jis_charsetcCstd}|t|ddS)Nz EmptyHeader:zEmptyHeader: )rrr-rr\r4r4r5!test_flatten_header_with_no_values z,TestHeader.test_flatten_header_with_no_valuecCs"t}d|d<|t|ddS)Nz value with leading wsZ SomeHeaderz&SomeHeader: value with leading ws )rr-rr\r4r4r5)test_encode_preserves_leading_ws_on_valuesz4TestHeader.test_encode_preserves_leading_ws_on_valuecCs|tdddS)Nr*rrr4r4r5test_whitespace_headersz!TestHeader.test_whitespace_headerN)rorprqrrrrrrrrrrrrrrrrrrrrrrrrrr4r4r4r5rKs2?E6   rc@seZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZddZddZdd Zd!d"Zd#d$Zd%d&Zd'd(Zd)d*Zd+d,Zd-d.Zd/d0Zd1d2Zd3d4Zd5d6Zd7d8Zd9d:Zd;S)< TestRFC2231cCs8|j}|d}||dd||jdddddS)Nz msg_29.txtr rGr %This is even more ***fun*** isn't it!Fr)rGr z'"This is even more ***fun*** isn't it!")r-r.rCr0r4r4r5rs  zTestRFC2231.test_get_paramcCs|j}t}|jdddd||dd|jddddd||dd|d }|jddddd||jd d d dS) Nr rrGr )rGr)rr r;languagerr|rra"Return-Path: Delivered-To: bbb@zzz.org Received: by mail.zzz.org (Postfix, from userid 889) id 27CEAD38CC; Fri, 4 May 2001 14:05:44 -0400 (EDT) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Message-ID: <15090.61304.110929.45684@aaa.zzz.org> From: bbb@ddd.com (John X. Doe) To: bbb@zzz.org Subject: This is a test message Date: Fri, 4 May 2001 14:05:44 -0400 Content-Type: text/plain; charset=us-ascii; title*=us-ascii'en'This%20is%20even%20more%20%2A%2A%2Afun%2A%2A%2A%20isn%27t%20it%21 Hi, Do you like this message? -Me )rrrrCr.rr0r4r4r5rs&   zTestRFC2231.test_set_paramcCsft}|dd||dd|jdddd||dd|jdd dd||dd dS) Nr rr:ztext/plain; title="foo"rF)Zrequoteztext/plain; title=barz (bar)bellztext/plain; title="(bar)bell")rrr-r\r4r4r5test_set_param_requotes z"TestRFC2231.test_set_param_requotecCsX|j}|d}|jddddd|jddddd|jdd d ||jd d d dS)Nr|rrrGr rr rr>rrra$Return-Path: Delivered-To: bbb@zzz.org Received: by mail.zzz.org (Postfix, from userid 889) id 27CEAD38CC; Fri, 4 May 2001 14:05:44 -0400 (EDT) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Message-ID: <15090.61304.110929.45684@aaa.zzz.org> From: bbb@ddd.com (John X. Doe) To: bbb@zzz.org Subject: This is a test message Date: Fri, 4 May 2001 14:05:44 -0400 Content-Type: text/plain; charset="us-ascii"; title*=us-ascii'en'This%20is%20even%20more%20%2A%2A%2Afun%2A%2A%2A%20isn%27t%20it%21 Hi, Do you like this message? -Me )rr.rrrr0r4r4r5rs zTestRFC2231.test_del_paramcCs"|j}|d}||ddS)NrrG)r-r.get_content_charsetr0r4r4r5 test_rfc2231_get_content_charset s z,TestRFC2231.test_rfc2231_get_content_charsetcCs8td}t|}||d|||dS)Nz Content-Disposition: inline; filename*0*=''This%20is%20even%20more%20; filename*1*=%2A%2A%2Afun%2A%2A%2A%20; filename*2="is it not.pdf" )This is even more ***fun*** is it not.pdfrrrrr-rjrrr4r4r5test_rfc2231_parse_rfc_quotings    z*TestRFC2231.test_rfc2231_parse_rfc_quotingcCs8td}t|}||d|||dS)Nz Content-Disposition: inline; filename*0*="''This%20is%20even%20more%20"; filename*1*="%2A%2A%2Afun%2A%2A%2A%20"; filename*2="is it not.pdf" rrrr4r4r5 test_rfc2231_parse_extra_quoting!s    z,TestRFC2231.test_rfc2231_parse_extra_quotingcCs4d}t|}|d}||t||ddS)NaContent-Transfer-Encoding: 8bit Content-Disposition: inline; filename="file____C__DOCUMENTS_20AND_20SETTINGS_FABIEN_LOCAL_20SETTINGS_TEMP_nsmail.htm" Content-Type: text/html; NAME*0=file____C__DOCUMENTS_20AND_20SETTINGS_FABIEN_LOCAL_20SETTINGS_TEM; NAME*1=P_nsmail.htm NAMEzMfile____C__DOCUMENTS_20AND_20SETTINGS_FABIEN_LOCAL_20SETTINGS_TEMP_nsmail.htmrrrCZassertNotIsInstancetupler-r1rr3Zparamr4r4r5#test_rfc2231_no_language_or_charset1s   z/TestRFC2231.test_rfc2231_no_language_or_charsetcCs"d}t|}||ddSNzContent-Disposition: inline; filename*0*="''This%20is%20even%20more%20"; filename*1*="%2A%2A%2Afun%2A%2A%2A%20"; filename*2="is it not.pdf" rrrr4r4r5/test_rfc2231_no_language_or_charset_in_filename@s   z;TestRFC2231.test_rfc2231_no_language_or_charset_in_filenamecCs"d}t|}||ddSrrrr4r4r57test_rfc2231_no_language_or_charset_in_filename_encodedMs   zCTestRFC2231.test_rfc2231_no_language_or_charset_in_filename_encodedcCs"d}t|}||ddS)NzContent-Disposition: inline; filename*0="''This%20is%20even%20more%20"; filename*1*="%2A%2A%2Afun%2A%2A%2A%20"; filename*2="is it not.pdf" z1This%20is%20even%20more%20***fun*** is it not.pdfrrr4r4r5test_rfc2231_partly_encoded[s  z'TestRFC2231.test_rfc2231_partly_encodedcCs"d}t|}||ddS)NzContent-Disposition: inline; filename*0="This%20is%20even%20more%20"; filename*1="%2A%2A%2Afun%2A%2A%2A%20"; filename*2="is it not.pdf" z?This%20is%20even%20more%20%2A%2A%2Afun%2A%2A%2A%20is it not.pdfrrr4r4r5test_rfc2231_partly_nonencodedhs  z*TestRFC2231.test_rfc2231_partly_nonencodedcCs"d}t|}||ddS)NzContent-Type: multipart/alternative; boundary*0*="''This%20is%20even%20more%20"; boundary*1*="%2A%2A%2Afun%2A%2A%2A%20"; boundary*2="is it not.pdf" rrrr4r4r5/test_rfc2231_no_language_or_charset_in_boundaryus   z;TestRFC2231.test_rfc2231_no_language_or_charset_in_boundarycCs"d}t|}||ddS)NzContent-Type: text/plain; charset*0*="This%20is%20even%20more%20"; charset*1*="%2A%2A%2Afun%2A%2A%2A%20"; charset*2="is it not.pdf" z)this is even more ***fun*** is it not.pdfrrr-rrr4r4r5.test_rfc2231_no_language_or_charset_in_charsets   z:TestRFC2231.test_rfc2231_no_language_or_charset_in_charsetcCs"d}t|}||ddS)NzContent-Disposition: inline; filename*0*="bogus'xx'This%20is%20even%20more%20"; filename*1*="%2A%2A%2Afun%2A%2A%2A%20"; filename*2="is it not.pdf" rrrr4r4r5%test_rfc2231_bad_encoding_in_filenames   z1TestRFC2231.test_rfc2231_bad_encoding_in_filenamecCs"d}t|}||ddS)Nz:Content-Type: text/plain; charset*=bogus''utf-8%E2%80%9D rrr4r4r5$test_rfc2231_bad_encoding_in_charsets z0TestRFC2231.test_rfc2231_bad_encoding_in_charsetcCs"d}t|}||ddS)Nz:Content-Type: text/plain; charset*=ascii''utf-8%E2%80%9D rrr4r4r5%test_rfc2231_bad_character_in_charsets z1TestRFC2231.test_rfc2231_bad_character_in_charsetcCs"d}t|}||ddS)NzContent-Disposition: inline; filename*0*="ascii'xx'This%20is%20even%20more%20"; filename*1*="%2A%2A%2Afun%2A%2A%2A%20"; filename*2*="is it not.pdf%E2" u,This is even more ***fun*** is it not.pdf�rrr4r4r5&test_rfc2231_bad_character_in_filenames   z2TestRFC2231.test_rfc2231_bad_character_in_filenamecCs"d}t|}||ddS)Nz^Content-Transfer-Encoding: 8bit Content-Disposition: inline; filename*=X-UNKNOWN''myfile.txt z myfile.txtrrr4r4r5test_rfc2231_unknown_encodings z)TestRFC2231.test_rfc2231_unknown_encodingcCsF|j}d}t|}|d\}}}||d||d||ddS)NzJContent-Type: application/x-foo; name*0*="Frank's"; name*1*=" Document" rFrank's Documentrr1r2rr3r;rrr4r4r5-test_rfc2231_single_tick_in_filename_extendeds   z9TestRFC2231.test_rfc2231_single_tick_in_filename_extendedcCs4d}t|}|d}||t||ddS)NzGContent-Type: application/x-foo; name*0="Frank's"; name*1=" Document" rrrrr4r4r5$test_rfc2231_single_tick_in_filenames    z0TestRFC2231.test_rfc2231_single_tick_in_filenamecCs"d}t|}||ddS)NzAContent-Disposition: inline; filename*0*="'This%20is%20broken"; z'This is brokenrrr4r4r5test_rfc2231_missing_ticks  z%TestRFC2231.test_rfc2231_missing_tickcCs"d}t|}||ddS)NzAContent-Disposition: inline; filename*0*="'This%20is%E2broken"; u'This is�brokenrrr4r4r50test_rfc2231_missing_tick_with_encoded_non_asciis  z To: "xxx" Subject: ��� ���������� ����� ����� � ��������� �� ���� MIME-Version: 1.0 Content-Type: text/plain; charset="windows-1251"; Content-Transfer-Encoding: 8bit �� ����� � ���� ������ ��� �������� )r)rrr)r1messagesrr3r4r4r5+test_should_not_hang_on_invalid_ew_messages5s z7TestRFC2231.test_should_not_hang_on_invalid_ew_messagesN) rorprqrrrrrrrrrrrrrrrrrrrrrr r r r rrrrr4r4r4r5rs:% !              rc@s4eZdZddZddZddZddZd d Zd S) TestSignedcCsBt|"}|}t|}Wdn1s00Y||fSrZr)r1rroriginalr3r4r4r5 _msg_and_objQs (zTestSigned._msg_and_objcCsLddl}|d|j|jB}||d}||d}|||dS)Nrz^--([^\n]+)\n(.*?)\n--\1$r)r0r1Srsearchgroupr-)r1rresultr0ZrepartZinpartZoutpartr4r4r5_signed_parts_eqWs zTestSigned._signed_parts_eqcCs&|d\}}|}|||dSrrrrr1rr3rr4r4r5test_long_headers_as_string_sz&TestSigned.test_long_headers_as_stringcCs*|d\}}|jdd}|||dS)Nr<rrrr4r4r5(test_long_headers_as_string_maxheaderlends z3TestSigned.test_long_headers_as_string_maxheaderlencCs:|d\}}t}t|||}|||dSr)rrrrrr)r1rr3rrr4r4r5test_long_headers_flattenis z$TestSigned.test_long_headers_flattenN)rorprqrrrr r!r4r4r4r5rOs r__main__)`r0r8rNr.riorr itertoolsrrandomr threadingrZ unittest.mockrrZ email.policyZ email.charsetr Z email.headerr r r Z email.parserr rZemail.generatorrrrZ email.messagerZemail.mime.applicationrZemail.mime.audiorZemail.mime.textrZemail.mime.imagerZemail.mime.baserZemail.mime.messagerZemail.mime.multipartrZemail.mime.nonmultipartrrrrrr r!Z test.supportr"r#Ztest.test_emailr$r%r&r'rrrr+ZTestCaserrrrrr r rr0rirrrrrrrrr*r.r2r3rIrrrrromainr4r4r4r5s                    lCAO((\<0< "g0K!  5D:h!#