B
    18™\éå  ã               @   s`  d dl Z d dlZd dlZd dlmZ d dlmZ d dlmZ d dlm	Z	m
Z
 d dlmZ d dlmZmZ eƒ ZG dd	„ d	e	ƒZG d
d„ de	ƒZG dd„ deƒZe
G dd„ deƒƒZe
G dd„ deƒƒZe
G dd„ deƒƒZe
G dd„ deƒƒZe
G dd„ deƒƒZe
G dd„ deƒƒZe
G dd„ deƒƒZG dd„ de	ƒZG dd„ deƒZed kr\e ¡  dS )!é    N)Úerrors)Úpolicy)ÚMessage)ÚTestEmailBaseÚparameterize)Úheaderregistry)ÚAddressÚGroupc               @   s`   e Zd Zdd„ Zdd„ ZG dd„ dƒZdd„ ZG d	d
„ d
ƒZdd„ Zdd„ Z	dd„ Z
dd„ ZdS )ÚTestHeaderRegistryc             C   s2   t  ¡ }|ddƒ}|  |t j¡ |  |t j¡ d S )NÚfoobarÚtest)r   ÚHeaderRegistryÚassertIsInstanceÚ
BaseHeaderÚUnstructuredHeader)ÚselfÚfactoryÚh© r   úg/oak/stanford/groups/akundaje/marinovg/programs/Python-3.7.3/Lib/test/test_email/test_headerregistry.pyÚ test_arbitrary_name_unstructured   s    
z3TestHeaderRegistry.test_arbitrary_name_unstructuredc             C   s@   t  ¡ }|  d|j¡ |ddƒ}|  |t j¡ |  |t j¡ d S )NÚSubjectr   )r   r   ÚassertNotInÚregistryr   r   ÚUniqueUnstructuredHeader)r   r   r   r   r   r   Útest_name_case_ignored   s
    
z)TestHeaderRegistry.test_name_case_ignoredc               @   s   e Zd Zdd„ ZdS )zTestHeaderRegistry.FooBasec             O   s   d S )Nr   )r   ÚargsÚkwr   r   r   Ú__init__    s    z#TestHeaderRegistry.FooBase.__init__N)Ú__name__Ú
__module__Ú__qualname__r   r   r   r   r   ÚFooBase   s   r"   c             C   s8   t j| jd}|ddƒ}|  || j¡ |  |t j¡ d S )N)Ú
base_classr   r   )r   r   r"   r   r   )r   r   r   r   r   r   Ú test_override_default_base_class#   s    
z3TestHeaderRegistry.test_override_default_base_classc               @   s   e Zd ZejjZdS )zTestHeaderRegistry.FooDefaultN)r   r    r!   r   r   Úparser   r   r   r   Ú
FooDefault)   s   r&   c             C   s8   t j| jd}|ddƒ}|  |t j¡ |  || j¡ d S )N)Údefault_classr   r   )r   r   r&   r   r   )r   r   r   r   r   r   Útest_override_default_class,   s    
z.TestHeaderRegistry.test_override_default_classc             C   s8   t j| jd}|ddƒ}|  |t j¡ |  |t j¡ d S )N)r'   Úsubjectr   )r   r   r&   r   r   r   )r   r   r   r   r   r   Ú2test_override_default_class_only_overrides_default2   s    
zETestHeaderRegistry.test_override_default_class_only_overrides_defaultc             C   s6   t jdd}|ddƒ}|  |t j¡ |  |t j¡ d S )NF)Úuse_default_mapr)   r   )r   r   r   r   r   )r   r   r   r   r   r   Útest_dont_use_default_map8   s    
z,TestHeaderRegistry.test_dont_use_default_mapc             C   sf   t  ¡ }|ddƒ}| dt j¡ |ddƒ}|  |t j¡ |  |t j¡ |  |t j¡ |  |t j¡ d S )Nr   r   )r   r   Úmap_to_typer   r   r   r   )r   r   Zh1Úh2r   r   r   Útest_map_to_type>   s    

z#TestHeaderRegistry.test_map_to_typeN)r   r    r!   r   r   r"   r$   r&   r(   r*   r,   r/   r   r   r   r   r
      s   r
   c               @   s   e Zd Ze ¡ Zdd„ ZdS )ÚTestHeaderBasec             C   s   |   ||¡S )N)r   )r   ÚnameÚvaluer   r   r   Úmake_headerM   s    zTestHeaderBase.make_headerN)r   r    r!   r   r   r   r3   r   r   r   r   r0   I   s   r0   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 )ÚTestBaseHeaderFeaturesc             C   s8   |   dd¡}|  |t¡ |  |d¡ |  t|ƒd¡ d S )Nr)   zthis is a test)r3   r   ÚstrÚassertEqual)r   r   r   r   r   Útest_strS   s    zTestBaseHeaderFeatures.test_strc             C   s$   |   dd¡}|  |dd… d¡ d S )Nr)   zthis is a testé   é   Úis)r3   r6   )r   r   r   r   r   Útest_substrY   s    z"TestBaseHeaderFeatures.test_substrc             C   s   |   dd¡}|  |jd¡ d S )Nr)   zthis is a test)r3   r6   r1   )r   r   r   r   r   Útest_has_name]   s    z$TestBaseHeaderFeatures.test_has_namec          	   C   s2   |   dd¡}|  t¡ t||dƒ W d Q R X d S )Nr)   zthis is a testÚfoo)r3   ÚassertRaisesÚAttributeErrorÚsetattr)r   Úattrr   r   r   r   Ú_test_attr_roa   s    z$TestBaseHeaderFeatures._test_attr_roc             C   s   |   d¡ d S )Nr1   )rB   )r   r   r   r   Útest_name_read_onlyf   s    z*TestBaseHeaderFeatures.test_name_read_onlyc             C   s   |   d¡ d S )NÚdefects)rB   )r   r   r   r   Útest_defects_read_onlyi   s    z-TestBaseHeaderFeatures.test_defects_read_onlyc             C   s\   |   dd¡}|  t|jƒd¡ |  |jt¡ |   dd¡}|  t|jƒd¡ |  |jt¡ d S )Nr)   zthis is a testr   ÚdateÚ é   )r3   r6   ÚlenrD   r   Útuple)r   r   r   r   r   Útest_defects_is_tuplel   s    z,TestBaseHeaderFeatures.test_defects_is_tupleN)
