a
    ze|                     @   sl  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 d dl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rhe   dS )"    N)errorspolicy)Message)TestEmailBaseparameterize)headerregistry)AddressGroup)	ALWAYS_EQc                   @   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   9/usr/lib/python3.9/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   ZassertNotInregistryr   r   UniqueUnstructuredHeaderr   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    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Zdefault_classr   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 )Nr+   subjectr   )r   r   r*   r   r   r   r   r   r   r   2test_override_default_class_only_overrides_default3   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   test_dont_use_default_map9   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 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/   r0   r   r   r   r   r      s   r   c                   @   s   e Zd Ze Zdd ZdS )TestHeaderBasec                 C   s   |  ||S r    )r   )r   namevaluer   r   r   make_headerN   s    zTestHeaderBase.make_headerN)r$   r%   r&   r   r   r   r4   r   r   r   r   r1   J   s   r1   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-   this is a test)r4   r   strassertEqualr   r   r   r   r   test_strT   s    zTestBaseHeaderFeatures.test_strc                 C   s$   |  dd}| |dd d d S )Nr-   r7         is)r4   r9   r:   r   r   r   test_substrZ   s    z"TestBaseHeaderFeatures.test_substrc                 C   s   |  dd}| |jd d S r6   )r4   r9   r2   r:   r   r   r   test_has_name^   s    z$TestBaseHeaderFeatures.test_has_namec                 C   sF   |  dd}| t t||d W d    n1 s80    Y  d S )Nr-   r7   foo)r4   assertRaisesAttributeErrorsetattr)r   attrr   r   r   r   _test_attr_rob   s    z$TestBaseHeaderFeatures._test_attr_roc                 C   s   |  d d S )Nr2   rF   r   r   r   r   test_name_read_onlyg   s    z*TestBaseHeaderFeatures.test_name_read_onlyc                 C   s   |  d d S )NdefectsrG   rH   r   r   r   test_defects_read_onlyj   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-   r7   r   date    )r4   r9   lenrJ   r   tupler:   r   r   r   test_defects_is_tuplem   s    z,TestBaseHeaderFeatures.test_defects_is_tupleN)
r$   r%   r&   r;   r?   r@   rF   rI   rK   rQ   r   r   r   r   r5   R   s   r5   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: rM   rN   
r   r   )rO   r4   r9   assertDefectsEqualrJ   foldr   default)	r   sourcedecodedr!   lrJ   headerfoldedr   r   r   r   string_as_value   s    z&TestUnstructuredHeader.string_as_valuez=?utf-8?q?this_is_a_test?=r7   z!=?gb2312?b?1eLKx9bQzsSy4srUo6E=?=u   这是中文测试！z(=?utf-8?b?6L+Z5piv5Lit5paH5rWL6K+V77yB?=)z=?utf-8?q?=C3=89ric?=   Éric)z$The =?utf-8?q?=C3=89ric=2C?= Himself   The Éric, Himself)Zrfc2047_simple_quopriZrfc2047_gb2312_base64Zrfc2047_simple_nonascii_quopriZ rfc2047_quopri_with_regular_textN)r$   r%   r&   r]   Zstring_paramsr   r   r   r   rR      s   rR   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 NrL   r   )r4   
datestringr9   datetimedt	utcoffsetrJ   r:   r   r   r   test_parse_date   s
    zTestDateHeader.test_parse_datec                 C   s>   |  d| j}| || j | |j| j | |jd d S rf   )r4   ri   r9   rg   rh   rJ   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 )NrL   rN   r   )r4   rg   r   r   ZUniqueDateHeaderr9   	max_countrJ   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   )r4   rg   r   r   Z
