B
    v9aæ  ã               @   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   ú)/usr/lib/python3.7/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   Z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)Z
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)Z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   Zmap_to_typer   r   r   r   )r   r   Zh1Z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   r.   r   r   r   r   r+   I   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 )ÚTestBaseHeaderFeaturesc             C   s8   |   dd¡}|  |t¡ |  |d¡ |  t|ƒd¡ d S )Nr'   zthis is a test)r.   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)r.   r1   )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)r.   r1   r,   )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)r.   ÚassertRaisesÚAttributeErrorÚsetattr)r   Úattrr   r   r   r   Ú_test_attr_roa   s    z$TestBaseHeaderFeatures._test_attr_roc             C   s   |   d¡ d S )Nr,   )r=   )r   r   r   r   Útest_name_read_onlyf   s    z*TestBaseHeaderFeatures.test_name_read_onlyc             C   s   |   d¡ d S )NÚdefects)r=   )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Ú é   )r.   r1   Úlenr?   r   Útuple)r   r   r   r   r   Útest_defects_is_tuplel   s    z,TestBaseHeaderFeatures.test_defects_is_tupleN)
r   r   r    r2   r6   r7   r=   r>   r@   rF   r   r   r   r   r/   Q   s   r/   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:ú rB   rC   Ú
r   )r   )rD   r.   r1   ÚassertDefectsEqualr?   Úfoldr   Údefault)	r   ÚsourceÚdecodedr   Úlr?   Ú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    rR   Zstring_paramsr   r   r   r   rG      s   rG   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ùÿÿÿ)ZhoursiÑ  é	   é   é   é
   é7   )Ztzinfoc             C   sR   |   d| j¡}|  || j¡ |  |j| j¡ |  |j ¡ | j¡ |  |jd¡ d S )NrA   r   )r.   Ú