r   r    r!   r7   r;   r<   rB   rC   rE   rK   r   r   r   r   r4   Q   s   r4   c               @   s2   e Zd Zdd„ Zddg dfddg dfdd	d
œZdS )ÚTestUnstructuredHeaderc       	      G   sˆ   t |ƒ}|dkr|d ng }d|r&dnd }||dkr>|d n| d }|  d|¡}|  ||¡ |  |j|¡ |  |jtjd|¡ d S )	Nr   zSubject:ú rG   rH   Ú
r   )r   )rI   r3   r6   ÚassertDefectsEqualrD   Úfoldr   Údefault)	r   ÚsourceÚdecodedr   ÚlrD   ÚheaderÚfoldedr   r   r   r   Ústring_as_value‚   s    z&TestUnstructuredHeader.string_as_valuez=?utf-8?q?this_is_a_test?=zthis is a testz!=?gb2312?b?1eLKx9bQzsSy4srUo6E=?=u   è¿™æ˜¯ä¸­æ–‡æµ‹è¯•ï¼z(=?utf-8?b?6L+Z5piv5Lit5paH5rWL6K+V77yB?=)z=?utf-8?q?=C3=89ric?=u   Ã‰ric)z$The =?utf-8?q?=C3=89ric=2C?= Himselfu   The Ã‰ric, Himself)Zrfc2047_simple_quopriZrfc2047_gb2312_base64Zrfc2047_simple_nonascii_quopriZ rfc2047_quopri_with_regular_textN)r   r    r!   rW   Zstring_paramsr   r   r   r   rL      s   rL   c            	   @   sv   e Zd ZdZejddZe e¡Zejdddddd	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S )ÚTestDateHeaderzSun, 23 Sep 2001 20:10:55 -0700iùÿÿÿ)ÚhoursiÑ  é	   é   é   é
   é7   )Útzinfoc             C   sR   |   d| j¡}|  || j¡ |  |j| j¡ |  |j ¡ | j¡ |  |jd¡ d S )NrF   r   )r3   Ú
datestringr6   ÚdatetimeÚdtÚ	utcoffsetrD   )r   r   r   r   r   Útest_parse_date°   s
    zTestDateHeader.test_parse_datec             C   s>   |   d| j¡}|  || j¡ |  |j| j¡ |  |jd¡ d S )NrF   r   )r3   rb   r6   r`   ra   rD   )r   r   r   r   r   Útest_set_from_datetime·   s    z%TestDateHeader.test_set_from_datetimec             C   s<   |   d| j¡}|  |tj¡ |  |jd¡ |  |jd¡ d S )NrF   rH   r   )r3   r`   r   r   ÚUniqueDateHeaderr6   Ú	max_countrD   )r   r   r   r   r   Útest_date_header_properties½   s    z*TestDateHeader.test_date_header_propertiesc             C   s<   |   d| j¡}|  |tj¡ |  |jd ¡ |  |jd¡ d S )Nzresent-dater   )r3   r`   r   r   Ú
DateHeaderr6   rg   rD   )r   r   r   r   r   Ú"test_resent_date_header_propertiesÃ   s    z1TestDateHeader.test_resent_date_header_propertiesc             C   s6   |   dd¡}|  t|jƒd¡ |  |jd tj¡ d S )NrF   rG   rH   r   )r3   r6   rI   rD   r   r   ÚHeaderMissingRequiredValue)r   r   r   r   r   Útest_no_value_is_defectÉ   s    z&TestDateHeader.test_no_value_is_defectc          	   C   s.   |   d| j¡}|  t¡ d|_W d Q R X d S )NrF   r=   )r3   r`   r>   r?   ra   )r   r   r   r   r   Útest_datetime_read_onlyÎ   s    z&TestDateHeader.test_datetime_read_onlyc             C   s@   t tjd}| j|d< |  |d | j¡ |  |d j| j¡ d S )N)r   ÚDate)r   r   rQ   rb   r6   r`   ra   )r   Úmr   r   r   Ú"test_set_date_header_from_datetimeÓ   s    
z1TestDateHeader.test_set_date_header_from_datetimeN)r   r    r!   r`   ra   Ú	timedeltarc   ÚtimezoneÚtzrb   rd   re   rh   rj   rl   rm   rp   r   r   r   r   rX   ¨   s   
rX   c            5   @   sà  e Zd Zdd„ Zddddddig d	fd
dddddig d	fd	dddddifddddi ejgfddddi ejgfddddi ejgfddddi ejgfddddddddddifddddddifddddddifddddddig dfddddddig dfddddddifd ddddd!ifd"dddd#d#d$œejgd% fd&d'd(d)d*d+ig d,fd-d.d/d0d1d2d3d4œg d5d6fd7d.d/d0d1d2d3d8d9œg d7d:fd;d.d/d0d<d=ifd>d.d/d0d<d?ifd@d.d/d0d<dAig d@fdB dC¡ ddD¡dEdFdGdHdIdJœejgd% dKdLfdMd.d/d0d<dNig dOfdPd.d/d0dGdQig dRfdS dC¡ ddD¡dddddTdUœejgdVdWfdXdddddig d	fdYdddd<dZig d[fd\dddd<d]iejgd^ d_fd`dddddadUœejgd^ dbdcfdddedfdgd<dhiejgd^ difdjdedfdgd<dkig dlfdmdddd<dniejgdofdpdddd<dqiejgd^ drfdpdddd<dqiejgd^ drfdsdddd<dtiejgdudvfdwdddd<dxig dyfdzddddd{iejgd|d}fd~dddddiejgd€dfd‚dedfdgd<dƒiejgd„fd…dedfdgd<dƒiejgd% d„fd†dedfdgd<d‡iejgd^ dˆfd‰dedfdgd<dŠig d‹dŒfdœ.Z	dŽS )ÚTestContentTypeHeaderc          	   G   s  t |ƒ}|dkr|d ni }|dkr,|d ng }|dkrL|d tk	rL|d n|}	|rXdnd}
|dkrl|d n
|
|	 d }|  d|¡}|  |j|¡ |  |j|¡ |  |j|¡ |  |j|¡ |  t	¡ d	|jd
< W d Q R X |  
|j|¡ |  ||	¡ |  |jtjd|¡ d S )Nr   rH   é   zContent-Type: rG   é   rN   zContent-TypeÚxyzÚabc)r   )rI   ÚDITTOr3   r6   Úcontent_typeÚmaintypeÚsubtypeÚparamsr>   Ú	TypeErrorrO   rD   rP   r   rQ   )r   rR   rz   r{   r|   r   rT   ÚparmdictrD   rS   rU   rV   r   r   r   r   Úcontent_type_as_valueÝ   s      z+TestContentTypeHeader.content_type_as_valuez)text/plain; charset=us-ascii (Plain text)z
text/plainÚtextÚplainÚcharsetzus-asciiztext/plain; charset="us-ascii"ztext/plain; charset=us-asciiztext/r=   z<crazy "stuff">zimage/jpeg/foo)z	bad/namesz	bad/namesÚbadÚnames)z
ImAge/JPegz
image/jpegÚimageÚjpeg)z  text  /  plain  z
text/plainr   r‚   )z"(foo) text (bar)/(baz)plain(stuff)z
text/plainr   r‚   ztext/plain; charset="utf-8"zutf-8ztext/plain; charset="US-ASCII"zUS-ASCIIztext/plain; charset="fOo"ZfOoz*text/plain; (interjection) Charset="utf-8"ztext/plain; Charset="utf-8"ztext/plain; title=fooÚtitleztext/plain; title="foo"z!text/plain; title="(bar)foo blue"z(bar)foo bluez0text/plain; title="  a     loong  way 	 home   "z  a     loong  way 	 home   zblarg; baz; boorG   )ÚbazZboorv   z0Multipart/mixed; boundary = "CPIMSSMTPC06p5f3tG"zmultipart/mixedÚ	multipartÚmixedÚboundaryÚCPIMSSMTPC06p5f3tGz.Multipart/mixed; boundary="CPIMSSMTPC06p5f3tG"zPimage/jpeg; name="wibble.JPG" ; x-mac-type="4A504547" ; x-mac-creator="474B4F4E"z
image/jpegr†   r‡   z
wibble.JPGZ4A504547Z474B4F4E)r1   z
x-mac-typezx-mac-creatorzNimage/jpeg; name="wibble.JPG"; x-mac-type="4A504547"; x-mac-creator="474B4F4E"z^Content-Type: image/jpeg; name="wibble.JPG"; x-mac-type="4A504547";
 x-mac-creator="474B4F4E"