DateHeaderr9   rm   rJ   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 )NrL   rM   rN   r   )r4   r9   rO   rJ   r   r   HeaderMissingRequiredValuer:   r   r   r   test_no_value_is_defect   s    z&TestDateHeader.test_no_value_is_defectc                 C   sB   |  d| j}| t d|_W d    n1 s40    Y  d S )NrL   rA   )r4   rg   rB   rC   rh   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 )Nr   Date)r   r   rW   ri   r9   rg   rh   )r   mr   r   r   "test_set_date_header_from_datetime   s    
z1TestDateHeader.test_set_date_header_from_datetimeN)r$   r%   r&   rg   rh   Z	timedeltarj   timezoneZtzri   rk   rl   rn   ro   rq   rr   ru   r   r   r   r   r`      s   
r`   c                6   @   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ddfddddddig ddfddedfdgd<diejgdfddedfdgd<diejgd% dfddedfdgd<diejgd^ dfddedfdgd<dig ddfd/Z	dS )TestContentTypeHeaderc                 G   s$  t |}|dkr|d ni }|dkr,|d ng }|dkrL|d turL|d n|}	|rXdnd}
|dkrl|d n
|
|	 d }| d|}| |j| | |j| | |j| | |j| | t	 d	|jd
< W d    n1 s0    Y  | 
|j| | ||	 | |jtjd| d S )Nr   rN      zContent-Type: rM      rT   zContent-TypeZxyzabcr   )rO   DITTOr4   r9   content_typemaintypesubtypeparamsrB   	TypeErrorrU   rJ   rV   r   rW   )r   rX   r|   r}   r~   r!   rZ   parmdictrJ   rY   r[   r\   r   r   r   r   content_type_as_value   s      (z+TestContentTypeHeader.content_type_as_valuez)text/plain; charset=us-ascii (Plain text)
text/plaintextplaincharsetzus-asciiztext/plain; charset="us-ascii"ztext/plain; charset=us-asciiztext/rA   z<crazy "stuff">zimage/jpeg/foo)	bad/namesr   Zbadnames)z
ImAge/JPeg
image/jpegimagejpeg)z  text  /  plain  r   r   r   )z"(foo) text (bar)/(baz)plain(stuff)r   r   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; boorM   )bazZboory   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"r   r   r   z
wibble.JPGZ4A504547Z474B4F4E)r2   
x-mac-type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)r2   r   r   z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"r2   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; br="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.pdfrx   z<text/plain; name="This is even more ***fun*** is it not.pdf"ztext/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
u-   text/plain; charset*=utf-8”''utf-8%E2%80%9Dz9Content-Type: text/plain; charset*=utf-8''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"zContent-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_valueZ6rfc2231_nonascii_in_charset_of_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decodeZUndecodableBytesDefectZcontent_type_paramsr   r   r   r   rw      s  

			
	












    rw   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ur8|d n|}|rDdnd}|dkrX|d n
