a
    åze½> ã                   @   s–  d dl Z d dlZd dlZd dlZd dlZd dlmZmZ d dlm	Z	 d dl
mZ d dlmZ d dlmZ d dlZd dlZd dlmZ d dlmZmZmZ d d	lmZmZ d d
lmZmZmZ d dlm Z  d dl!m"Z" d dl#m$Z$ d dl%m&Z& d dl'm(Z( d dl)m*Z* d dl+m,Z, d dl-m.Z. d dl/m0Z0 d dlm1Z1 d dlm2Z2 d dlm3Z3 d dlm4Z4 d dlm5Z5 d dlm6Z6 d dl7m8Z8m9Z9 d dl:m;Z;m<Z< d dlm=Z=m>Z> dZ?dZ@dZAG d d!„ d!e<ƒZBG d"d#„ d#ejCƒZDG d$d%„ d%e<ƒZEG d&d'„ d'ejCƒZFG d(d)„ d)ejCƒZGG d*d+„ d+ejCƒZHG d,d-„ d-ejCƒZIG d.d/„ d/ejCƒZJG d0d1„ d1e<ƒZKG d2d3„ d3e<ƒZLG d4d5„ d5e<ƒZMG d6d7„ d7e<ƒZNG d8d9„ d9e<ƒZOG d:d;„ d;e<ƒZPG d<d=„ d=e<ƒZQG d>d?„ d?e<ƒZRG d@dA„ dAe<ƒZSG dBdC„ dCe<ƒZTG dDdE„ dEe<ƒZUG dFdG„ dGƒZVG dHdI„ dIeVePƒZWG dJdK„ dKeVePƒZXG dLdM„ dMejCƒZYG dNdO„ dOejCƒZZG dPdQ„ dQejCƒZ[G dRdS„ dSe<ƒZ\G dTdU„ dUe<ƒZ]G dVdW„ dWe<ƒZ^e_dXkr’e `¡  dS )Yé    N)ÚStringIOÚBytesIO)Úchain©Úchoice)ÚThread)Úpatch)ÚCharset)ÚHeaderÚdecode_headerÚmake_header)ÚParserÚHeaderParser)Ú	GeneratorÚDecodedGeneratorÚBytesGenerator)ÚMessage)ÚMIMEApplication)Ú	MIMEAudio)ÚMIMEText)Ú	MIMEImage)ÚMIMEBase)ÚMIMEMessage)ÚMIMEMultipart)ÚMIMENonMultipart)Úutils©Úerrors)Úencoders)Ú	iterators)Ú
base64mime)Ú
quoprimime)ÚunlinkÚstart_threads)ÚopenfileÚTestEmailBase)Ú
FeedParserÚBytesFeedParserÚ
Ú ú c                   @   s´  e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ Zdd„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd „ Zd!d"„ Zd#d$„ Zd%d&„ Zd'd(„ Zd)d*„ Zd+d,„ Zd-d.„ Zd/d0„ Zd1d2„ Zd3d4„ Zd5d6„ Zd7d8„ Zd9d:„ Zd;d<„ Z d=d>„ Z!d?d@„ Z"dAdB„ Z#dCdD„ Z$dEdF„ Z%dGdH„ Z&dIdJ„ Z'dKdL„ Z(dMdN„ Z)dOdP„ Z*dQdR„ Z+dSdT„ Z,dUdV„ Z-dWdX„ Z.dYdZ„ Z/d[d\„ Z0d]d^„ Z1d_d`„ Z2dadb„ Z3dcdd„ Z4dedf„ Z5dgdh„ Z6didj„ Z7dkdl„ Z8dmdn„ Z9dodp„ Z:dqdr„ Z;dsdt„ Z<dudv„ Z=dwdx„ Z>dydz„ Z?d{d|„ Z@d}d~„ ZAdd€„ ZBdd‚„ ZCdƒd„„ ZDd…d†„ ZEd‡dˆ„ ZFd‰dŠ„ ZGd‹dŒ„ ZHddŽ„ ZIdd„ ZJd‘d’„ ZKd“d”„ ZLd•d–„ ZMd—d˜„ ZNd™dš„ ZOd›dœ„ ZPddž„ ZQdŸd „ ZRd¡d¢„ ZSd£d¤„ ZTd¥d¦„ ZUd§d¨„ ZVd©dª„ ZWd«S )¬ÚTestMessageAPIc                 C   s:   | j }|  d¡}|| d¡g d¢ƒ || dd¡dƒ d S )Nz
msg_20.txtZcc)zccc@zzz.orgzddd@zzz.orgzeee@zzz.orgÚxxzn/a)ÚassertEqualÚ_msgobjÚget_all©ÚselfÚeqÚmsg© r4   ú0/usr/lib/python3.9/test/test_email/test_email.pyÚtest_get_all6   s    
zTestMessageAPI.test_get_allc                 C   s   | j }tƒ }|| ¡ d ƒ tdƒ}| |¡ ||d dƒ || ¡ dƒ ||d dƒ || d¡dƒ ||d d	ƒ || ¡ jdƒ | d ¡ || ¡ d ƒ ||d dƒ tƒ }d
|d< d|d< d|d< | |¡ ||d d
ƒ ||d dƒ ||d dƒ d S )Nú
iso-8859-1úmime-versionz1.0ú
text/plainúcontent-typez text/plain; charset="iso-8859-1"Úcharsetúcontent-transfer-encodingúquoted-printablez2.0zMIME-Versionztext/x-weirdúContent-Typezquinted-puntableúContent-Transfer-Encodingz"text/x-weird; charset="iso-8859-1")r-   r   Úget_charsetr	   Úset_charsetÚget_content_typeÚ	get_paramÚinput_charset©r1   r2   r3   r;   r4   r4   r5   Útest_getset_charset<   s,    


z"TestMessageAPI.test_getset_charsetc                 C   s8   | j }tƒ }| d¡ || ¡ jdƒ ||d dƒ d S )Núus-asciir:   útext/plain; charset="us-ascii")r-   r   rA   r@   rD   r0   r4   r4   r5   Útest_set_charset_from_stringV   s
    
z+TestMessageAPI.test_set_charset_from_stringc                 C   s0   t ƒ }tdƒ}| d|¡ |  | ¡ jd¡ d S )Nr7   zThis is a string payload)r   r	   Úset_payloadr-   r@   rD   )r1   r3   r;   r4   r4   r5   Útest_set_payload_with_charset]   s    z,TestMessageAPI.test_set_payload_with_charsetc                 C   sV   d}t dƒ}tƒ }| ||¡ |  |d d¡ |  |jdd|¡ |  | ¡ d¡ d S )Nó   ÐÐ‘Ð’úutf-8r<   Úbase64T©Údecodez	0JDQkdCS
)r	   r   rJ   r-   Úget_payload©r1   Údatar;   r3   r4   r4   r5   Ú+test_set_payload_with_8bit_data_and_charsetc   s    z:TestMessageAPI.test_set_payload_with_8bit_data_and_charsetc                 C   sR   d}t dƒ}d |_tƒ }| | d¡|¡ |  |d d¡ |  |jdd|¡ d S ©NrL   rM   r<   Ú8bitTrO   )r	   Úbody_encodingr   rJ   rP   r-   rQ   rR   r4   r4   r5   Ú>test_set_payload_with_non_ascii_and_charset_body_encoding_nonel   s    zMTestMessageAPI.test_set_payload_with_non_ascii_and_charset_body_encoding_nonec                 C   sL   d}t dƒ}d |_tƒ }| ||¡ |  |d d¡ |  |jdd|¡ d S rU   )r	   rW   r   rJ   r-   rQ   rR   r4   r4   r5   Ú>test_set_payload_with_8bit_data_and_charset_body_encoding_noneu   s    zMTestMessageAPI.test_set_payload_with_8bit_data_and_charset_body_encoding_nonec                 C   s$   t ƒ }| g ¡ |  | ¡ g ¡ d S ©N©r   rJ   r-   rQ   ©r1   r3   r4   r4   r5   Útest_set_payload_to_list~   s    
z'TestMessageAPI.test_set_payload_to_listc                 C   s8   t ƒ }d|d< | d¡ tt ƒ ƒ}|  td|j|¡ d S )Númultipart/mixedr>   zstring payloadz[Aa]ttach.*non-multipart)r   rJ   r   ZassertRaisesRegexÚ	TypeErrorÚattach)r1   r3   Zsub_msgr4   r4   r5   Ú"test_attach_when_payload_is_stringƒ   s    

ÿz1TestMessageAPI.test_attach_when_payload_is_stringc                 C   sl   | j }|  d¡}| ¡ }||g d¢ƒ |  d¡}| d¡}||g d¢ƒ |  d¡}| ¡ }||g d¢ƒ d S )Nz
msg_08.txt)NrG   r7   ú
iso-8859-2úkoi8-rz
msg_09.txtÚdingbat)rd   rG   r7   rd   rc   z
msg_12.txt)NrG   r7   Nrb   z
iso-8859-3rG   rc   )r-   r.   Úget_charsets)r1   r2   r3   Úcharsetsr4   r4   r5   Útest_get_charsets‹   s    



z TestMessageAPI.test_get_charsetsc                 C   sV   | j }|  d¡}dd„ | ¡ D ƒ}||ddgƒ |  d¡}| d¡}|| ¡ dƒ d S )Nú
msg_04.txtc                 S   s   g | ]}|  ¡ ‘qS r4   ©Úget_filename©Ú.0Úpr4   r4   r5   Ú
<listcomp>    ó    z4TestMessageAPI.test_get_filename.<locals>.<listcomp>úmsg.txtú
msg_07.txté   údingusfish.gif)r-   r.   rQ   rj   )r1   r2   r3   Ú	filenamesÚsubpartr4   r4   r5   Útest_get_filenameœ   s    


z TestMessageAPI.test_get_filenamec                 C   s4   | j }|  d¡}dd„ | ¡ D ƒ}||ddgƒ d S )Nz
msg_44.txtc                 S   s   g | ]}|  ¡ ‘qS r4   ri   rk   r4   r4   r5   rn   «   ro   zHTestMessageAPI.test_get_filename_with_name_parameter.<locals>.<listcomp>rp   ©r-   r.   rQ   )r1   r2   r3   rt   r4   r4   r5   Ú%test_get_filename_with_name_parameter§   s    
z4TestMessageAPI.test_get_filename_with_name_parameterc                 C   s"   | j }|  d¡}|| ¡ dƒ d S )Nrq   ÚBOUNDARY)r-   r.   Úget_boundaryr0   r4   r4   r5   Útest_get_boundary®   s    
z TestMessageAPI.test_get_boundaryc                 C   sž   | j }|  d¡}| d¡ | ¡ d \}}|| ¡ dƒ ||dƒ |  d¡}| d¡ | ¡ d \}}|| ¡ dƒ ||dƒ |  d¡}|  tj|jd¡ d S )	Nú
msg_01.txtry   é   r:   z3text/plain; charset="us-ascii"; boundary="BOUNDARY"rh   z$multipart/mixed; boundary="BOUNDARY"ú
msg_03.txt)r-   r.   Úset_boundaryÚitemsÚlowerÚassertRaisesr   ÚHeaderParseError)r1   r2   r3   ÚheaderÚvaluer4   r4   r5   Útest_set_boundary´   s    






ÿz TestMessageAPI.test_set_boundaryc                 C   sL   t dƒ}|  | ¡ d d d¡ | ¡  |  | ¡ d d d d… d¡ d S )Nz	form-datar   rr   zmultipart/form-dataé!   z!multipart/form-data; boundary="==)r   r-   r€   Ú	as_stringr\   r4   r4   r5   Útest_make_boundaryÊ   s    ÿz!TestMessageAPI.test_make_boundaryc                 C   sr   t dƒ}| ¡ }W d   ƒ n1 s&0    Y  tƒ }| |¡}tƒ }t|ddƒ}| |d¡ |  | ¡ |¡ d S )Nú
msg_46.txtTr   F)	r$   Úreadr   Úparsestrr   r   Úflattenr-   Úgetvalue©r1   ÚfpZmsgdataÚparserr3   ÚoutÚgenr4   r4   r5   Útest_message_rfc822_onlyÕ   s    
&
z'TestMessageAPI.test_message_rfc822_onlyc                 C   sz   t dƒ}| ¡  d¡}W d   ƒ n1 s,0    Y  tj ¡ }| |¡}tƒ }tj 	|¡}| 
|¡ |  | ¡ |¡ d S )NrŠ   Úascii)r$   r‹   ÚencodeÚemailr‘   ÚBytesHeaderParserZ
parsebytesr   Ú	generatorr   r   r-   rŽ   r   r4   r4   r5   Útest_byte_message_rfc822_onlyá   s    
,


z,TestMessageAPI.test_byte_message_rfc822_onlyc                 C   sž   | j }|  d¡}||jddd ƒ || d¡jdddƒ || d¡jdddƒ || d¡jddd	ƒ || d
¡jdddƒ || d¡jdddƒ d S )Nz
msg_10.txtTrO   r   s    This is a 7bit encoded message.
rr   s-   ¡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.
rw   r0   r4   r4   r5   Útest_get_decoded_payloadì   s$    
ÿÿÿÿÿz'TestMessageAPI.test_get_decoded_payloadc                 C   sZ   | j }tƒ }| d¡ dD ]}||d< ||jdddƒ q| d¡ ||jdddƒ d S )	Nz$begin 666 -
+:&5L;&\@=V]R;&0 
 
end
©z
x-uuencodeÚuuencodeZuuezx-uuer<   TrO   ó   hello worldÚfoos   foo)r-   r   rJ   rQ   )r1   r2   r3   Úcter4   r4   r5   Útest_get_decoded_uu_payload  s    

z*TestMessageAPI.test_get_decoded_uu_payloadc                 C   s   t ƒ }|  t|jd¡ d S )Nrr   )r   r‚   r_   rQ   r\   r4   r4   r5   Ú*test_get_payload_n_raises_on_non_multipart  s    z9TestMessageAPI.test_get_payload_n_raises_on_non_multipartc                 C   sj   | j }|  d¡}tdƒ}| ¡ }W d   ƒ n1 s60    Y  tƒ }t|ƒ}| |¡ || ¡ |ƒ d S )Nrq   z
msg_17.txt)r-   r.   r$   r‹   r   r   r   rŽ   )r1   r2   r3   r   ÚtextÚsÚgr4   r4   r5   Útest_decoded_generator  s    

&
z%TestMessageAPI.test_decoded_generatorc                 C   sb   t ƒ }d|d< d|d< |  d|¡ |  d|¡ |  d|¡ |  d|¡ |  d|¡ |  d|¡ d S )	NZMeÚFromZYouÚtoÚfromZFROMÚToZTO)r   ÚassertInr\   r4   r4   r5   Útest__contains__  s    zTestMessageAPI.test__contains__c                 C   s’   |   d¡}tdƒ}| ¡ }W d   ƒ n1 s00    Y  |  |t|ƒ¡ |jdd}| d¡}|  |d  d¡¡ |  |t	 
|dd … ¡¡ d S )Nr|   T©Úunixfromr(   r   zFrom rr   )r.   r$   r‹   r-   Ústrrˆ   ÚsplitÚ
assertTrueÚ
startswithÚNLÚjoin)r1   r3   r   r¥   ÚfullreprÚlinesr4   r4   r5   Útest_as_string'  s    

&
zTestMessageAPI.test_as_stringc                 C   sT   |   d¡}|jjdd}|j|d}tƒ }t||d}| |¡ |  || ¡ ¡ d S ©Nr|   ú
©Úlinesep©Úpolicy)	r.   r¿   Úclonerˆ   r   r   r   r-   rŽ   ©r1   r3   Z	newpolicyr·   r¦   r§   r4   r4   r5   Útest_as_string_policy1  s    

z$TestMessageAPI.test_as_string_policyc                 C   s<   t  d¡}| d¡}t  d¡}t |¡}|  | ¡ |¡ d S )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
            r7   a%              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
            )ÚtextwrapÚdedentr–   r—   Úmessage_from_bytesr-   rˆ   ©r1   ÚmÚsourceÚexpectedr3   r4   r4   r5   Ú#test_nonascii_as_string_without_cte:  s
    


	
z2TestMessageAPI.test_nonascii_as_string_without_ctec                 C   s>   t  d¡}| d¡}| dd¡}t |¡}|  | ¡ |¡ d S )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
            r7   r•   Úreplace)rÃ   rÄ   r–   rP   r—   rÅ   r-   rˆ   rÆ   r4   r4   r5   Ú4test_nonascii_as_string_without_content_type_and_cteP  s
    


zCTestMessageAPI.test_nonascii_as_string_without_content_type_and_ctec                 C   s˜   |   d¡}tdƒ}| ¡  d¡}W d   ƒ n1 s60    Y  |  |t|ƒ¡ |jdd}| d¡}|  |d  	d¡¡ |  |d 
|dd … ¡¡ d S )	Nr|   r•   Tr¯   ó   
r   s   From rr   )r.   r$   r‹   r–   r-   ÚbytesÚas_bytesr²   r³   r´   r¶   )r1   r3   r   rS   r·   r¸   r4   r4   r5   Útest_as_bytes]  s    

,
zTestMessageAPI.test_as_bytesc                 C   sT   |   d¡}|jjdd}|j|d}tƒ }t||d}| |¡ |  || ¡ ¡ d S rº   )	r.   r¿   rÀ   rÏ   r   r   r   r-   rŽ   rÁ   r4   r4   r5   Útest_as_bytes_policyg  s    

z#TestMessageAPI.test_as_bytes_policyc                 C   s    t  d¡}|  | d¡d¡ d S )NzContent-Type: blarg; baz; boo
Úbazr)   ©r—   Úmessage_from_stringr-   rC   r\   r4   r4   r5   Útest_bad_paramq  s    
zTestMessageAPI.test_bad_paramc                 C   s   t  d¡}|  | ¡ d ¡ d S ©Nz
From: foo
©r—   rÔ   r-   rj   r\   r4   r4   r5   Útest_missing_filenameu  s    
z$TestMessageAPI.test_missing_filenamec                 C   s   t  d¡}|  | ¡ d¡ d S )Nz%Content-Disposition: blarg; filename
r)   r×   r\   r4   r4   r5   Útest_bogus_filenamey  s    ÿz"TestMessageAPI.test_bogus_filenamec                 C   s   t  d¡}|  | ¡ d ¡ d S rÖ   ©r—   rÔ   r-   rz   r\   r4   r4   r5   Útest_missing_boundary~  s    
z$TestMessageAPI.test_missing_boundaryc                 C   sx   | j }t d¡}||jddg d¢ƒ t d¡}||jddg d¢ƒ || ¡ d ƒ t d¡}||jddg d¢ƒ d S )Nú&X-Header: foo=one; bar=two; baz=three
úx-header©r„   ))r¡   Úone)ÚbarÚtwo©rÒ   Zthreez X-Header: foo; bar=one; baz=two
))r¡   r)   )rà   rß   )rÒ   rá   ú"X-Header: foo; bar="one"; baz=two
)r-   r—   rÔ   Ú
get_paramsr0   r4   r4   r5   Útest_get_params‚  s(    ÿÿÿÿÿÿzTestMessageAPI.test_get_paramsc                 C   s$   t ƒ }d|d< |  | d¡d¡ d S )Nz>Content-Type: Multipart/mixed; boundary = "CPIMSSMTPC06p5f3tG"r>   ÚboundaryZCPIMSSMTPC06p5f3tG)r   r-   rC   r\   r4   r4   r5   Útest_get_param_liberal“  s    z%TestMessageAPI.test_get_param_liberalc                 C   s’   | j }t d¡}||jddddƒ ||jdddd ƒ || d¡d ƒ t d¡}||jdddd	ƒ ||jdddd
ƒ ||jddddƒ d S )NrÜ   rà   rÝ   rÞ   rá   Zquuzrã   r¡   r)   rß   rÒ   ©r-   r—   rÔ   rC   r0   r4   r4   r5   Útest_get_param˜  s    ÿÿzTestMessageAPI.test_get_paramc                 C   s&   |   d¡}|  | d¡ d¡d¡ d S )Nz
msg_22.txtrr   Únamez
wibble.JPG)r.   r-   rQ   rC   r\   r4   r4   r5   Ú'test_get_param_funky_continuation_linesª  s    
z6TestMessageAPI.test_get_param_funky_continuation_linesc                 C   s6   t  d¡}|  | d¡d¡ |  |jdddd¡ d S )Nz4Content-Type: image/pjpeg; name="Jim&amp;&amp;Jill"
rê   zJim&amp;&amp;JillF©Úunquotez"Jim&amp;&amp;Jill"rÓ   r\   r4   r4   r5   Ú#test_get_param_with_semis_in_quotes¯  s    ÿÿz2TestMessageAPI.test_get_param_with_semis_in_quotesc                 C   s<   t  d¡}|  | d¡d¡ t  d¡}|  | d¡d¡ d S )Nz5Content-Type: foo; bar*0="baz\"foobar"; bar*1="\"baz"rà   zbaz"foobar"bazrÓ   r\   r4   r4   r5   Útest_get_param_with_quotes·  s    ÿÿz)TestMessageAPI.test_get_param_with_quotesc                 C   s>   t  d¡}|  d|¡ |  d|¡ |  d|¡ |  d|¡ d S )NzHeader: existsr„   r
   ZHEADERZheaderx)r—   rÔ   r­   ZassertNotInr\   r4   r4   r5   Útest_field_containment¿  s
    
z%TestMessageAPI.test_field_containmentc                 C   s¨   | j }tƒ }| dd¡ || d¡dƒ | dd¡ || d¡dƒ ||jddddƒ || ¡ g d¢ƒ ||jddg d	¢ƒ |jdd
dd ||jdddd
ƒ d S )Nr;   úiso-2022-jpÚ
importanceú
high valueFrì   ú"high value")©r9   r)   )r;   rñ   )rò   ró   )rõ   )r;   z"iso-2022-jp")rò   rô   ziso-9999-xxzX-JimmyrÞ   )r-   r   Ú	set_paramrC   rä   r0   r4   r4   r5   Útest_set_paramÆ  s    zTestMessageAPI.test_set_paramc                 C   sp   | j }|  d¡}|| ¡ g d¢ƒ | d¡}| d¡ || ¡ ddgƒ | d|¡ || ¡ ddd|fgƒ d S )Nú
msg_05.txt)©úmultipart/reportr)   )úreport-typeúdelivery-status©ræ   ú%D1690A7AC1.996856090/mail.example.comrû   rù   rý   )r-   r.   rä   rC   Ú	del_paramrö   )r1   r2   r3   Zold_valr4   r4   r5   Útest_del_param×  s&    
ÿ

ÿÿþÿzTestMessageAPI.test_del_paramc                 C   s6   t ƒ }|jdddd | dd¡ |  |d d¡ d S )NúContent-DispositionÚ
attachmentúbud.gif©Úfilenamer  úcontent-disposition©r   Ú
add_headerrÿ   r-   r\   r4   r4   r5   Útest_del_param_on_other_headerè  s    z-TestMessageAPI.test_del_param_on_other_headerc                 C   s   t ƒ }| dd¡ d S )Nr  r  )r   rÿ   r\   r4   r4   r5   Ú$test_del_param_on_nonexistent_headerî  s    z3TestMessageAPI.test_del_param_on_nonexistent_headerc                 C   s@   t ƒ }|jdddd |d }|jddd |  |d |¡ d S )Nr>   r9   rM   ©r;   ÚfoobarrÞ   r  )r1   r3   Zexisting_headerr4   r4   r5   Útest_del_nonexistent_paramó  s
    z)TestMessageAPI.test_del_nonexistent_paramc                 C   sj   | j }tƒ }|  t|jd¡ | d¡ ||d dƒ | dd¡ ||d dƒ | d¡ ||d dƒ d S )	Nr¥   r9   r:   r;   rG   rH   z	text/htmlztext/html; charset="us-ascii")r-   r   r‚   Ú
ValueErrorÚset_typerö   r0   r4   r4   r5   Útest_set_typeú  s    