zmimage/jpeg; name="wibble.JPG"; x-mac-type="4A504547"; x-mac-creator="474B4F4E"; x-extrastuff="make it longer"zmake it longer)r1   z
x-mac-typezx-mac-creatorzx-extrastuffz}Content-Type: image/jpeg; name="wibble.JPG"; x-mac-type="4A504547";
 x-mac-creator="474B4F4E"; x-extrastuff="make it longer"
z$image/jpeg; name="Jim&amp;&amp;Jill"r1   zJim&amp;&amp;Jillz!image/jpeg; name="Jim 'Bob' Jill"zJim 'Bob' Jillz#image/jpeg; name="Jim \"Bob\" Jill"zJim "Bob" Jillu   fooÂ§/bar; bÂ§r=two; baz=thrÂ§ezlatin-1Úsurrogateescapeu
   fooï¿½/baru   fooï¿½ÚbarÚtwou   thrï¿½e)u   bï¿½rr‰   u&   fooï¿½/bar; bï¿½r="two"; baz="thrï¿½e"uV   Content-Type: =?unknown-8bit?q?foo=A7?=/bar; bí²§r="two";
 baz*=unknown-8bit''thr%A7e
z(image/jpeg; name*0="abc"; name*1=".html"zabc.htmlzimage/jpeg; name="abc.html"z.image/jpeg; bar*0="baz\"foobar"; bar*1="\"baz"zbaz"foobar"bazz"image/jpeg; bar="baz\"foobar\"baz"uG   text/plain; charset=us-ascii; title*=us-ascii'en'This%20is%20not%20fÂ§nu   This is not fï¿½n)rƒ   rˆ   u9   text/plain; charset="us-ascii"; title="This is not fï¿½n"z\Content-Type: text/plain; charset="us-ascii";
 title*=unknown-8bit''This%20is%20not%20f%A7n
z-text/plain; charset*=ansi-x3.4-1968''us-asciiz\text/plain;	name*0*=''This%20is%20;	name*1*=%2A%2A%2Afun%2A%2A%2A%20;	name*2="is it not.pdf"zThis is ***fun*** is it not.pdfz2text/plain; name="This is ***fun*** is it not.pdf"zvtext/plain;	name*0*="us-ascii''This%20is%20even%20more%20";	name*1*="%2A%2A%2Afun%2A%2A%2A%20";	name*2="is it not.pdf"z)This is even more ***fun*** is it not.pdfru   z<text/plain; name="This is even more ***fun*** is it not.pdf"z„text/plain; charset=us-ascii;	title*0*="us-ascii'en'This%20is%20really%20";	title*1*="%2A%2A%2Afun%2A%2A%2A%20";	title*2="isn't it!"z"This is really ***fun*** isn't it!zJtext/plain; charset="us-ascii"; title="This is really ***fun*** isn't it!"zZContent-Type: text/plain; charset="us-ascii";
 title="This is really ***fun*** isn't it!"
zHapplication/x-foo;	name*0*="us-ascii'en-us'Frank's"; name*1*=" Document"zapplication/x-fooÚapplicationzx-foozFrank's Documentz*application/x-foo; name="Frank's Document"zFapplication/x-foo;	name*0="us-ascii'en-us'Frank's"; name*1=" Document"zus-ascii'en-us'Frank's Documentz9application/x-foo; name="us-ascii'en-us'Frank's Document"z/text/plain; NAME*0*=english_is_the_default.htmlzenglish_is_the_default.htmlz.text/plain; NAME="english_is_the_default.html"zjtext/plain;	name*0*="''This%20is%20even%20more%20";	name*1*="%2A%2A%2Afun%2A%2A%2A%20";	name*2="is it.pdf"z%This is even more ***fun*** is it.pdfz8text/plain; name="This is even more ***fun*** is it.pdf"zitext/plain;	name*0*="''This%20is%20even%20more%20";	name*1="%2A%2A%2Afun%2A%2A%2A%20";	name*2="is it.pdf"z3This is even more %2A%2A%2Afun%2A%2A%2A%20is it.pdfzFtext/plain; name="This is even more %2A%2A%2Afun%2A%2A%2A%20is it.pdf"zVContent-Type: text/plain;
 name="This is even more %2A%2A%2Afun%2A%2A%2A%20is it.pdf"