datestringr1   ÚdatetimeÚdtÚ	utcoffsetr?   )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 )NrA   r   )r.   r[   r1   rY   rZ   r?   )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 )NrA   rC   r   )r.   rY   r   r   ZUniqueDateHeaderr1   Ú	max_countr?   )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   )r.   rY   r   r   Z
DateHeaderr1   r_   r?   )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 )NrA   rB   rC   r   )r.   r1   rD   r?   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 )NrA   r8   )r.   rY   r9   r:   rZ   )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   rL   r[   r1   rY   rZ   )r   Úmr   r   r   Ú"test_set_date_header_from_datetimeÓ   s    
z1TestDateHeader.test_set_date_header_from_datetimeN)r   r   r    rY   rZ   Z	timedeltar\   ZtimezoneZtzr[   r]   r^   r`   ra   rc   rd   rg   r   r   r   r   rS   ¨   s   
rS   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   rC   é   zContent-Type: rB   é   rI   zContent-TypeZxyzÚabc)r   )rD   ÚDITTOr.   r1   Úcontent_typeÚmaintypeÚsubtypeÚparamsr9   Ú	TypeErrorrJ   r?   rK   r   rL   )r   rM   rm   rn   ro   r   rO   Úparmdictr?   rN   rP   rQ   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/r8   z<crazy "stuff">zimage/jpeg/foo)z	bad/namesz	bad/namesZbadÚnames)z
ImAge/JPegz
image/jpegÚimageÚjpeg)z  text  /  plain  z
text/plainrt   ru   )z"(foo) text (bar)/(baz)plain(stuff)z
text/plainrt   ru   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; boorB   )ÚbazZboorj   z0Multipart/mixed; boundary = "CPIMSSMTPC06p5f3tG"zmultipart/mixedZ	multipartZmixedÚboundaryZCPIMSSMTPC06p5f3tGz.Multipart/mixed; boundary="CPIMSSMTPC06p5f3tG"zPimage/jpeg; name="wibble.JPG" ; x-mac-type="4A504547" ; x-mac-creator="474B4F4E"z
image/jpegrx   ry   z
wibble.JPGZ4A504547Z474B4F4E)r,   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)r,   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"r,   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ï¿½ÚbarZ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)rv   rz   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.pdfri   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-fooZ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    rs   r   ÚInvalidHeaderDefectÚencodeÚdecodeZUndecodableBytesDefectZcontent_type_paramsr   r   r   r   rh   Ú   sP  	
	







	rh   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   rC   zContent-Transfer-Encoding: rB   ri   rI   zContent-Transfer-Encoding)r   )
rD   rl   r.   r1   ÚcterJ   r?   rK   r   rL   )
r   rM   r†   r   rO   r?   rN   rP   rQ   r   r   r   r   Úcte_as_value	  s     z(TestContentTransferEncoding.cte_as_value)Úbase64rˆ   rB   Z7bitzContent-Transfer-Encoding:
z7bit and a bunch more)Ú
RFC_2183_1Úno_valueZjunk_after_cteN)r   r   r    r‡   r   rb   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   rC   ri   zContent-Disposition: rB   rj   rI   zContent-Disposition)r   )rD   rl   r.   r1   Úcontent_dispositionrp   rJ   r?   rK   r   rL   )r   rM   rŒ   r   rO   rr   r?   rN   rP   rQ   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";Z
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"
rB   NzContent-Disposition:
zab./kzab.zab./k; filename="foo"r   r8   )r‰   Z
RFC_2183_2rŠ   Zinvalid_valueZinvalid_value_with_params)r   r   r    r   r   rb   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-VersionrH   )r   zMIME-Version:rI   )
r.   r1   ÚversionÚmajorÚminorrJ   r?   rK   r   rL   )r   rM   rN   r‘   r’   r“   r?   r   r   r   r   Úversion_string_as_MIME_Versionq  s    z4TestMIMEVersionHeader.version_string_as_MIME_Versionz1.0rC   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.1ri   z1 .0z  1.0  z	1.0 <abc>z	<abc> 1.0Nz1.<abc>0z1..0z2.xr8   rB   )r   r€   r   Z
RFC_2045_4Z1_1Z2_1Z
whitespaceZ#leading_trailing_whitespace_ignoredZnon_comment_garbage_afterZnon_comment_garbage_beforeZnon_comment_garbage_insideZtwo_periodsZ2_xr8   Úmissing)r   r   r    r”   r   r‚   rb   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e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<>rB   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.comrj   z"example example"@example.comzexample examplez!"\"example\" example"@example.comz"example" examplez#"\\"example\\" example"@example.comr3   z#"\\example\\\\ example"@example.comz\example\\ examplezmerwok  wok  @example.comri   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.comr8   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ÚsenderrC   r   )r.   r1   rJ   r?   Úaddressr0   rD   ÚgroupsÚlistÚ	addressesÚdisplay_nameÚ	addr_specÚusernameÚdomain)r   rM   r?   rN   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   rC   )Úformatr.   r1   rJ   r?   rš   rœ   rD   r0   r   rž   rŸ   r    )r   rM   r?   rN   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¤   rj   r   zFred <dinsdale@python.org>rC   zfoo@example.comri   z'"Harry W. Hastings" <hasty@example.com>zHarry W. Hastings)r.   r1   rD   rš   rœ   Úranger0   r   )r   r-   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 )ri   r   )rª   r«   r   r   r   r¬   ë  s    c             S   s   g | ]}|d  ‘qS )ri   r   )rª   r«   r   r   r   r¬   í  s    z;, c             S   s   g | ]}|d  ‘qS )ri   r   )rª   r«   r   r   r   r¬   î  s    r¤   ú,r4   r   z
dummy listrC   ZanotherzA "list"ri   )r›   Úexample_paramsÚvaluesÚjoinr.   r1   ÚsplitrD   rš   r   rœ   r§   ÚassertIsNoner0   rž   )r   ZexamplesrM   Z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.comr8   )r.   r9   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.comr8   )r.   r9   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.comr8   )r.   r9   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   )r.   r   rœ   rE   r   )r   rM   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   )r.   r   rš   rE   r	   )r   rM   r   r   r   r   Útest_groups_types  s    z#TestAddressHeader.test_groups_typesc             C   s$   |   dtdddƒ¡}|  |d¡ d S )Nr¤   Úmer8   zexample.comzme <foo@example.com>)r.   r   r1   )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»   r8   zexample.comÚyour~   z+me <foo@example.com>, you <bar@example.com>)r.   r   r1   )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»   r8   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>
)r.   r   r	   r1   rK   r   rL   Ú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>;)r.   r	   r   r1   )r   r   r   r   r   Útest_set_from_Group_list3  s    z*TestAddressHeader.test_set_from_Group_list)r   r   r    r   r‚   Z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 )Nr8   )r9   r:   r;   )r   Úobjr<   r   r   r   r=   ;  s    z!TestAddressAndGroup._test_attr_roc             C   s   |   tdddƒd¡ d S )Nr8   r~   r{   r   )r=   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 )Nr8   r~   r{   rŸ   )r=   r   )r   r   r   r   Útest_address_username_roB  s    z,TestAddressAndGroup.test_address_username_roc             C   s   |   tdddƒd¡ d S )Nr8   r~   r{   r    )r=   r   )r   r   r   r   Útest_address_domain_roE  s    z*TestAddressAndGroup.test_address_domain_roc             C   s   |   tdƒd¡ d S )Nr8   r   )r=   r	   )r   r   r   r   Útest_group_display_name_roH  s    z.TestAddressAndGroup.test_group_display_name_roc             C   s   |   tdƒd¡ d S )Nr8   rœ   )r=   r	   )r   r   r   r   Útest_group_addresses_roK  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 )Nr8   r~   r{   zbar@bazzfoo <bar@baz>)r   r1   r   rŸ   r    rž   r0   )r   r¢   r   r   r   Ú!test_address_from_username_domainN  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 )Nr8   zbar@baz)rž   r~   r{   zfoo <bar@baz>)r   r1   r   rŸ   r    rž   r0   )r   r¢   r   r   r   Útest_address_from_addr_specV  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ž   rB   r~   r{   )r   r1   r   rŸ   r    rž   r0   )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 )NrB   z<>)r   r1   r   rŸ   r    rž   r0   )r   r¢   r   r   r   Útest_null_addressf  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    rB   z@buzz)r   r1   r   rŸ   r    rž   r0   )r   r¢   r   r   r   Útest_domain_onlyn  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Ÿ   rB   )r   r1   r   rŸ   r    rž   r0   )r   r¢   r   r   r   Útest_username_onlyw  s    
z&TestAddressAndGroup.test_username_onlyc             C   sT   t dƒ}|  |jd¡ |  |jd¡ |  |jd¡ |  |jd¡ |  t|ƒd¡ d S )NrÔ   rB   z<>zbuzz <>)r   r1   r   rŸ   r    rž   r0   )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   r1   r   rŸ   r    rž   r0   )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   r1   r   rŸ   r    rž   r0   )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 )Nr8   u   wÅ‘k@example.com)rž   )r9   Ú
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 )Nr8   r¿   zbar@baz)rŸ   rž   )r9   rq   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 )Nr8   r¿   zbar@baz)r    rž   )r9   rq   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 )Nr8   Zbongr¿   zbar@baz)rŸ   r    rž   )r9   rq   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 )Nr8   zbad name@example.com)rž   )r9   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 )Nr8   zname@ex[]ample.com)rž   )r9   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 )Nr8   zfoo:;)r	   r1   r   rœ   rE   r0   )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 )Nr8   )rœ   zfoo:;)r	   r1   r   rœ   rE   r0   )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   r1   rœ   rE   r0   )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¢   r8   zfoo: b <b@c>, a <b@c>;)r   r	   r1   r   rœ   rE   r0   )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   r1   rœ   rE   r0   )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   r1   rœ   rE   r0   )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	   r1   r   rœ   rE   r0   )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	   r1   r   rœ   rE   r0   )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 )Nr8   r~   zexample.com)r   ÚTor¤   zfoo <bar@example.com>)r   r   r   rL   r1   rœ   )r   r¢   rf   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   rL   r1   rœ   )r   rá   rf   r   r   r   Ú"test_set_message_header_from_groupñ  s
    z6TestAddressAndGroup.test_set_message_header_from_groupN)"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É   9  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
)r.   r1   rK   r   rL   )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
)r.   r1   rK   r   rL   )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 anywayrV   )rÅ   )r   zŽ                Subject: this is a
                 short header that
                 will be folded
                 anyway
                )r.   r1   rK   r   rL   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
)r.   r1   rK   r   rL   )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
)r.   r1   rK   r   rL   )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   Z5thisisaverylonglineconsistingofasinglewordthatwontfitrV   )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?=
)r.   r1   rK   r   rL   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 plusanotherverylongwordthatwontfitrV   )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?=
)r.   r1   rK   r   rL   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
)r.   r1   rK   r   rL   rÆ   )r   r   r   r   r   Ú.test_fold_unstructured_with_slightly_long_wordE  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.
                 )r.   r1   rK   r   rL   rÆ   ró   rô   )r   r   r   r   r   Ú"test_fold_unstructured_with_commasK  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>
             )r.   r1   rK   r   rL   ró   rô   )r   r   r   r   r   Útest_fold_address_listX  s    z"TestFolding.test_fold_address_listc             C   s&   |   dd¡}|  |jtjdd¡ d S )Nre   zSat, 2 Feb 2002 17:00:06 -0800)r   z&Date: Sat, 02 Feb 2002 17:00:06 -0800
)r.   r1   rK   r   rL   )r   r   r   r   r   Útest_fold_date_headerb  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=5Fabuse?=
 =?utf-8?q?=2Ephp=3Fmid=3Dxxx-xxx-xxxxxxxxxxxxxxxxxxxxxxxx=3D=3D-xxx-xx-xx?=
 =?utf-8?q?=3E?=
)r.   r1   rK   r   rL   )r   r   r   r   r   Ú&test_fold_overlong_words_using_RFC2047g  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__)rZ   ró   ZunittestZemailr   r   Zemail.messager   Ztest.test_emailr   r   r   Zemail.headerregistryr   r	   Úobjectrl   r
   r+   r/   rG   rS   rh   r…   r‹   r   r–   rÉ   rð   r   Úmainr   r   r   r   Ú<module>   sL   :.(1    /'?   . A|