zTestMessageAPI.test_set_typec                 C   s.   t ƒ }d|d< | dd¡ |  |d d¡ d S )Nr9   zX-Content-Typeúapplication/octet-streamzx-content-type)r   r  r-   r\   r4   r4   r5   Útest_set_type_on_other_header  s    z,TestMessageAPI.test_set_type_on_other_headerc                 C   s   t ƒ }|  | ¡ d¡ d S )Nr9   )r   r-   rB   r\   r4   r4   r5   Útest_get_content_type_missing  s    z,TestMessageAPI.test_get_content_type_missingc                 C   s$   t ƒ }| d¡ |  | ¡ d¡ d S )Númessage/rfc822)r   Úset_default_typer-   rB   r\   r4   r4   r5   Ú/test_get_content_type_missing_with_default_type  s    
z>TestMessageAPI.test_get_content_type_missing_with_default_typec                 C   s$   |   d¡}|  | d¡ ¡ d¡ d S )Nú
msg_30.txtr   r  ©r.   r-   rQ   rB   r\   r4   r4   r5   Ú+test_get_content_type_from_message_implicit  s    
ÿz:TestMessageAPI.test_get_content_type_from_message_implicitc                 C   s$   |   d¡}|  | d¡ ¡ d¡ d S )Nú
msg_28.txtr   r  r  r\   r4   r4   r5   Ú+test_get_content_type_from_message_explicit  s    
ÿz:TestMessageAPI.test_get_content_type_from_message_explicitc                 C   s   |   d¡}|  | ¡ d¡ d S )Nr~   r9   ©r.   r-   rB   r\   r4   r4   r5   Ú6test_get_content_type_from_message_text_plain_implicit  s    
zETestMessageAPI.test_get_content_type_from_message_text_plain_implicitc                 C   s   |   d¡}|  | ¡ d¡ d S )Nr|   r9   r  r\   r4   r4   r5   Ú6test_get_content_type_from_message_text_plain_explicit"  s    
zETestMessageAPI.test_get_content_type_from_message_text_plain_explicitc                 C   s   t ƒ }|  | ¡ d¡ d S )Nr¥   ©r   r-   Úget_content_maintyper\   r4   r4   r5   Ú!test_get_content_maintype_missing&  s    z0TestMessageAPI.test_get_content_maintype_missingc                 C   s$   t ƒ }| d¡ |  | ¡ d¡ d S )Nr  Úmessage)r   r  r-   r   r\   r4   r4   r5   Ú3test_get_content_maintype_missing_with_default_type*  s    
zBTestMessageAPI.test_get_content_maintype_missing_with_default_typec                 C   s$   |   d¡}|  | d¡ ¡ d¡ d S )Nr  r   r"  ©r.   r-   rQ   r   r\   r4   r4   r5   Ú/test_get_content_maintype_from_message_implicit/  s    
z>TestMessageAPI.test_get_content_maintype_from_message_implicitc                 C   s$   |   d¡}|  | d¡ ¡ d¡ d S )Nr  r   r"  r$  r\   r4   r4   r5   Ú/test_get_content_maintype_from_message_explicit3  s    
z>TestMessageAPI.test_get_content_maintype_from_message_explicitc                 C   s   |   d¡}|  | ¡ d¡ d S )Nr~   r¥   ©r.   r-   r   r\   r4   r4   r5   Ú:test_get_content_maintype_from_message_text_plain_implicit7  s    
zITestMessageAPI.test_get_content_maintype_from_message_text_plain_implicitc                 C   s   |   d¡}|  | ¡ d¡ d S )Nr|   r¥   r'  r\   r4   r4   r5   Ú:test_get_content_maintype_from_message_text_plain_explicit;  s    
zITestMessageAPI.test_get_content_maintype_from_message_text_plain_explicitc                 C   s   t ƒ }|  | ¡ d¡ d S )NÚplain©r   r-   Úget_content_subtyper\   r4   r4   r5   Ú test_get_content_subtype_missing?  s    z/TestMessageAPI.test_get_content_subtype_missingc                 C   s$   t ƒ }| d¡ |  | ¡ d¡ d S )Nr  Úrfc822)r   r  r-   r,  r\   r4   r4   r5   Ú2test_get_content_subtype_missing_with_default_typeC  s    
zATestMessageAPI.test_get_content_subtype_missing_with_default_typec                 C   s$   |   d¡}|  | d¡ ¡ d¡ d S )Nr  r   r.  ©r.   r-   rQ   r,  r\   r4   r4   r5   Ú.test_get_content_subtype_from_message_implicitH  s    
z=TestMessageAPI.test_get_content_subtype_from_message_implicitc                 C   s$   |   d¡}|  | d¡ ¡ d¡ d S )Nr  r   r.  r0  r\   r4   r4   r5   Ú.test_get_content_subtype_from_message_explicitL  s    
z=TestMessageAPI.test_get_content_subtype_from_message_explicitc                 C   s   |   d¡}|  | ¡ d¡ d S )Nr~   r*  ©r.   r-   r,  r\   r4   r4   r5   Ú9test_get_content_subtype_from_message_text_plain_implicitP  s    
zHTestMessageAPI.test_get_content_subtype_from_message_text_plain_implicitc                 C   s   |   d¡}|  | ¡ d¡ d S )Nr|   r*  r3  r\   r4   r4   r5   Ú9test_get_content_subtype_from_message_text_plain_explicitT  s    
zHTestMessageAPI.test_get_content_subtype_from_message_text_plain_explicitc                 C   s"   t ƒ }d|d< |  | ¡ d¡ d S )Núno-slash-in-this-stringr>   r¥   r  r\   r4   r4   r5   Útest_get_content_maintype_errorX  s    z.TestMessageAPI.test_get_content_maintype_errorc                 C   s"   t ƒ }d|d< |  | ¡ d¡ d S )Nr6  r>   r*  r+  r\   r4   r4   r5   Útest_get_content_subtype_error]  s    z-TestMessageAPI.test_get_content_subtype_errorc                 C   sÖ   | j }tƒ }| dd¡ | dd¡ | dd¡ || ¡ g d¢ƒ || ¡ g d¢ƒ | dd	¡ || ¡ g d¢ƒ || ¡ g d
¢ƒ | dd¡ | dd¡ || ¡ g d¢ƒ || ¡ g d¢ƒ |  t|jdd¡ d S )NÚFirstÚOneÚSecondÚTwoÚThirdÚThree)r9  r;  r=  )r:  r<  r>  ÚTwenty)r:  r?  r>  ÚElevenúOne Hundred)r9  r;  r=  r9  )rA  r?  r>  r@  ZFourthZMissing)r-   r   r  ÚkeysÚvaluesÚreplace_headerr‚   ÚKeyErrorr0   r4   r4   r5   Útest_replace_headerb  s    z"TestMessageAPI.test_replace_headerc                 C   sp   t ƒ }|  | ¡ ¡ |jdddd |  | ¡ d¡ | dd¡ |  | ¡ d¡ | dd¡ |  | ¡ d¡ d S )Nr  r  z
random.avir  ÚinlineZInlinE)r   ÚassertIsNoneZget_content_dispositionr  r-   rD  r\   r4   r4   r5   Útest_get_content_dispositions  s    ÿz+TestMessageAPI.test_get_content_dispositionc                 C   sP   d}t ƒ }d|d< d|d< | |¡ |  |jddd¡ |  |jd	 tj¡ d S )
NzAwDp0P7//y6LwKEAcPa/6Q=9zaudio/x-midir:   rN   r<   TrO   s    éÐþÿÿ.‹À¡ pö¿ér   )r   rJ   r-   rQ   ÚassertIsInstanceÚdefectsr   ÚInvalidBase64CharactersDefect©r1   Úxr3   r4   r4   r5   Útest_broken_base64_payload  s    
ÿÿz)TestMessageAPI.test_broken_base64_payloadc                 C   sB   d}t ƒ }d|d< d|d< | |¡ |  |jddt|dƒ¡ d S )	Nu   this is a brÃ¶ken thing to dor9   r:   rV   r<   TrO   zraw-unicode-escape)r   rJ   r-   rQ   rÎ   rM  r4   r4   r5   Útest_broken_unicode_payload‹  s    
ÿz*TestMessageAPI.test_broken_unicode_payloadc                 C   s>   d  d¡}tƒ }d|d< d|d< ||_|  |jdd|¡ d S )	Nu#   this is a quÃ©stionable thing to dorM   útext/plain; charset="utf-8"r:   rV   r<   TrO   )r–   r   Z_payloadr-   rQ   rM  r4   r4   r5   Útest_questionable_bytes_payload–  s    
z.TestMessageAPI.test_questionable_bytes_payloadc                 C   s*   t ƒ }|jdddd |  d|d ¡ d S )Nr  r  r  r  zattachment; filename="bud.gif"©r   r  r-   r\   r4   r4   r5   Útest_ascii_add_header¡  s    ÿÿz$TestMessageAPI.test_ascii_add_headerc                 C   s*   t ƒ }|jdddd |  d|d ¡ d S )Nr  r  õ   FuÃŸballer.pptr  z/attachment; filename*=utf-8''Fu%C3%9Fballer.pptrS  r\   r4   r4   r5   Útest_noascii_add_header¨  s    ÿþz&TestMessageAPI.test_noascii_add_headerc                 C   s*   t ƒ }|jdddd |  d|d ¡ d S )Nr  r  )r7   r)   rU  r  z1attachment; filename*=iso-8859-1''Fu%DFballer.pptrS  r\   r4   r4   r5   Ú#test_nonascii_add_header_via_triple°  s    ÿþz2TestMessageAPI.test_nonascii_add_header_via_triplec                 C   s*   t ƒ }|jdddd |  d|d ¡ d S )Nr  r  zwindows [filename].pptr  z-attachment; filename="windows [filename].ppt"rS  r\   r4   r4   r5   Ú#test_ascii_add_header_with_tspecial¸  s    ÿþz2TestMessageAPI.test_ascii_add_header_with_tspecialc                 C   s*   t ƒ }|jdddd |  d|d ¡ d S )Nr  r  u   FuÃŸballer [filename].pptr  z@attachment; filename*=utf-8''Fu%C3%9Fballer%20%5Bfilename%5D.pptrS  r\   r4   r4   r5   Ú&test_nonascii_add_header_with_tspecialÀ  s    ÿþz5TestMessageAPI.test_nonascii_add_header_with_tspecialc                 C   sL   dD ]B}t ƒ }d| |d< d|d< | d¡ |  |jddd	d
| ¡ qd S )N©úlatin-1r•   útext/plain; charset=%sr:   r=   r<   s   foo=e6=96=87barTrO   ó	   fooæ–‡barú1get_payload returns wrong result with charset %s.r[   ©r1   r;   r3   r4   r4   r5   Útest_binary_quopri_payloadÈ  s    

ýz)TestMessageAPI.test_binary_quopri_payloadc                 C   sL   dD ]B}t ƒ }d| |d< d|d< | d¡ |  |jddd	d
| ¡ qd S )NrZ  r\  r:   rN   r<   s   Zm9v5paHYmFyTrO   r]  r^  r[   r_  r4   r4   r5   Útest_binary_base64_payloadÓ  s    

ýz)TestMessageAPI.test_binary_base64_payloadc              
   C   s^   dD ]T}dD ]J}t ƒ }d| |d< ||d< | d¡ |  |jddd	td
ƒ ||¡¡ qqd S )NrZ  rž   r\  r:   r<   s    begin 666 -
)9F]OYI:'8F%R
 
end
TrO   r]  )z!get_payload returns wrong result z"with charset {0} and encoding {1}.)r   rJ   r-   rQ   r±   Úformat)r1   r;   Úencodingr3   r4   r4   r5   Útest_binary_uuencode_payloadÞ  s    

þýz+TestMessageAPI.test_binary_uuencode_payloadc                 C   s*   t ƒ }|jddd d |  d|d ¡ d S )Nr  rG  )Zfoo_barzinline; foo-barrS  r\   r4   r4   r5   Ú$test_add_header_with_name_only_paramì  s    z3TestMessageAPI.test_add_header_with_name_only_paramc                 C   s&   t ƒ }| dd ¡ |  d|d ¡ d S )NzX-Statusr)   rS  r\   r4   r4   r5   Útest_add_header_with_no_valueñ  s    z,TestMessageAPI.test_add_header_with_no_valuec                 C   s&   t ƒ }tdƒ|d< |  tj|j¡ d S ©Nzdummy
X-Injected-Header: testZDummy)r   r
   r‚   r   rƒ   rˆ   r\   r4   r4   r5   Ú(test_embedded_header_via_Header_rejectedø  s    z7TestMessageAPI.test_embedded_header_via_Header_rejectedc                 C   s"   t ƒ }d|d< |  tj|j¡ d S rg  )r   r‚   r   rƒ   rˆ   r\   r4   r4   r5   Ú(test_embedded_header_via_string_rejectedý  s    z7TestMessageAPI.test_embedded_header_via_string_rejectedc                 C   s*   t dƒ}d|d< |  t|ƒt d¡¡ d S )Nzabc
u   Ã‰ testÚSubjectzÍ            Content-Type: text/plain; charset="us-ascii"
            MIME-Version: 1.0
            Content-Transfer-Encoding: 7bit
            Subject: =?utf-8?q?=C3=89_test?=

            abc
            ©r   r-   r±   rÃ   rÄ   ©r1   rÇ   r4   r4   r5   Ú-test_unicode_header_defaults_to_utf8_encoding  s    z<TestMessageAPI.test_unicode_header_defaults_to_utf8_encodingc                 C   s"   t dƒ}|  t|ƒt d¡¡ d S )Nu   Ã‰ testabc
z¬            Content-Type: text/plain; charset="utf-8"
            MIME-Version: 1.0
            Content-Transfer-Encoding: base64

            w4kgdGVzdGFiYwo=
            rk  rl  r4   r4   r5   Ú+test_unicode_body_defaults_to_utf8_encoding  s    z:TestMessageAPI.test_unicode_body_defaults_to_utf8_encodingN)XÚ__name__Ú
__module__Ú__qualname__r6   rF   rI   rK   rT   rX   rY   r]   ra   rg   rv   rx   r{   r†   r‰   r”   rš   r   r£   r¤   r¨   r®   r¹   rÂ   rÊ   rÌ   rÐ   rÑ   rÕ   rØ   rÙ   rÛ   rå   rç   ré   rë   rî   rï   rð   r÷   r   r	  r
  r  r  r  r  r  r  r  r  r  r!  r#  r%  r&  r(  r)  r-  r/  r1  r2  r4  r5  r7  r8  rF  rI  rO  rP  rR  rT  rV  rW  rX  rY  r`  ra  rd  re  rf  rh  ri  rm  rn  r4   r4   r4   r5   r+   5   sª   			

	

r+   c                   @   s<   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ ZdS )ÚTestEncodersc                 C   sp   t ddƒ}| ¡ }W d   ƒ n1 s(0    Y  tjj |¡}| ¡ }| d¡}|  t	dd„ |D ƒƒd¡ d S )NúPyBanner048.gifÚrbr(   c                 S   s   g | ]}t |ƒ‘qS r4   )Úlen©rl   rN  r4   r4   r5   rn   %  ro   z;TestEncoders.test_EncodersEncode_base64.<locals>.<listcomp>éL   )
r$   r‹   r—   ÚmimeÚimager   rQ   r²   ÚassertLessEqualÚmax)r1   r   ÚbindataZmimedZbase64edr¸   r4   r4   r5   Útest_EncodersEncode_base64  s    &
z'TestEncoders.test_EncodersEncode_base64c                 C   s(   | j }tƒ }| d¡ ||d dƒ d S )NrG   r<   Ú7bit)r-   r   rA   r0   r4   r4   r5   Útest_encode_empty_payload'  s    
z&TestEncoders.test_encode_empty_payloadc                 C   sP   | j }tdƒ}||d dƒ tdƒ}||d dƒ tddd}||d dƒ d S )	Núhello worldr<   r~  u   hello Ã¸ worldrN   r7   ©Ú_charsetr=   )r-   r   r0   r4   r4   r5   Útest_default_cte-  s    zTestEncoders.test_default_ctec                 C   s8   | j }tddd}||d dƒ || ¡ t d¡ƒ d S )Nu   æ–‡
úeuc-jpr  r<   r~  z¨            MIME-Version: 1.0
            Content-Type: text/plain; charset="iso-2022-jp"
            Content-Transfer-Encoding: 7bit

            $BJ8(B
            )r-   r   rˆ   rÃ   rÄ   r0   r4   r4   r5   Útest_encode7or8bit9  s    zTestEncoders.test_encode7or8bitc                 C   s&   t dddƒ}|  t|ƒt d¡¡ d S )Nu   Ã¡Ã¶
r¥   z
ISO-8859-1z°            MIME-Version: 1.0
            Content-Type: text/text; charset="iso-8859-1"
            Content-Transfer-Encoding: quoted-printable

            =E1=F6
            rk  r\   r4   r4   r5   Útest_qp_encode_latin1H  s    z"TestEncoders.test_qp_encode_latin1c                 C   s&   t dddƒ}|  t|ƒt d¡¡ d S )Nu   Å¼
r¥   z
ISO-8859-2z­            MIME-Version: 1.0
            Content-Type: text/text; charset="iso-8859-2"
            Content-Transfer-Encoding: quoted-printable

            =BF
            rk  r\   r4   r4   r5   Útest_qp_encode_non_latin1R  s    z&TestEncoders.test_qp_encode_non_latin1N)	ro  rp  rq  r}  r  rƒ  r…  r†  r‡  r4   r4   r4   r5   rr    s   	
rr  c                   @   sH  e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
d„ Zdd„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zd d!„ Zd"d#„ Zd$d%„ Zd&d'„ Zd(d)„ Zd*d+„ Zd,d-„ Zd.d/„ Zd0d1„ Zd2d3„ Zd4d5„ Zd6d7„ Zd8d9„ Zd:d;„ Z d<d=„ Z!d>d?„ Z"d@dA„ Z#dBdC„ Z$dDdE„ Z%dFdG„ Z&dHdI„ Z'dJdK„ Z(dLdM„ Z)dNdO„ Z*dS )PÚTestLongHeadersNc                 C   s:   | j }t d¡}tƒ }t|ƒ}| |¡ || ¡ dƒ d S )NzºSubject: bug demonstration
	12345678911234567892123456789312345678941234567895123456789612345678971234567898112345678911234567892123456789112345678911234567892123456789
	more text

test
)ÚndiffAssertEqualr—   rÔ   r   r   r   rŽ   ©r1   r2   r3   Úsfpr§   r4   r4   r5   Útest_split_long_continuationc  s    

z,TestLongHeaders.test_split_long_continuationc                 C   sF   | j }d}t|dd}|| ¡ dƒ t| dd¡ƒ}|| ¡ dƒ d S )Nzªbug demonstration
	12345678911234567892123456789312345678941234567895123456789612345678971234567898112345678911234567892123456789112345678911234567892123456789
	more textú	©Úcontinuation_wsr*   zªbug demonstration
 12345678911234567892123456789312345678941234567895123456789612345678971234567898112345678911234567892123456789112345678911234567892123456789
 more text)r‰  r
   r–   rË   ©r1   r2   ZhstrÚhr4   r4   r5   Ú,test_another_long_almost_unsplittable_headerw  s    z<TestLongHeaders.test_another_long_almost_unsplittable_headerc                 C   sš   | j }tdƒ}tdƒ}tdƒ}d}d}d}t||dd}| ||¡ | ||¡ tƒ }	||	d< tƒ }
t|
ƒ}| |	¡ ||
 ¡ d	ƒ ||j	d
ddƒ d S )Nr7   rb   rM   ó©   Die 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.ã€ã¨è¨€ã£ã¦ã„ã¾ã™ã€‚rj  ©Úheader_namea!  Subject: =?iso-8859-1?q?Die_Mieter_treten_hier_ein_werden_mit_einem_Foerderb?=
 =?iso-8859-1?q?and_komfortabel_den_Korridor_entlang=2C_an_s=FCdl=FCndischen?=
 =?iso-8859-1?q?_Wandgem=E4lden_vorbei=2C_gegen_die_rotierenden_Klingen_bef?=
 =?iso-8859-1?q?=F6rdert=2E_?= =?iso-8859-2?q?Finan=E8ni_metropole_se_hrouti?=
 =?iso-8859-2?q?ly_pod_tlakem_jejich_d=F9vtipu=2E=2E_?= =?utf-8?b?5q2j56K6?=
 =?utf-8?b?44Gr6KiA44GG44Go57+76Kiz44Gv44GV44KM44Gm44GE44G+44Gb44KT44CC5LiA?=
 =?utf-8?b?6YOo44Gv44OJ44Kk44OE6Kqe44Gn44GZ44GM44CB44GC44Go44Gv44Gn44Gf44KJ?=
 =?utf-8?b?44KB44Gn44GZ44CC5a6f6Zqb44Gr44Gv44CMV2VubiBpc3QgZGFzIE51bnN0dWNr?=
 =?utf-8?b?IGdpdCB1bmQgU2xvdGVybWV5ZXI/IEphISBCZWloZXJodW5kIGRhcyBPZGVyIGRp?=
 =?utf-8?b?ZSBGbGlwcGVyd2FsZHQgZ2Vyc3B1dC7jgI3jgajoqIDjgaPjgabjgYTjgb7jgZk=?=
 =?utf-8?b?44CC?=

rw  ©Ú
maxlinelena	  =?iso-8859-1?q?Die_Mieter_treten_hier_ein_werden_mit_einem_Foerde?=
 =?iso-8859-1?q?rband_komfortabel_den_Korridor_entlang=2C_an_s=FCdl=FCndis?=
 =?iso-8859-1?q?chen_Wandgem=E4lden_vorbei=2C_gegen_die_rotierenden_Klinge?=
 =?iso-8859-1?q?n_bef=F6rdert=2E_?= =?iso-8859-2?q?Finan=E8ni_metropole_se?=
 =?iso-8859-2?q?_hroutily_pod_tlakem_jejich_d=F9vtipu=2E=2E_?=
 =?utf-8?b?5q2j56K644Gr6KiA44GG44Go57+76Kiz44Gv44GV44KM44Gm44GE44G+44Gb?=
 =?utf-8?b?44KT44CC5LiA6YOo44Gv44OJ44Kk44OE6Kqe44Gn44GZ44GM44CB44GC44Go?=
 =?utf-8?b?44Gv44Gn44Gf44KJ44KB44Gn44GZ44CC5a6f6Zqb44Gr44Gv44CMV2VubiBp?=
 =?utf-8?b?c3QgZGFzIE51bnN0dWNrIGdpdCB1bmQgU2xvdGVybWV5ZXI/IEphISBCZWlo?=
 =?utf-8?b?ZXJodW5kIGRhcyBPZGVyIGRpZSBGbGlwcGVyd2FsZHQgZ2Vyc3B1dC7jgI0=?=
 =?utf-8?b?44Go6KiA44Gj44Gm44GE44G+44GZ44CC?=)
r‰  r	   r
   Úappendr   r   r   r   rŽ   r–   )r1   r2   r§   ÚczÚutf8Úg_headÚcz_headÚ	utf8_headr‘  r3   r‹  r4   r4   r5   Útest_long_nonstringˆ  s"    
z#TestLongHeaders.test_long_nonstringc                 C   s$   | j }tddd}|| ¡ dƒ d S )Núiwasnipoop; giraffes="very-long-necked-animals"; spooge="yummy"; hippos="gargantuan"; marshmallows="gooey"úX-Foobar-Spoink-Defrobnitr–  újwasnipoop; giraffes="very-long-necked-animals";
 spooge="yummy"; hippos="gargantuan"; marshmallows="gooey"©r‰  r
   r–   ©r1   r2   r‘  r4   r4   r5   Útest_long_header_encode¾  s
    þz'TestLongHeaders.test_long_header_encodec                 C   s&   | j }tdddd}|| ¡ dƒ d S )Nr¡  r¢  r  ©r—  r  r£  r¤  r¥  r4   r4   r5   Ú<test_long_header_encode_with_tab_continuation_is_just_a_hintÇ  s    ýzLTestLongHeaders.test_long_header_encode_with_tab_continuation_is_just_a_hintc                 C   s&   | j }tdddd}|| ¡ dƒ d S )Nziwasnipoop; giraffes="very-long-necked-animals";	spooge="yummy"; hippos="gargantuan"; marshmallows="gooey"r¢  r  r§  zjwasnipoop; giraffes="very-long-necked-animals";
	spooge="yummy"; hippos="gargantuan"; marshmallows="gooey"r¤  r¥  r4   r4   r5   Ú-test_long_header_encode_with_tab_continuationÑ  s    ýz=TestLongHeaders.test_long_header_encode_with_tab_continuationc                 C   s   t ddƒ}|  | ¡ d¡ d S )Nõ   æ–‡r„  ú=?iso-2022-jp?b?GyRCSjgbKEI=?=©r
   r-   r–   ©r1   r‘  r4   r4   r5   Ú0test_header_encode_with_different_output_charsetÛ  s    
z@TestLongHeaders.test_header_encode_with_different_output_charsetc                 C   s(   t d d¡dƒ}d}|  | ¡ |¡ d S )Ns6   test-ja ¤ØÅê¹Æ¤µ¤ì¤¿¥á¡¼¥ë¤Ï»Ê²ñ¼Ô¤Î¾µÇ§¤òÂÔ¤Ã¤Æ¤¤¤Þ¤¹r„  z‚=?iso-2022-jp?b?dGVzdC1qYSAbJEIkWEVqOUYkNSRsJD8lYSE8JWskTztKMnE8VCROPjUbKEI=?=
 =?iso-2022-jp?b?GyRCRyckckJUJEMkRiQkJF4kORsoQg==?=)r
   rP   r-   r–   )r1   r‘  Úresr4   r4   r5   Ú5test_long_header_encode_with_different_output_charsetß  s    ýýzETestLongHeaders.test_long_header_encode_with_different_output_charsetc                 C   s@   | j }tdƒ}d|d< tƒ }t|ƒ}| |¡ || ¡ dƒ d S )Nr)   r¡  r¢  zæContent-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Foobar-Spoink-Defrobnit: wasnipoop; giraffes="very-long-necked-animals";
 spooge="yummy"; hippos="gargantuan"; marshmallows="gooey"

)r‰  r   r   r   r   rŽ   rŠ  r4   r4   r5   Útest_header_splitteré  s    ÿ
z$TestLongHeaders.test_header_splitterc                 C   sd   | j }tƒ }d|d< t dd„ tdƒD ƒ¡|d< | d¡ tƒ }t|ƒ}| |¡ || 	¡ dƒ d S )	Nútest@dom.ainr©   c                 s   s   | ]}d | V  qdS )z<%d@dom.ain>Nr4   ©rl   Úir4   r4   r5   Ú	<genexpr>  ro   z@TestLongHeaders.test_no_semis_header_splitter.<locals>.<genexpr>é
   Ú
ReferencesÚTestzFrom: 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)
r‰  r   ÚSPACEr¶   ÚrangerJ   r   r   r   rŽ   rŠ  r4   r4   r5   Útest_no_semis_header_splitterý  s    

z-TestLongHeaders.test_no_semis_header_splitterc                 C   s    | j }tdƒ}|| ¡ dƒ d S )Nz‡Subject: 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_itselfzˆSubject: 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_itselfr¤  r¥  r4   r4   r5   Ú"test_last_split_chunk_does_not_fit  s    z2TestLongHeaders.test_last_split_chunk_does_not_fitc                 C   s    | j }tdƒ}|| ¡ dƒ d S )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_itselfr¤  r¥  r4   r4   r5   Ú>test_splittable_leading_char_followed_by_overlong_unsplittable  s    zNTestLongHeaders.test_splittable_leading_char_followed_by_overlong_unsplittablec                 C   s    | j }tdƒ}|| ¡ dƒ d S )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_itselfr¤  r¥  r4   r4   r5   ÚGtest_multiple_splittable_leading_char_followed_by_overlong_unsplittable  s    zWTestLongHeaders.test_multiple_splittable_leading_char_followed_by_overlong_unsplittablec                 C   s    | j }tdƒ}|| ¡ dƒ d S )NzTthis_part_does_not_fit_within_maxlinelen_and_thus_should_be_on_a_line_all_by_itself;r¤  r¥  r4   r4   r5   Ú1test_trailing_splittable_on_overlong_unsplittable(  s    zATestLongHeaders.test_trailing_splittable_on_overlong_unsplittablec                 C   s    | j }tdƒ}|| ¡ dƒ d S )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; r¤  r¥  r4   r4   r5   ÚItest_trailing_splittable_on_overlong_unsplittable_with_leading_splittable/  s    zYTestLongHeaders.test_trailing_splittable_on_overlong_unsplittable_with_leading_splittablec                 C   s    | j }tdƒ}|| ¡ dƒ d S )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 foldedr¤  r¥  r4   r4   r5   Ú5test_long_header_with_multiple_sequential_split_chars8  s    zETestLongHeaders.test_long_header_with_multiple_sequential_split_charsc                 C   s    | j }tdƒ}|| ¡ dƒ d S )NúKthisverylongheaderhas;semicolons;and,commas,butthey;arenotlegal;fold,pointsr¤  r¥  r4   r4   r5   Ú:test_splitter_split_on_punctuation_only_if_fws_with_header@  s    zJTestLongHeaders.test_splitter_split_on_punctuation_only_if_fws_with_headerc                 C   s    | j }tdƒ}|| ¡ dƒ d S )NzÂthis 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;zÄthis 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;r¤  r¥  r4   r4   r5   ÚDtest_leading_splittable_in_the_middle_just_before_overlong_last_partG  s    zTTestLongHeaders.test_leading_splittable_in_the_middle_just_before_overlong_last_partc                 C   s    | j }tdƒ}|| ¡ dƒ d S )NzTthis_part_does_not_fit_within_maxlinelen_and_thus_should_be_on_a_line_all_by_itself r¤  r¥  r4   r4   r5   Ú/test_overlong_last_part_followed_by_split_pointR  s    z?TestLongHeaders.test_overlong_last_part_followed_by_split_pointc                 C   s    | j }tdƒ}|| ¡ dƒ d S )Nz¨this_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; zªthis_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; r¤  r¥  r4   r4   r5   Ú@test_multiline_with_overlong_parts_separated_by_two_split_pointsY  s    zPTestLongHeaders.test_multiline_with_overlong_parts_separated_by_two_split_pointsc                 C   s    | j }tdƒ}|| ¡ dƒ d S )Nz¦this 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; z¨this 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; r¤  r¥  r4   r4   r5   Ú>test_multiline_with_overlong_last_part_followed_by_split_pointd  s    zNTestLongHeaders.test_multiline_with_overlong_last_part_followed_by_split_pointc                 C   s\   | j }tƒ }d|d< t dgd ¡|d< | d¡ tƒ }t|ƒ}| |¡ || ¡ dƒ d S )Nr²  r©   z<foo@dom.ain>  r¶  r·  r¸  zÆFrom: test@dom.ain
References: <foo@dom.ain>   <foo@dom.ain>   <foo@dom.ain>   <foo@dom.ain>
   <foo@dom.ain>   <foo@dom.ain>   <foo@dom.ain>   <foo@dom.ain>
   <foo@dom.ain>   <foo@dom.ain>  

Test©	r‰  r   r¹  r¶   rJ   r   r   r   rŽ   rŠ  r4   r4   r5   Ú%test_long_header_with_whitespace_runso  s    