z1text/plain; name*0*=bogus'xx'ascii_is_the_defaultZascii_is_the_defaultz'text/plain; name="ascii_is_the_default"z*text/plain; charset*=ascii''utf-8%F1%F2%F3u   utf-8ï¿½ï¿½ï¿½u$   text/plain; charset="utf-8ï¿½ï¿½ï¿½"z@Content-Type: text/plain; charset*=unknown-8bit''utf-8%F1%F2%F3
z*text/plain; charset*=ascii''utf-8%E2%80%9Du   utf-8â€u   text/plain; charset="utf-8â€"z@Content-Type: text/plain; charset*=unknown-8bit''utf-8%E2%80%9D
zUapplication/x-foo;	name*0*="us-ascii'en-us'My";	name*1=" Document";	name*2=" For You"zMy Document For Youz-application/x-foo; name="My Document For You"zTapplication/x-foo;	name*0=us-ascii'en-us'My;	name*1*=" Document";	name*2*=" For You"zVapplication/x-foo;	name*0="us-ascii'en-us'My";	name*1*=" Document";	name*2*=" For You"z"us-ascii'en-us'My Document For Youz<application/x-foo; name="us-ascii'en-us'My Document For You"zrapplication/x-foo;	name="with spaceswith spaceswith spaceswith spaceswith spaceswith spaceswith spaceswith spaces"zXwith spaceswith spaceswith spaceswith spaceswith spaceswith spaceswith spaceswith spaceszrapplication/x-foo; name="with spaceswith spaceswith spaceswith spaceswith spaceswith spaceswith spaceswith spaces"z¨Content-Type: application/x-foo;
 name*0*=us-ascii''with%20spaceswith%20spaceswith%20spaceswith%20spaceswith;
 name*1*=%20spaceswith%20spaceswith%20spaceswith%20spaces
).Ú
RFC_2045_1Ú
RFC_2045_2Ú
RFC_2045_3Zno_subtype_in_content_typeZno_slash_in_content_typeZjunk_text_in_content_typeZ too_many_slashes_in_content_typeZunknown_content_typeZmixed_case_content_typeZspaces_in_content_typeZcfws_in_content_typeZcharset_paramZcapitalized_charsetZunknown_charsetZ*capitalized_charset_param_name_and_commentZunquoted_param_valueZparam_value_with_tspecialsZ"param_with_extra_quoted_whitespaceZ
bad_paramsZspaces_around_param_equalsZspaces_around_semisZlots_of_mime_paramsZsemis_inside_quotesZsingle_quotes_inside_quotesZdouble_quotes_inside_quotesZnon_ascii_in_paramsZrfc2231_segmented_normal_valuesZquotes_inside_rfc2231_valueZnon_ascii_rfc2231_valueZrfc2231_encoded_charsetZ rfc2231_encoded_no_double_quotesZ"rfc2231_encoded_with_double_quotesZ)rfc2231_single_quote_inside_double_quotesZ3rfc2231_single_quote_in_value_with_charset_and_langZ)rfc2231_single_quote_in_non_encoded_valueZrfc2231_no_language_or_charsetZrfc2231_encoded_no_charsetZrfc2231_partly_encodedZrfc2231_partly_encoded_2Z(rfc2231_unknown_charset_treated_as_asciiZ0rfc2231_bad_character_in_charset_parameter_valueZ8rfc2231_utf8_in_supposedly_ascii_charset_parameter_valueZ'rfc2231_encoded_then_unencoded_segmentsZ'rfc2231_unencoded_then_encoded_segmentsZ.rfc2231_quoted_unencoded_then_encoded_segmentsZ+rfc2231_folded_segments_correctly_formattedN)
r   r    r!   r€   r   ÚInvalidHeaderDefectÚencodeÚdecodeÚUndecodableBytesDefectZcontent_type_paramsr   r   r   r   rt   Ú   sP  	
	







	rt   c               @   s8   e Zd Zdd„ ZdddejgddfddejgfdœZd	S )
ÚTestContentTransferEncodingc       
      G   s²   t |ƒ}|dkr|d ng }|dkr8|d tk	r8|d n|}|rDdnd}|dkrX|d n
|| d }|  d|¡}	|  |	j|¡ |  |	j|¡ |  |	|¡ |  |	jtj	d|¡ d S )	Nr   rH   zContent-Transfer-Encoding: rG   ru   rN   zContent-Transfer-Encoding)r   )
rI   ry   r3   r6   ÚcterO   rD   rP   r   rQ   )
r   rR   rš   r   rT   rD   rS   rU   rV   r   r   r   r   Úcte_as_value	  s     z(TestContentTransferEncoding.cte_as_value)Úbase64rœ   rG   Ú7bitzContent-Transfer-Encoding:
z7bit and a bunch more)Ú
RFC_2183_1Úno_valueZjunk_after_cteN)r   r    r!   r›   r   rk   r•   Z
cte_paramsr   r   r   r   r™     s   r™   c               @   sb   e Zd Zdd„ Zddddddœg d	d
fddi ejgddfddi ejgfddddiejgfdœZdS )ÚTestContentDispositionc             G   sÔ   t |ƒ}|dkr|d ni }|dkr,|d ng }|dkrL|d tk	rL|d n|}|rXdnd}|dkrl|d n
|| d }	|  d|¡}
|  |
j|¡ |  |
j|¡ |  |
j|¡ |  |
|¡ |  |
jt	j
d	|	¡ d S )
Nr   rH   ru   zContent-Disposition: rG   rv   rN   zContent-Disposition)r   )rI   ry   r3   r6   Úcontent_dispositionr}   rO   rD   rP   r   rQ   )r   rR   r¡   r   rT   r   rD   rS   rU   rV   r   r   r   r   Úcontent_disp_as_value1  s     z,TestContentDisposition.content_disp_as_value)Úinliner£   zWattachment; filename=genome.jpeg;  modification-date="Wed, 12 Feb 1997 16:29:51 -0500";Ú
attachmentzgenome.jpegzWed, 12 Feb 1997 16:29:51 -0500)Úfilenamezmodification-datezWattachment; filename="genome.jpeg"; modification-date="Wed, 12 Feb 1997 16:29:51 -0500"znContent-Disposition: attachment; filename="genome.jpeg";
 modification-date="Wed, 12 Feb 1997 16:29:51 -0500"