|| d }| d|}	| |	j| | |	j| | |	| | |	jtj	d| d S )	Nr   rN   zContent-Transfer-Encoding: rM   rx   rT   zContent-Transfer-Encodingr   )
rO   r{   r4   r9   cterU   rJ   rV   r   rW   )
r   rX   r   r!   rZ   rJ   rY   r[   r\   r   r   r   r   cte_as_value  s     z(TestContentTransferEncoding.cte_as_value)base64r   rM   Z7bitzContent-Transfer-Encoding:
z7bit and a bunch more)
RFC_2183_1no_valueZjunk_after_cteN)r$   r%   r&   r   r   rp   r   Z
cte_paramsr   r   r   r   r     s   	r   c                   @   s   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dddiejgd ddfddddiejgdd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urL|d n|}|rXdnd}|dkrl|d n
|| d }	| d|}
| |
j| | |
j| | |
j| | |
| | |
jt	j
d	|	 d S )
Nr   rN   rx   zContent-Disposition: rM   ry   rT   zContent-Dispositionr   )rO   r{   r4   r9   content_dispositionr   rU   rJ   rV   r   rW   )r   rX   r   r!   rZ   r   rJ   rY   r[   r\   r   r   r   r   content_disp_as_value>  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"
rM   NzContent-Disposition:
zab./kzab.zab./k; filename="foo"r   rA   zaattachment; filename="=?UTF-8?Q?Schulbesuchsbest=C3=A4ttigung=2E?=               =?UTF-8?Q?pdf?="u   Schulbesuchsbestättigung.pdfry   u4   attachment; filename="Schulbesuchsbestättigung.pdf"zUContent-Disposition: attachment;
 filename*=utf-8''Schulbesuchsbest%C3%A4ttigung.pdf
z<attachment; filename="File =?utf-8?q?Name?= With Spaces.pdf"zFile Name With Spaces.pdfz0attachment; filename="File Name With Spaces.pdf"zFContent-Disposition: attachment; filename="File Name With Spaces.pdf"
)r   Z
RFC_2183_2r   Zinvalid_valueZinvalid_value_with_paramsZ+invalid_parameter_value_with_fws_between_ewZ'parameter_value_with_fws_between_tokens)r$   r%   r&   r   r   rp   r   Zcontent_disp_paramsr   r   r   r   r   ;  sV   	
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-VersionrS   r   zMIME-Version:rT   )
r4   r9   versionmajorminorrU   rJ   rV   r   rW   )r   rX   rY   r   r   r   rJ   r   r   r   r   version_string_as_MIME_Version  s    
z4TestMIMEVersionHeader.version_string_as_MIME_Versionz1.0rN   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.1rx   z1 .0z  1.0  z	1.0 <abc>z	<abc> 1.0Nz1.<abc>0z1..0z2.xrA   rM   )r   r   r   Z
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_xrA   missing)r$   r%   r&   r   r   r   rp   Zversion_string_paramsr   r   r   r   r     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TestAddressHeader<>rM   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.com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jxdexample.comz""example" example"@example.comry   z"example example"@example.comzexample examplez!"\"example\" example"@example.comz"example" examplez#"\\"example\\" example"@example.comr<   z#"\\example\\\\ example"@example.comz\example\\ examplezmerwok  wok  @example.comrx   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>r^   foo@example.comrA   z6The =?utf-8?q?=C3=89ric=2C?= Himself <foo@example.com>u&   "The Éric, Himself" <foo@example.com>r_   z)"=?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senderrN   r   )r4   r9   rU   rJ   addressr8   rO   groupslist	addressesdisplay_name	addr_specusernamedomain)r   rX   rJ   rY   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: {};foo:;tor   rN   )formatr4   r9   rU   rJ   r   r   rO   r8   r   r   r   r   )r   rX   rJ   rY   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 tdD ]"}| |j| jd |j|  qH| 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   ry   r   zFred <dinsdale@python.org>rN   r   rx   z'"Harry W. Hastings" <hasty@example.com>zHarry W. Hastings)r4   r9   rO   r   r   ranger8   r   )r   r3   r   ir   r   r   test_simple_address_list  s     z*TestAddressHeader.test_simple_address_listc                 C   sn  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| tdD ]D}| |j|d  j	 | t|j|d  j
d || d  q~tddt| d D ]@}| |j| j	 | t|j| j
d ||d  d  qtt|D ]@}| t|j
| || d  | |j
| j|| d  q(d S )Nz dummy list:;, another: (empty);,z, c                 S   s   g | ]}|d  qS r   r   .0xr   r   r   
<listcomp>      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      z;,c                 S   s   g | ]}|d  qS r   r   r   r   r   r   r     r   zdummy list:;, another:;, c                 S   s   g | ]}|d  qS rx   r   r   r   r   r   r     r   c                 S   s   g | ]}|d  qS r   r   r   r   r   r   r     r   z;, c                 S   s   g | ]}|d  qS r   r   r   r   r   r   r     r   r   ,r=   r   z
dummy listrN   ZanotherzA "list"rx   )r   example_paramsvaluesjoinr4   r9   splitrO   r   r   r   r   assertIsNoner8   r   )r   ZexamplesrX   Zexpectedr   r   r   r   r   test_complex_address_list   sX    ,,z+TestAddressHeader.test_complex_address_listc                 C   s@   |  dd}| t d|_W d    n1 s20    Y  d S Nr   zabc@xyz.comrA   )r4   rB   rC   r   r:   r   r   r   test_address_read_only#  s    z(TestAddressHeader.test_address_read_onlyc                 C   s@   |  dd}| t d|_W d    n1 s20    Y  d S r   )r4   rB   rC   r   r:   r   r   r   test_addresses_read_only(  s    z*TestAddressHeader.test_addresses_read_onlyc                 C   s@   |  dd}| t d|_W d    n1 s20    Y  d S r   )r4   rB   rC   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   )r4   r   r   rP   r	   r   rX   r   r   r   r   test_addresses_types2  s    z&TestAddressHeader.test_addresses_typesc                 C   s4   d}|  d|}| |jt | |jd t d S r   )r4   r   r   rP   r
   r   r   r   r   test_groups_types8  s    z#TestAddressHeader.test_groups_typesc                 C   s$   |  dtddd}| |d d S )Nr   merA   r   zme <foo@example.com>r4   r	   r9   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   rA   r   your   z+me <foo@example.com>, you <bar@example.com>r   r:   r   r   r   test_set_from_Address_listB  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   rA   r   bingfizzb.comziffc.comr   r   zPme <foo@example.com>, bing: fiz <z@b.com>, zif <f@c.com>;, you <bar@example.com>(   Zmax_line_lengthr   zWto: me <foo@example.com>,
 bing: fiz <z@b.com>, zif <f@c.com>;,
 you <bar@example.com>
)r4   r	   r
   r9   rV   r   rW   cloner:   r   r   r   $test_set_from_Address_and_Group_listG  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   r   r   r   r   z#bing: fiz <z@b.com>, zif <f@c.com>;)r4   r
   r	   r9   r:   r   r   r   test_set_from_Group_listS  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   ,  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$dES )FTestAddressAndGroupc                 C   s:   |  t t||d W d    n1 s,0    Y  d S )NrA   )rB   rC   rD   )r   objrE   r   r   r   rF   [  s    z!TestAddressAndGroup._test_attr_roc                 C   s   |  tdddd d S )NrA   r   r   r   rF   r	   rH   r   r   r   test_address_display_name_ro_  s    z0TestAddressAndGroup.test_address_display_name_roc                 C   s   |  tdddd d S )NrA   r   r   r   r   rH   r   r   r   test_address_username_rob  s    z,TestAddressAndGroup.test_address_username_roc                 C   s   |  tdddd d S )NrA   r   r   r   r   rH   r   r   r   test_address_domain_roe  s    z*TestAddressAndGroup.test_address_domain_roc                 C   s   |  tdd d S )NrA   r   rF   r
   rH   r   r   r   test_group_display_name_roh  s    z.TestAddressAndGroup.test_group_display_name_roc                 C   s   |  tdd d S )NrA   r   r   rH   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 )NrA   r   r   bar@bazfoo <bar@baz>r	   r9   r   r   r   r   r8   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 )NrA   r   r   r   r   r   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 )Nr   r   rM   r   r   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 )NrM   r   r   r   r   r   r   test_null_address  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   rM   z@buzzr   r   r   r   r   test_domain_only  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   rM   r   r   r   r   r   test_username_only  s    