z5TestLongHeaders.test_long_header_with_whitespace_runsc                 C   s`   | j }tƒ }d|d< t dgd ¡d |d< | d¡ tƒ }t|ƒ}| |¡ || ¡ dƒ d S )	Nr²  r©   z<foo@dom.ain>r¶  z; abcr·  r¸  z·From: test@dom.ain
References: <foo@dom.ain> <foo@dom.ain> <foo@dom.ain> <foo@dom.ain>
 <foo@dom.ain> <foo@dom.ain> <foo@dom.ain> <foo@dom.ain> <foo@dom.ain>
 <foo@dom.ain>; abc

TestrÈ  rŠ  r4   r4   r5   Ú'test_long_run_with_semi_header_splitter€  s    

z7TestLongHeaders.test_long_run_with_semi_header_splitterc                 C   sP   | j }tƒ }d|d< d|d< | d¡ tƒ }t|ƒ}| |¡ || ¡ dƒ d S )Nr²  r©   rÂ  r·  r¸  zrFrom: test@dom.ain
References: 
 thisverylongheaderhas;semicolons;and,commas,butthey;arenotlegal;fold,points

Test)r‰  r   rJ   r   r   r   rŽ   rŠ  r4   r4   r5   Ú.test_splitter_split_on_punctuation_only_if_fws‘  s    

z>TestLongHeaders.test_splitter_split_on_punctuation_only_if_fwsc                 C   s:   | j }d}t|ƒ}|| ¡ dƒ tdƒ}|| ¡ dƒ d S )Nz\References: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxz]References:
 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxZPxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxr¤  r  r4   r4   r5   Útest_no_split_long_header£  s    z)TestLongHeaders.test_no_split_long_headerc                 C   s(   | j }d}t|dd}|| ¡ dƒ d S )NaW  from babylon.socal-raves.org (localhost [127.0.0.1]); by babylon.socal-raves.org (Postfix) with ESMTP id B570E51B81; for <mailman-admin@babylon.socal-raves.org>; Sat, 2 Feb 2002 17:00:06 -0800 (PST)
	from babylon.socal-raves.org (localhost [127.0.0.1]); by babylon.socal-raves.org (Postfix) with ESMTP id B570E51B81; for <mailman-admin@babylon.socal-raves.org>; Sat, 2 Feb 2002 17:00:06 -0800 (PST)
	from babylon.socal-raves.org (localhost [127.0.0.1]); by babylon.socal-raves.org (Postfix) with ESMTP id B570E51B81; for <mailman-admin@babylon.socal-raves.org>; Sat, 2 Feb 2002 17:00:06 -0800 (PST)
r  rŽ  a_  from babylon.socal-raves.org (localhost [127.0.0.1]);
 by babylon.socal-raves.org (Postfix) with ESMTP id B570E51B81;
 for <mailman-admin@babylon.socal-raves.org>;
 Sat, 2 Feb 2002 17:00:06 -0800 (PST)
	from babylon.socal-raves.org (localhost [127.0.0.1]);
 by babylon.socal-raves.org (Postfix) with ESMTP id B570E51B81;
 for <mailman-admin@babylon.socal-raves.org>;
 Sat, 2 Feb 2002 17:00:06 -0800 (PST)
	from babylon.socal-raves.org (localhost [127.0.0.1]);
 by babylon.socal-raves.org (Postfix) with ESMTP id B570E51B81;
 for <mailman-admin@babylon.socal-raves.org>;
 Sat, 2 Feb 2002 17:00:06 -0800 (PST)r¤  r  r4   r4   r5   Ú"test_splitting_multiple_long_lines¯  s    z2TestLongHeaders.test_splitting_multiple_long_linesc                 C   s,   | j }d}t|dddd}|| ¡ dƒ d S )NzÞfrom 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 -0400éN   ZReceivedr  )r™  r—  r  zßfrom 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 -0400r¤  r  r4   r4   r5   Ú&test_splitting_first_line_only_is_longÅ  s    ÿz6TestLongHeaders.test_splitting_first_line_only_is_longc                 C   sf   | j }tƒ }tdddd}| d¡ ||jdddƒ ||d< ||jdd	d
ƒ ||jdd	dƒ d S )NzBritische Regierung gibtr7   rj  r–  u-   grÃ¼nes Licht fÃ¼r Offshore-Windkraftprojekterw  r˜  zl=?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?=

r   zdSubject: =?iso-8859-1?q?Britische_Regierung_gibt_gr=FCnes_Licht_f=FCr_Offshore-Windkraftprojekte?=

)r‰  r   r
   rš  r–   rˆ   )r1   r2   r3   r‘  r4   r4   r5   Útest_long_8bit_headerÕ  s    ÿ
z%TestLongHeaders.test_long_8bit_headerc                 C   sV   | j }tƒ }d}||d< ||jdddƒ tƒ }t|dd|d< ||jdddƒ d S )Nuh   Britische Regierung gibt grÃ¼nes Licht fÃ¼r Offshore-Windkraftprojekte <a-very-long-address@example.com>zReply-TorÎ  rÐ  zžReply-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–  )r‰  r   rˆ   r
   )r1   r2   r3   Zheader_stringr4   r4   r5   Ú test_long_8bit_header_no_charseté  s    ÿ
z0TestLongHeaders.test_long_8bit_header_no_charsetc                 C   s.   | j }d}tƒ }||d< ||jdddƒ d S )NzÂ"Someone Test #A" <someone@eecs.umich.edu>,<someone@eecs.umich.edu>, "Someone Test #B" <someone@umich.edu>, "Someone Test #C" <someone@eecs.umich.edu>, "Someone Test #D" <someone@eecs.umich.edu>r¬   rÎ  rÐ  zËTo: "Someone Test #A" <someone@eecs.umich.edu>,<someone@eecs.umich.edu>,
 "Someone Test #B" <someone@umich.edu>,
 "Someone Test #C" <someone@eecs.umich.edu>,
 "Someone Test #D" <someone@eecs.umich.edu>

)r‰  r   rˆ   )r1   r2   rª   r3   r4   r4   r5   Útest_long_to_headerþ  s
    z#TestLongHeaders.test_long_to_headerc                 C   s2   | j }d}t|ƒ}| d¡ ||jdddƒ d S )NzIThis is an example of string which has almost the limit of header length.zAdd another line.rw  r˜  z\This is an example of string which has almost the limit of header length.
 Add another line.©r‰  r
   rš  r–   ©r1   r2   r¦   r‘  r4   r4   r5   Útest_long_line_after_append  s
    
z+TestLongHeaders.test_long_line_after_appendc                 C   s.   | j }d}t|ƒ}| d¡ || ¡ dƒ d S )NzThis is a shorter line.z!Add another sentence. (Surprise?)z9This is a shorter line. Add another sentence. (Surprise?)rÔ  rÕ  r4   r4   r5   Útest_shorter_line_with_append  s    
ÿz-TestLongHeaders.test_shorter_line_with_appendc                 C   s2   | j }d}d}t|d|d}||jdddƒ d S )Nz!X-Very-Very-Very-Long-Header-Nameu­   Die 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. r7   r–  rw  r˜  a  =?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¤  )r1   r2   ÚfnZgsr‘  r4   r4   r5   Útest_long_field_name   s
    z$TestLongHeaders.test_long_field_namec                 C   s:   d}t ƒ }t|dd|d< ||d< |  |jddd¡ d S )	Nz‰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 -0700r  rŽ  ú
Received-1ú
Received-2rÎ  rÐ  a1  Received-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

©r   r
   r‰  rˆ   ©r1   r‘  r3   r4   r4   r5   Útest_long_received_header/  s
    z)TestLongHeaders.test_long_received_headerc                 C   s<   d}t ƒ }t|ddd|d< ||d< |  |jddd¡ d S )	Nz<15975.17901.207240.414604@sgigritzmann1.mathematik.tu-muenchen.de> (David Bremner's message of "Thu, 6 Mar 2003 13:58:21 +0100")rÚ  r  r§  rÛ  rÎ  rÐ  a#  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")

rÜ  rÝ  r4   r4   r5   Útest_string_headerinst_eqA  s    ÿ
z)TestLongHeaders.test_string_headerinst_eqc                 C   sJ   | j }tƒ }d}||d< t|dd|d< d| |d< ||jddd	ƒ d S )
Nz’iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAGFBMVEUAAAAkHiJeRUIcGBi9
 locQDQ4zJykFBAXJfWDjAAACYUlEQVR4nF2TQY/jIAyFc6lydlG5x8Nyp1Y69wj1PN2I5gzpzFace-1zFace-2r–  r*   zFace-3rÎ  rÐ  aØ  Face-1: 
 iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAGFBMVEUAAAAkHiJeRUIcGBi9
 locQDQ4zJykFBAXJfWDjAAACYUlEQVR4nF2TQY/jIAyFc6lydlG5x8Nyp1Y69wj1PN2I5gzp
Face-2: 
 iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAGFBMVEUAAAAkHiJeRUIcGBi9
 locQDQ4zJykFBAXJfWDjAAACYUlEQVR4nF2TQY/jIAyFc6lydlG5x8Nyp1Y69wj1PN2I5gzp
Face-3: 
 iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAGFBMVEUAAAAkHiJeRUIcGBi9
 locQDQ4zJykFBAXJfWDjAAACYUlEQVR4nF2TQY/jIAyFc6lydlG5x8Nyp1Y69wj1PN2I5gzp

©r‰  r   r
   rˆ   )r1   r2   r3   Útr4   r4   r5   Ú-test_long_unbreakable_lines_with_continuationT  s    z=TestLongHeaders.test_long_unbreakable_lines_with_continuationc                 C   s*   | j }d}t |¡}||jdddƒ d S )Nz‰Received: 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 -0700rÎ  rÐ  zŒReceived: 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

)r‰  r—   rÔ   rˆ   ©r1   r2   rÇ   r3   r4   r4   r5   Ú"test_another_long_multiline_headerl  s    
z2TestLongHeaders.test_another_long_multiline_headerc                 C   s>   | j }d}tƒ }||d< t|dd|d< ||jdddƒ d S )Nz¦List-Unsubscribe: <http://lists.sourceforge.net/lists/listinfo/spamassassin-talk>,        <mailto:spamassassin-talk-request@lists.sourceforge.net?subject=unsubscribe>ÚListr–  rÎ  rÐ  a_  List: List-Unsubscribe:
 <http://lists.sourceforge.net/lists/listinfo/spamassassin-talk>,
        <mailto:spamassassin-talk-request@lists.sourceforge.net?subject=unsubscribe>
List: List-Unsubscribe:
 <http://lists.sourceforge.net/lists/listinfo/spamassassin-talk>,
        <mailto:spamassassin-talk-request@lists.sourceforge.net?subject=unsubscribe>

rà  )r1   r2   r‘  r3   r4   r4   r5   Ú%test_long_lines_with_different_headery  s    z5TestLongHeaders.test_long_lines_with_different_headerc                 C   s6   t t d¡ddd}|  | ¡ d t d¡d ¡ d S )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 worksrM   r¸  )r;   r—  r(   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
   rÃ   rÄ   r-   r–   r­  r4   r4   r5   Ú*test_long_rfc2047_header_with_embedded_fwsŒ  s    
ûüz:TestLongHeaders.test_long_rfc2047_header_with_embedded_fws)+ro  rp  rq  ÚmaxDiffrŒ  r’  r   r¦  r¨  r©  r®  r°  r±  r»  r¼  r½  r¾  r¿  rÀ  rÁ  rÃ  rÄ  rÅ  rÆ  rÇ  rÉ  rÊ  rË  rÌ  rÍ  rÏ  rÑ  rÒ  rÓ  rÖ  r×  rÙ  rÞ  rß  râ  rä  ræ  rç  r4   r4   r4   r5   rˆ  _  sP   6	


					rˆ  c                   @   s<   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ ZdS )ÚTestFromManglingc                 C   s"   t ƒ | _d| jd< | j d¡ d S )Nzaaa@bbb.orgr©   z(From the desk of A.A.A.:
Blah blah blah
)r   r3   rJ   ©r1   r4   r4   r5   ÚsetUp  s    
zTestFromMangling.setUpc                 C   s2   t ƒ }t|dd}| | j¡ |  | ¡ d¡ d S )NT©Zmangle_from_z<From: aaa@bbb.org

>From the desk of A.A.A.:
Blah blah blah
©r   r   r   r3   r-   rŽ   ©r1   r¦   r§   r4   r4   r5   Útest_mangled_from¥  s    z"TestFromMangling.test_mangled_fromc                 C   s2   t ƒ }t|dd}| | j¡ |  | ¡ d¡ d S )NFrì  z;From: aaa@bbb.org

From the desk of A.A.A.:
Blah blah blah
rí  rî  r4   r4   r5   Útest_dont_mangle_from°  s    z&TestFromMangling.test_dont_mangle_fromc                 C   sT   t ƒ }t|dd}t t d¡¡}| |¡ |  tdd„ | 	¡  
d¡D ƒƒd¡ d S )NTrì  a)              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
            c                 S   s   g | ]}|  d ¡rd‘qS )z>From rr   )r´   rv  r4   r4   r5   rn   Ï  s   
ÿzLTestFromMangling.test_mangle_from_in_preamble_and_epilog.<locals>.<listcomp>r(   r›   )r   r   r—   rÔ   rÃ   rÄ   r   r-   ru  rŽ   r²   )r1   r¦   r§   r3   r4   r4   r5   Ú'test_mangle_from_in_preamble_and_epilog»  s    
ÿz8TestFromMangling.test_mangle_from_in_preamble_and_epilogc                 C   sR   t  d¡ d¡}t |d ¡}tƒ }t|dd}| |¡ |  | 	¡ |d ¡ d S )Nz§            Content-Type: text/plain; charset="utf-8"
            MIME-Version: 1.0
            Content-Transfer-Encoding: 8bit
            From: aaa@bbb.org

        rM   s   From RÃ¶lli
Trì  s   >From RÃ¶lli
)
rÃ   rÄ   r–   r—   rÅ   r   r   r   r-   rŽ   )r1   rÈ   r3   Úbr§   r4   r4   r5   Ú test_mangled_from_with_bad_bytesÒ  s    
ú
z1TestFromMangling.test_mangled_from_with_bad_bytesc                 C   s   t  d¡ d¡}t |¡}d S )Nu               From: aperson@example.com
            Content-Type: multipart/mixed; boundary="1"
            Content-Transfer-Encoding: Ãˆ
        rM   )rÃ   rÄ   r–   r—   rÅ   )r1   rÈ   r3   r4   r4   r5   Ú$test_multipart_with_bad_bytes_in_cteà  s    
üz5TestFromMangling.test_multipart_with_bad_bytes_in_cteN)	ro  rp  rq  rë  rï  rð  rñ  ró  rô  r4   r4   r4   r5   ré  œ  s   ré  c                   @   s4   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ ZdS )ÚTestMIMEAudioc                 C   sD   t ddƒ}| ¡ | _W d   ƒ n1 s*0    Y  t| jƒ| _d S )Núaudiotest.aurt  )r$   r‹   Ú
_audiodatar   Ú_au©r1   r   r4   r4   r5   rë  ì  s    (zTestMIMEAudio.setUpc                 C   s   |   | j ¡ d¡ d S )Nzaudio/basic)r-   rø  rB   rê  r4   r4   r5   Útest_guess_minor_typeñ  s    z#TestMIMEAudio.test_guess_minor_typec                 C   s(   | j  ¡ }|  t t|dƒ¡| j¡ d S ©Nr•   )rø  rQ   r-   rN   ÚdecodebytesrÎ   r÷  ©r1   Úpayloadr4   r4   r5   Útest_encodingô  s    
ÿzTestMIMEAudio.test_encodingc                 C   s    t | jdƒ}|  | ¡ d¡ d S )NÚfishz
audio/fish)r   r÷  r-   rB   )r1   Zaur4   r4   r5   Útest_checkSetMinorù  s    z TestMIMEAudio.test_checkSetMinorc                 C   s¾   | j }| jjdddd || jd dƒ || jjdddd	gƒ || jjd
dddƒ g }|| jjddddƒ |  | jjd|dd|¡ |  | j d|¡|¡ |  | jjd|dd|¡ d S )Nr  r  rö  r  r  z#attachment; filename="audiotest.au"rÞ   ©r  r)   )r  rö  r  r)   r¡   ©Zfailobjr„   r  )r-   rø  r  rä   rC   ÚassertIs©r1   r2   Úmissingr4   r4   r5   Útest_add_headerý  s4    
ÿ
ÿÿÿÿÿÿÿzTestMIMEAudio.test_add_headerN©ro  rp  rq  rë  rú  rÿ  r  r  r4   r4   r4   r5   rõ  ë  s
   rõ  c                   @   s4   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ ZdS )ÚTestMIMEImagec                 C   sD   t ddƒ}| ¡ | _W d   ƒ n1 s*0    Y  t| jƒ| _d S )Nrs  rt  )r$   r‹   Ú_imgdatar   Ú_imrù  r4   r4   r5   rë    s    (zTestMIMEImage.setUpc                 C   s   |   | j ¡ d¡ d S )Nz	image/gif)r-   r  rB   rê  r4   r4   r5   rú    s    z#TestMIMEImage.test_guess_minor_typec                 C   s(   | j  ¡ }|  t t|dƒ¡| j¡ d S rû  )r  rQ   r-   rN   rü  rÎ   r
  rý  r4   r4   r5   rÿ    s    
ÿzTestMIMEImage.test_encodingc                 C   s    t | jdƒ}|  | ¡ d¡ d S )Nr   z
image/fish)r   r
  r-   rB   )r1   Zimr4   r4   r5   r  !  s    z TestMIMEImage.test_checkSetMinorc                 C   s¾   | j }| jjdddd || jd dƒ || jjdddd	gƒ || jjd
dddƒ g }|| jjddddƒ |  | jjd|dd|¡ |  | j d|¡|¡ |  | jjd|dd|¡ d S )Nr  r  rs   r  r  z%attachment; filename="dingusfish.gif"rÞ   r  )r  rs   r  r)   r¡   r  r  )r-   r  r  rä   rC   r  r  r4   r4   r5   r  %  s4    
ÿ
ÿÿÿÿÿÿÿzTestMIMEImage.test_add_headerNr  r4   r4   r4   r5   r	    s
   r	  c                   @   sD   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ Zdd„ Z	dS )ÚTestMIMEApplicationc                 C   s.   | j }tdƒ}|| ¡ dƒ ||d dƒ d S )Nó   úûüýþÿr  r<   rN   )r-   r   rB   r0   r4   r4   r5   Útest_headers<  s    z TestMIMEApplication.test_headersc                 C   s:   | j }d}t|ƒ}|| ¡  ¡ dƒ ||jdd|ƒ d S )Nr  z+vv8/f7/TrO   )r-   r   rQ   Ústrip)r1   r2   Ú	bytesdatar3   r4   r4   r5   Ú	test_bodyB  s
    zTestMIMEApplication.test_bodyc                 C   s¸   d}t |tjd}|  | ¡ dt|ƒ ¡ |  |jdd|¡ |  |d d¡ tƒ }t|ƒ}| |¡ | 	¡ }t
 |¡}|  | ¡ dt|ƒ ¡ |  |jdd|¡ |  |d d¡ d S )Nr  ©Z_encoderõ   ï¿½TrO   r?   rV   )r   r   Úencode_7or8bitr-   rQ   ru  r   r   r   rŽ   r—   rÅ   ©r1   r  r3   r¦   r§   ZwireformÚmsg2r4   r4   r5   Ú$test_binary_body_with_encode_7or8bitJ  s    

z8TestMIMEApplication.test_binary_body_with_encode_7or8bitc                 C   s˜   d}t |tjd}|  | ¡ dt|ƒ ¡ |  |jdd|¡ tƒ }t|ƒ}| |¡ | 	¡ }t
 |¡}|  | ¡ dt|ƒ ¡ |  |jdd|¡ d S )Nr  r  r  TrO   )r   r   Úencode_noopr-   rQ   ru  r   r   r   rŽ   r—   rÅ   r  r4   r4   r5   Ú!test_binary_body_with_encode_noop[  s    

z5TestMIMEApplication.test_binary_body_with_encode_noopc                 C   sh   d}t |tjd}|  |jdd|¡ tƒ }t|ƒ}| |¡ | ¡ }t	 
|¡}|  |jdd|¡ d S )Ns   úûüýþÿr  TrO   )r   r   r  r-   rQ   r   r   r   rŽ   r—   rÅ   r  r4   r4   r5   Ú0test_binary_body_with_unicode_linend_encode_noopl  s    

zDTestMIMEApplication.test_binary_body_with_unicode_linend_encode_noopc                 C   s¨   d}t |tjd}|  | ¡ d¡ |  |jdd|¡ |  |d d¡ tƒ }t|ƒ}| |¡ | ¡ }t	 
|¡}|  | ¡ d¡ |  |jdd|¡ |  |d d¡ d S )Ns   úûüýþÿ r  z=FA=FB=FC=FD=FE=FF=20TrO   r?   r=   )r   r   Zencode_quoprir-   rQ   r   r   r   rŽ   r—   rÅ   r  r4   r4   r5   Ú#test_binary_body_with_encode_quoprix  s    

z7TestMIMEApplication.test_binary_body_with_encode_quopric                 C   sˆ   d}t |tjd}|  | ¡ d¡ |  |jdd|¡ tƒ }t|ƒ}| |¡ | ¡ }t	 
|¡}|  | ¡ d¡ |  |jdd|¡ d S )Nr  r  z	+vv8/f7/
TrO   )r   r   Zencode_base64r-   rQ   r   r   r   rŽ   r—   rÅ   r  r4   r4   r5   Ú#test_binary_body_with_encode_base64ˆ  s    

z7TestMIMEApplication.test_binary_body_with_encode_base64N)
ro  rp  rq  r  r  r  r  r  r  r  r4   r4   r4   r5   r  ;  s   r  c                   @   sV   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ Zdd„ Z	e
 d¡dd„ ƒZdS )ÚTestMIMETextc                 C   s   t dƒ| _d S ©Núhello there)r   Ú_msgrê  r4   r4   r5   rë  ˜  s    zTestMIMEText.setUpc                 C   s`   | j }|| j ¡ dƒ || j d¡dƒ g }|  | j d|¡|¡ |  | jjd|dd|¡ d S )Nr9   r;   rG   r  rÞ   )r-   r   rB   rC   r  r  r4   r4   r5   Ú
test_types›  s    ÿzTestMIMEText.test_typesc                 C   s&   |   | j ¡ d¡ |  | j ¡ ¡ d S r  )r-   r   rQ   ÚassertFalseÚis_multipartrê  r4   r4   r5   Útest_payload¤  s    zTestMIMEText.test_payloadc                 C   sz   | j }tddd}|| ¡ jdƒ ||d dƒ tdƒ}d |_td|d}|| ¡ jdƒ ||d dƒ || ¡ dƒ d S )Nr  rG   r  r:   rH   rM   rQ  )r-   r   r@   rD   r	   rW   rQ   rE   r4   r4   r5   Útest_charset¨  s    zTestMIMEText.test_charsetc                 C   s4   | j }tddd}|| ¡ jdƒ ||d dƒ d S )Nr  rG   r  r:   rH   )r-   r   r@   rD   r0   r4   r4   r5   Útest_7bit_inputµ  s    zTestMIMEText.test_7bit_inputc                 C   s>   | j }tdƒ}|| ¡ dƒ ||d dƒ |  d| ¡ ¡ d S )Nr  rG   r:   rH   )r-   r   r@   r­   rˆ   r0   r4   r4   r5   Útest_7bit_input_no_charset»  s
    z'TestMIMEText.test_7bit_input_no_charsetc                 C   sP   d}| j }t|dd}|| ¡ jdƒ ||d dƒ ||jdd| d¡ƒ d S )Nõ   ÐºÐ¸Ñ€Ð¸Ð»Ð¸Ñ†Ð°rM   r  r:   rQ  TrO   )r-   r   r@   Úoutput_charsetrQ   r–   )r1   Úteststrr2   r3   r4   r4   r5   Útest_utf8_inputÂ  s    zTestMIMEText.test_utf8_inputzBcan't fix because of backward compat in email5, will fix in email6c                 C   s   d}|   tt|¡ d S )Nr(  )r‚   ÚUnicodeEncodeErrorr   )r1   r*  r4   r4   r5   Útest_utf8_input_no_charsetÊ  s    z'TestMIMEText.test_utf8_input_no_charsetN)ro  rp  rq  rë  r!  r$  r%  r&  r'  r+  ÚunittestÚskipr-  r4   r4   r4   r5   r  —  s   	r  c                   @   s¬   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ Zdd„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd „ Zd!d"„ Zd#d$„ Zd%d&„ Zd'd(„ Zd)S )*ÚTestMultipartc                 C   s
  t ddƒ}| ¡ }W d   ƒ n1 s(0    Y  tdddd}t|dd}|jd	d
dd tdƒ}| |¡ | |¡ d|d< d|d< d|d< d}t |¡}|d dkr²tj	}ntj
}|dkrÆd}	nd}	d|	|d f }
t dt |¡¡|
 |d< || _|| _|| _d S )Nrs  rt  Ú	multipartÚmixedry   ©ræ   rs   )rê   r  r  r  z$Hi there,

This is the dingus fish.
zBarry <barry@digicool.com>r©   z)Dingus Lovers <cravindogs@cravindogs.com>r¬   zHere is your dingus fishrj  gÊ4FÓcpÍAéÿÿÿÿr   ú-ú+z %s%04dé$   z%a, %d %b %Y %H:%M:%SZDate)r$   r‹   r   r   r  r   r`   ÚtimeÚ	localtimeÚtimezoneÚaltzoneÚstrftimer   r  Ú_txt)r1   r   rS   Ú	containerry  ZintroÚnowZ	timetupleZtzsecsÚsignZtzoffsetr4   r4   r5   rë  Ô  s>    &ÿ


þþzTestMultipart.setUpc                 C   s°   | j }| j}| j}|  | ¡ ¡ || ¡ dƒ |t| ¡ ƒdƒ |t|jdƒ | d¡}| d¡}|  	|| j
¡ |  	|| j¡ || ¡ ||gƒ |  | ¡ ¡ |  | ¡ ¡ d S )Nr^   r›   r   rr   )r-   r‚   r   r³   r#  rB   ru  rQ   Ú
IndexErrorr  r=  r  r"  )r1   r2   ÚraisesrÇ   Zm0Zm1r4   r4   r5   Útest_hierarchyø  s    

zTestMultipart.test_hierarchyc                 C   s$   d}t ƒ  |¡}|  || ¡ ¡ d S )NzžContent-Type: multipart/mixed; boundary="BOUNDARY"
MIME-Version: 1.0
Subject: A subject
To: aperson@dom.ain
From: bperson@dom.ain


--BOUNDARY


--BOUNDARY--
)r   rŒ   r‰  rˆ   )r1   r¥   r3   r4   r4   r5   Útest_empty_multipart_idempotent
  s    z-TestMultipart.test_empty_multipart_idempotentc                 C   s@   t ddƒ}d|d< d|d< d|d< | d	¡ |  | ¡ d
¡ d S )Nr1  r2  ú	A subjectrj  úaperson@dom.ainr¬   úbperson@dom.ainr©   ry   zœContent-Type: multipart/mixed; boundary="BOUNDARY"
MIME-Version: 1.0
Subject: A subject
To: aperson@dom.ain
From: bperson@dom.ain

--BOUNDARY

--BOUNDARY--
)r   r   r‰  rˆ   ©r1   Úouterr4   r4   r5   Ú/test_no_parts_in_a_multipart_with_none_epilogue  s    

z=TestMultipart.test_no_parts_in_a_multipart_with_none_epiloguec                 C   sL   t ddƒ}d|d< d|d< d|d< d	|_d	|_| d
¡ |  | ¡ d¡ d S )Nr1  r2  rE  rj  rF  r¬   rG  r©   r)   ry   zContent-Type: multipart/mixed; boundary="BOUNDARY"
MIME-Version: 1.0
Subject: A subject
To: aperson@dom.ain
From: bperson@dom.ain


--BOUNDARY

--BOUNDARY--
)r   ÚpreambleÚepiloguer   r‰  rˆ   rH  r4   r4   r5   Ú0test_no_parts_in_a_multipart_with_empty_epilogue-  s    

z>TestMultipart.test_no_parts_in_a_multipart_with_empty_epiloguec                 C   sV   | j }tddƒ}d|d< d|d< d|d< | d	¡ td
ƒ}| |¡ || ¡ dƒ d S )Nr1  r2  rE  rj  rF  r¬   rG  r©   ry   r€  á  Content-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--
)r‰  r   r   r   r`   rˆ   ©r1   r2   rI  r3   r4   r4   r5   Útest_one_part_in_a_multipartB  s    


z*TestMultipart.test_one_part_in_a_multipartc                 C   s\   | j }tddƒ}d|d< d|d< d|d< d	|_td
ƒ}| |¡ | d¡ || ¡ dƒ d S )Nr1  r2  rE  rj  rF  r¬   rG  r©   r)   r€  ry   a  Content-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--
©r‰  r   rK  r   r`   r   rˆ   rO  r4   r4   r5   Ú1test_seq_parts_in_a_multipart_with_empty_preamble[  s    


z?TestMultipart.test_seq_parts_in_a_multipart_with_empty_preamblec                 C   s\   | j }tddƒ}d|d< d|d< d|d< d |_td	ƒ}| |¡ | d
¡ || ¡ dƒ d S ©Nr1  r2  rE  rj  rF  r¬   rG  r©   r€  ry   rN  rQ  rO  r4   r4   r5   Ú0test_seq_parts_in_a_multipart_with_none_preamblew  s    


z>TestMultipart.test_seq_parts_in_a_multipart_with_none_preamblec                 C   s\   | j }tddƒ}d|d< d|d< d|d< d |_td	ƒ}| |¡ | d
¡ || ¡ dƒ d S rS  ©r‰  r   rL  r   r`   r   rˆ   rO  r4   r4   r5   Ú0test_seq_parts_in_a_multipart_with_none_epilogue’  s    


z>TestMultipart.test_seq_parts_in_a_multipart_with_none_epiloguec                 C   s\   | j }tddƒ}d|d< d|d< d|d< d	|_td
ƒ}| |¡ | d¡ || ¡ dƒ d S )Nr1  r2  rE  rj  rF  r¬   rG  r©   r)   r€  ry   rN  rU  rO  r4   r4   r5   Ú1test_seq_parts_in_a_multipart_with_empty_epilogue­  s    


z?TestMultipart.test_seq_parts_in_a_multipart_with_empty_epiloguec                 C   s\   | j }tddƒ}d|d< d|d< d|d< d	|_td
ƒ}| |¡ | d¡ || ¡ dƒ d S )Nr1  r2  rE  rj  rF  r¬   rG  r©   r(   r€  ry   a  Content-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--

rU  rO  r4   r4   r5   Ú.test_seq_parts_in_a_multipart_with_nl_epilogueÈ  s    


z<TestMultipart.test_seq_parts_in_a_multipart_with_nl_epiloguec                 C   s–   | j }|  d¡}|t| ¡ ƒdƒ | d¡}|| ¡ dƒ |t| ¡ ƒdƒ | ¡ D ]<}|| ¡ dƒ |t| ¡ ƒdƒ | d¡}|| ¡ dƒ qTd S )Nú
msg_36.txtr›   rr   zmultipart/alternativezmessage/external-bodyr   r9   )r-   r.   ru  rQ   rB   )r1   r2   r3   Úmsg1ru   Ú
subsubpartr4   r4   r5   Útest_message_external_bodyã  s    


z(TestMultipart.test_message_external_bodyc                 C   s"   |   d¡}|  t| ¡ ƒd¡ d S )Nz
msg_37.txtrœ   )r.   r-   ru  rQ   r\   r4   r4   r5   Útest_double_boundaryð  s    
z"TestMultipart.test_double_boundaryc                 C   s4   | j }|  d¡}tƒ }t ||¡ || ¡ dƒ d S )Nz
msg_38.txtzŠmultipart/mixed
    multipart/mixed
        multipart/alternative
            text/plain
        text/plain
    text/plain
    text/plain