rG   NzContent-Disposition:
zab./kzab.zab./k; filename="foo"r¥   r=   )rž   Z
RFC_2183_2rŸ   Zinvalid_valueZinvalid_value_with_params)r   r    r!   r¢   r   rk   r•   Zcontent_disp_paramsr   r   r   r   r    .  s.   r    c               @   s  e Zd Zdd„ Zdddddg fdddddg fdddddg fdddddg fd	d	d	ddg fd
d
d
ddg fdddddg fdddddg fdddddejgfdddddejgfdddddejgfdddddejgfdddddejgfdddddejgfdddddejgfdœZdS )ÚTestMIMEVersionHeaderc             C   s~   |   d|¡}|  ||¡ |  |j|¡ |  |j|¡ |  |j|¡ |  |j|¡ |r\d| }|  |jtj	dd| d ¡ d S )NzMIME-VersionrM   )r   zMIME-Version:rN   )
r3   r6   ÚversionÚmajorÚminorrO   rD   rP   r   rQ   )r   rR   rS   r§   r¨   r©   rD   r   r   r   r   Úversion_string_as_MIME_Versionq  s    z4TestMIMEVersionHeader.version_string_as_MIME_Versionz1.0rH   r   z1.0 (produced by MetaSend Vx.x)z(produced by MetaSend Vx.x) 1.0z1.(produced by MetaSend Vx.x)0z1.1z2.1ru   z1 .0z  1.0  z	1.0 <abc>z	<abc> 1.0Nz1.<abc>0z1..0z2.xr=   rG   )r’   r“   r”   Ú
RFC_2045_4Z1_1Z2_1Ú
whitespaceZ#leading_trailing_whitespace_ignoredZnon_comment_garbage_afterZnon_comment_garbage_beforeZnon_comment_garbage_insideZtwo_periodsZ2_xr=   Úmissing)r   r    r!   rª   r   r•   rk   Zversion_string_paramsr   r   r   r   r¦   n  s¶   r¦   c               @   s°  e Zd Zdejgddddddfdg ddddddfdg ddddddfd	g d	dd
dddfdg ddddddfdg ddddddfdejgddddddfdejgd ddddddfdg ddddddfd ejgd! d"dd"d#ddfd$ejgd% d&dd&d'ddfd(ejgd)dd)d*ddfd+g d,d-d.d/ddfd0g d1d2d.d/ddfd3ejgd,d-d.d/ddfd4œ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dS )OÚTestAddressHeaderz<>rG   Nzzippy@pinhead.comZzippyzpinhead.comz%Zaphrod Beblebrux <zippy@pinhead.com>zZaphrod Beblebruxz)Zaphrod Beblebrux <"foo bar"@pinhead.com>z"foo bar"@pinhead.comzfoo barz'"A \(Special\) Person" <person@dom.ain>z%"A (Special) Person" <person@dom.ain>zA (Special) Personzperson@dom.ainZpersonzdom.ainz."Arthur \\Backslash\\ Foobar" <person@dom.ain>zArthur \Backslash\ FoobarzJohn X. Doe <jxd@example.com>z"John X. Doe" <jxd@example.com>zJohn X. Doezjxd@example.comZjxdzexample.comz""example" example"@example.comrv   z"example example"@example.comzexample examplez!"\"example\" example"@example.comz"example" examplez#"\\"example\\" example"@example.comr8   z#"\\example\\\\ example"@example.comz\example\\ examplezmerwok  wok  @example.comru   z"merwok wok"@example.comz
merwok wokzmerwok. wok .  wok@example.comzmerwok.wok.wok@example.comzmerwok.wok.wokz'=?utf-8?q?=C3=89ric?= <foo@example.com>u   Ã‰ric <foo@example.com>u   Ã‰riczfoo@example.comr=   z6The =?utf-8?q?=C3=89ric=2C?= Himself <foo@example.com>u&   "The Ã‰ric, Himself" <foo@example.com>u   The Ã‰ric, Himselfz)"=?utf-8?q?=C3=89ric?=" <foo@example.com>)ÚemptyZaddress_onlyZname_and_addressZquoted_local_partZquoted_parens_in_nameZquoted_backslashes_in_nameZname_with_dotZquoted_strings_in_local_partZ$escaped_quoted_strings_in_local_partZescaped_escapes_in_local_partZ'spaces_in_unquoted_local_part_collapsedZ(spaces_around_dots_in_local_part_removedZrfc2047_atom_is_decodedZ!rfc2047_atom_in_phrase_is_decodedZ(rfc2047_atom_in_quoted_string_is_decodedc	             C   s¸   |   d|¡}	|  |	|¡ |  |	j|¡ |	j}
|  t|
ƒ|¡ |  t|	jƒd¡ |  |
gt|	jd j	ƒ¡ |  |
gt|	j	ƒ¡ |  |
j
|¡ |  |
j|¡ |  |
j|¡ |  |
j|¡ d S )NÚsenderrH   r   )r3   r6   rO   rD   Úaddressr5   rI   ÚgroupsÚlistÚ	addressesÚdisplay_nameÚ	addr_specÚusernameÚdomain)r   rR   rD   rS   rµ   r¶   r·   r¸   Úcommentr   Úar   r   r   Úexample_as_address­  s    z$TestAddressHeader.example_as_addressc	             C   sÒ   d  |¡}|rd  |¡nd}	|  d|¡}
|  |
|	¡ |  |
j|¡ |  |
jd j|
j¡ |  t|
jƒd¡ |  t|
jƒd¡ |
jd }|  t|ƒ|¡ |  |j	|¡ |  |j
|¡ |  |j|¡ |  |j|¡ d S )Nzfoo: {};zfoo:;Útor   rH   )Úformatr3   r6   rO   rD   r²   r´   rI   r5   rµ   r¶   r·   r¸   )r   rR   rD   rS   rµ   r¶   r·   r¸   r¹   Zgdecodedr   rº   r   r   r   Úexample_as_group¾  s    

z"TestAddressHeader.example_as_groupc             C   sÊ   d}|   d|¡}|  ||¡ |  t|jƒd¡ |  t|jƒd¡ x.tdƒD ]"}|  |j| jd |j| ¡ qJW |  t|jd ƒd¡ |  t|jd ƒd¡ |  t|jd ƒd	¡ |  |jd jd
¡ d S )NzTFred <dinsdale@python.org>, foo@example.com, "Harry W. Hastings" <hasty@example.com>r¼   rv   r   zFred <dinsdale@python.org>rH   zfoo@example.comru   z'"Harry W. Hastings" <hasty@example.com>zHarry W. Hastings)r3   r6   rI   r²   r´   Úranger5   rµ   )r   r2   r   Úir   r   r   Útest_simple_address_listÏ  s    "z*TestAddressHeader.test_simple_address_listc             C   sz  t | j ¡ ƒ}dd dd„ |d d… D ƒ¡ d d d dd„ |dd… D ƒ¡ d	 d d
d„ |dd … D ƒ¡ }dd dd„ |d d… D ƒ¡ d d d dd„ |dd… D ƒ¡ d d dd„ |dd … D ƒ¡ }|  d|¡}|  | d¡| d¡¡ |  ||¡ |  t|jƒdt|ƒ d ¡ |  |jd j	d¡ |  |jd j	d¡ |  |jd j	d¡ |  t|j
ƒt|ƒ¡ xPtdƒD ]D}|  |j|d  j	¡ |  t|j|d  j
d ƒ|| d ¡ q€W xZtddt|ƒ d ƒD ]@}|  |j| j	¡ |  t|j| j
d ƒ||d  d ¡ qàW xPtt|ƒƒD ]@}|  t|j
| ƒ|| d ¡ |  |j
| j|| d ¡ q2W d S )Nz dummy list:;, another: (empty);,z, c             S   s   g | ]}|d  ‘qS )r   r   )Ú.0Úxr   r   r   ú
<listcomp>â  s    z?TestAddressHeader.test_complex_address_list.<locals>.<listcomp>é   z"A \"list\"": c             S   s   g | ]}|d  ‘qS )r   r   )rÂ   rÃ   r   r   r   rÄ   ä  s    é   z;,c             S   s   g | ]}|d  ‘qS )r   r   )rÂ   rÃ   r   r   r   rÄ   å  s    zdummy list:;, another:;, c             S   s   g | ]}|d  ‘qS )ru   r   )rÂ   rÃ   r   r   r   rÄ   ê  s    c             S   s   g | ]}|d  ‘qS )ru   r   )rÂ   rÃ   r   r   r   rÄ   ì  s    z;, c             S   s   g | ]}|d  ‘qS )ru   r   )rÂ   rÃ   r   r   r   rÄ   í  s    r¼   ú,r9   r   z
dummy listrH   ZanotherzA "list"ru   )r³   Úexample_paramsÚvaluesÚjoinr3   r6   ÚsplitrI   r²   rµ   r´   r¿   ÚassertIsNoner5   r¶   )r   ZexamplesrR   Úexpectedr   rÀ   r   r   r   Útest_complex_address_listß  s,    FF..z+TestAddressHeader.test_complex_address_listc          	   C   s,   |   dd¡}|  t¡ d|_W d Q R X d S )Nr°   zabc@xyz.comr=   )r3   r>   r?   r±   )r   r   r   r   r   Útest_address_read_only  s    z(TestAddressHeader.test_address_read_onlyc          	   C   s,   |   dd¡}|  t¡ d|_W d Q R X d S )Nr°   zabc@xyz.comr=   )r3   r>   r?   r´   )r   r   r   r   r   Útest_addresses_read_only  s    z*TestAddressHeader.test_addresses_read_onlyc          	   C   s,   |   dd¡}|  t¡ d|_W d Q R X d S )Nr°   zabc@xyz.comr=   )r3   r>   r?   r²   )r   r   r   r   r   Útest_groups_read_only  s    z'TestAddressHeader.test_groups_read_onlyc             C   s4   d}|   d|¡}|  |jt¡ |  |jd t¡ d S )Nzme <who@example.com>r¼   r   )r3   r   r´   rJ   r   )r   rR   r   r   r   r   Útest_addresses_types  s    z&TestAddressHeader.test_addresses_typesc             C   s4   d}|   d|¡}|  |jt¡ |  |jd t¡ d S )Nzme <who@example.com>r¼   r   )r3   r   r²   rJ   r	   )r   rR   r   r   r   r   Útest_groups_types  s    z#TestAddressHeader.test_groups_typesc             C   s$   |   dtdddƒ¡}|  |d¡ d S )Nr¼   Úmer=   zexample.comzme <foo@example.com>)r3   r   r6   )r   r   r   r   r   Útest_set_from_Address  s    z'TestAddressHeader.test_set_from_Addressc             C   s0   |   dtdddƒtdddƒg¡}|  |d¡ d S )Nr¼   rÔ   r=   zexample.comÚyour   z+me <foo@example.com>, you <bar@example.com>)r3   r   r6   )r   r   r   r   r   Útest_set_from_Address_list!  s    z,TestAddressHeader.test_set_from_Address_listc             C   sj   |   dtdddƒtdtdddƒtd	d
dƒgƒtdddƒg¡}|  |d¡ |  |jtjjdddd¡ d S )Nr¼   rÔ   r=   zexample.comÚbingÚfizÚzzb.comÚzifÚfzc.comrÖ   r   zPme <foo@example.com>, bing: fiz <z@b.com>, zif <f@c.com>;, you <bar@example.com>é(   )Úmax_line_length)r   zWto: me <foo@example.com>,
 bing: fiz <z@b.com>, zif <f@c.com>;,
 you <bar@example.com>
)r3   r   r	   r6   rP   r   rQ   Úclone)r   r   r   r   r   Ú$test_set_from_Address_and_Group_list&  s    z6TestAddressHeader.test_set_from_Address_and_Group_listc          
   C   s8   |   dtdtdddƒtdddƒgƒg¡}|  |d	¡ d S )