z&TestAddressAndGroup.test_username_onlyc                 C   sT   t d}| |jd | |jd | |jd | |jd | t|d d S )Nr   rM   r   zbuzz <>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 namer   z"bad name"@example.comz""Sara J." <"bad name"@example.com>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 )Nr^   Zwoku   exàmple.comu   wok@exàmple.comu   Éric <wok@exàmple.com>r   r   r   r   r   	test_il8n  s    zTestAddressAndGroup.test_il8nc                 C   s   t ddt ddt ddt ddt ddt ddt d	d
t dd
t dd
t ddt ddt ddf}|D ]j}| j|dJ | td tf i | W d    n1 s0    Y  W d    qh1 s0    Y  qhd S )Nzfoo)r   zfoo
zfoo
zexample.comr   zexample.com
zexample.com
zwokr  zwok
zwok
zwok@example.comr   zwok@example.com
zwok@example.com
)kwargszinvalid arguments)dictZsubTestZassertRaisesRegex
ValueErrorr	   )r   Zcasesr  r   r   r   $test_crlf_in_constructor_args_raises  s     z8TestAddressAndGroup.test_crlf_in_constructor_args_raisesc                 C   s:   |  t tddd W d    n1 s,0    Y  d S )NrA   u   wők@example.comr   rB   r	  r	   rH   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    n1 s.0    Y  d S )NrA   r   r   )r   r   rB   r   r	   rH   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    n1 s.0    Y  d S )NrA   r   r   )r   r   r  rH   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    n1 s00    Y  d S )NrA   Zbongr   r   )r   r   r   r  rH   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    n1 s,0    Y  d S )NrA   zbad name@example.comr   r  rH   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    n1 s,0    Y  d S )NrA   zname@ex[]ample.comr   r  rH   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 )NrA   r   r
   r9   r   r   rP   r8   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 )NrA   r   r   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   r9   r   rP   r8   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   rA   zfoo: b <b@c>, a <b@c>;)r	   r
   r9   r   r   rP   r8   r   Z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   r9   r   rP   r8   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   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  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 )Nr   	foo bar:;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 )NrA   r   r   r   Tor   zfoo <bar@example.com>)r	   r   r   rW   r9   r   )r   r   rt   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 )Nr   r   r$  r   r"  )r
   r   r   rW   r9   r   )r   r  rt   r   r   r   "test_set_message_header_from_group$  s
    z6TestAddressAndGroup.test_set_message_header_from_groupc                 C   s~   t ddd}| t ddd| | t ddd| | t ddd| | t ddd| | |t k | |tk d S )NrA   r   r   r   )r	   r9   assertNotEqualassertFalseobject