©r‰  r.   r   r   Z
_structurerŽ   ©r1   r2   r3   r‹  r4   r4   r5   Ú)test_nested_inner_contains_outer_boundary÷  s
    
z7TestMultipart.test_nested_inner_contains_outer_boundaryc                 C   s4   | j }|  d¡}tƒ }t ||¡ || ¡ dƒ d S )Nz
msg_39.txtz“multipart/mixed
    multipart/mixed
        multipart/alternative
        application/octet-stream
        application/octet-stream
    text/plain
r^  r_  r4   r4   r5   Útest_nested_with_same_boundary
  s
    
z,TestMultipart.test_nested_with_same_boundaryc                 C   s   |   d¡}|  | ¡ d¡ d S )Nz
msg_40.txtzÅMIME-Version: 1.0
Content-Type: text/html; boundary="--961284236552522269"

----961284236552522269
Content-Type: text/html;
Content-Transfer-Encoding: 7Bit

<html></html>

----961284236552522269--
)r.   r-   rˆ   r\   r4   r4   r5   Útest_boundary_in_non_multipart  s    
z,TestMultipart.test_boundary_in_non_multipartc                 C   sB   | j }t d¡}|  | ¡ ¡ || ¡ dƒ |t| ¡ ƒdƒ d S )NzžMIME-Version: 1.0
Content-Type: multipart/mixed; boundary="    XXXX"

--    XXXX
Content-Type: text/plain


--    XXXX
Content-Type: text/plain

--    XXXX--
z    XXXXr›   )r-   r—   rÔ   r³   r#  rz   ru  rQ   r0   r4   r4   r5   Ú test_boundary_with_leading_space*  s
    
z.TestMultipart.test_boundary_with_leading_spacec                 C   s&   t ƒ  d¡}|  | d¡ ¡ d¡ d S )NzòContent-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==--r   zYXNkZg==)r   rŒ   r-   rQ   rl  r4   r4   r5   Ú&test_boundary_without_trailing_newline=  s    z4TestMultipart.test_boundary_without_trailing_newlinec                 C   s    t ddƒ}|  |jtjj¡ d S )Nr1  r2  )r   r  r¿   r—   Úcompat32rl  r4   r4   r5   Útest_mimebase_default_policyK  s    
z*TestMultipart.test_mimebase_default_policyc                 C   s(   t ddtjjd}|  |jtjj¡ d S )Nr1  r2  r¾   )r   r—   r¿   Údefaultr  rl  r4   r4   r5   Útest_mimebase_custom_policyO  s    z)TestMultipart.test_mimebase_custom_policyN)ro  rp  rq  rë  rC  rD  rJ  rM  rP  rR  rT  rV  rW  rX  r\  r]  r`  ra  rb  rc  rd  rf  rh  r4   r4   r4   r5   r0  Ó  s(   $r0  c                   @   s~   e Zd Zdd„ Zdd„ Zdd„ Ze d¡Zdd	„ Z	d
d„ Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ ZdS )ÚTestNonConformantc                 C   s>   | j }|  d¡}|| ¡ dƒ || ¡ dƒ || ¡ dƒ d S )Nz
msg_14.txtr9   r¥   r*  )r-   r.   rB   r   r,  r0   r4   r4   r5   Útest_parse_missing_minor_typeV  s
    
z/TestNonConformant.test_parse_missing_minor_typec                 C   sN   |   d¡}| d¡}|  t|dƒ¡ |  t|jƒd¡ |  |jd tj	¡ d S )Nú
msg_15.txtr   rK  rr   )
r.   rQ   r³   Úhasattrr-   ru  rK  rJ  r   ÚStartBoundaryNotFoundDefect)r1   r3   Úinnerr4   r4   r5   Útest_same_boundary_inner_outer^  s    

ÿz0TestNonConformant.test_same_boundary_inner_outerc                 C   sX   |   d¡}|  | ¡ t¡ |  t|jƒd¡ |  |jd tj¡ |  |jd tj	¡ d S )Nz
msg_25.txtr›   r   rr   )
r.   rJ  rQ   r±   r-   ru  rK  r   ÚNoBoundaryInMultipartDefectÚ!MultipartInvariantViolationDefectr\   r4   r4   r5   Útest_multipart_no_boundaryh  s    
ÿÿ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==--
        c                 C   s<   |   | j d¡¡}|  t|jƒd¡ |  |jd tj¡ d S )Nz"
Content-Transfer-Encoding: base64rr   r   )	Ú_str_msgÚmultipart_msgrb  r-   ru  rK  rJ  r   Z-InvalidMultipartContentTransferEncodingDefectr\   r4   r4   r5   Útest_multipart_invalid_cte‰  s    
ÿÿz,TestNonConformant.test_multipart_invalid_ctec                 C   s(   |   | j d¡¡}|  t|jƒd¡ d S )Nr)   r   ©rs  rt  rb  r-   ru  rK  r\   r4   r4   r5   Útest_multipart_no_cte_no_defect‘  s    z1TestNonConformant.test_multipart_no_cte_no_defectc                 C   s8   dD ].}|   | j d |¡¡¡}|  t|jƒd¡ qd S )N)r~  rV   ZBINaryz
Content-Transfer-Encoding: {}r   rv  )r1   r¢   r3   r4   r4   r5   Ú"test_multipart_valid_cte_no_defect–  s    ÿÿz4TestNonConformant.test_multipart_valid_cte_no_defectc                 C   s¦   | j }| j}tƒ }d|d< || ¡ dƒ || ¡ dƒ || ¡ dƒ |d= d|d< || ¡ dƒ || ¡ dƒ || ¡ dƒ tƒ }t|ƒ}| |¡ || 	¡ dƒ d S )Nr¥   r>   r*  r9   r:   r¡   zContent-Type: foo

)
r-   r‰  r   r   r,  rB   r   r   r   rŽ   )r1   r2   Úneqr3   r¦   r§   r4   r4   r5   Útest_invalid_content_typež  s     
z+TestNonConformant.test_invalid_content_typec                 C   s"   | j }|  d¡}|| ¡ dƒ d S )Nú
msg_31.txtzm--BOUNDARY
Content-Type: text/plain

message 1

--BOUNDARY
Content-Type: text/plain

message 2

--BOUNDARY--
)r‰  r.   rQ   r0   r4   r4   r5   Útest_no_start_boundary³  s    
z(TestNonConformant.test_no_start_boundaryc                 C   s"   | j }|  d¡}|| ¡ dƒ d S )Nz
msg_35.txtz‰From: aperson@dom.ain
To: bperson@dom.ain
Subject: here's something interesting

counter to RFC 2822, there's no separating newline here
)r‰  r.   rˆ   r0   r4   r4   r5   Útest_no_separating_blank_lineÄ  s    
z/TestNonConformant.test_no_separating_blank_linec                 C   sX   |   d¡}|  t|dƒ¡ |  t|jƒd¡ |  |jd tj¡ |  |jd tj	¡ d S )Nz
msg_41.txtrK  r›   r   rr   )
r.   r³   rl  r-   ru  rK  rJ  r   rp  rq  r\   r4   r4   r5   Útest_lying_multipartÐ  s    
ÿÿz&TestNonConformant.test_lying_multipartc                 C   sD   |   d¡}| d¡ d¡}|  t|jƒd¡ |  |jd tj¡ d S )Nz
msg_42.txtrr   r   )r.   rQ   r-   ru  rK  rJ  r   rm  )r1   rI  Zbadr4   r4   r5   Útest_missing_start_boundaryÚ  s    
	ÿz-TestNonConformant.test_missing_start_boundaryc                 C   sj   | j }d}t |¡}|| ¡ dgƒ || ¡ dƒ |t|jƒdƒ |  |jtj	g¡ ||jd j
dƒ d S )Nz Line 1
Subject: test

bodyrj  Úbodyrr   r   z Line 1
)r-   r—   rÔ   rB  rQ   ru  rK  ÚassertDefectsEqualr   Z#FirstHeaderLineIsContinuationDefectÚlinerã  r4   r4   r5   Ú&test_first_line_is_continuation_headerê  s    
ÿz8TestNonConformant.test_first_line_is_continuation_headerc                 C   sB   |   d¡}|  | ¡ dg¡ |  | ¡ d¡ |  |jtjg¡ d S )Nz&Subject: test
not a header
To: abc

b
rj  znot a header
To: abc

b
)rs  r-   rB  rQ   r  rK  r   Z MissingHeaderBodySeparatorDefectr\   r4   r4   r5   Ú"test_missing_header_body_separatorö  s    
ÿz4TestNonConformant.test_missing_header_body_separatorN)ro  rp  rq  rj  ro  rr  rÃ   rÄ   rt  ru  rw  rx  rz  r|  r}  r~  r  rƒ  r„  r4   r4   r4   r5   ri  T  s   
	

ri  c                   @   sŒ   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ Zdd„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd „ Zd!S )"ÚTestRFC2047c                 C   sN   | j }d}t|ƒ}||g d¢ƒ t|ƒ}|t|ƒdƒ |  |jddd¡ d S )NzVRe: =?mac-iceland?q?r=8Aksm=9Arg=8Cs?= baz
 foo bar =?mac-iceland?q?r=8Aksm=9Arg=8Cs?=))s   Re: N©s
   rŠksmšrgŒszmac-iceland)s    baz foo bar Nr†  u+   Re: rÃ¤ksmÃ¶rgÃ¥s baz foo bar rÃ¤ksmÃ¶rgÃ¥srw  r˜  ziRe: =?mac-iceland?q?r=8Aksm=9Arg=8Cs?= baz foo bar =?mac-iceland?q?r=8Aksm?=
 =?mac-iceland?q?=9Arg=8Cs?=)r-   r   r   r±   r‰  r–   ©r1   r2   r¦   Údhr„   r4   r4   r5   Útest_rfc2047_multiline	  s    ÿz"TestRFC2047.test_rfc2047_multilinec                 C   s:   | j }d}t|ƒ}||ddgƒ tt|ƒƒ}||dƒ d S )Nz0=?ISO-8859-1?Q?Andr=E9?= Pirard <pirard@dom.ain>)s   Andrér7   )s    Pirard <pirard@dom.ain>Nu   AndrÃ© Pirard <pirard@dom.ain>©r-   r   r±   r   r‡  r4   r4   r5   Útest_whitespace_keeper_unicode	  s    ÿz*TestRFC2047.test_whitespace_keeper_unicodec                 C   s:   | j }d}t|ƒ}||g d¢ƒ tt|ƒƒ}||dƒ d S )NzWThe =?iso-8859-1?b?cXVpY2sgYnJvd24gZm94?= jumped over the =?iso-8859-1?b?bGF6eSBkb2c=?=))s   The N)s   quick brown foxr7   )s    jumped over the N)s   lazy dogr7   z,The quick brown fox jumped over the lazy dogrŠ  )r1   r2   r¦   rˆ  Úhur4   r4   r5   Ú test_whitespace_keeper_unicode_2	  s    z,TestRFC2047.test_whitespace_keeper_unicode_2c                 C   s    d}t |ƒ}|  |g d¢¡ d S )Nz3Sm=?ISO-8859-1?B?9g==?=rg=?ISO-8859-1?B?5Q==?=sbord))s   SmN©ó   ör7   )s   rgN©ó   år7   )s   sbordN©r   r-   ©r1   r¦   rˆ  r4   r4   r5   Útest_rfc2047_missing_whitespace'	  s    z+TestRFC2047.test_rfc2047_missing_whitespacec                 C   s    d}t |ƒ}|  |g d¢¡ d S )Nz7Sm =?ISO-8859-1?B?9g==?= rg =?ISO-8859-1?B?5Q==?= sbord))s   Sm NrŽ  )s    rg Nr  )s    sbordNr’  r“  r4   r4   r5   Útest_rfc2047_with_whitespace.	  s    z(TestRFC2047.test_rfc2047_with_whitespacec                 C   s<   d}g d¢}|D ]&\}}t || ƒ}|  ||dfg¡ qd S )Nz=?iso-8859-1?B?%s?=))zdm==ó   v)zdm=r–  )Zdmr–  )zdmk=ó   vi)Zdmkr—  r7   r’  )r1   r¦   rS   ÚqÚarˆ  r4   r4   r5   Útest_rfc2047_B_bad_padding5	  s
    z&TestRFC2047.test_rfc2047_B_bad_paddingc                 C   s   d}|   t|ƒdg¡ d S )Nz=?iso-8859-1?Q?andr=e9=zz?=)s   andré=zzr7   ©r-   r   ©r1   r¦   r4   r4   r5   Útest_rfc2047_Q_invalid_digits?	  s    
ÿz)TestRFC2047.test_rfc2047_Q_invalid_digitsc                 C   s   d}|   t|ƒg d¢¡ d S )Nz(=?ISO-8859-1?Q?a?=))©ó   (N©ó   ar7   ©ó   )Nr›  rœ  r4   r4   r5   Útest_rfc2047_rfc2047_1E	  s    
ÿz"TestRFC2047.test_rfc2047_rfc2047_1c                 C   s   d}|   t|ƒg d¢¡ d S )Nz(=?ISO-8859-1?Q?a?= b))rž  r   )s    b)Nr›  rœ  r4   r4   r5   Útest_rfc2047_rfc2047_2K	  s    
ÿz"TestRFC2047.test_rfc2047_rfc2047_2c                 C   s   d}|   t|ƒg d¢¡ d S )Nz'(=?ISO-8859-1?Q?a?= =?ISO-8859-1?Q?b?=)©rž  )s   abr7   r¢  r›  rœ  r4   r4   r5   Útest_rfc2047_rfc2047_3Q	  s    
ÿz"TestRFC2047.test_rfc2047_rfc2047_3c                 C   s   d}|   t|ƒg d¢¡ d S )Nz((=?ISO-8859-1?Q?a?=  =?ISO-8859-1?Q?b?=)r¦  r›  rœ  r4   r4   r5   Útest_rfc2047_rfc2047_4W	  s    
ÿz"TestRFC2047.test_rfc2047_rfc2047_4c                 C   s   d}|   t|ƒg d¢¡ d S )Nz,(=?ISO-8859-1?Q?a?=
    =?ISO-8859-1?Q?b?=)r¦  r›  rœ  r4   r4   r5   Útest_rfc2047_rfc2047_5a]	  s    
ÿz#TestRFC2047.test_rfc2047_rfc2047_5ac                 C   s   d}|   t|ƒg d¢¡ d S )Nz+(=?ISO-8859-1?Q?a?=
    =?ISO-8859-1?Q?b?=)r¦  r›  rœ  r4   r4   r5   Útest_rfc2047_rfc2047_5bc	  s    
ÿz#TestRFC2047.test_rfc2047_rfc2047_5bc                 C   s   d}|   t|ƒg d¢¡ d S )Nz(=?ISO-8859-1?Q?a_b?=))rž  )s   a br7   r¢  r›  rœ  r4   r4   r5   Útest_rfc2047_rfc2047_6i	  s    
ÿz"TestRFC2047.test_rfc2047_rfc2047_6c                 C   sP   d}|   t|ƒg d¢¡ |   tt|ƒƒ ¡ | ¡ ¡ |   ttt|ƒƒƒd¡ d S )Nz((=?ISO-8859-1?Q?a?= =?ISO-8859-2?Q?_b?=))rž  r   )s    brb   r¢  z(a b))r-   r   r   r–   r   r±   rœ  r4   r4   r5   Útest_rfc2047_rfc2047_7o	  s    
ÿz"TestRFC2047.test_rfc2047_rfc2047_7c                 C   sV   d}|   t|ƒddg¡ |   tt|ƒƒ ¡ d | ¡ ¡¡ |   ttt|ƒƒƒd¡ d S )Nz9=?windows-1252?q?=22M=FCller_T=22?=
 <T.Mueller@xxx.com>)s
   "Müller T"zwindows-1252)s   <T.Mueller@xxx.com>Nr)   u   "MÃ¼ller T" <T.Mueller@xxx.com>)r-   r   r   r–   r¶   Ú
splitlinesr±   rœ  r4   r4   r5   Útest_multiline_headerx	  s    
ÿÿÿÿz!TestRFC2047.test_multiline_headerN)ro  rp  rq  r‰  r‹  r  r”  r•  rš  r  r¤  r¥  r§  r¨  r©  rª  r«  r¬  r®  r4   r4   r4   r5   r…  	  s    		
	r…  c                   @   sŒ   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ Zdd„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd „ Zd!S )"ÚTestMIMEMessagec                 C   s6   t dƒ}| ¡ | _W d   ƒ n1 s(0    Y  d S )Nú
msg_11.txt)r$   r‹   Z_textrù  r4   r4   r5   rë  …	  s    
zTestMIMEMessage.setUpc                 C   s   |   ttd¡ d S )Nza plain string)r‚   r_   r   rê  r4   r4   r5   Útest_type_error‰	  s    zTestMIMEMessage.test_type_errorc                 C   sv   | j }d}tƒ }||d< t|ƒ}|| ¡ dƒ | ¡ }|  |t¡ |t|ƒdƒ |d }|  ||¡ ||d |ƒ d S )NzA sub-messagerj  r  rr   r   Úsubject)	r-   r   r   rB   rQ   rJ  Úlistru  r  )r1   r2   r²  rÇ   Úrrþ  ru   r4   r4   r5   Útest_valid_argumentŒ	  s    z#TestMIMEMessage.test_valid_argumentc                 C   s:   t ƒ }d|d< t ƒ }d|d< t|ƒ}|  tj|j|¡ d S )Nú	subpart 1rj  z	subpart 2)r   r   r‚   r   ÚMultipartConversionErrorr`   )r1   rZ  r  r´  r4   r4   r5   Útest_bad_multipartš	  s    z"TestMIMEMessage.test_bad_multipartc                 C   sT   t ƒ }d|d< | d¡ t|ƒ}d|d< tƒ }t|ƒ}| |¡ |  | ¡ d¡ d S )NúAn enclosed messagerj  ú!Here is the body of the message.
zThe enclosing messagezŽContent-Type: message/rfc822
MIME-Version: 1.0
Subject: The enclosing message

Subject: An enclosed message

Here is the body of the message.
)r   rJ   r   r   r   r   r-   rŽ   )r1   rÇ   r´  r¦   r§   r4   r4   r5   Útest_generate¢	  s    

zTestMIMEMessage.test_generatec                 C   st   | j }|  d¡}|| ¡ dƒ | ¡ }|  |t¡ |t|ƒdƒ |d }|  |t¡ ||d dƒ || ¡ dƒ d S )Nr°  r  rr   r   r²  r¹  rº  )r-   r.   rB   rQ   rJ  r³  ru  r   )r1   r2   r3   rþ  Zsubmsgr4   r4   r5   Útest_parse_message_rfc822¶	  s    
z)TestMIMEMessage.test_parse_message_rfc822c                 C   s–  | j }|  d¡}|| ¡ dƒ |  | ¡ ¡ |t| ¡ ƒdƒ | d¡}|| ¡ dƒ || ¡ dƒ | d¡}|| ¡ dƒ |t| ¡ ƒd	ƒ | d¡}|  |t¡ ||d
 dƒ ||j	ddddƒ ||j	dddd ƒ | d¡}|  |t¡ ||d dƒ ||j
ddddgƒ ||j	ddddƒ | d	¡}|| ¡ dƒ | ¡ }|  |t¡ |t|ƒdƒ |d }|  |t¡ || ¡ dƒ ||d dƒ d S )Nú
msg_16.txtrú   rœ   r   r9   a¶  This 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" <henryi@oxy.edu>
  To: SoCal Raves <scr@socal-raves.org>
  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

rr   zmessage/delivery-statusr›   zoriginal-envelope-idz"0GK500B4HD0888@cougar.noc.ucla.eduZdnszreporting-mtarÞ   r)   ZnsdÚactionZfailedzoriginal-recipient)r.  r)   )zjangel1@cougar.noc.ucla.edur)   r.  zfinal-recipientr  ú
message-idz(<002001c144a6$8752e060$56104586@oxy.edu>)r-   r.   rB   r³   r#  ru  rQ   rJ  r   rC   rä   r³  )r1   r2   r3   ru   Zdsn1Zdsn2rþ  r[  r4   r4   r5   Útest_dsnÂ	  sD    




ÿ
ÿzTestMIMEMessage.test_dsnc           	      C   s¾   | j }tdƒ}| ¡ }W d   ƒ n1 s,0    Y  tƒ }d|d< d|d< d|d< d|_d	|_td
ƒ}tdƒ}|jdddd | |¡ | |¡ t	ƒ }t
|ƒ}| |¡ || ¡ |ƒ d S )Nú
msg_21.txtrF  r©   rG  r¬   r¸  rj  úMIME messagezEnd of MIME message
r:  r<  r>   r^   ry   r3  )r‰  r$   r‹   r   rK  rL  r   r  r`   r   r   r   rŽ   )	r1   r2   r   r¥   r3   rZ  r  r‹  r§   r4   r4   r5   Útest_epilogueû	  s$    
&


zTestMIMEMessage.test_epiloguec                 C   sv   | j }tƒ }d|d< d|d< d|d< d|_d|_td	ƒ}td
ƒ}|jdddd | |¡ | |¡ || ¡ dƒ d S )NrF  r©   rG  r¬   r¸  rj  rÂ  r)   r:  r<  r>   r^   ry   r3  ad  From: 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--
)r‰  r   rK  rL  r   r  r`   rˆ   )r1   r2   r3   rZ  r  r4   r4   r5   Útest_no_nl_preamble
  s    

z#TestMIMEMessage.test_no_nl_preamblec                 C   sÔ   | j }tdƒ}t |¡}W d   ƒ n1 s.0    Y  | d¡}|| ¡ dƒ || ¡ dƒ | d¡}|| ¡ dƒ || ¡ dƒ | d¡}|| ¡ dƒ || ¡ dƒ | d¡}|| ¡ dƒ || ¡ dƒ d S )Nr  r   r  rr   r9   ©r-   r$   r—   Úmessage_from_filerQ   Úget_default_typerB   ©r1   r2   r   r3   Z
container1Z
container2Zcontainer1aZcontainer2ar4   r4   r5   Útest_default_type2
  s    
(



z!TestMIMEMessage.test_default_typec                 C   sÔ   | j }tdƒ}t |¡}W d   ƒ n1 s.0    Y  | d¡}|| ¡ dƒ || ¡ dƒ | d¡}|| ¡ dƒ || ¡ dƒ | d¡}|| ¡ dƒ || ¡ dƒ | d¡}|| ¡ dƒ || ¡ dƒ d S )Nr  r   r  rr   r9   rÅ  rÈ  r4   r4   r5   Ú.test_default_type_with_explicit_container_typeC
  s    
(



z>TestMIMEMessage.test_default_type_with_explicit_container_typec                 C   sü   | j }| j}tddƒ}d|_tdƒ}tdƒ}t|ƒ}t|ƒ}| |¡ | |¡ || ¡ dƒ || ¡ dƒ || ¡ dƒ || ¡ dƒ || 	d¡dƒ |d	= |d
= |d	= |d
= || ¡ dƒ || ¡ dƒ || ¡ dƒ || ¡ dƒ || 	d¡dƒ d S )NÚdigestry   r)   ú
message 1
ú
message 2
r  r   a   Content-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:   r8   aB  Content-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-   r‰  r   rL  r   r   r`   rB   rÇ  rˆ   )r1   r2   ry  r>  Z	subpart1aZ	subpart2aZsubpart1Zsubpart2r4   r4   r5   Útest_default_type_non_parsedT
  s0    


z,TestMIMEMessage.test_default_type_non_parsedc                 C   sZ   | j }tdƒ}tdƒ}t||fd}|t| ¡ ƒdƒ || d¡|ƒ || d¡|ƒ d S )Nr)   )Z	_subpartsr›   r   rr   )r-   r   r   ru  rQ   )r1   r2   Ztext1Ztext2r3   r4   r4   r5   Ú$test_mime_attachments_in_constructorž
  s    z4TestMIMEMessage.test_mime_attachments_in_constructorc                 C   s   t ƒ }|  | ¡ ¡ d S rZ   )r   r³   r#  r\   r4   r4   r5   Ú"test_default_multipart_constructor§
  s    z2TestMIMEMessage.test_default_multipart_constructorc                 C   s0   t ƒ }d|d< d|d< |  | d¡ddg¡ d S )Núa@b.comr¬   úc@d.comrª   )r   r-   r/   r\   r4   r4   r5   Útest_multipart_default_policy«
  s    z-TestMIMEMessage.test_multipart_default_policyc                 C   s^   t tjjd}d|d< |  t¡}d|d< W d   ƒ n1 s>0    Y  |  t|jƒd¡ d S )Nr¾   rÑ  r¬   rÒ  z.There may be at most 1 To headers in a message)	r   r—   r¿   rg  r‚   r  r-   r±   Ú	exception)r1   r3   Úcmr4   r4   r5   Útest_multipart_custom_policy±
  s    &ÿz,TestMIMEMessage.test_multipart_custom_policyN)ro  rp  rq  rë  r±  rµ  r¸  r»  r¼  rÀ  rÃ  rÄ  rÉ  rÊ  rÎ  rÏ  rÐ  rÓ  rÖ  r4   r4   r4   r5   r¯  „	  s    9#J	r¯  c                   @   s   e Zd Zdd„ Zdd„ ZdS )ÚTestNonMultipartc                 C   s   t ddƒ}|  | ¡ ¡ d S )Nr¥   r*  )r   r"  r#  r\   r4   r4   r5   Ú"test_nonmultipart_is_not_multipart¼
  s    
z3TestNonMultipart.test_nonmultipart_is_not_multipartc                 C   s.   t ƒ }d|d< tddƒ}|  tj|j|¡ d S )Nr¶  rj  r¥   r*  )r   r   r‚   r   r·  r`   )r1   r3   r´  r4   r4   r5   Útest_attach_raises_exceptionÀ
  s    
z-TestNonMultipart.test_attach_raises_exceptionN)ro  rp  rq  rØ  rÙ  r4   r4   r4   r5   r×  »
  s   r×  c                   @   sÒ   e Zd ZdZdd„ Zd4dd„Zdd„ Zd	d
„ Zdd„ Zdd„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd „ Zd!d"„ Zd#d$„ Zd%d&„ Zd'd(„ Zd)d*„ Zd+d,„ Zd-d.„ Zd/d0„ Zd1d2„ Zd3S )5ÚTestIdempotentr(   c                 C   sB   t |ƒ}| ¡ }W d   ƒ n1 s&0    Y  t |¡}||fS rZ   ©r$   r‹   r—   rÔ   ©r1   r  r   rS   r3   r4   r4   r5   r.   Ð
  s    
&
zTestIdempotent._msgobjFc                 C   s8   | j }tƒ }t|dd}|j||d ||| ¡ ƒ d S )Nr   rÐ  r¯   )r‰  r   r   r   rŽ   )r1   r3   r¥   r°   r2   r¦   r§   r4   r4   r5   Ú_idempotentÖ
  s
    zTestIdempotent._idempotentc                 C   sˆ   | j }|  d¡\}}|| ¡ dƒ || ¡ dƒ || ¡ dƒ || ¡ d dƒ || d¡dƒ ||jd ƒ ||jd ƒ |  	||¡ d S )	Nr|   r9   r¥   r*  rr   )r;   rG   r;   rG   )
r-   r.   rB   r   r,  rä   rC   rK  rL  rÝ  ©r1   r2   r3   r¥   r4   r4   r5   Útest_parse_text_messageÝ
  s    z&TestIdempotent.test_parse_text_messagec                 C   sP   | j }|  d¡\}}|| ¡ dƒ || ¡ d ƒ || d¡d ƒ |  ||¡ d S )Nr~   r9   r;   )r-   r.   rB   rä   rC   rÝ  rÞ  r4   r4   r5   Útest_parse_untyped_messageé
  s    z)TestIdempotent.test_parse_untyped_messagec                 C   s   |   d¡\}}|  ||¡ d S )Nrh   ©r.   rÝ  ©r1   r3   r¥   r4   r4   r5   Útest_simple_multipartñ
  s    z$TestIdempotent.test_simple_multipartc                 C   s   |   d¡\}}|  ||¡ d S )Nú
msg_02.txtrá  râ  r4   r4   r5   Útest_MIME_digestõ
  s    zTestIdempotent.test_MIME_digestc                 C   s   |   d¡\}}|  ||¡ d S )Nz
msg_27.txtrá  râ  r4   r4   r5   Útest_long_headerù
  s    zTestIdempotent.test_long_headerc                 C   s   |   d¡\}}|  ||¡ d S )Nr  rá  râ  r4   r4   r5   Ú"test_MIME_digest_with_part_headersý
  s    z1TestIdempotent.test_MIME_digest_with_part_headersc                 C   s   |   d¡\}}|  ||¡ d S )Nú