Nr¼   rØ   rÙ   rÚ   zb.comrÛ   rÜ   zc.comz#bing: fiz <z@b.com>, zif <f@c.com>;)r3   r	   r   r6   )r   r   r   r   r   Útest_set_from_Group_list2  s    z*TestAddressHeader.test_set_from_Group_list)r   r    r!   r   r•   ÚObsoleteHeaderDefectrÈ   r»   r¾   rÁ   rÎ   rÏ   rÐ   rÑ   rÒ   rÓ   rÕ   r×   rà   rá   r   r   r   r   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d3d4„ Zd5d6„ Zd7d8„ Zd9d:„ Zd;d<„ Z d=d>„ Z!d?S )@ÚTestAddressAndGroupc          	   C   s&   |   t¡ t||dƒ W d Q R X d S )Nr=   )r>   r?   r@   )r   ÚobjrA   r   r   r   rB   :  s    z!TestAddressAndGroup._test_attr_roc             C   s   |   tdddƒd¡ d S )Nr=   r   r‰   rµ   )rB   r   )r   r   r   r   Útest_address_display_name_ro>  s    z0TestAddressAndGroup.test_address_display_name_roc             C   s   |   tdddƒd¡ d S )Nr=   r   r‰   r·   )rB   r   )r   r   r   r   Útest_address_username_roA  s    z,TestAddressAndGroup.test_address_username_roc             C   s   |   tdddƒd¡ d S )Nr=   r   r‰   r¸   )rB   r   )r   r   r   r   Útest_address_domain_roD  s    z*TestAddressAndGroup.test_address_domain_roc             C   s   |   tdƒd¡ d S )Nr=   rµ   )rB   r	   )r   r   r   r   Útest_group_display_name_roG  s    z.TestAddressAndGroup.test_group_display_name_roc             C   s   |   tdƒd¡ d S )Nr=   r´   )rB   r	   )r   r   r   r   Útest_group_addresses_roJ  s    z+TestAddressAndGroup.test_group_addresses_roc             C   sX   t dddƒ}|  |jd¡ |  |jd¡ |  |jd¡ |  |jd¡ |  t|ƒd¡ d S )Nr=   r   r‰   zbar@bazzfoo <bar@baz>)r   r6   rµ   r·   r¸   r¶   r5   )r   rº   r   r   r   Ú!test_address_from_username_domainM  s    z5TestAddressAndGroup.test_address_from_username_domainc             C   sX   t ddd}|  |jd¡ |  |jd¡ |  |jd¡ |  |jd¡ |  t|ƒd¡ d S )Nr=   zbar@baz)r¶   r   r‰   zfoo <bar@baz>)r   r6   rµ   r·   r¸   r¶   r5   )r   rº   r   r   r   Útest_address_from_addr_specU  s    z/TestAddressAndGroup.test_address_from_addr_specc             C   sV   t dd}|  |jd¡ |  |jd¡ |  |jd¡ |  |jd¡ |  t|ƒd¡ d S )Nzbar@baz)r¶   rG   r   r‰   )r   r6   rµ   r·   r¸   r¶   r5   )r   rº   r   r   r   Ú!test_address_with_no_display_name]  s    
z5TestAddressAndGroup.test_address_with_no_display_namec             C   sR   t ƒ }|  |jd¡ |  |jd¡ |  |jd¡ |  |jd¡ |  t|ƒd¡ d S )NrG   z<>)r   r6   rµ   r·   r¸   r¶   r5   )r   rº   r   r   r   Útest_null_addresse  s    z%TestAddressAndGroup.test_null_addressc             C   sV   t dd}|  |jd¡ |  |jd¡ |  |jd¡ |  |jd¡ |  t|ƒd¡ d S )NÚbuzz)r¸   rG   z@buzz)r   r6   rµ   r·   r¸   r¶   r5   )r   rº   r   r   r   Útest_domain_onlym  s    
z$TestAddressAndGroup.test_domain_onlyc             C   sV   t dd}|  |jd¡ |  |jd¡ |  |jd¡ |  |jd¡ |  t|ƒd¡ d S )Nrî   )r·   rG   )r   r6   rµ   r·   r¸   r¶   r5   )r   rº   r   r   r   Útest_username_onlyv  s    
z&TestAddressAndGroup.test_username_onlyc             C   sT   t dƒ}|  |jd¡ |  |jd¡ |  |jd¡ |  |jd¡ |  t|ƒd¡ d S )Nrî   rG   z<>zbuzz <>)r   r6   rµ   r·   r¸   r¶   r5   )r   rº   r   r   r   Útest_display_name_only  s    z*TestAddressAndGroup.test_display_name_onlyc             C   sX   t dddƒ}|  |jd¡ |  |jd¡ |  |jd¡ |  |jd¡ |  t|ƒd¡ d S )NzSara J.zbad namezexample.comz"bad name"@example.comz""Sara J." <"bad name"@example.com>)r   r6   rµ   r·   r¸   r¶   r5   )r   rº   r   r   r   Útest_quoting‡  s    z TestAddressAndGroup.test_quotingc             C   sX   t dddƒ}|  |jd¡ |  |jd¡ |  |jd¡ |  |jd¡ |  t|ƒd¡ d S )Nu   Ã‰ricZwoku   exÃ mple.comu   wok@exÃ mple.comu   Ã‰ric <wok@exÃ mple.com>)r   r6   rµ   r·   r¸   r¶   r5   )r   rº   r   r   r   Ú	test_il8n‘  s    zTestAddressAndGroup.test_il8nc          	   C   s&   |   t¡ tddd W d Q R X d S )Nr=   u   wÅ‘k@example.com)r¶   )r>   Ú
ValueErrorr   )r   r   r   r   Ú+test_non_ascii_username_in_addr_spec_raisesž  s    z?TestAddressAndGroup.test_non_ascii_username_in_addr_spec_raisesc          	   C   s(   |   t¡ tdddd W d Q R X d S )Nr=   rØ   zbar@baz)r·   r¶   )r>   r~   r   )r   r   r   r   Ú*test_address_addr_spec_and_username_raises¢  s    z>TestAddressAndGroup.test_address_addr_spec_and_username_raisesc          	   C   s(   |   t¡ tdddd W d Q R X d S )Nr=   rØ   zbar@baz)r¸   r¶   )r>   r~   r   )r   r   r   r   Ú(test_address_addr_spec_and_domain_raises¦  s    z<TestAddressAndGroup.test_address_addr_spec_and_domain_raisesc          	   C   s*   |   t¡ tddddd W d Q R X d S )Nr=   ZbongrØ   zbar@baz)r·   r¸   r¶   )r>   r~   r   )r   r   r   r   Ú5test_address_addr_spec_and_username_and_domain_raisesª  s    zITestAddressAndGroup.test_address_addr_spec_and_username_and_domain_raisesc          	   C   s&   |   t¡ tddd W d Q R X d S )Nr=   zbad name@example.com)r¶   )r>   rô   r   )r   r   r   r   Ú'test_space_in_addr_spec_username_raises®  s    z;TestAddressAndGroup.test_space_in_addr_spec_username_raisesc          	   C   s&   |   t¡ tddd W d Q R X d S )Nr=   zname@ex[]ample.com)r¶   )r>   rô   r   )r   r   r   r   Útest_bad_addr_sepc_raises²  s    z-TestAddressAndGroup.test_bad_addr_sepc_raisesc             C   s:   t dƒ}|  |jd¡ |  |jtƒ ¡ |  t|ƒd¡ d S )Nr=   zfoo:;)r	   r6   rµ   r´   rJ   r5   )r   Úgr   r   r   Útest_empty_group¶  s    z$TestAddressAndGroup.test_empty_groupc             C   s>   t dg d}|  |jd¡ |  |jtƒ ¡ |  t|ƒd¡ d S )Nr=   )r´   zfoo:;)r	   r6   rµ   r´   rJ   r5   )r   rû   r   r   r   Útest_empty_group_list¼  s    z)TestAddressAndGroup.test_empty_group_listc             C   s6   t ƒ }|  |j¡ |  |jtƒ ¡ |  t|ƒd¡ d S )NzNone:;)r	   rÌ   rµ   r6   r´   rJ   r5   )r   rû   r   r   r   Útest_null_groupÂ  s    z#TestAddressAndGroup.test_null_groupc             C   sV   t dddƒt dddƒg}td|ƒ}|  |jd¡ |  |jt|ƒ¡ |  t|ƒd¡ d S )NÚbÚcrº   r=   zfoo: b <b@c>, a <b@c>;)r   r	   r6   rµ   r´   rJ   r5   )r   Úaddrsrû   r   r   r   Útest_group_with_addressesÈ  s
    