assertTruer   r   r   r   r   test_address_comparison+  s    z+TestAddressAndGroup.test_address_comparisonc                 C   st   t ddd}td|g}| td|f| | td|g| | tdg | | |t k | |tk d S )NrA   r   r   r   r   )r	   r
   r9   r'  r(  r)  r*  r   )r   r   r  r   r   r   test_group_comparison4  s    z)TestAddressAndGroup.test_group_comparisonN)%r$   r%   r&   rF   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   Y  sD   		
	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S )TestFoldingc                 C   s@   dD ]6\}}|  dt|dd}| |jtjdd|  qd S )N)	)zFoo Bar, Francez"Foo Bar, France")zFoo Bar (France)z"Foo Bar (France)")u   Foo Bar, Españaz"Foo =?utf-8?q?Bar=2C_Espa=C3=B1a?=)u   Foo Bar (España)z Foo Bar =?utf-8?b?KEVzcGHDsWEp?=)u   Foo, Bar Españaz"=?utf-8?q?Foo=2C_Bar_Espa=C3=B1a?=)u   Foo, Bar [España]z(=?utf-8?q?Foo=2C_Bar_=5BEspa=C3=B1a=5D?=)u   Foo Bär, Francez"Foo =?utf-8?q?B=C3=A4r=2C?= France)u   Foo Bär <France>z%Foo =?utf-8?q?B=C3=A4r_=3CFrance=3E?=)ur   Lôrem ipsum dôlôr sit amet, cônsectetuer adipiscing. Suspendisse pôtenti. Aliquam nibh. Suspendisse pôtenti.z=?utf-8?q?L=C3=B4rem_ipsum_d=C3=B4l=C3=B4r_sit_amet=2C_c=C3=B4nsectetuer?=
 =?utf-8?q?adipiscing=2E_Suspendisse_p=C3=B4tenti=2E_Aliquam_nibh=2E?=
 Suspendisse =?utf-8?q?p=C3=B4tenti=2E?=r$  za@b.comr   r   zTo: %s <a@b.com>
)r4   r	   r9   rV   r   rW   )r   r2   resultr   r   r   r   test_address_display_names@  s
    z&TestFolding.test_address_display_namesc                 C   s&   |  dd}| |jtjdd d S )Nr-   r7   r   zsubject: this is a test