msg_06.txtrá  râ  r4   r4   r5   Útest_mixed_with_image  s    z$TestIdempotent.test_mixed_with_imagec                 C   s   |   d¡\}}|  ||¡ d S )Nrø   rá  râ  r4   r4   r5   Útest_multipart_report  s    z$TestIdempotent.test_multipart_reportc                 C   s   |   d¡\}}|  ||¡ d S )Nr½  rá  râ  r4   r4   r5   rÀ  	  s    zTestIdempotent.test_dsnc                 C   s   |   d¡\}}|  ||¡ d S )NrÁ  rá  râ  r4   r4   r5   Útest_preamble_epilogue  s    z%TestIdempotent.test_preamble_epiloguec                 C   s   |   d¡\}}|  ||¡ d S )Nz
msg_23.txtrá  râ  r4   r4   r5   Útest_multipart_one_part  s    z&TestIdempotent.test_multipart_one_partc                 C   s   |   d¡\}}|  ||¡ d S )Nz
msg_24.txtrá  râ  r4   r4   r5   Útest_multipart_no_parts  s    z&TestIdempotent.test_multipart_no_partsc                 C   s   |   d¡\}}|  ||¡ d S )Nr{  rá  râ  r4   r4   r5   r|    s    z%TestIdempotent.test_no_start_boundaryc                 C   s   |   d¡\}}|  ||¡ d S )Nú
msg_32.txtrá  râ  r4   r4   r5   Útest_rfc2231_charset  s    z#TestIdempotent.test_rfc2231_charsetc                 C   s   |   d¡\}}|  ||¡ d S )Nz
msg_33.txtrá  râ  r4   r4   r5   Útest_more_rfc2231_parameters!  s    z+TestIdempotent.test_more_rfc2231_parametersc                 C   s   |   d¡\}}|  ||¡ d S )Nz
msg_34.txtrá  râ  r4   r4   r5   Ú%test_text_plain_in_a_multipart_digest%  s    z4TestIdempotent.test_text_plain_in_a_multipart_digestc                 C   s   |   d¡\}}|  ||¡ d S )Nzmsg_12a.txtrá  râ  r4   r4   r5   Útest_nested_multipart_mixeds)  s    z+TestIdempotent.test_nested_multipart_mixedsc                 C   s   |   d¡\}}|  ||¡ d S )NrY  rá  râ  r4   r4   r5   Ú%test_message_external_body_idempotent-  s    z4TestIdempotent.test_message_external_body_idempotentc                 C   s"   |   d¡\}}| j||dd d S )Nú
msg_43.txtTr¯   rá  râ  r4   r4   r5   Útest_message_delivery_status1  s    z+TestIdempotent.test_message_delivery_statusc                 C   s   |   d¡\}}|  ||¡ d S ©Nú
msg_45.txtrá  râ  r4   r4   r5   Útest_message_signed_idempotent5  s    z-TestIdempotent.test_message_signed_idempotentc                 C   sX  | j }|  d¡\}}|| ¡ dƒ i }| ¡ D ]\}}|||< q.||d dƒ ||d dƒ ||jd| j ƒ ||j| jƒ |t| ¡ ƒdƒ | d	¡}|| ¡ d
ƒ || ¡ d| j ƒ | d¡}|| ¡ d
ƒ || ¡ d| j ƒ | d¡}	||	 ¡ dƒ |  	|	t
¡ |	 ¡ }
|  	|
t¡ |t|
ƒdƒ |
d	 }|  	|t
¡ || ¡ d| j ƒ d S )Nrø   rú   rû   rü   ræ   rþ   z$This is a MIME-encapsulated message.rœ   r   r9   zYadda yadda yaddarr   r›   r  )r-   r.   rB   rä   rK  r½   rL  ru  rQ   rJ  r   r³  )r1   r2   r3   r¥   ÚparamsZpkZpvrZ  r  Zmsg3rþ  Zmsg4r4   r4   r5   Útest_content_type9  s4    



z TestIdempotent.test_content_typec                 C   sŠ   | j }|  d¡\}}|| ¡ dƒ | ¡ }|  |t¡ |t|ƒdƒ |d }|  |t¡ || ¡ dƒ |  | ¡ t¡ || ¡ | j	ƒ d S )Nrè  r  rr   r   r9   )
r-   r.   rB   rQ   rJ  r³  ru  r   r±   r½   )r1   r2   r3   r¥   rþ  rZ  r4   r4   r5   Útest_parserX  s    zTestIdempotent.test_parserN)F)ro  rp  rq  r½   r.   rÝ  rß  rà  rã  rå  ræ  rç  ré  rê  rÀ  rë  rì  rí  r|  rï  rð  rñ  rò  ró  rõ  rø  rú  rû  r4   r4   r4   r5   rÚ  Ì
  s2   
rÚ  c                   @   s¬  e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ Zdd„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd „ Zd!d"„ Zd#d$„ Zd%d&„ Zd'd(„ Zd)d*„ Zd+d,„ Zd-d.„ Zd/d0„ Zd1d2„ Zd3d4„ Zd5d6„ Zd7d8„ Zd9d:„ Zd;d<„ Z d=d>„ Z!d?d@„ Z"dAdB„ Z#dCdD„ Z$dEdF„ Z%dGdH„ Z&dIdJ„ Z'dKdL„ Z(dMdN„ Z)dOdP„ Z*dQdR„ Z+dSdT„ Z,dUdV„ Z-dWdX„ Z.dYdZ„ Z/d[d\„ Z0d]d^„ Z1d_d`„ Z2dadb„ Z3dcdd„ Z4dedf„ Z5dgdh„ Z6diS )jÚTestMiscellaneousc                 C   sj   t dƒ}| ¡ }W d   ƒ n1 s&0    Y  t |¡}tƒ }t|dd}| |¡ |  || ¡ ¡ d S ©Nr|   r   rÐ  ©	r$   r‹   r—   rÔ   r   r   r   r-   rŽ   ©r1   r   r¥   r3   r¦   r§   r4   r4   r5   Útest_message_from_stringl  s    
&

z*TestMiscellaneous.test_message_from_stringc                 C   st   t dƒX}| ¡ }| d¡ t |¡}tƒ }t|dd}| |¡ |  || 	¡ ¡ W d   ƒ n1 sf0    Y  d S rý  )
r$   r‹   Úseekr—   rÆ  r   r   r   r-   rŽ   rÿ  r4   r4   r5   Útest_message_from_filew  s    



z(TestMiscellaneous.test_message_from_filec                 C   s²   t dƒ}| ¡ }W d   ƒ n1 s&0    Y  G dd„ dtƒ}t ||¡}|  ||¡ t dƒ}| ¡ }W d   ƒ n1 s~0    Y  t ||¡}| ¡ D ]}|  ||¡ qœd S )Nr|   c                   @   s   e Zd ZdS )zHTestMiscellaneous.test_message_from_string_with_class.<locals>.MyMessageN©ro  rp  rq  r4   r4   r4   r5   Ú	MyMessageˆ  s   r  rä  )r$   r‹   r   r—   rÔ   rJ  Úwalk)r1   r   r¥   r  r3   ru   r4   r4   r5   Ú#test_message_from_string_with_classƒ  s    
&
&z5TestMiscellaneous.test_message_from_string_with_classc                 C   s¢   G dd„ dt ƒ}tdƒ}t ||¡}W d   ƒ n1 s:0    Y  |  ||¡ tdƒ}t ||¡}W d   ƒ n1 sz0    Y  | ¡ D ]}|  ||¡ qŒd S )Nc                   @   s   e Zd ZdS )zFTestMiscellaneous.test_message_from_file_with_class.<locals>.MyMessageNr  r4   r4   r4   r5   r  –  s   r  r|   rä  )r   r$   r—   rÆ  rJ  r  )r1   r  r   r3   ru   r4   r4   r5   Ú!test_message_from_file_with_class”  s    
*
*z3TestMiscellaneous.test_message_from_file_with_classc                 C   s,   G dd„ dt ƒ}|  d|¡}|  ||¡ d S )Nc                       s   e Zd Z‡ fdd„Z‡  ZS )zSTestMiscellaneous.test_custom_message_does_not_require_arguments.<locals>.MyMessagec                    s   t ƒ  ¡  d S rZ   )ÚsuperÚ__init__rê  ©Ú	__class__r4   r5   r	  ¤  s    z\TestMiscellaneous.test_custom_message_does_not_require_arguments.<locals>.MyMessage.__init__)ro  rp  rq  r	  Ú__classcell__r4   r4   r
  r5   r  £  s   r  zSubject: test

test)r   rs  rJ  )r1   r  r3   r4   r4   r5   Ú.test_custom_message_does_not_require_arguments¢  s    z@TestMiscellaneous.test_custom_message_does_not_require_argumentsc                 C   s"   t dƒ}|  t|jƒg d¢¡ d S )Nr—   )r    r;   r   r   Ú
feedparserr™   r„   r   r"  Zmessage_from_binary_filerÅ   rÆ  rÔ   rx  r‘   r!   r   )Ú
__import__r-   ÚsortedÚ__all__)r1   Úmoduler4   r4   r5   Útest__all__©  s    zTestMiscellaneous.test__all__c                 C   s:   t   ¡ }|  t t |¡¡d d… t  |¡d d… ¡ d S )Né   )r8  r-   r   Ú	parsedateÚ
formatdateÚgmtime©r1   r?  r4   r4   r5   Útest_formatdate³  s    ÿz!TestMiscellaneous.test_formatdatec                 C   s>   t   ¡ }|  t tj|dd¡d d… t  |¡d d… ¡ d S )NT©r9  r  )r8  r-   r   r  r  r9  r  r4   r4   r5   Útest_formatdate_localtime¸  s
    þz+TestMiscellaneous.test_formatdate_localtimec              	   C   sV   t   ¡ }|  tj|ddt  dt  |¡¡¡ |  tj|dddt  dt  |¡¡¡ d S )NFr  z%a, %d %b %Y %H:%M:%S -0000T)r9  Zusegmtz%a, %d %b %Y %H:%M:%S GMT)r8  r-   r   r  r<  r  r  r4   r4   r5   Útest_formatdate_usegmt¾  s    þþz(TestMiscellaneous.test_formatdate_usegmtc                 C   s´   |   t d¡¡ |   t d¡¡ |   t d¡¡ |   t d¡¡ |   t d¡¡ |   t d¡¡ |   t d¡¡ |   t d¡¡ |   t d¡¡ |   t d ¡¡ |   t d ¡¡ d S )Nr)   r*   Ú0zA Complete Waste of Timez Wed, 3 Apr 2002 12.34.56.78+0800)rH  r   r  Úparsedate_tzrê  r4   r4   r5   Ú/test_parsedate_returns_None_for_invalid_stringsÈ  s    zATestMiscellaneous.test_parsedate_returns_None_for_invalid_stringsc                 C   s   |   t d¡t d¡¡ d S )NzWed,3 Apr 2002 14:58:26 +0800zWed, 3 Apr 2002 14:58:26 +0800)r-   r   r  rê  r4   r4   r5   Útest_parsedate_compactÖ  s    ÿz(TestMiscellaneous.test_parsedate_compactc                 C   s   | j }|t d¡dƒ d S )Nú25 Feb 2003 13:47:26 -0800)
éÓ  r›   é   é   é/   é   r   rr   r4  é€ÿÿ©r-   r   r  ©r1   r2   r4   r4   r5   Útest_parsedate_no_dayofweekÛ  s    
ÿz-TestMiscellaneous.test_parsedate_no_dayofweekc                 C   s   | j }|t d¡dƒ d S )Nú5 Feb 2003 13:47:26 -0800©
r"  r›   é   r$  r%  r&  r   rr   r4  r'  r(  r)  r4   r4   r5   Ú#test_parsedate_compact_no_dayofweekà  s    
ÿz5TestMiscellaneous.test_parsedate_compact_no_dayofweekc                 C   s   |   t d¡d¡ d S )NzWed, 3 Apr 2002 14:58:26+0800)
éÒ  r}   rœ   é   é:   r&  r   rr   r4  i€p  r(  rê  r4   r4   r5   Ú.test_parsedate_no_space_before_positive_offsetå  s    ÿz@TestMiscellaneous.test_parsedate_no_space_before_positive_offsetc                 C   s   |   t d¡d¡ d S )NzWed, 3 Apr 2002 14:58:26-0800)
r/  r}   rœ   r0  r1  r&  r   rr   r4  r'  r(  rê  r4   r4   r5   Ú.test_parsedate_no_space_before_negative_offseté  s    ÿz@TestMiscellaneous.test_parsedate_no_space_before_negative_offsetc                 C   s*   | j }|t d¡dƒ |t d¡dƒ d S )Nz5 Feb 2003 13.47.26 -0800r,  z5 Feb 2003 13.47 -0800)
r"  r›   r-  r$  r%  r   r   rr   r4  r'  r(  r)  r4   r4   r5   Ú%test_parsedate_accepts_time_with_dotsï  s    
ÿ
ÿz7TestMiscellaneous.test_parsedate_accepts_time_with_dotsc                 C   s¶   | j }t d¡}tt |¡ƒ}|t |¡d d… |d d… ƒ |tt d|¡ƒdƒ t d¡}tt |d d… ¡ƒ}|t |¡d d… |d d… ƒ |tt d|d d… ¡ƒdƒ d S )Nr+  r  z%Yr"  é	   )	r-   r   r  Úintr8  Úmktimer9  r<  r  )r1   r2   Ztimetuprá  r4   r4   r5   Ú+test_parsedate_acceptable_to_time_functionsö  s    
 
 z=TestMiscellaneous.test_parsedate_acceptable_to_time_functionsc                 C   s(   |   t d¡d¡ |   t d¡d¡ d S )N)
é²  rr   rr   r   r   r   r4  r4  r4  r   r   )
r9  rr   rr   r   r   r   r4  r4  r4  iÒ  i.ûÿÿ)r-   r   Z	mktime_tzrê  r4   r4   r5   Útest_mktime_tz  s    ÿÿz TestMiscellaneous.test_mktime_tzc                 C   s4   |   t d¡t d¡¡ |   t d¡t d¡¡ d S )Nz25 Feb 03 13:47:26 -0800r!  z25 Feb 71 13:47:26 -0800z25 Feb 1971 13:47:26 -0800r(  rê  r4   r4   r5   Útest_parsedate_y2k  s    ÿÿz$TestMiscellaneous.test_parsedate_y2kc                 C   s.   |   t d¡d¡ |   t t d¡¡d¡ d S )Nz<>©r)   r)   r)   ©r-   r   Ú	parseaddrÚ
formataddrrê  r4   r4   r5   Útest_parseaddr_empty  s    z&TestMiscellaneous.test_parseaddr_emptyc                 C   s:   |   t d¡d¡ |   t d¡d¡ |   t d¡d¡ d S )Nza@b@cr<  za@b.c@cza@172.17.0.1@c©r-   r   r>  rê  r4   r4   r5   Útest_parseaddr_multiple_domains  s    þþþz1TestMiscellaneous.test_parseaddr_multiple_domainsc                 C   s   |   t d¡d¡ d S )N)zA Silly Personúperson@dom.ainzA Silly Person <person@dom.ain>©r-   r   r?  rê  r4   r4   r5   Útest_noquote_dump&  s    þz#TestMiscellaneous.test_noquote_dumpc                 C   sP   |   t d¡d¡ |   t d¡d¡ d}d}|   t t ||f¡¡||f¡ d S )N)zA (Very) Silly PersonrC  z("A (Very) Silly Person" <person@dom.ain>z*"A \(Very\) Silly Person" <person@dom.ain>zA \(Special\) PersonrC  ©r-   r   r?  r>  ©r1   r™  rò  r4   r4   r5   Útest_escape_dump+  s    þþz"TestMiscellaneous.test_escape_dumpc                 C   s>   |   t d¡d¡ d}d}|   t t ||f¡¡||f¡ d S )N)úArthur \Backslash\ FoobarrC  z."Arthur \\Backslash\\ Foobar" <person@dom.ain>rI  rC  rF  rG  r4   r4   r5   Útest_escape_backslashes6  s    þz)TestMiscellaneous.test_escape_backslashesc                 C   sB   d}d}d}d}|   t ||f¡|¡ |   t ||fd¡|¡ d S )Nõ   HÃ¤ns WÃ¼rstrC  ú-=?utf-8?b?SMOkbnMgV8O8cnN0?= <person@dom.ain>z0=?iso-8859-1?q?H=E4ns_W=FCrst?= <person@dom.ain>r7   rD  )r1   rê   ÚaddrÚutf8_base64Zlatin1_quoprir4   r4   r5   Útest_quotes_unicode_names>  s    ÿz+TestMiscellaneous.test_quotes_unicode_namesc                    sl   d}d}d}d‰ G ‡ fdd„dƒ}|ƒ }dˆ |f }|   t ||f|¡|¡ |   t ||ftdƒ¡|¡ d S )	NrK  rC  rL  ZFOOBARc                       s   e Zd Z‡ fdd„ZdS )zKTestMiscellaneous.test_accepts_any_charset_like_object.<locals>.CharsetMockc                    s   ˆ S rZ   r4   )r1   Ústring©r  r4   r5   Úheader_encodeO  s    zYTestMiscellaneous.test_accepts_any_charset_like_object.<locals>.CharsetMock.header_encodeN)ro  rp  rq  rR  r4   rQ  r4   r5   ÚCharsetMockN  s   rS  z%s <%s>rM   )r-   r   r?  r	   )r1   rê   rM  rN  rS  ZmockZmock_expectedr4   rQ  r5   Ú$test_accepts_any_charset_like_objectH  s    ÿz6TestMiscellaneous.test_accepts_any_charset_like_objectc                 C   s(   d}d}t ƒ }|  ttj||f|¡ d S )NrK  rC  )Úobjectr‚   ÚAttributeErrorr   r?  )r1   rê   rM  Zbad_charsetr4   r4   r5   Ú-test_invalid_charset_like_object_raises_errorW  s    ÿz?TestMiscellaneous.test_invalid_charset_like_object_raises_errorc                 C   s0   d}|   ttjd |f¡ |   ttjd|f¡ d S )Nu   persÃ¶n@dom.inÚName)r‚   ÚUnicodeErrorr   r?  )r1   rM  r4   r4   r5   Ú!test_unicode_address_raises_error`  s    z3TestMiscellaneous.test_unicode_address_raises_errorc                 C   sV   d}d}d\}}|   t |¡||f¡ |   t |¡||f¡ |   t ||f¡|¡ d S )NzJohn X. Doe <jxd@example.com>z"John X. Doe" <jxd@example.com>)zJohn X. Doezjxd@example.comr=  )r1   rN  Úyr™  rò  r4   r4   r5   Útest_name_with_dotf  s    z$TestMiscellaneous.test_name_with_dotc                 C   s:   | j }|t d¡dƒ |t d¡dƒ |t d¡dƒ d S )Nú""example" example"@example.com)r)   r]  ú!"\"example\" example"@example.com)r)   r^  ú#"\\"example\\" example"@example.com)r)   r_  rA  r)  r4   r4   r5   Ú2test_parseaddr_preserves_quoted_pairs_in_addresseso  s    

ÿ
ÿ
ÿzDTestMiscellaneous.test_parseaddr_preserves_quoted_pairs_in_addressesc                 C   s^   |   dt d¡¡ |   dt d¡¡ |   dt d¡¡ |   dt d¡¡ |   dt d	¡¡ d S )
N)r)   úmerwok wok@xample.comra  )r)   úmerwok  wok@xample.comrb  z merwok  wok  @xample.com)r)   úmerwok"wok"  wok@xample.comrc  )r)   zmerwok.wok.wok@xample.comzmerwok. wok .  wok@xample.comrA  rê  r4   r4   r5   Ú-test_parseaddr_preserves_spaces_in_local_part  s    ÿÿÿÿÿz?TestMiscellaneous.test_parseaddr_preserves_spaces_in_local_partc                 C   s0   d}d}|   t |¡|¡ |   t |¡|¡ d S )N)z#'foo@example.com' (foo@example.com)úfoo@example.comz7"'foo@example.com' (foo@example.com)" <foo@example.com>r=  )r1   rM  Zaddrstrr4   r4   r5   Ú6test_formataddr_does_not_quote_parens_in_quoted_string“  s    zHTestMiscellaneous.test_formataddr_does_not_quote_parens_in_quoted_stringc                 C   s   d}|   t |¡d¡ d S )NzFoo
	Bar <foo@example.com>)zFoo Barre  rA  )r1   rN  r4   r4   r5   Útest_multiline_from_commentœ  s    z-TestMiscellaneous.test_multiline_from_commentc                 C   s   |   t d¡d¡ d S )N)zA Silly; PersonrC  z""A Silly; Person" <person@dom.ain>rD  rê  r4   r4   r5   Útest_quote_dump¢  s    þz!TestMiscellaneous.test_quote_dumpc                 C   s¨   | j }| j}tƒ }tƒ }||dƒ ||dƒ ||dƒ |d|ƒ |d|ƒ |d|ƒ ||dƒ ||dƒ ||dƒ |d|ƒ |d|ƒ |d|ƒ |||ƒ |||ƒ d S )NrG   úUS-ASCIIzUs-AsCiIZusasciiZUSASCIIZUsAsCiI)r-   ZassertNotEqualr	   )r1   r2   ÚneZcset1Zcset2r4   r4   r5   Útest_charset_richcomparisons§  s$    












z.TestMiscellaneous.test_charset_richcomparisonsc                 C   s"   | j }|t ddg¡ddgƒ d S )Nzaperson@dom.ain (Al Person)zBud Person <bperson@dom.ain>)z	Al PersonrF  )z
Bud PersonrG  ©r-   r   Úgetaddressesr)  r4   r4   r5   Útest_getaddresses»  s    ÿÿþz#TestMiscellaneous.test_getaddressesc                 C   sL   | j }|t dg¡dgƒ |t dg¡g d¢ƒ |t ddg¡ddgƒ d S )Nzfoo: ;r<  z	[]*-- =~$)r<  r<  )r)   z*--z#"Jason R. Mastaler" <jason@dom.ain>)zJason R. Mastalerzjason@dom.ainrl  r)  r4   r4   r5   Útest_getaddresses_nastyÂ  s    ÿþÿþz)TestMiscellaneous.test_getaddresses_nastyc                 C   s(   | j }t dg¡}||d d dƒ d S )Nz%User ((nested comment)) <foo@bar.com>r   rr   úfoo@bar.comrl  )r1   r2   Úaddrsr4   r4   r5   Ú"test_getaddresses_embedded_commentÌ  s    z4TestMiscellaneous.test_getaddresses_embedded_commentc                 C   s(   t  tdƒg¡}|  |d d d¡ d S )NzAl Person <aperson@dom.ain>r   rr   rF  )r   rm  r
   r-   )r1   rq  r4   r4   r5   Útest_getaddresses_header_objÒ  s    z.TestMiscellaneous.test_getaddresses_header_objc                    s~   G dd„ dt ƒ‰ ‡ fdd„tdƒD ƒ}t|ƒ W d   ƒ n1 sD0    Y  tdd„ |D ƒg ƒ}|  tt|ƒƒt|ƒ¡ d S )Nc                   @   s   e Zd Zdd„ ZdS )zBTestMiscellaneous.test_make_msgid_collisions.<locals>.MsgidsThreadc                 S   sB   g | _ | j j}tj}tj}|ƒ d }|ƒ |k r>||ddƒ q$d S )Ng      @útestdomain-string©Údomain)Úmsgidsrš  r   Ú
make_msgidr8  Ú	monotonic)r1   rš  rx  ZclockZtfinr4   r4   r5   ÚrunÚ  s    

zFTestMiscellaneous.test_make_msgid_collisions.<locals>.MsgidsThread.runN)ro  rp  rq  rz  r4   r4   r4   r5   ÚMsgidsThreadÙ  s   r{  c                    s   g | ]
}ˆ ƒ ‘qS r4   r4   r³  ©r{  r4   r5   rn   ä  ro   z@TestMiscellaneous.test_make_msgid_collisions.<locals>.<listcomp>r-  c                 S   s   g | ]
}|j ‘qS r4   )rw  )rl   rá  r4   r4   r5   rn   ç  ro   )r   rº  r#   Úsumr-   ru  Úset)r1   ÚthreadsZall_idsr4   r|  r5   Útest_make_msgid_collisions×  s    
z,TestMiscellaneous.test_make_msgid_collisionsc                 C   s.   | j }tƒ }|jdddd || ¡ dƒ d S )Nr  r  zfoo\wacky"namer  )r-   r   r  rj   r0   r4   r4   r5   Útest_utils_quote_unquoteê  s    ÿz*TestMiscellaneous.test_utils_quote_unquotec                 C   s   t dƒ}|  | ¡ d¡ d S )Nznot a charsetrN   ©r	   r-   Úget_body_encoding©r1   r;   r4   r4   r5   Ú)test_get_body_encoding_with_bogus_charsetñ  s    z;TestMiscellaneous.test_get_body_encoding_with_bogus_charsetc                 C   s  | j }tƒ }d|d< ||d dƒ | ¡ }|t|ƒdƒ ||d dƒ t|d ƒ}|| ¡ dƒ |jd|d	 || ¡ d
ƒ ||jdddƒ ||d dƒ tƒ }d|d< | ¡ }|t|ƒdƒ ||d dƒ t|d ƒ}|| ¡ tj	ƒ |jd|d	 || ¡ dƒ ||d dƒ d S )Nztext/plain; charset=UTF-8r>   r:   rr   r   rM   rN   r    r  úaGVsbG8gd29ybGQ=
TrO   r<   ztext/plain; charset="US-ASCII"rG   r€  r~  )
r-   r   re   ru  r	   rƒ  rJ   rQ   r   r  )r1   r2   r3   rf   r;   r4   r4   r5   Ú-test_get_body_encoding_with_uppercase_charsetõ  s.    z?TestMiscellaneous.test_get_body_encoding_with_uppercase_charsetc                 C   s(   t dƒ}t dƒ}|  | ¡ | ¡ ¡ d S )NrG   ri  r‚  )r1   ZlcZucr4   r4   r5   Útest_charsets_case_insensitive  s    z0TestMiscellaneous.test_charsets_case_insensitivec                 C   s4   | j }|  d¡}tƒ }t ||¡ || ¡ dƒ d S )Nrô  aB  multipart/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_  r4   r4   r5   Ú1test_partial_falls_inside_message_delivery_status  s
    
zCTestMiscellaneous.test_partial_falls_inside_message_delivery_statusc                 C   s"   |   tjjdddd … d¡ d S )Nrt  ru  iíÿÿÿz@testdomain-string>©r-   r—   r   rx  rê  r4   r4   r5   Útest_make_msgid_domain>  s    þz(TestMiscellaneous.test_make_msgid_domainc                 C   s$   |   tjjddddd … d¡ d S )Nztest-idstringrt  )Zidstringrv  ißÿÿÿz!.test-idstring@testdomain-string>rŠ  rê  r4   r4   r5   Útest_make_msgid_idstringC  s    ÿÿýz*TestMiscellaneous.test_make_msgid_idstringc                 C   sT   t dƒ8}d |_}|  tj ¡  d| d ¡¡ W d   ƒ n1 sF0    Y  d S )Nzsocket.getfqdnzpythontest.example.comú@ú>)r   Zreturn_valuer³   r—   r   rx  Úendswith)r1   Zmock_getfqdnrv  r4   r4   r5   Útest_make_msgid_default_domainI  s    



ÿÿz0TestMiscellaneous.test_make_msgid_default_domainc                 C   sz   t ddd}| ¡ }W d   ƒ n1 s*0    Y  | dd¡}t |¡}tƒ }tj |¡}| |¡ |  	| 
¡ |¡ d S )Nú
msg_26.txtr(   ©Únewliner»   )r$   r‹   rË   r—   rÔ   r   r™   r   r   r-   rŽ   ©r1   ÚfZmsgtxtZ	msgtxt_nlr3   r¦   r§   r4   r4   r5   Útest_Generator_linendP  s    &