z-TestAddressAndGroup.test_group_with_addressesc             C   sT   t dddƒt dddƒg}t|d}|  |j¡ |  |jt|ƒ¡ |  t|ƒd¡ d S )Nrÿ   r   rº   )r´   zNone: b <b@c>, a <b@c>;)r   r	   rÌ   rµ   r6   r´   rJ   r5   )r   r  rû   r   r   r   Ú)test_group_with_addresses_no_display_nameÏ  s
    
z=TestAddressAndGroup.test_group_with_addresses_no_display_namec             C   sJ   t dddƒg}t|d}|  |j¡ |  |jt|ƒ¡ |  t|ƒd¡ d S )Nrÿ   r   )r´   zb <b@c>)r   r	   rÌ   rµ   r6   r´   rJ   r5   )r   r  rû   r   r   r   Ú+test_group_with_one_address_no_display_nameÖ  s
    
z?TestAddressAndGroup.test_group_with_one_address_no_display_namec             C   s:   t dƒ}|  |jd¡ |  |jtƒ ¡ |  t|ƒd¡ d S )Nzfoo.barz"foo.bar":;)r	   r6   rµ   r´   rJ   r5   )r   rû   r   r   r   Útest_display_name_quotingÝ  s    z-TestAddressAndGroup.test_display_name_quotingc             C   s:   t dƒ}|  |jd¡ |  |jtƒ ¡ |  t|ƒd¡ d S )Nzfoo barz	foo bar:;)r	   r6   rµ   r´   rJ   r5   )r   rû   r   r   r   Ú#test_display_name_blanks_not_quotedã  s    z7TestAddressAndGroup.test_display_name_blanks_not_quotedc             C   sH   t dddƒ}ttjd}||d< |  |d d¡ |  |d j|f¡ d S )Nr=   r   zexample.com)r   ÚTor¼   zfoo <bar@example.com>)r   r   r   rQ   r6   r´   )r   rº   ro   r   r   r   Ú$test_set_message_header_from_addressé  s
    z8TestAddressAndGroup.test_set_message_header_from_addressc             C   sD   t dƒ}ttjd}||d< |  |d d¡ |  |d j|j¡ d S )Nzfoo bar)r   r  r¼   z	foo bar:;)r	   r   r   rQ   r6   r´   )r   rû   ro   r   r   r   Ú"test_set_message_header_from_groupð  s
    z6TestAddressAndGroup.test_set_message_header_from_groupN)"r   r    r!   rB   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ã   8  s>   		