r4   r9   rV   r   rW   r:   r   r   r   test_short_unstructuredX  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 foldingr   zsSubject: This is a long header line that will need to be folded into two lines
 and will demonstrate basic folding
r0  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 anywayrc   r   r   z                Subject: this is a
                 short header that
                 will be folded
                 anyway
                r4   r9   rV   r   rW   r   textwrapdedentr:   r   r   r   'test_unstructured_short_max_line_lengthf  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
r0  r:   r   r   r   "test_fold_unstructured_single_wordr  s    z.TestFolding.test_fold_unstructured_single_wordc                 C   s&   |  dd}| |jtjdd d S )Nr   ztest test testr   zSubject: test test test
r0  r:   r   r   r   test_fold_unstructured_shortv  s    z(TestFolding.test_fold_unstructured_shortc                 C   s.   |  dd}| |jtjjdddd d S )Nr   Z5thisisaverylonglineconsistingofasinglewordthatwontfitrc   r   r   zSubject: 
 =?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?=
r4   r9   rV   r   rW   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 plusanotherverylongwordthatwontfitrc   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?=
r9  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
r9  r:   r   r   r   .test_fold_unstructured_with_slightly_long_word  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   zThis 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  r:   r   r   r   "test_fold_unstructured_with_commas  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>
             )r4   r9   rV   r   rW   r4  r5  r:   r   r   r   test_fold_address_list  s    z"TestFolding.test_fold_address_listc                 C   s&   |  dd}| |jtjdd d S )Nrs   zSat, 2 Feb 2002 17:00:06 -0800r   z&Date: Sat, 02 Feb 2002 17:00:06 -0800
r0  r:   r   r   r   test_fold_date_header  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   zX-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?=
r0  r:   r   r   r   &test_fold_overlong_words_using_RFC2047  s    z2TestFolding.test_fold_overlong_words_using_RFC2047c                 C   s   |  dd}| |jtjjdddd |  dd}| |jtjjdddd |  dd	}| |jtjjd
ddd |  dd}| |jtjjdddd d S )Nz
Message-IDz+<somemessageidlongerthan@maxlinelength.com>rc   r   r   z8Message-ID: <somemessageidlongerthan@maxlinelength.com>
z1<somemessageidlongerthan@[127.0.0.0.0.0.0.0.0.1]>z>Message-ID: <somemessageidlongerthan@[127.0.0.0.0.0.0.0.0.1]>
u   <ईमेल@wők.com>   u$   Message-ID: <ईमेल@wők.com>
u"   <ईमेलfromMessage@wők.com>u0   Message-ID:
 <ईमेलfromMessage@wők.com>
r9  r:   r   r   r   $test_message_id_header_is_not_folded  s4    z0TestFolding.test_message_id_header_is_not_foldedN)r$   r%   r&   r/  r1  r2  r6  r7  r8  r:  r;  r=  r?  r@  rA  rB  rD  r   r   r   r   r-  >  s   	
r-  __main__)!rh   r4  ZunittestZemailr   r   Zemail.messager   Ztest.test_emailr   r   r   Zemail.headerregistryr	   r
   Ztest.supportr   r)  r{   r   r1   r5   rR   r`   rw   r   r   r   r   r   r-  r$   mainr   r   r   r   <module>   sP   :.(1    ;'R   . f 1