z'TestMiscellaneous.test_Generator_linendc                 C   s„   t ddd}| ¡ }W d   ƒ n1 s*0    Y  | dd¡}t |¡}tƒ }tj |¡}|j|dd |  	| 
¡  d¡|¡ d S )Nr‘  r(   r’  r»   r¼   r•   )r$   r‹   rË   r—   rÔ   r   r™   r   r   r-   rŽ   rP   r”  r4   r4   r5   Útest_BytesGenerator_linend[  s    &
z,TestMiscellaneous.test_BytesGenerator_linendc                 C   sˆ   t ddƒ}| ¡ }W d   ƒ n1 s(0    Y  | dd¡}| dd¡}t |¡}tƒ }tj |¡}|j|dd |  	| 
¡ |¡ d S )	Nr‘  rt  s   with attachments   foöó   
rÍ   r»   r¼   )r$   r‹   rË   r—   rÅ   r   r™   r   r   r-   rŽ   r”  r4   r4   r5   Ú)test_BytesGenerator_linend_with_non_asciif  s    &
z;TestMiscellaneous.test_BytesGenerator_linend_with_non_asciic              	   C   sF  t ddƒ}| ¡ }W d   ƒ n1 s(0    Y  t ddƒ}| ¡ }W d   ƒ n1 sZ0    Y  tdft|fft|ffttƒ fftdftdfg}|D ]¨\}}| j	|j
dd* ||Ž }|  |jtjj¡ W d   ƒ n1 sà0    Y  | j	|j
dd4 ||d	tjjiŽ}|  |jtjj¡ W d   ƒ q˜1 s60    Y  q˜d S )
Nrö  rt  rs  )r)   )r1  r2  re  )Úclsr¿   rg  r¿   )r$   r‹   r   r   r   r   r   r   r   ÚsubTestro  r  r¿   r—   re  rg  )r1   r   Z	audiodatar|  Úclassesrš  ÚconstructorrÇ   r4   r4   r5   Ú!test_mime_classes_policy_argumentr  s$    &&
ú0z3TestMiscellaneous.test_mime_classes_policy_argumentN)7ro  rp  rq  r   r  r  r  r  r  r  r  r  r  r   r*  r.  r2  r3  r4  r8  r:  r;  r@  rB  rE  rH  rJ  rO  rT  rW  rZ  r\  r`  rd  rf  rg  rh  rk  rn  ro  rr  rs  r€  r  r…  r‡  rˆ  r‰  r‹  rŒ  r  r–  r—  r™  rž  r4   r4   r4   r5   rü  k  sh   


			
*rü  c                   @   s4   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ ZdS )ÚTestIteratorsc                 C   s´   | j }| j}|  d¡}t |¡}t|ƒ}|t|ƒdƒ |t |¡| 	¡ ƒ |  d¡}t |¡}t|ƒ}|t|ƒdƒ t
dƒ$}|t |¡| ¡ ƒ W d   ƒ n1 s¦0    Y  d S )Nr|   r  rä  é+   z
msg_19.txt)r-   r‰  r.   r   Zbody_line_iteratorr³  ru  ÚEMPTYSTRINGr¶   rQ   r$   r‹   )r1   r2   ry  r3   Úitr¸   r   r4   r4   r5   Útest_body_line_iteratorŠ  s    




z%TestIterators.test_body_line_iteratorc                 C   sb   | j }|  d¡}t |d¡}g }d}|D ]}|d7 }| | ¡ ¡ q(||dƒ |t |¡dƒ d S )Nrh   r¥   r   rr   r›   z`a simple kind of mirror
to reflect upon our own
a simple kind of mirror
to reflect upon our own
©r-   r.   r   Ztyped_subpart_iteratorrš  rQ   r¡  r¶   ©r1   r2   r3   r¢  r¸   Zsubpartsru   r4   r4   r5   Útest_typed_subpart_iterator›  s    

z)TestIterators.test_typed_subpart_iteratorc                 C   sd   | j }|  d¡}t |dd¡}g }d}|D ]}|d7 }| | ¡ ¡ q*||dƒ |t |¡dƒ d S )Nr~   r¥   r*  r   rr   z%
Hi,

Do you like this message?

-Me
r¤  r¥  r4   r4   r5   Ú(test_typed_subpart_iterator_default_type¬  s    

z6TestIterators.test_typed_subpart_iterator_default_typec                 C   s°   g d¢}ddl m}m} |ƒ }g }d}|D ]N\}}| |¡ ||7 }d}	t|j|ƒD ]}
| |
¡ |	d7 }	qT|  ||	¡ q*|  t|ƒ|¡ |  d 	dd„ |D ƒ¡d 	|¡¡ d S )N))za 
r›   )rò  r   )zc
rr   )r)   r   )zd
rr   )zer   )z
frr   )r»   rr   r   ©ÚBufferedSubFileÚNeedMoreDatarr   r)   c                 S   s   g | ]\}}|‘qS r4   r4   )rl   ÚilÚnr4   r4   r5   rn   Û  ro   z0TestIterators.test_pushCR_LF.<locals>.<listcomp>)
Úemail.feedparserr©  rª  ÚpushÚiterÚreadlinerš  r-   ru  r¶   )r1   Zimtr©  rª  ÚbsfZomÚntr«  r¬  Zn1Zolr4   r4   r5   Útest_pushCR_LF¿  s    



zTestIterators.test_pushCR_LFc                    s¢   ddl m}m} d}d}d‰ d ‡ fdd„t|ƒD ƒ¡d	 }| d
¡}|ƒ }g }tdt|ƒ|ƒD ]0}	||	|	| … }
| |
¡ | t	|j
|ƒ¡ q`|  ||¡ d S )Nr   r¨  i'  r-  zabcd 	
r)   c                 3   s   | ]}t ˆ ƒV  qd S rZ   r   r³  ©Úcharsr4   r5   rµ  ä  ro   z1TestIterators.test_push_random.<locals>.<genexpr>r(   T)r­  r©  rª  r¶   rº  r­  ru  r®  Úextendr¯  r°  r-   )r1   r©  rª  r¬  Ú	chunksizer¦   Útargetr±  r¸   r´  Úchunkr4   r´  r5   Útest_push_randomÝ  s     

zTestIterators.test_push_randomN)ro  rp  rq  r£  r¦  r§  r³  rº  r4   r4   r4   r5   rŸ  ‰  s
   rŸ  c                   @   s,   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	S )
ÚTestFeedParsersc                 C   s"   t ƒ }|D ]}| |¡ q
| ¡ S rZ   )r&   ÚfeedÚclose)r1   Úchunksr  r¹  r4   r4   r5   Úparseò  s    zTestFeedParsers.parsec                 C   s.   |   d¡}|  |d d¡ |  |d d¡ d S )NzFirst: val
: bad
Second: valr9  Úvalr;  )r¿  r-   r\   r4   r4   r5   Útest_empty_header_name_handledø  s    
z.TestFeedParsers.test_empty_header_name_handledc                 C   sê   |   dg¡}|  | ¡ g d¢¡ |   dg¡}|  | ¡ g d¢¡ |   ddg¡}|  | ¡ ddg¡ |   dd	g¡}|  | ¡ dd
g¡ |   ddg¡}|  | ¡ dd
g¡ |   dg¡}|  | ¡ dg¡ |   g d¢¡}|  | ¡ ddg¡ d S )Nza:
b:c:
d:
)r™  rò  ÚcÚdza:
b:c:
d:za:búc:
r™  Zbcúa:zb:
rò  z
b:
u   a:Â…b:â€¨c:
)r™  u	   Â…b:â€¨c:)rÅ  u   b:Â…rÄ  ©r™  r)   )rò  u   Â…c:)r¿  r-   rB  r€   rl  r4   r4   r5   Útest_newlinesþ  s    zTestFeedParsers.test_newlinesc                 C   s  d\}}|   dgd| g|  ¡}|  | ¡ dg¡ |  | ¡ d| | ¡ |   dgd| g|  ¡}|  | ¡ dg¡ |  | ¡ d| | ¡ |   dgd| d g|  ¡}|  | ¡ dg¡ |  | ¡ d| d | ¡ |   ddgd| g|  ¡}|  | ¡ d	d
d| | fg¡ d S )N)iè  i N  za:b

rN  )r™  rò  za:bõ   Â…rÅ  zb: rÆ  rò  )r¿  r-   r€   rQ   )r1   ÚMÚNrÇ   r4   r4   r5   Útest_long_lines  s    zTestFeedParsers.test_long_linesN)ro  rp  rq  r¿  rÁ  rÇ  rË  r4   r4   r4   r5   r»  ð  s   r»  c                   @   s˜   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ Zdd„ Z	dd„ Z
dd„ Zdd„ ZdZdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zd d!„ Zd"d#„ ZdS )$ÚTestParsersc                 C   s†   | j }tdƒ}tƒ  |¡}W d   ƒ n1 s00    Y  ||d dƒ ||d dƒ || ¡ dƒ |  | ¡ ¡ |  | ¡ t	¡ d S )Nrä  r«   úppp-request@zzz.orgrª   úppp@zzz.orgr^   )
r-   r$   r   r¿  rB   r"  r#  rJ  rQ   r±   ©r1   r2   r   r3   r4   r4   r5   Útest_header_parser"  s    
*zTestParsers.test_header_parserc                 C   s    | j }tddƒ }tj ¡  |¡}W d   ƒ n1 s60    Y  ||d dƒ ||d dƒ || ¡ dƒ |  | ¡ ¡ |  	| 
¡ t¡ |  	|j
dd	t¡ d S )
Nrä  rt  r«   rÍ  rª   rÎ  r^   TrO   )r-   r$   r—   r‘   r˜   r¿  rB   r"  r#  rJ  rQ   r±   rÎ   rÏ  r4   r4   r5   Útest_bytes_header_parser-  s    .z$TestParsers.test_bytes_header_parserc                 C   sJ   t ddƒ,}tj ¡  |¡ |  |j¡ W d   ƒ n1 s<0    Y  d S )Nrä  rt  )r$   r—   r‘   ÚBytesParserr¿  r"  Úclosedrù  r4   r4   r5   Ú%test_bytes_parser_does_not_close_file9  s    z1TestParsers.test_bytes_parser_does_not_close_filec                 C   s`   t ddƒB}tjj}|  tjj|tjjdj	|¡ |  
|j¡ W d   ƒ n1 sR0    Y  d S )Nrk  rt  r¾   )r$   r—   r‘   rÒ  r‚   r   rm  r¿   Ústrictr¿  r"  rÓ  )r1   r   ZbytesParserr4   r4   r5   Ú2test_bytes_parser_on_exception_does_not_close_file>  s    
þz>TestParsers.test_bytes_parser_on_exception_does_not_close_filec                 C   sJ   t ddƒ,}tj ¡  |¡ |  |j¡ W d   ƒ n1 s<0    Y  d S )Nrä  r´  )r$   r—   r‘   r   r¿  r"  rÓ  rù  r4   r4   r5   Útest_parser_does_not_close_fileF  s    z+TestParsers.test_parser_does_not_close_filec                 C   s`   t ddƒB}tjj}|  tjj|tjjdj	|¡ |  
|j¡ W d   ƒ n1 sR0    Y  d S )Nrk  r´  r¾   )r$   r—   r‘   r   r‚   r   rm  r¿   rÕ  r¿  r"  rÓ  )r1   r   r‘   r4   r4   r5   Ú,test_parser_on_exception_does_not_close_fileK  s    
ÿz8TestParsers.test_parser_on_exception_does_not_close_filec                 C   s>   | j }t d¡}||d dƒ ||d dƒ || ¡ dƒ d S )Nz¤From: 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
 r¿  ÚspamúHere's the message body
©r-   r—   rÔ   rQ   r0   r4   r4   r5   Útest_whitespace_continuationR  s
    

z(TestParsers.test_whitespace_continuationc                 C   s>   | j }t d¡}||d dƒ ||d dƒ || ¡ dƒ d S )Nz¤From: 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
r²  rÙ  r¿  rÚ  rÛ  rÜ  r0   r4   r4   r5   Ú(test_whitespace_continuation_last_headerd  s
    

z4TestParsers.test_whitespace_continuation_last_headerc                 C   s’   | j }tddd}tƒ  |¡}W d   ƒ n1 s40    Y  |t| ¡ ƒdƒ | d¡}|| ¡ dƒ || ¡ dƒ | d¡}|| ¡ d	ƒ d S )
Nr‘  r(   r’  r›   r   r9   z!Simple email with attachment.

rr   zapplication/riscos)r-   r$   r   r¿  ru  rQ   rB   )r1   r2   r   r3   Úpart1Úpart2r4   r4   r5   Útest_crlf_separationv  s    *

z TestParsers.test_crlf_separationc                 C   sn   t ddd}| ¡ }W d   ƒ n1 s*0    Y  t |¡}tƒ }t|ƒ}|j|dd |  | ¡ |¡ d S )Nr‘  r(   r’  r»   r¼   rþ  rÿ  r4   r4   r5   Útest_crlf_flatten  s    &
zTestParsers.test_crlf_flattenNc           	      C   s:  | j }| j}tdƒ}t |¡}W d   ƒ n1 s40    Y  || ¡ dƒ |t| ¡ ƒdƒ | d¡}|| ¡ dƒ || ¡ dƒ |t| ¡ ƒdƒ | d¡}|| ¡ dƒ || ¡ dƒ || ¡ dƒ | d¡}|| ¡ dƒ || ¡ dƒ |t| ¡ ƒdƒ | d¡}|| ¡ dƒ || ¡ dƒ || ¡ dƒ d S )	Nr  rr   r›   r   r  r9   rÌ  rÍ  )	r-   r‰  r$   r—   rÆ  r#  ru  rQ   rB   )	r1   r2   ry  r   r3   rß  Zpart1arà  Zpart2ar4   r4   r5   Ú-test_multipart_digest_with_extra_mime_headers  s,    
(



z9TestParsers.test_multipart_digest_with_extra_mime_headersc                 C   s,   g d¢}t  t |¡¡}|  |d d¡ d S )N)z$From: Andrew Person <aperson@dom.ainzSubject: Testz%Date: Tue, 20 Aug 2002 16:43:45 +1000ÚdatezTue, 20 Aug 2002 16:43:45 +1000)r—   rÔ   rµ   r¶   r-   )r1   r¸   r3   r4   r4   r5   Útest_three_lines¬  s    zTestParsers.test_three_linesc                 C   sH   | j }d}d}d||f }t |¡}|| d¡|ƒ || d¡|ƒ d S )Nr¥   z	more textz'Header: %s
Next-Header: %s

Body

r
   zNext-Header)r-   r—   rÔ   Úget)r1   r2   Zvalue1Zvalue2rÇ   r3   r4   r4   r5   Ú3test_strip_line_feed_and_carriage_return_in_headers´  s    ÿ
z?TestParsers.test_strip_line_feed_and_carriage_return_in_headersc                 C   sP   | j }d}t |¡}|t|ƒdƒ |tdd„ |D ƒƒg d¢ƒ || ¡ dƒ d S )Nz(>From: foo
From: bar
!"#QUX;~: zoo

bodyrœ   c                 s   s   | ]
}|V  qd S rZ   r4   )rl   Zfieldr4   r4   r5   rµ  Ä  ro   z9TestParsers.test_rfc2822_header_syntax.<locals>.<genexpr>)z!"#QUX;~z>Fromr©   r€  )r-   r—   rÔ   ru  r  rQ   rã  r4   r4   r5   Útest_rfc2822_header_syntax¿  s    
z&TestParsers.test_rfc2822_header_syntaxc                 C   s*   | j }d}t |¡}|t| ¡ ƒdƒ d S )Nz<>From foo@example.com 11:25:53
From: bar
!"#QUX;~: zoo

bodyr   )r-   r—   rÔ   ru  rB  rã  r4   r4   r5   Ú(test_rfc2822_space_not_allowed_in_headerÇ  s    
z4TestParsers.test_rfc2822_space_not_allowed_in_headerc                 C   sD   | j }d}t |¡}| ¡ }| ¡  ||g d¢ƒ || ¡ dƒ d S )Nz7A: first header
B: second header
CC: third header

body)ÚAÚBZCCr€  )r-   r—   rÔ   rB  ÚsortrQ   )r1   r2   rÇ   r3   Zheadersr4   r4   r5   Ú!test_rfc2822_one_character_headerÍ  s    
z-TestParsers.test_rfc2822_one_character_headerc                 C   s,   d}t  |¡}|  | d¡ ¡  d¡¡ d S )Nz°From: 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--
r   r»   )r—   rÔ   r³   rQ   r  ©r1   rÇ   r3   r4   r4   r5   Útest_CRLFLF_at_end_of_partÖ  s    ÿ
z&TestParsers.test_CRLFLF_at_end_of_part)ro  rp  rq  rÐ  rÑ  rÔ  rÖ  r×  rØ  rÝ  rÞ  rá  râ  rè  rã  rå  rç  rè  ré  rí  rï  r4   r4   r4   r5   rÌ     s$   
	rÌ  c                   @   s‚  e Zd Ze d¡Zdd„ Zdd„ Zdd„ Zdd	„ Z	d
d„ Z
dd„ ZdZd dd„ eD ƒ¡d  d¡Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zd d!„ Zd"d#„ Zd$d%„ Zd&d'„ Zd(d)„ Ze d*¡ d¡Zd+d,„ Zd-d.„ Ze d/¡Zd0d1„ Zd2d3„ Z d4d5„ Z!e "d¡Z#d6ge#d7d8…< d e#¡Z#d9d:„ Z$e d;¡ d<¡Z%e d=¡Z&d>d?„ Z'd@dA„ Z(dBdC„ Z)dDdE„ Z*dFdG„ Z+dHdI„ Z,dJdK„ Z-dLZ.dLS )MÚTest8BitBytesHandlingz½        From: foo@bar.com
        To: baz
        Mime-Version: 1.0
        Content-Type: text/plain; charset={charset}
        Content-Transfer-Encoding: {cte}

        {bodyline}
        c                 C   sP   | j jdddd d¡}t |¡}|  | ¡ d¡ |  |jddd d¡¡ d S )NrM   rV   õ   pÃ¶stal©r;   r¢   Zbodylineõ   pÃ¶stal
TrO   ©Úbodytest_msgrb  r–   r—   rÅ   r-   rQ   rî  r4   r4   r5   Útest_known_8bit_CTEý  s    þþ
ÿz)Test8BitBytesHandling.test_known_8bit_CTEc                 C   sP   | j jdddd d¡}t |¡}|  | ¡ d¡ |  |jddd	 d¡¡ d S )
NZnotavalidcharsetrV   rñ  rò  rM   u   pï¿½ï¿½stal
TrO   ró  rô  rî  r4   r4   r5   Útest_unknown_8bit_CTE  s    þþ
ÿz+Test8BitBytesHandling.test_unknown_8bit_CTEc                 C   sP   | j jdddd d¡}t |¡}|  | ¡ d¡ |  |jddd d¡¡ d S )	NrM   r=   õ   p=C3=B6stÃ¡lrò  u   p=C3=B6stÃ¡l
TrO   õ	   pÃ¶stÃ¡l
rô  rî  r4   r4   r5   Útest_8bit_in_quopri_body  s    
þþ
ÿz.Test8BitBytesHandling.test_8bit_in_quopri_bodyc                 C   sP   | j jdddd d¡}t |¡}|  | ¡ d¡ |  |jddd	 d¡¡ d S )
Nr•   r=   rø  rò  rM   u   p=C3=B6stï¿½ï¿½l
TrO   rù  rô  rî  r4   r4   r5   Ú.test_invalid_8bit_in_non_8bit_cte_uses_replace!  s    þþ
ÿzDTest8BitBytesHandling.test_invalid_8bit_in_non_8bit_cte_uses_replacec                 C   sT   | j jdddd d¡}t |¡}|  |jddd d¡¡ |  |jd t	j
¡ d S )	NrM   rN   u   cMO2c3RhbAÃ¡=rò  TrO   rñ  r   )rõ  rb  r–   r—   rÅ   r-   rQ   rJ  rK  r   rL  rî  r4   r4   r5   Útest_8bit_in_base64_body1  s    þþ
ÿÿz.Test8BitBytesHandling.test_8bit_in_base64_bodyc                 C   s@   | j jdddd d¡}t |¡}|  |jddd d¡¡ d S )NrM   rŸ   u   <,.V<W1A; Ã¡ rò  TrO   u   <,.V<W1A; Ã¡ 
rô  rî  r4   r4   r5   Útest_8bit_in_uuencode_body>  s    þþ
ÿz0Test8BitBytesHandling.test_8bit_in_uuencode_body))zFrom: foo@bar.com©r©   rp  )u   To: bÃ¡z)r¬   z=?unknown-8bit?q?b=C3=A1z?=)uV   Subject: Maintenant je vous prÃ©sente mon collÃ¨gue, le pouf cÃ©lÃ¨bre
	Jean de Baddie)rj  z†=?unknown-8bit?q?Maintenant_je_vous_pr=C3=A9sente_mon_coll=C3=A8gue=2C_le_pouf_c=C3=A9l=C3=A8bre?=
 =?unknown-8bit?q?_Jean_de_Baddie?=)u   From: gÃ¶st)r©   z=?unknown-8bit?b?Z8O2c3Q=?=r(   c                 C   s   g | ]\}}|‘qS r4   r4   )rl   ÚsrcÚ_r4   r4   r5   rn   S  ro   z Test8BitBytesHandling.<listcomp>z
Yes, they are flying.
rM   c                 C   s:   t  | j¡}|  t| d¡ƒd¡ |  t|d ƒd¡ d S )Nrª   õ   bï¿½ï¿½z)r—   rÅ   Úheadertest_msgr-   r±   ræ  r\   r4   r4   r5   Útest_get_8bit_headerV  s    z*Test8BitBytesHandling.test_get_8bit_headerc                 C   s8   t  | j¡}|  t|ƒt d¡jdd„ | jD ƒŽ ¡ d S )Nzä                            From: {}
                            To: {}
                            Subject: {}
                            From: {}

                            Yes, they are flying.
                            c                 S   s   g | ]\}}|d  ‘qS )rr   r4   )rl   r   rÉ   r4   r4   r5   rn   e  ro   zATest8BitBytesHandling.test_print_8bit_headers.<locals>.<listcomp>)	r—   rÅ   r  r-   r±   rÃ   rÄ   rb  Úheadertest_headersr\   r4   r4   r5   Útest_print_8bit_headers[  s    

ÿùÿz-Test8BitBytesHandling.test_print_8bit_headersc                 C   s.   t  | j¡}|  dd„ | ¡ D ƒg d¢¡ d S )Nc                 S   s   g | ]}t |ƒ‘qS r4   ©r±   rv  r4   r4   r5   rn   j  ro   zGTest8BitBytesHandling.test_values_with_8bit_headers.<locals>.<listcomp>)rp  r  õ]   Maintenant je vous prï¿½ï¿½sente mon collï¿½ï¿½gue, le pouf cï¿½ï¿½lï¿½ï¿½bre
	Jean de Baddieõ	   gï¿½ï¿½st)r—   rÅ   r  ÚassertListEqualrC  r\   r4   r4   r5   Útest_values_with_8bit_headersh  s    ÿz3Test8BitBytesHandling.test_values_with_8bit_headersc                 C   s.   t  | j¡}|  dd„ | ¡ D ƒg d¢¡ d S )Nc                 S   s    g | ]\}}t |ƒt |ƒf‘qS r4   r  )rl   rN  r[  r4   r4   r5   rn   u  ro   zFTest8BitBytesHandling.test_items_with_8bit_headers.<locals>.<listcomp>)rþ  )r¬   r  )rj  r  )r©   r  )r—   rÅ   r  r	  r€   r\   r4   r4   r5   Útest_items_with_8bit_headerss  s    ÿz2Test8BitBytesHandling.test_items_with_8bit_headersc                 C   s0   t  | j¡}|  dd„ | d¡D ƒddg¡ d S )Nc                 S   s   g | ]}t |ƒ‘qS r4   r  rv  r4   r4   r5   rn     ro   zHTest8BitBytesHandling.test_get_all_with_8bit_headers.<locals>.<listcomp>r«   rp  r  )r—   rÅ   r  r	  r/   r\   r4   r4   r5   Útest_get_all_with_8bit_headers  s    ÿÿz4Test8BitBytesHandling.test_get_all_with_8bit_headersc                 C   sJ   t  t d¡ d¡¡}|  | ¡ d¡ |  | ¡ d¡ |  | ¡ d¡ d S )NuA               Content-Type: text/plÂ§in; charset=utf-8
            r[  u   text/plï¿½inr¥   u   plï¿½in)	r—   rÅ   rÃ   rÄ   r–   r-   rB   r   r,  r\   r4   r4   r5   Útest_get_content_type_with_8bit…  s    þz5Test8BitBytesHandling.test_get_content_type_with_8bitc                 C   sX   t  d d¡¡}|  |jddg d¢¡ |  |jdddd¡ |  |jdddd ¡ d S )	Nu(   X-Header: foo=Â§ne; bÂ§r=two; baz=three
r[  rÝ   rÞ   ))r¡   õ   ï¿½ne)u   bï¿½rrá   râ   ZFoor  u   bÂ§r)r—   rÅ   r–   r-   rä   rC   r\   r4   r4   r5   Útest_get_params_with_8bitŽ  s    ÿÿz/Test8BitBytesHandling.test_get_params_with_8bitc                 C   s,   t  t d¡ d¡¡}|  | d¡d¡ d S )Nõn               Content-Type: text/plain; charset=us-ascii;
             title*=us-ascii'en'This%20is%20not%20fÂ§nr[  Útitle)rG   Úenu   This is not fï¿½n)r—   rÅ   rÃ   rÄ   r–   r-   rC   r\   r4   r4   r5   Ú!test_get_rfc2231_params_with_8bit˜  s    ýÿz7Test8BitBytesHandling.test_get_rfc2231_params_with_8bitc                 C   s8   t  t d¡ d¡¡}| dd¡ |  | d¡d¡ d S )Nr  r[  r  Útest)r—   rÅ   rÃ   rÄ   r–   rö   r-   rC   r\   r4   r4   r5   Ú!test_set_rfc2231_params_with_8bit   s
    ýz7Test8BitBytesHandling.test_set_rfc2231_params_with_8bitc                 C   sF   t  t d¡ d¡¡}| d¡ |  | d¡d ¡ |  | ¡ d¡ d S )Nr  r[  r  r¥   )	r—   rÅ   rÃ   rÄ   r–   rÿ   r-   rC   r   r\   r4   r4   r5   Ú!test_del_rfc2231_params_with_8bit¨  s    ý
z7Test8BitBytesHandling.test_del_rfc2231_params_with_8bitc                 C   s>   t  t d¡ d¡¡}|  | ¡ d¡ |  |jddd¡ d S )Nu†               Content-Transfer-Encoding: bÂ§se64
            Content-Type: text/plain; charset=latin-1

            payload
            r[  zpayload
TrO   s   payload
)r—   rÅ   rÃ   rÄ   r–   r-   rQ   r\   r4   r4   r5   Ú%test_get_payload_with_8bit_cte_header±  s
    û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

        Ð”Ð°, Ð¾Ð½Ð¸ Ð»ÐµÑ‚ÑÑ‚.
        c                 C   s:   t  | j¡}tƒ }t j |¡ |¡ |  | ¡ | j¡ d S rZ   )	r—   rÅ   Únon_latin_bin_msgr   r™   r   r   r-   rŽ   ©r1   r3   r’   r4   r4   r5   Útest_bytes_generatorÇ  s    z*Test8BitBytesHandling.test_bytes_generatorc                 C   s6   t j ¡ }tƒ }t j |¡ |¡ |  | ¡ d¡ d S )NrÍ   )	r—   r"  r   r   r™   r   r   r-   rŽ   r  r4   r4   r5   Ú&test_bytes_generator_handles_None_bodyÍ  s    
z<Test8BitBytesHandling.test_bytes_generator_handles_None_bodya«          From: foo@bar.com
        To: =?unknown-8bit?q?b=C3=A1z?=
        Subject: =?unknown-8bit?q?Maintenant_je_vous_pr=C3=A9sente_mon_coll=C3=A8gue?=
         =?unknown-8bit?q?=2C_le_pouf_c=C3=A9l=C3=A8bre?=
         =?unknown-8bit?q?_Jean_de_Baddie?=
        Mime-Version: 1.0
        Content-Type: text/plain; charset="utf-8"
        Content-Transfer-Encoding: base64

        0JTQsCwg0L7QvdC4INC70LXRgtGP0YIuCg==
        c                 C   s:   t  | j¡}tƒ }t j |¡ |¡ |  | ¡ | j	¡ d S rZ   )