rã   c               @   sl   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S )ÚTestFoldingc             C   s&   |   dd¡}|  |jtjdd¡ d S )Nr)   zthis is a test)r   zsubject: this is a test
)r3   r6   rP   r   rQ   )r   r   r   r   r   Útest_short_unstructuredú  s    z#TestFolding.test_short_unstructuredc             C   s&   |   dd¡}|  |jtjdd¡ d S )Nr   zhThis is a long header line that will need to be folded into two lines and will demonstrate basic folding)r   zsSubject: This is a long header line that will need to be folded into two lines
 and will demonstrate basic folding
)r3   r6   rP   r   rQ   )r   r   r   r   r   Útest_long_unstructuredÿ  s    z"TestFolding.test_long_unstructuredc             C   s4   |   dd¡}|  |jtjjdddt d¡¡ d S )Nr   z1this is a short header that will be folded anywayr\   )rÞ   )r   zŽ                Subject: this is a
                 short header that
                 will be folded
                 anyway
                )r3   r6   rP   r   rQ   rß   ÚtextwrapÚdedent)r   r   r   r   r   Ú'test_unstructured_short_max_line_length  s
    z3TestFolding.test_unstructured_short_max_line_lengthc             C   s&   |   dd¡}|  |jtjdd¡ d S )Nr   r   )r   zSubject: test
)r3   r6   rP   r   rQ   )r   r   r   r   r   Ú"test_fold_unstructured_single_word  s    z.TestFolding.test_fold_unstructured_single_wordc             C   s&   |   dd¡}|  |jtjdd¡ d S )Nr   ztest test test)r   zSubject: test test test
)r3   r6   rP   r   rQ   )r   r   r   r   r   Útest_fold_unstructured_short  s    z(TestFolding.test_fold_unstructured_shortc             C   s.   |   dd¡}|  |jtjjdddd¡ d S )Nr   Z5thisisaverylonglineconsistingofasinglewordthatwontfitr\   )rÞ   )r   z¯Subject: 
 =?utf-8?q?thisisa?=
 =?utf-8?q?verylon?=
 =?utf-8?q?glineco?=
 =?utf-8?q?nsistin?=
 =?utf-8?q?gofasin?=
 =?utf-8?q?gleword?=
 =?utf-8?q?thatwon?=
 =?utf-8?q?tfit?=
)r3   r6   rP   r   rQ   rß   )r   r   r   r   r   Ú)test_fold_unstructured_with_overlong_word  s    z5TestFolding.test_fold_unstructured_with_overlong_wordc             C   s.   |   dd¡}|  |jtjjdddd¡ d S )Nr   zXthisisaverylonglineconsistingofasinglewordthatwontfit plusanotherverylongwordthatwontfitr\   )rÞ   )r   a  Subject: 
 =?utf-8?q?thisisa?=
 =?utf-8?q?verylon?=
 =?utf-8?q?glineco?=
 =?utf-8?q?nsistin?=
 =?utf-8?q?gofasin?=
 =?utf-8?q?gleword?=
 =?utf-8?q?thatwon?=
 =?utf-8?q?tfit_pl?=
 =?utf-8?q?usanoth?=
 =?utf-8?q?erveryl?=
 =?utf-8?q?ongword?=
 =?utf-8?q?thatwon?=
 =?utf-8?q?tfit?=
)r3   r6   rP   r   rQ   rß   )r   r   r   r   r   Ú.test_fold_unstructured_with_two_overlong_words-  s    z:TestFolding.test_fold_unstructured_with_two_overlong_wordsc             C   s.   |   dd¡}|  |jtjjdddd¡ d S )Nr   Z thislongwordislessthanmaxlinelené#   )rÞ   )r   z+Subject:
 thislongwordislessthanmaxlinelen
)r3   r6   rP   r   rQ   rß   )r   r   r   r   r   Ú.test_fold_unstructured_with_slightly_long_wordD  s    z:TestFolding.test_fold_unstructured_with_slightly_long_wordc             C   s4   |   dd¡}|  |jtjjdddt d¡¡ d S )Nr   zˆThis header is intended to demonstrate, in a fairly succinct way, that we now do not give a , special treatment in unstructured headers.é<   )rÞ   )r   zÕ                Subject: This header is intended to demonstrate, in a fairly
                 succinct way, that we now do not give a , special treatment
                 in unstructured headers.
                 )r3   r6   rP   r   rQ   rß   r  r  )r   r   r   r   r   Ú"test_fold_unstructured_with_commasJ  s
    z.TestFolding.test_fold_unstructured_with_commasc             C   s,   |   dd¡}|  |jtjdt d¡¡ d S )Nr  zƒ"Theodore H. Perfect" <yes@man.com>, "My address is very long because my name is long" <foo@bar.com>, "Only A. Friend" <no@yes.com>)r   z»            To: "Theodore H. Perfect" <yes@man.com>,
             "My address is very long because my name is long" <foo@bar.com>,
             "Only A. Friend" <no@yes.com>
             )r3   r6   rP   r   rQ   r  r  )r   r   r   r   r   Útest_fold_address_listW  s    z"TestFolding.test_fold_address_listc             C   s&   |   dd¡}|  |jtjdd¡ d S )Nrn   zSat, 2 Feb 2002 17:00:06 -0800)r   z&Date: Sat, 02 Feb 2002 17:00:06 -0800
)r3   r6   rP   r   rQ   )r   r   r   r   r   Útest_fold_date_headera  s    z!TestFolding.test_fold_date_headerc             C   s&   |   dd¡}|  |jtjdd¡ d S )NzX-Report-Abusez]<https://www.mailitapp.com/report_abuse.php?mid=xxx-xxx-xxxxxxxxxxxxxxxxxxxxxxxx==-xxx-xx-xx>)r   z¬X-Report-Abuse: =?utf-8?q?=3Chttps=3A//www=2Emailitapp=2Ecom/report=5F?=
 =?utf-8?q?abuse=2Ephp=3Fmid=3Dxxx-xxx-xxxxxxxxxxxxxxxxxxxxxxxx=3D=3D-xxx-?=
 =?utf-8?q?xx-xx=3E?=
)r3   r6   rP   r   rQ   )r   r   r   r   r   Ú&test_fold_overlong_words_using_RFC2047f  s    z2TestFolding.test_fold_overlong_words_using_RFC2047N)r   r    r!   r  r  r  r  r  r  r  r  r  r  r  r  r   r   r   r   r
  ø  s   	
r
  Ú__main__)ra   r  ÚunittestÚemailr   r   Úemail.messager   Ztest.test_emailr   r   r   Úemail.headerregistryr   r	   Úobjectry   r
   r0   r4   rL   rX   rt   r™   r    r¦   r®   rã   r
  r   Úmainr   r   r   r   Ú<module>   sL   :.(1    /'?   - A|