r—   rÅ   r  r   r™   r   r   r-   rŽ   Ú non_latin_bin_msg_as7bit_wrappedr  r4   r4   r5   Útest_generator_handles_8bitá  s    z1Test8BitBytesHandling.test_generator_handles_8bitc                 C   s`   t  | j¡}tƒ }t|ƒ |¡ | ¡ }ttƒ ƒ |¡ tƒ }t|ƒ |¡ |  	| ¡ |¡ d S rZ   )
r—   rÅ   r  r   r   r   rŽ   r   r   r-   )r1   r3   r’   Z
orig_valuer4   r4   r5   Ú;test_str_generator_should_not_mutate_msg_when_handling_8bitç  s    zQTest8BitBytesHandling.test_str_generator_should_not_mutate_msg_when_handling_8bitc                 C   sn   t  | j¡}tƒ }t j |¡j|dd | ¡  d¡}|  	|d  ¡ d d¡ |  	d 
|dd … ¡| j¡ d S )NTr¯   rÍ   r   s   Fromrr   )r—   rÅ   r  r   r™   r   r   rŽ   r²   r-   r¶   )r1   r3   r’   r¸   r4   r4   r5   Ú#test_bytes_generator_with_unix_fromñ  s    z9Test8BitBytesHandling.test_bytes_generator_with_unix_fromzkSubject: =?unknown-8bit?q?Maintenant_je_vous_pr=C3=A9sente_mon_coll=C3=A8gue=2C_le_pouf_c=C3=A9l=C3=A8bre?=r›   r}   c                 C   s–   d}|   t|¡ t|dƒ}| | j¡ W d   ƒ n1 s<0    Y  t|dƒ }tj ¡  |¡}W d   ƒ n1 sv0    Y  |  	t
|ƒ| j¡ d S )Nztest.msgÚwbrt  )Z
addCleanupr"   ÚopenÚwriter  r—   r‘   rÒ  r¿  r-   r±   Únon_latin_bin_msg_as7bit)r1   rØ  ZtestfilerÇ   r4   r4   r5   Útest_message_from_binary_file  s    *.z3Test8BitBytesHandling.test_message_from_binary_fileu          From: foo@bar.com
        To: Dinsdale
        Subject: Nudge nudge, wink, wink
        Mime-Version: 1.0
        Content-Type: text/plain; charset="latin-1"
        Content-Transfer-Encoding: 8bit

        oh lÃ  lÃ , know what I mean, know what I mean?
        r[  a           From: foo@bar.com
        To: Dinsdale
        Subject: Nudge nudge, wink, wink
        Mime-Version: 1.0
        Content-Type: text/plain; charset="iso-8859-1"
        Content-Transfer-Encoding: quoted-printable

        oh l=E0 l=E0, know what I mean, know what I mean?
        c                 C   s"   t  | j¡}|  t|ƒ| j¡ d S rZ   )r—   rÅ   Úlatin_bin_msgr-   r±   Úlatin_bin_msg_as7bitrl  r4   r4   r5   Ú:test_string_generator_reencodes_to_quopri_when_appropriate!  s    zPTest8BitBytesHandling.test_string_generator_reencodes_to_quopri_when_appropriatec                 C   sD   t  | j¡}tƒ }t j |¡ |¡ |  | ¡ | j 	d¡d ¡ d S )Nr[  r(   )
r—   rÅ   r%  r   r™   r   r   r-   rŽ   rP   )r1   rÇ   r’   r4   r4   r5   Ú)test_decoded_generator_emits_unicode_body%  s    
ÿz?Test8BitBytesHandling.test_decoded_generator_emits_unicode_bodyc                 C   sX   t j ¡ }tdt| jƒdƒD ]}| | j||d … ¡ q| ¡ }|  t	|ƒ| j
¡ d S )Nr   r¶  )r—   r  r'   rº  ru  r%  r¼  r½  r-   r±   r&  )r1   Zbfpr´  rÇ   r4   r4   r5   Útest_bytes_feedparser/  s
    
z+Test8BitBytesHandling.test_bytes_feedparserc                 C   sp   t ddƒ}| ¡ }W d   ƒ n1 s(0    Y  t |¡}tƒ }tj |¡}|j|dd |  | 	¡ |¡ d S )Nr‘  rt  r»   r¼   )
r$   r‹   r—   rÅ   r   r™   r   r   r-   rŽ   rÿ  r4   r4   r5   râ  6  s    &
z'Test8BitBytesHandling.test_crlf_flattenc                 C   sJ   t  d¡ d¡}t |¡}tƒ }tj |¡}| |¡ |  	| 
¡ |¡ d S )Nuo              Date: Fri, 18 Mar 2011 17:15:43 +0100
            To: foo@example.com
            From: foodwatch-Newsletter <bar@example.com>
            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

            <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                "http://www.w3.org/TR/html4/loose.dtd">
            <html lang="de">
            <head>
                    <title>foodwatch - Newsletter</title>
            </head>
            <body>
              <p>mit gro&szlig;er Betroffenheit verfolgen auch wir im foodwatch-Team
                 die Nachrichten aus Japan.</p>
            </body>
            </html>
            --b1_76a486bee62b0d200f33dc2ca08220ad--

            rM   )rÃ   rÄ   r–   r—   rÅ   r   r™   r   r   r-   rŽ   )r1   rÈ   r3   r¦   r§   r4   r4   r5   Útest_8bit_multipart?  s    
%Û&

z)Test8BitBytesHandling.test_8bit_multipartc                 C   sF   t ƒ }tdƒ|d< tƒ }tj |¡}|j|dd |  | ¡ d¡ d S )Nõ   Å¾luÅ¥ouÄkÃ½ kÅ¯Åˆrj  r»   r¼   s5   Subject: =?utf-8?b?xb5sdcWlb3XEjWvDvSBrxa/FiA==?=

)	r   r
   r   r—   r™   r   r   r-   rŽ   ©r1   rÇ   r¦   r§   r4   r4   r5   Ú'test_bytes_generator_b_encoding_linesepm  s    þz=Test8BitBytesHandling.test_bytes_generator_b_encoding_linesepc                 C   sF   t ƒ }tdƒ|d< tƒ }tj |¡}|j|dd |  | ¡ d¡ d S )Nr+  rj  r»   r¼   z5Subject: =?utf-8?b?xb5sdcWlb3XEjWvDvSBrxa/FiA==?=

)	r   r
   r   r—   r™   r   r   r-   rŽ   r,  r4   r4   r5   Ú!test_generator_b_encoding_linesepy  s    þz7Test8BitBytesHandling.test_generator_b_encoding_linesepN)/ro  rp  rq  rÃ   rÄ   rõ  rö  r÷  rú  rû  rü  rý  r  r¶   r–   r  r  r  r
  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r²   r#  r$  r%  r&  r'  r(  r)  râ  r*  r-  r.  rè  r4   r4   r4   r5   rð  ê  sd   	

		
ÿÿ	
	


ö


ÿ
	
	÷

	.rð  c                   @   s"   e Zd ZdZdd„ Zddd„ZdS )Ú BaseTestBytesGeneratorIdempotentNc                 C   sT   t |dƒ}| ¡ }W d   ƒ n1 s(0    Y  | j | j|¡}t |¡}||fS )Nrt  )r$   r‹   Únormalize_linesep_regexÚsubÚblinesepr—   rÅ   rÜ  r4   r4   r5   r.   Œ  s
    &
z(BaseTestBytesGeneratorIdempotent._msgobjFc                 C   s<   t ƒ }tjj|dd}|j||| jd |  || ¡ ¡ d S )Nr   rÐ  )r°   r½   )r   r—   r™   r   r   r½   r-   rŽ   )r1   r3   rS   r°   rò  r§   r4   r4   r5   rÝ  “  s    z,BaseTestBytesGeneratorIdempotent._idempotent)F)ro  rp  rq  rè  r.   rÝ  r4   r4   r4   r5   r/  ˆ  s   r/  c                   @   s   e Zd ZdZdZe d¡ZdS )ÚTestBytesGeneratorIdempotentNLr(   rÍ   s   \r\nN©ro  rp  rq  r½   r2  ÚreÚcompiler0  r4   r4   r4   r5   r3  š  s   r3  c                   @   s   e Zd ZdZdZe d¡ZdS )Ú TestBytesGeneratorIdempotentCRLFr»   r˜  s	   (?<!\r)\nNr4  r4   r4   r4   r5   r7  ¡  s   r7  c                   @   s,   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	S )
Ú
TestBase64c                 C   s”   | j }|t d¡ttjdddƒƒ tdƒD ]b}|dkr>d}n<|dkrLd}n.|d	krZd
}n |dkrhd}n|dkrvd}nd}|t d| ¡|ƒ q,d S )NÚhelloó   hellor)   ©Úeolé   r   rœ   r}   r  é   r5  é   é   é   rN  )r-   r    Úheader_lengthru  Úbody_encoderº  )r1   r2   ÚsizeZbsizer4   r4   r5   Útest_len©  s    
ÿzTestBase64.test_lenc                 C   s*   | j }|t d¡dƒ |t d¡dƒ d S )Nr)   ro   zaGVsbG8=r:  )r-   r    rP   r)  r4   r4   r5   Útest_decode¶  s    zTestBase64.test_decodec                 C   sd   | j }|t d¡dƒ |t d¡dƒ |t d¡dƒ |tjdddd	ƒ |tjddd
ddƒ d S )Nro   r:  z	aGVsbG8=
s   hello
z	aGVsbG8K
sd   xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx é(   r˜  zŒeHh4eCB4eHh4IHh4eHggeHh4eCB4eHh4IHh4eHgg
eHh4eCB4eHh4IHh4eHggeHh4eCB4eHh4IHh4eHgg
eHh4eCB4eHh4IHh4eHggeHh4eCB4eHh4IHh4eHgg
eHh4eCB4eHh4IA==
r»   ©r™  r<  zeHh4eCB4eHh4IHh4eHggeHh4eCB4eHh4IHh4eHgg
eHh4eCB4eHh4IHh4eHggeHh4eCB4eHh4IHh4eHgg
eHh4eCB4eHh4IHh4eHggeHh4eCB4eHh4IHh4eHgg
eHh4eCB4eHh4IA==
)r-   r    rC  r)  r4   r4   r5   Útest_encode»  s    ÿzTestBase64.test_encodec                 C   sZ   | j }tj}||dƒdƒ ||dƒdƒ ||dƒdƒ ||dddd	ƒ ||dƒdƒ d S )
Nr9  z=?iso-8859-1?b?aGVsbG8=?=úhello
worldz!=?iso-8859-1?b?aGVsbG8NCndvcmxk?=úhello
worldz!=?iso-8859-1?b?aGVsbG8Kd29ybGQ=?=rb   r  z=?iso-8859-2?b?aGVsbG8=?=)r-   r    rR  )r1   r2   Úher4   r4   r5   Útest_header_encodeÑ  s    zTestBase64.test_header_encodeN)ro  rp  rq  rE  rF  rI  rM  r4   r4   r4   r5   r8  ¨  s   r8  c                   @   s*  e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ Zdˆdd„Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zd d!„ Zd"d#„ Zd$d%„ Zd‰d&d'„Zd(d)„ Zd*d+„ Zd,d-„ Zd.d/„ Zd0d1„ Zd2d3„ Zd4d5„ Zd6d7„ Zd8d9„ Zd:d;„ Zd<d=„ Z d>d?„ Z!d@dA„ Z"dBdC„ Z#dDdE„ Z$dFdG„ Z%dHdI„ Z&dJdK„ Z'dLdM„ Z(dNdO„ Z)dPdQ„ Z*dRdS„ Z+dTdU„ Z,dŠdVdW„Z-dXdY„ Z.dZd[„ Z/d\d]„ Z0d^d_„ Z1d`da„ Z2dbdc„ Z3ddde„ Z4dfdg„ Z5dhdi„ Z6djdk„ Z7dldm„ Z8dndo„ Z9dpdq„ Z:drds„ Z;dtdu„ Z<dvdw„ Z=dxdy„ Z>dzd{„ Z?d|d}„ Z@d~d„ ZAd€d„ ZBd‚dƒ„ ZCd„d…„ ZDd†d‡„ ZEdS )‹Ú
TestQuopric                    sÄ   t tttdƒtdƒd ƒttdƒtdƒd ƒttdƒtdƒd ƒdd	„ d
D ƒƒƒˆ _‡ fdd„tdƒD ƒˆ _t ttdƒtdƒd ƒƒˆ _ˆ j tdƒ¡ ˆ j tdƒ¡ ‡ fdd„tdƒD ƒˆ _	d S )Nr™  Úzrr   rê  ÚZr  Ú9c                 s   s   | ]
}|V  qd S rZ   r4   ©rl   rÂ  r4   r4   r5   rµ  å  ro   z#TestQuopri.setUp.<locals>.<genexpr>s   !*+-/c                    s   g | ]}|ˆ j vr|‘qS r4   )ÚhlitrR  rê  r4   r5   rn   è  ro   z$TestQuopri.setUp.<locals>.<listcomp>é   r*   ú~r  ú=c                    s   g | ]}|ˆ j vr|‘qS r4   )ÚblitrR  rê  r4   r5   rn   ñ  ro   )
r³  r   rº  ÚordrS  ÚhnonrW  rš  ÚremoveÚbnonrê  r4   rê  r5   rë  Þ  s    üzTestQuopri.setUpc                 C   sP   | j D ]}|  t |¡dt|ƒ ¡ q| jD ]}|  t |¡dt|ƒ ¡ q,d S )Nz'Should not be header quopri encoded: %sz#Should be header quopri encoded: %s)rS  r"  r!   Zheader_checkÚchrrY  r³   ©r1   rÂ  r4   r4   r5   Útest_quopri_header_checkô  s    

ÿ

ÿz#TestQuopri.test_quopri_header_checkc                 C   sP   | j D ]}|  t |¡dt|ƒ ¡ q| jD ]}|  t |¡dt|ƒ ¡ q,d S )Nz%Should not be body quopri encoded: %sz!Should be body quopri encoded: %s)rW  r"  r!   Z
body_checkr\  r[  r³   r]  r4   r4   r5   Útest_quopri_body_checkü  s    

ÿ

ÿz!TestQuopri.test_quopri_body_checkc                 C   sä   | j }|t d¡dƒ |ttjdddƒt d¡d ƒ |t d¡dƒ |ttjdddƒt d¡d ƒ | jD ]$}|t t|gƒ¡dd	t|ƒ ƒ qp| jD ]2}|t	d
ƒkr®qœ|t t|gƒ¡ddt|ƒ ƒ qœ|t d¡dƒ d S )Nr:  r-  Zxxxr  r¶  s
   h@e@l@l@o@rA  rr   zexpected length 1 for %rr*   rœ   zexpected length 3 for %ró    )
r-   r!   rB  ru  rR  rS  rÎ   r\  rY  rX  ©r1   r2   rÂ  r4   r4   r5   Útest_header_quopri_len  s0    þÿþÿ

ÿ

ÿz!TestQuopri.test_header_quopri_lenc                 C   sN   | j }| jD ]}|t t|gƒ¡dƒ q| jD ]}|t t|gƒ¡dƒ q.d S )Nrr   rœ   )r-   rW  r!   Zbody_lengthrÎ   r[  ra  r4   r4   r5   Útest_body_quopri_len  s
    

zTestQuopri.test_body_quopri_lenc                 C   s2   t dƒD ]$}t|ƒ}|  t t |¡¡|¡ qd S )NrT  )rº  r\  r-   r!   rí   Úquote)r1   rN  rÂ  r4   r4   r5   Útest_quote_unquote_idempotent$  s    z(TestQuopri.test_quote_unquote_idempotentNc                 C   s0   |d u rt  |¡}nt  ||¡}|  ||¡ d S rZ   )r!   rR  r-   )r1   r„   Zexpected_encoded_headerr;   Úencoded_headerr4   r4   r5   Ú_test_header_encode)  s    zTestQuopri._test_header_encodec                 C   s   |   dd¡ d S )Nro   r)   ©rg  rê  r4   r4   r5   Útest_header_encode_null0  s    z"TestQuopri.test_header_encode_nullc                 C   s   |   dd¡ d S )Nr:  z=?iso-8859-1?q?hello?=rh  rê  r4   r4   r5   Útest_header_encode_one_word3  s    z&TestQuopri.test_header_encode_one_wordc                 C   s   |   dd¡ d S )Ns   hello
worldz=?iso-8859-1?q?hello=0Aworld?=rh  rê  r4   r4   r5   Útest_header_encode_two_lines6  s    ÿz'TestQuopri.test_header_encode_two_linesc                 C   s   |   dd¡ d S )Ns   helloÇtherez=?iso-8859-1?q?hello=C7there?=rh  rê  r4   r4   r5   Útest_header_encode_non_ascii:  s    ÿz'TestQuopri.test_header_encode_non_asciic                 C   s   | j dddd d S )Nr:  z=?iso-8859-2?q?hello?=rb   r  rh  rê  r4   r4   r5   Útest_header_encode_alt_charset>  s    ÿz)TestQuopri.test_header_encode_alt_charsetc                 C   s   t  |¡}|  ||¡ d S rZ   )r!   Úheader_decoder-   )r1   rf  Zexpected_decoded_headerZdecoded_headerr4   r4   r5   Ú_test_header_decodeB  s    
zTestQuopri._test_header_decodec                 C   s   |   dd¡ d S ©Nr)   ©ro  rê  r4   r4   r5   Útest_header_decode_nullF  s    z"TestQuopri.test_header_decode_nullc                 C   s   |   dd¡ d S ©Nr9  rq  rê  r4   r4   r5   Útest_header_decode_one_wordI  s    z&TestQuopri.test_header_decode_one_wordc                 C   s   |   dd¡ d S )Nzhello=0AworldrK  rq  rê  r4   r4   r5   Útest_header_decode_two_linesL  s    z'TestQuopri.test_header_decode_two_linesc                 C   s   |   dd¡ d S )Nzhello=C7thereu   helloÃ‡thererq  rê  r4   r4   r5   Útest_header_decode_non_asciiO  s    z'TestQuopri.test_header_decode_non_asciic                 C   s   |   t d¡d¡ d S )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=30A  00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000)r-   r!   rn  rê  r4   r4   r5   Útest_header_decode_re_bug_18380R  s    z*TestQuopri.test_header_decode_re_bug_18380c                 C   s2   |d u rt  |¡}nt j||d}|  ||¡ d S )Nr;  )r!   rP   r-   )r1   ÚencodedZexpected_decodedr<  Údecodedr4   r4   r5   Ú_test_decodeV  s    zTestQuopri._test_decodec                 C   s   |   dd¡ d S rp  ©rz  rê  r4   r4   r5   Útest_decode_null_word]  s    z TestQuopri.test_decode_null_wordc                 C   s   |   dd¡ d S )Nr»   r(   r{  rê  r4   r4   r5   Útest_decode_null_line_null_word`  s    z*TestQuopri.test_decode_null_line_null_wordc                 C   s   |   dd¡ d S rs  r{  rê  r4   r4   r5   Útest_decode_one_wordc  s    zTestQuopri.test_decode_one_wordc                 C   s   | j dddd d S )Nr9  ÚXr;  r{  rê  r4   r4   r5   Útest_decode_one_word_eolf  s    z#TestQuopri.test_decode_one_word_eolc                 C   s   |   dd¡ d S ©Núhello
úhello
r{  rê  r4   r4   r5   Útest_decode_one_linei  s    zTestQuopri.test_decode_one_linec                 C   s   |   dd¡ d S ©Nrƒ  r{  rê  r4   r4   r5   Útest_decode_one_line_lfl  s    z"TestQuopri.test_decode_one_line_lfc                 C   s   |   dd¡ d S )Nzhellorƒ  r{  rê  r4   r4   r5   Útest_decode_one_line_cro  s    z"TestQuopri.test_decode_one_line_crc                 C   s   | j dddd d S )Nrƒ  ÚhelloXr  r;  r{  rê  r4   r4   r5   Útest_decode_one_line_nlr  s    z"TestQuopri.test_decode_one_line_nlc                 C   s   | j dddd d S )Nr‚  rˆ  r  r;  r{  rê  r4   r4   r5   Útest_decode_one_line_crnlu  s    z$TestQuopri.test_decode_one_line_crnlc                 C   s   |   dd¡ d S )NrJ  rK  r{  rê  r4   r4   r5   Útest_decode_one_line_one_wordx  s    z(TestQuopri.test_decode_one_line_one_wordc                 C   s   | j dddd d S )NrJ  ZhelloXworldr  r;  r{  rê  r4   r4   r5   Ú!test_decode_one_line_one_word_eol{  s    z,TestQuopri.test_decode_one_line_one_word_eolc                 C   s   |   dd¡ d S )Núhello
world
úhello
world
r{  rê  r4   r4   r5   Útest_decode_two_lines~  s    z TestQuopri.test_decode_two_linesc                 C   s   | j dddd d S )Nr  ZhelloXworldXr  r;  r{  rê  r4   r4   r5   Útest_decode_two_lines_eol  s    z$TestQuopri.test_decode_two_lines_eolc                 C   s   |   dd¡ d S )NAè  SpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamr{  rê  r4   r4   r5   Útest_decode_one_long_line„  s    z$TestQuopri.test_decode_one_long_linec                 C   s   |   dd¡ d S )Nr*   r)   r{  rê  r4   r4   r5   Útest_decode_one_space‡  s    z TestQuopri.test_decode_one_spacec                 C   s   |   dd¡ d S )Nz     r)   r{  rê  r4   r4   r5   Útest_decode_multiple_spacesŠ  s    z&TestQuopri.test_decode_multiple_spacesc                 C   s   |   dd¡ d S )Nzhello    
rƒ  r{  rê  r4   r4   r5   Ú$test_decode_one_line_trailing_spaces  s    z/TestQuopri.test_decode_one_line_trailing_spacesc                 C   s   |   dd¡ d S )Nzhello    
world   
rŽ  r{  rê  r4   r4   r5   Ú%test_decode_two_lines_trailing_spaces  s    z0TestQuopri.test_decode_two_lines_trailing_spacesc                 C   s   |   dd¡ d S )Nz=22quoted=20words=22z"quoted words"r{  rê  r4   r4   r5   Útest_decode_quoted_word“  s    z"TestQuopri.test_decode_quoted_wordc                 C   s   |   dd¡ d S )Nzab=CD=EFõ   abÃÃ¯r{  rê  r4   r4   r5   Útest_decode_uppercase_quoting–  s    z(TestQuopri.test_decode_uppercase_quotingc                 C   s   |   dd¡ d S )Nzab=cd=efr—  r{  rê  r4   r4   r5   Útest_decode_lowercase_quoting™  s    z(TestQuopri.test_decode_lowercase_quotingc                 C   s   |   dd¡ d S )Nzsoft line=
breakzsoft linebreakr{  rê  r4   r4   r5   Útest_decode_soft_line_breakœ  s    z&TestQuopri.test_decode_soft_line_breakc                 C   s   |   dd¡ d S )NzA=1,B=A ==> A+B==2r{  rê  r4   r4   r5   Útest_decode_false_quotingŸ  s    z$TestQuopri.test_decode_false_quotingc                 C   s€   i }|d u rd}n||d< |d u r(d}n||d< t j|fi |¤Ž}|  ||¡ |dks^|dkr|| ¡ D ]}|  t|ƒ|¡ qfd S )Nrw  r™  r(   r<  r»   )r!   rC  r-   r­  rz  ru  )r1   r€  Zexpected_encoded_bodyr™  r<  ÚkwargsZencoded_bodyr‚  r4   r4   r5   Ú_test_encode¢  s    zTestQuopri._test_encodec                 C   s   |   dd¡ d S rp  ©r  rê  r4   r4   r5   Útest_encode_null¶  s    zTestQuopri.test_encode_nullc                 C   s   |   dd¡ d S )Nz

rž  rê  r4   r4   r5   Útest_encode_null_lines¹  s    z!TestQuopri.test_encode_null_linesc                 C   s   |   dd¡ d S r…  rž  rê  r4   r4   r5   Útest_encode_one_line¼  s    zTestQuopri.test_encode_one_linec                 C   s   |   dd¡ d S r  rž  rê  r4   r4   r5   Útest_encode_one_line_crlf¿  s    z$TestQuopri.test_encode_one_line_crlfc                 C   s   | j dddd d S )Nrƒ  r‚  r»   r;  rž  rê  r4   r4   r5   Útest_encode_one_line_eolÂ  s    z#TestQuopri.test_encode_one_line_eolc                 C   s    | j d d¡ d¡ddd d S )Nu   helloÏ…
rM   Úlatin1zhello=CF=85
r»   r;  )r  r–   rP   rê  r4   r4   r5   Ú(test_encode_one_line_eol_after_non_asciiÅ  s    ÿz3TestQuopri.test_encode_one_line_eol_after_non_asciic                 C   s   |   dd¡ d S )Nr*   z=20rž  rê  r4   r4   r5   Útest_encode_one_spaceÊ  s    z TestQuopri.test_encode_one_spacec                 C   s   |   dd¡ d S )Nz 
z=20
rž  rê  r4   r4   r5   Útest_encode_one_line_one_spaceÍ  s    z)TestQuopri.test_encode_one_line_one_spacec                 C   s   |   dd¡ d S )Nz 
 
z=20
=20
rž  rê  r4   r4   r5   Útest_encode_two_lines_one_spaceÕ  s    z*TestQuopri.test_encode_two_lines_one_spacec                 C   s   |   dd¡ d S )Nzhello   z
hello  =20rž  rê  r4   r4   r5   Ú$test_encode_one_word_trailing_spacesØ  s    z/TestQuopri.test_encode_one_word_trailing_spacesc                 C   s   |   dd¡ d S )Nz	hello   
zhello  =20
rž  rê  r4   r4   r5   Ú$test_encode_one_line_trailing_spacesÛ  s    z/TestQuopri.test_encode_one_line_trailing_spacesc                 C   s   |   dd¡ d S )Nzhello  	z
hello  =09rž  rê  r4   r4   r5   Ú!test_encode_one_word_trailing_tabÞ  s    z,TestQuopri.test_encode_one_word_trailing_tabc                 C   s   |   dd¡ d S )Nz	hello  	
zhello  =09
rž  rê  r4   r4   r5   Ú!test_encode_one_line_trailing_tabá  s    z,TestQuopri.test_encode_one_line_trailing_tabc                 C   s   | j dddd d S )Nú
abcd 
1234zabcd =

1234r  r˜  rž  rê  r4   r4   r5   Ú,test_encode_trailing_space_before_maxlinelenä  s    z7TestQuopri.test_encode_trailing_space_before_maxlinelenc                 C   s   | j dddd d S )Nr­  zabcd=
=20
1234r-  r˜  rž  rê  r4   r4   r5   Ú(test_encode_trailing_space_at_maxlinelenç  s    z3TestQuopri.test_encode_trailing_space_at_maxlinelenc                 C   s   | j dddd d S )Nr­  zabc=
d=20
1234r}   r˜  rž  rê  r4   r4   r5   Ú,test_encode_trailing_space_beyond_maxlinelenê  s    z7TestQuopri.test_encode_trailing_space_beyond_maxlinelenc                 C   s   |   dd¡ d S )Nz
 
 
 
 
 
z=20
=20
=20
=20
=20
rž  rê  r4   r4   r5   Útest_encode_whitespace_linesí  s    z'TestQuopri.test_encode_whitespace_linesc                 C   s   |   dd¡ d S )Nza = bza =3D brž  rê  r4   r4   r5   Útest_encode_quoted_equalsð  s    z$TestQuopri.test_encode_quoted_equalsc                 C   s   |   dd¡ d S )NZdxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxzfxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx=
xxxxxxxxxxxxxxxxxxxxxxxxxrž  rê  r4   r4   r5   Útest_encode_one_long_stringó  s    z&TestQuopri.test_encode_one_long_stringc                 C   s   |   dd¡ d S )Nzexxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
zgxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx=
xxxxxxxxxxxxxxxxxxxxxxxxx
rž  rê  r4   r4   r5   Útest_encode_one_long_lineö  s    z$TestQuopri.test_encode_one_long_linec                 C   s   |   dd¡ d S )NzÉxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
zÍxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx=
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx=
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
rž  rê  r4   r4   r5   Útest_encode_one_very_long_lineù  s    ÿz)TestQuopri.test_encode_one_very_long_linec                 C   s   | j dddd d S )Nz=====z=3D=
=3D=
=3D=
=3D=
=3Dr}   r˜  rž  rê  r4   r4   r5   Útest_encode_shortest_maxlinelený  s    z*TestQuopri.test_encode_shortest_maxlinelenc                 C   s   | j t| jdddd d S )Nr)   rœ   r˜  )r‚   r  r  rê  r4   r4   r5   Ú test_encode_maxlinelen_too_small   s    z+TestQuopri.test_encode_maxlinelen_too_smallc                 C   st   | j }|t d¡dƒ |t d¡dƒ |t d¡dƒ |tjddddƒ |tjddd	d
dƒ |t d¡dƒ d S )Nr)   r9  rJ  rK  údxxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx rG  r˜  zjxxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx=
 xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxx=
x xxxx xxxx xxxx xxxx=20r»   rH  zlxxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx=
 xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxx=
x xxxx xxxx xxxx xxxx=20zone line

two line)r-   r!   rC  r)  r4   r4   r5   rI    s    ÿ
ýzTestQuopri.test_encode)N)N)NN)Fro  rp  rq  rë  r^  r_  rb  rc  re  rg  ri  rj  rk  rl  rm  ro  rr  rt  ru  rv  rw  rz  r|  r}  r~  r€  r„  r†  r‡  r‰  rŠ  r‹  rŒ  r  r  r‘  r’  r“  r”  r•  r–  r˜  r™  rš  r›  r  rŸ  r   r¡  r¢  r£  r¥  r¦  r§  r¨  r©  rª  r«  r¬  r®  r¯  r°  r±  r²  r³  r´  rµ  r¶  r·  rI  r4   r4   r4   r5   rN  Ý  s†   


rN  c                   @   s,   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	S )
ÚTestCharsetc                 C   s0   ddl m} z|jd= W n ty*   Y n0 d S )Nr   r  Úfake)r—   r;   ZCHARSETSrE  )r1   ÚCharsetModuler4   r4   r5   ÚtearDown   s
    zTestCharset.tearDownc                 C   sN   | j }tdƒ}|| d¡dƒ d}|  t|j|¡ tdƒ}|| |¡dƒ d S )NrG   úHello World!u   Â¤Â¢Â¤Â¤Â¤Â¦Â¤Â¨Â¤ÂªrM   z(=?utf-8?b?wqTCosKkwqTCpMKmwqTCqMKkwqo=?=)r-   r	   rR  r‚   rY  )r1   r2   rÂ  r¦   r4   r4   r5   Útest_codec_encodeable'  s    z!TestCharset.test_codec_encodeablec                 C   s   | j }tdƒ}|d| d¡ƒ tdƒ}|d| d¡ƒ tdƒ}|d| d¡ƒ td	ƒ}d
dlm} | d|jd d¡ tdƒ}|d| d¡ƒ d S )Nr7   zhello w=F6rldu   hello wÃ¶rldrM   r†  r    rG   r€  r„  r   r  rº  )r-   r	   rC  r—   r;   Zadd_charsetZQP)r1   r2   rÂ  r»  r4   r4   r5   Útest_body_encode2  s    zTestCharset.test_body_encodec                 C   s,   t dƒ}|  t|ƒd¡ |  tjt d¡ d S )NrG   u   ascÃ¿ii)r	   r-   r±   r‚   r   ZCharsetErrorr„  r4   r4   r5   Útest_unicode_charset_nameQ  s    z%TestCharset.test_unicode_charset_nameN)ro  rp  rq  r¼  r¾  r¿  rÀ  r4   r4   r4   r5   r¹    s   r¹  c                   @   sÔ   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ Zdd„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd „ Zd!d"„ Zd#d$„ Zd%d&„ Zd'd(„ Zd)d*„ Zd+d,„ Zd-d.„ Zd/d0„ Zd1d2„ Zd3S )4Ú
TestHeaderc                 C   s8   | j }tdƒ}|| ¡ dƒ | d¡ || ¡ dƒ d S )Nr½  z Goodbye World!zHello World!  Goodbye World!©r‰  r
   r–   rš  r¥  r4   r4   r5   Útest_simpleZ  s
    
zTestHeader.test_simplec                 C   s8   | j }tdƒ}|| ¡ dƒ | d¡ || ¡ dƒ d S )Nr½  zGoodbye World!zHello World! Goodbye World!rÂ  r¥  r4   r4   r5   Útest_simple_surprisea  s
    
zTestHeader.test_simple_surprisec                 C   s   d}|   t|ƒ|d fg¡ d S )Nzno decoding neededr›  r­  r4   r4   r5   Útest_header_needs_no_decodingh  s    z(TestHeader.test_header_needs_no_decodingc                 C   s8   t ddd}|jdd d¡D ]}|  t|ƒd¡ qd S )Na¶  I 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.rw  r˜  r*   )Z
splitcharsz
 )r
   r–   r²   rz  ru  )r1   r‘  Úlr4   r4   r5   Ú	test_longl  s
    ÿzTestHeader.test_longc                 C   sæ   | j }tdƒ}tdƒ}tdƒ}d}d}d}t||ƒ}| ||¡ | ||¡ |jdd}	||	d	ƒ t|	ƒ}
|t|
ƒd
ƒ ||
d |dfƒ ||
d |dfƒ ||
d | d¡dfƒ t|ƒ}||d d¡ƒ t	t|	ƒƒ}|||ƒ d S )Nr7   rb   rM   r“  r”  r•  rw  r˜  a  =?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?=rœ   r   rr   r›   sâ  Die 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.ã€ã¨è¨€ã£ã¦ã„ã¾ã™ã€‚)
r‰  r	   r
   rš  r–   r   ru  r±   rP   r   )r1   r2   r§   r›  rœ  r  rž  rŸ  r‘  Úencry  ZustrZnewhr4   r4   r5   Útest_multilingualr  s2    

ðÿzTestHeader.test_multilingualc                 C   s   t ƒ }|  | ¡ d¡ d S rp  r¬  r­  r4   r4   r5   Útest_empty_header_encode±  s    z#TestHeader.test_empty_header_encodec                 C   s4   | j }tƒ }||dƒ | dtdƒ¡ ||dƒ d S )Nr)   r¡   r7   )r‰  r
   rš  r	   r¥  r4   r4   r5   Útest_header_ctor_default_argsµ  s
    
z(TestHeader.test_header_ctor_default_argsc                 C   s„   | j }d}t|ƒ}|| ¡ dƒ |t|ƒ|ƒ t|dd}|| ¡ dƒ |t|ƒ|ƒ t|ddd}|| ¡ |ƒ |t|ƒ|ƒ d S )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 behaviorrj  r–  z}A very long line that must get split to something other than at the
 76th character boundary to test the non-default behaviori   )r™  r—  )r‰  r
   r–   r±   r  r4   r4   r5   Útest_explicit_maxlinelen¼  s    z#TestHeader.test_explicit_maxlinelenc                 C   sŠ   | j }tddd}d}| |¡ | ¡ }||dƒ ||ttt|ƒƒƒƒ tddd}| d¡ | ¡ }||dƒ ||ttt|ƒƒƒƒ d S )Nr7   rA  ©r;   r™  r¸  a  =?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?_?=rG  zÁ=?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_?=©r‰  r
   rš  r–   r±   r   r   ©r1   r2   r‘  rN  r¦   r4   r4   r5   Útest_quopri_splittableÏ  s    

3

z!TestHeader.test_quopri_splittablec                 C   sŠ   | j }tddd}d}| |¡ | ¡ }||dƒ ||ttt|ƒƒƒƒ tddd}| |¡ | ¡ }||dƒ ||ttt|ƒƒƒƒ d S )Nrc   rA  rÍ  r¸  a„  =?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==?=rG  zà=?koi8-r?b?eHh4eCB4eHh4IHh4eHggeHh4?=
 =?koi8-r?b?eCB4eHh4IHh4eHggeHh4eCB4?=
 =?koi8-r?b?eHh4IHh4eHggeHh4eCB4eHh4?=
 =?koi8-r?b?IHh4eHggeHh4eCB4eHh4IHh4?=
 =?koi8-r?b?eHggeHh4eCB4eHh4IHh4eHgg?=
 =?koi8-r?b?eHh4eCB4eHh4IA==?=rÎ  rÏ  r4   r4   r5   Útest_base64_splittable  s    

#

z!TestHeader.test_base64_splittablec                 C   s8   | j }d}t|ƒ}||dgƒ t|ƒ}||| ¡ ƒ d S )Nr9  )r9  N©r-   r   r   r–   )r1   r2   r¦   rN  r‘  r4   r4   r5   Útest_us_ascii_headerJ  s    zTestHeader.test_us_ascii_headerc                 C   s&   | j }tƒ }| dd¡ ||dƒ d S )Nr9  r7   )r-   r
   rš  r¥  r4   r4   r5   Útest_string_charsetR  s    zTestHeader.test_string_charsetc                 C   s:   | j }tddƒ}|| ¡ dƒ tddƒ}|| ¡ dƒ d S )Nrñ  rM   z=?utf-8?q?p=C3=B6stal?=u   èŠåœ°æ™‚å¤«z=?utf-8?b?6I+K5Zyw5pmC5aSr?=©r-   r
   r–   r¥  r4   r4   r5   Útest_utf8_shortesta  s
    

zTestHeader.test_utf8_shortestc                 C   sr   | j }| j}d}|tt|ƒ tƒ }|t|j|ƒ | dd¡}|tt|ddƒ|ƒ |j|dd |t|ƒ|ƒ d S )Nó0   Ynwp4dUEbay Auction Semiar- No Charge – Earn BigrM   rË   r   )r‚   r-   rY  r
   rš  rP   r±   )r1   rB  r2   rN  r‘  Úer4   r4   r5   Útest_bad_8bit_headerh  s    zTestHeader.test_bad_8bit_headerc                 C   sN   d}|  dd¡}t|tjjd}|  t|ƒd¡ |  tj |¡|dfg¡ d S )Nr×  r•   Úsurrogateescaper  õ2   Ynwp4dUEbay Auction Semiar- No Charge ï¿½ Earn Bigúunknown-8bit)	rP   r
   r—   r;   ÚUNKNOWN8BITr-   r±   r„   r   )r1   rN  rØ  r‘  r4   r4   r5   Útest_escaped_8bit_headert  s    
ÿz#TestHeader.test_escaped_8bit_headerc                 C   sB   d}t |tjjd}|  t|ƒd¡ |  tj |¡|dfg¡ d S ©Nr×  r  rÛ  rÜ  )r
   r—   r;   rÝ  r-   r±   r„   r   )r1   rN  r‘  r4   r4   r5   Ú&test_header_handles_binary_unknown8bit|  s    
ÿz1TestHeader.test_header_handles_binary_unknown8bitc                 C   sV   d}t |tjjd}tj tj |¡¡}|  t|ƒd¡ |  tj |¡|dfg¡ d S rß  )	r
   r—   r;   rÝ  r„   r   r   r-   r±   )r1   rN  r‘  Zh2r4   r4   r5   Ú+test_make_header_handles_binary_unknown8bitƒ  s    
ÿz6TestHeader.test_make_header_handles_binary_unknown8bitc                 C   s2   t dƒ}tj |¡}| d¡ |  t|ƒd¡ d S )Nr  )r•   Ztest2)r
   r—   r„   r   rš  r-   r±   )r1   r‘  r¾  r4   r4   r5   Ú0test_modify_returned_list_does_not_change_header‹  s    
z;TestHeader.test_modify_returned_list_does_not_change_headerc                 C   sR   | j }tƒ }| dd¡ | d¡ | ¡ }||dƒ tt|ƒƒ}|| ¡ |ƒ d S )Nr9  r7   Zworldz=?iso-8859-1?q?hello?= world)r-   r
   rš  r–   r   r   )r1   r2   r‘  r¦   r4   r4   r5   Ú test_encoded_adjacent_nonencoded‘  s    

z+TestHeader.test_encoded_adjacent_nonencodedc                 C   s:   | j }d}t|ƒ}||g d¢ƒ t|ƒ}|| ¡ dƒ d S )NzGSubject: =?koi8-r?b?8NLP18XSy8EgzsEgxsnOwczYztk=?= =?koi8-r?q?=CA?= zz.))s	   Subject: N)s   ðÒÏ×ÅÒËÁ ÎÁ ÆÉÎÁÌØÎÙÊrc   )s    zz.Nz6Subject: =?koi8-r?b?8NLP18XSy8EgzsEgxsnOwczYztnK?= zz.rÒ  )r1   r2   r¦   ÚpartsZhdrr4   r4   r5   Útest_whitespace_keeper›  s    ÿz!TestHeader.test_whitespace_keeperc                 C   s   | j }d}|tjt|ƒ d S )NzXSubject: =?EUC-KR?B?CSixpLDtKSC/7Liuvsax4iC6uLmwMcijIKHaILzSwd/H0SC8+LCjwLsgv7W/+Mj3I ?=)r‚   r   rƒ   r   )r1   rB  r¦   r4   r4   r5   Útest_broken_base64_header¤  s    z$TestHeader.test_broken_base64_headerc                 C   s    t ddd}|  | ¡ d¡ d S )Nrª  Ú	shift_jisr  r«  r¬  r­  r4   r4   r5   Útest_shift_jis_charset©  s    z!TestHeader.test_shift_jis_charsetc                 C   s   t  d¡}|  t|ƒd¡ d S )NzEmptyHeader:zEmptyHeader: 

)r—   rÔ   r-   r±   r\   r4   r4   r5   Ú!test_flatten_header_with_no_value­  s    
z,TestHeader.test_flatten_header_with_no_valuec                 C   s"   t ƒ }d|d< |  t|ƒd¡ d S )Nz   value with leading wsZ
SomeHeaderz&SomeHeader:    value with leading ws

)r   r-   r±   r\   r4   r4   r5   Ú)test_encode_preserves_leading_ws_on_value´  s    z4TestHeader.test_encode_preserves_leading_ws_on_valuec                 C   s   |   tdƒ ¡ d¡ d S )Nr*   rÕ  rê  r4   r4   r5   Útest_whitespace_header¹  s    z!TestHeader.test_whitespace_headerN)ro  rp  rq  rÃ  rÄ  rÅ  rÇ  rÉ  rÊ  rË  rÌ  rÐ  rÑ  rÓ  rÔ  rÖ  rÙ  rÞ  rà  rá  râ  rã  rå  ræ  rè  ré  rê  rë  r4   r4   r4   r5   rÁ  Y  s2   ?E6
	rÁ  c                   @   sü   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ Zdd„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd „ Zd!d"„ Zd#d$„ Zd%d&„ Zd'd(„ Zd)d*„ Zd+d,„ Zd-d.„ Zd/d0„ Zd1d2„ Zd3d4„ Zd5d6„ Zd7d8„ Zd9d:„ Zd;d<„ Z d=S )>ÚTestRFC2231c                 C   s8   | j }|  d¡}|| d¡dƒ ||jddddƒ d S )Nz
msg_29.txtr  ©rG   r  ú%This is even more ***fun*** isn't it!Frì   )rG   r  z'"This is even more ***fun*** isn't it!")r-   r.   rC   r0   r4   r4   r5   ré   Ã  s    

ÿÿzTestRFC2231.test_get_paramc                 C   s€   | j }tƒ }|jdddd || d¡dƒ |jddddd || d¡dƒ |  d	¡}|jddddd ||jd
ddƒ d S )Nr  rî  rG   r  )rG   r)   rî  r  ©r;   Úlanguagerí  r|   rÎ  rÐ  a"  Return-Path: <bbb@zzz.org>
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
)r‰  r   rö   rC   r.   rˆ   r0   r4   r4   r5   r÷   Ë  s&    ÿ
ÿÿ
ÿ
ÿzTestRFC2231.test_set_paramc                 C   sf   t ƒ }| dd¡ |  |d d¡ |jdddd |  |d d¡ |jdd	dd |  |d d
¡ d S )Nr  r¡   r:   ztext/plain; title="foo"rà   F)Zrequoteztext/plain; title=barz	(bar)bellztext/plain; title="(bar)bell")r   rö   r-   r\   r4   r4   r5   Útest_set_param_requoteð  s    z"TestRFC2231.test_set_param_requotec                 C   sX   | j }|  d¡}|jddddd |jddddd |jdd	d
 ||jdddƒ d S )Nr|   r¡   rà   rG   r  rï  r  rî  r>   rÞ   rÎ  rÐ  a$  Return-Path: <bbb@zzz.org>
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
)r‰  r.   rö   rÿ   rˆ   r0   r4   r4   r5   r   ú  s    
ÿzTestRFC2231.test_del_paramc                 C   s"   | j }|  d¡}|| ¡ dƒ d S )Nrî  rG   )r-   r.   Úget_content_charsetr0   r4   r4   r5   Ú test_rfc2231_get_content_charset  s    
z,TestRFC2231.test_rfc2231_get_content_charsetc                 C   s8   t  d¡}t |¡}|  | ¡ d¡ |  || ¡ ¡ d S )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.pdf©rÃ   rÄ   r—   rÔ   r-   rj   rˆ   rî  r4   r4   r5   Útest_rfc2231_parse_rfc_quoting!  s    


ÿz*TestRFC2231.test_rfc2231_parse_rfc_quotingc                 C   s8   t  d¡}t |¡}|  | ¡ d¡ |  || ¡ ¡ d S )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"

            rô  rõ  rî  r4   r4   r5   Ú test_rfc2231_parse_extra_quoting/  s    


ÿz,TestRFC2231.test_rfc2231_parse_extra_quotingc                 C   s4   d}t  |¡}| d¡}|  |t¡ |  |d¡ d S )Na  Content-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.htm©r—   rÔ   rC   ZassertNotIsInstanceÚtupler-   ©r1   rÇ   r3   Zparamr4   r4   r5   Ú#test_rfc2231_no_language_or_charset?  s    

þz/TestRFC2231.test_rfc2231_no_language_or_charsetc                 C   s"   d}t  |¡}|  | ¡ d¡ d S ©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"

rô  r×   rî  r4   r4   r5   Ú/test_rfc2231_no_language_or_charset_in_filenameN  s
    

ÿz;TestRFC2231.test_rfc2231_no_language_or_charset_in_filenamec                 C   s"   d}t  |¡}|  | ¡ d¡ d S rý  r×   rî  r4   r4   r5   Ú7test_rfc2231_no_language_or_charset_in_filename_encoded[  s
    

ÿzCTestRFC2231.test_rfc2231_no_language_or_charset_in_filename_encodedc                 C   s"   d}t  |¡}|  | ¡ d¡ d S )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.pdfr×   rî  r4   r4   r5   Útest_rfc2231_partly_encodedi  s    
þz'TestRFC2231.test_rfc2231_partly_encodedc                 C   s"   d}t  |¡}|  | ¡ d¡ d S )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"

z?This%20is%20even%20more%20%2A%2A%2Afun%2A%2A%2A%20is it not.pdfr×   rî  r4   r4   r5   Útest_rfc2231_partly_nonencodedv  s    
þz*TestRFC2231.test_rfc2231_partly_nonencodedc                 C   s"   d}t  |¡}|  | ¡ d¡ d S )Nz˜Content-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"

rô  rÚ   rî  r4   r4   r5   Ú/test_rfc2231_no_language_or_charset_in_boundaryƒ  s
    

ÿz;TestRFC2231.test_rfc2231_no_language_or_charset_in_boundaryc                 C   s"   d}t  |¡}|  | ¡ d¡ d S )NzˆContent-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.pdf©r—   rÔ   r-   rò  rî  r4   r4   r5   Ú.test_rfc2231_no_language_or_charset_in_charset  s
    

ÿz:TestRFC2231.test_rfc2231_no_language_or_charset_in_charsetc                 C   s"   d}t  |¡}|  | ¡ d¡ d S )Nz—Content-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"

rô  r×   rî  r4   r4   r5   Ú%test_rfc2231_bad_encoding_in_filename  s
    

ÿz1TestRFC2231.test_rfc2231_bad_encoding_in_filenamec                 C   s"   d}t  |¡}|  | ¡ d ¡ d S )Nz:Content-Type: text/plain; charset*=bogus''utf-8%E2%80%9D

r  rî  r4   r4   r5   Ú$test_rfc2231_bad_encoding_in_charset©  s    
z0TestRFC2231.test_rfc2231_bad_encoding_in_charsetc                 C   s"   d}t  |¡}|  | ¡ d ¡ d S )Nz:Content-Type: text/plain; charset*=ascii''utf-8%E2%80%9D

r  rî  r4   r4   r5   Ú%test_rfc2231_bad_character_in_charset³  s    
z1TestRFC2231.test_rfc2231_bad_character_in_charsetc                 C   s"   d}t  |¡}|  | ¡ d¡ d S )Nz›Content-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ï¿½r×   rî  r4   r4   r5   Ú&test_rfc2231_bad_character_in_filename½  s
    

ÿz2TestRFC2231.test_rfc2231_bad_character_in_filenamec                 C   s"   d}t  |¡}|  | ¡ d¡ d S )Nz^Content-Transfer-Encoding: 8bit
Content-Disposition: inline; filename*=X-UNKNOWN''myfile.txt

ú
myfile.txtr×   rî  r4   r4   r5   Útest_rfc2231_unknown_encodingÉ  s    
z)TestRFC2231.test_rfc2231_unknown_encodingc                 C   s"   d}t  |¡}|  | ¡ d¡ d S )Nuc   Content-Transfer-Encoding: 8bit
Content-Disposition: inline; filename*=utf-8í³¢í²€í²''myfile.txt

r	  r×   rî  r4   r4   r5   Ú&test_rfc2231_bad_character_in_encodingÒ  s    
z2TestRFC2231.test_rfc2231_bad_character_in_encodingc                 C   sF   | j }d}t |¡}| d¡\}}}||d ƒ ||d ƒ ||dƒ d S )NzJContent-Type: application/x-foo;
	name*0*="Frank's"; name*1*=" Document"

rê   úFrank's Documentrè   ©r1   r2   rÇ   r3   r;   rð  r¦   r4   r4   r5   Ú-test_rfc2231_single_tick_in_filename_extendedÛ  s    


z9TestRFC2231.test_rfc2231_single_tick_in_filename_extendedc                 C   s4   d}t  |¡}| d¡}|  |t¡ |  |d¡ d S )NzGContent-Type: application/x-foo; name*0="Frank's"; name*1=" Document"

rê   r  rù  rû  r4   r4   r5   Ú$test_rfc2231_single_tick_in_filenameé  s
    

z0TestRFC2231.test_rfc2231_single_tick_in_filenamec                 C   s"   d}t  |¡}|  | ¡ d¡ d S )NzAContent-Disposition: inline;
	filename*0*="'This%20is%20broken";
z'This is brokenr×   rî  r4   r4   r5   Útest_rfc2231_missing_tickó  s    
þz%TestRFC2231.test_rfc2231_missing_tickc                 C   s"   d}t  |¡}|  | ¡ d¡ d S )NzAContent-Disposition: inline;
	filename*0*="'This%20is%E2broken";
u   'This isï¿½brokenr×   rî  r4   r4   r5   Ú0test_rfc2231_missing_tick_with_encoded_non_asciiý  s    
þz<TestRFC2231.test_rfc2231_missing_tick_with_encoded_non_asciic                 C   sF   | j }d}t |¡}| d¡\}}}||dƒ ||dƒ ||dƒ d S )NzYContent-Type: application/x-foo;
	name*0*="us-ascii'en-us'Frank's"; name*1*=" Document"

rê   rG   úen-usr  rè   r  r4   r4   r5   Ú!test_rfc2231_tick_attack_extended  s    


z-TestRFC2231.test_rfc2231_tick_attack_extendedc                 C   s4   d}t  |¡}| d¡}|  |t¡ |  |d¡ d S )NzWContent-Type: application/x-foo;
	name*0="us-ascii'en-us'Frank's"; name*1=" Document"

rê   zus-ascii'en-us'Frank's Documentrù  rû  r4   r4   r5   Útest_rfc2231_tick_attack  s
    

z$TestRFC2231.test_rfc2231_tick_attackc                 C   s(   | j }d}t |¡}|| d¡dƒ d S )Nz:Content-Type: application/x-foo; name="Frank's Document"

rê   r  rè   rã  r4   r4   r5   Útest_rfc2231_no_extended_values"  s    
z+TestRFC2231.test_rfc2231_no_extended_valuesc                 C   sF   | j }d}t |¡}| d¡\}}}||dƒ ||dƒ ||dƒ d S )NziContent-Type: application/x-foo;
	name*0*="us-ascii'en-us'My";
	name*1=" Document";
	name*2*=" For You"

rê   rG   r  úMy Document For Yourè   r  r4   r4   r5   Ú,test_rfc2231_encoded_then_unencoded_segments,  s    


z8TestRFC2231.test_rfc2231_encoded_then_unencoded_segmentsc                 C   sF   | j }d}t |¡}| d¡\}}}||dƒ ||dƒ ||dƒ d S )NziContent-Type: application/x-foo;
	name*0="us-ascii'en-us'My";
	name*1*=" Document";
	name*2*=" For You"

rê   rG   r  r  rè   r  r4   r4   r5   Ú,test_rfc2231_unencoded_then_encoded_segments=  s    


z8TestRFC2231.test_rfc2231_unencoded_then_encoded_segmentsc              	   C   sL   ddg}|D ]:}| j |d t |¡}W d   ƒ q1 s<0    Y  qd S )NzÿFrom: user@host.com
To: user@host.com
Bad-Header:
 =?us-ascii?Q?LCSwrV11+IB0rSbSker+M9vWR7wEDSuGqmHD89Gt=ea0nJFSaiz4vX3XMJPT4vrE?=
 =?us-ascii?Q?xGUZeOnp0o22pLBB7CYLH74Js=wOlK6Tfru2U47qR?=
 =?us-ascii?Q?72OfyEY2p2=2FrA9xNFyvH+fBTCmazxwzF8nGkK6D?=

Hello!
u‹  From: Ã¯Â¿Â½Ã¯Â¿Â½Ã¯Â¿Â½Ã¯Â¿Â½Ã¯Â¿Â½ Ã¯Â¿Â½Ã¯Â¿Â½Ã¯Â¿Â½Ã¯Â¿Â½Ã¯Â¿Â½Ã¯Â¿Â½Ã¯Â¿Â½Ã¯Â¿Â½ <xxx@xxx>
To: "xxx" <xxx@xxx>
Subject:   Ã¯Â¿Â½Ã¯Â¿Â½Ã¯Â¿Â½ Ã¯Â¿Â½Ã¯Â¿Â½Ã¯Â¿Â½Ã¯Â¿Â½Ã¯Â¿Â½Ã¯Â¿Â½Ã¯Â¿Â½Ã¯Â¿Â½Ã¯Â¿Â½Ã¯Â¿Â½ Ã¯Â¿Â½Ã¯Â¿Â½Ã¯Â¿Â½Ã¯Â¿Â½Ã¯Â¿Â½ Ã¯Â¿Â½Ã¯Â¿Â½Ã¯Â¿Â½Ã¯Â¿Â½Ã¯Â¿Â½ Ã¯Â¿Â½ Ã¯Â¿Â½Ã¯Â¿Â½Ã¯Â¿Â½Ã¯Â¿Â½Ã¯Â¿Â½Ã¯Â¿Â½Ã¯Â¿Â½Ã¯Â¿Â½Ã¯Â¿Â½ Ã¯Â¿Â½Ã¯Â¿Â½ Ã¯Â¿Â½Ã¯Â¿Â½Ã¯Â¿Â½Ã¯Â¿Â½
MIME-Version: 1.0
Content-Type: text/plain; charset="windows-1251";
Content-Transfer-Encoding: 8bit

Ã¯Â¿Â½Ã¯Â¿Â½ Ã¯Â¿Â½Ã¯Â¿Â½Ã¯Â¿Â½Ã¯Â¿Â½Ã¯Â¿Â½ Ã¯Â¿Â½ Ã¯Â¿Â½Ã¯Â¿Â½Ã¯Â¿Â½Ã¯Â¿Â½ Ã¯Â¿Â½Ã¯Â¿Â½Ã¯Â¿Â½Ã¯Â¿Â½Ã¯Â¿Â½Ã¯Â¿Â½ Ã¯Â¿Â½Ã¯Â¿Â½Ã¯Â¿Â½ Ã¯Â¿Â½Ã¯Â¿Â½Ã¯Â¿Â½Ã¯Â¿Â½Ã¯Â¿Â½Ã¯Â¿Â½Ã¯Â¿Â½Ã¯Â¿Â½
)rÇ   )r›  r—   rÔ   )r1   ÚmessagesrÇ   r3   r4   r4   r5   Ú+test_should_not_hang_on_invalid_ew_messagesL  s    øz7TestRFC2231.test_should_not_hang_on_invalid_ew_messagesN)!ro  rp  rq  ré   r÷   rñ  r   ró  rö  r÷  rü  rþ  rÿ  r   r  r  r  r  r  r  r  r
  r  r  r  r  r  r  r  r  r  r  r  r4   r4   r4   r5   rì  ¿  s<   %
!

		


rì  c                   @   s4   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ ZdS )Ú
TestSignedc                 C   sB   t |ƒ"}| ¡ }t |¡}W d   ƒ n1 s00    Y  ||fS rZ   rÛ  )r1   r  r   Úoriginalr3   r4   r4   r5   Ú_msg_and_objh  s    
(zTestSigned._msg_and_objc                 C   sL   dd l }| d|j|jB ¡}| |¡ d¡}| |¡ d¡}|  ||¡ d S )Nr   z^--([^\n]+)\n(.*?)\n--\1$r›   )r5  r6  ÚSrÉ  ÚsearchÚgroupr-   )r1   r  Úresultr5  ZrepartZinpartZoutpartr4   r4   r5   Ú_signed_parts_eqn  s
    zTestSigned._signed_parts_eqc                 C   s&   |   d¡\}}| ¡ }|  ||¡ d S rö  ©r  rˆ   r"  ©r1   r  r3   r!  r4   r4   r5   Útest_long_headers_as_stringv  s    z&TestSigned.test_long_headers_as_stringc                 C   s*   |   d¡\}}|jdd}|  ||¡ d S )Nr÷  é<   rÐ  r#  r$  r4   r4   r5   Ú(test_long_headers_as_string_maxheaderlen{  s    z3TestSigned.test_long_headers_as_string_maxheaderlenc                 C   s:   |   d¡\}}tƒ }t|ƒ |¡ | ¡ }|  ||¡ d S rö  )r  r   r   r   rŽ   r"  )r1   r  r3   r   r!  r4   r4   r5   Útest_long_headers_flatten€  s
    z$TestSigned.test_long_headers_flattenN)ro  rp  rq  r  r"  r%  r'  r(  r4   r4   r4   r5   r  f  s
   r  Ú__main__)ar5  r8  rN   r.  rÃ   Úior   r   Ú	itertoolsr   Úrandomr   Ú	threadingr   Zunittest.mockr   r—   Zemail.policyZemail.charsetr	   Zemail.headerr
   r   r   Zemail.parserr   r   Zemail.generatorr   r   r   Zemail.messager   Zemail.mime.applicationr   Zemail.mime.audior   Zemail.mime.textr   Zemail.mime.imager   Zemail.mime.baser   Zemail.mime.messager   Zemail.mime.multipartr   Zemail.mime.nonmultipartr   r   r   r   r   r    r!   Ztest.supportr"   r#   Ztest.test_emailr$   r%   r&   r'   rµ   r¡  r¹  r+   ZTestCaserr  rˆ  ré  rõ  r	  r  r  r0  ri  r…  r¯  r×  rÚ  rü  rŸ  r»  rÌ  rð  r/  r3  r7  r8  rN  r¹  rÁ  rì  r  ro  Úmainr4   r4   r4   r5   Ú<module>   sÌ        lC    AO((\<    0   9      "g0 K   !ÿÿ5  D:  h   *#
