o
    JXh                     @   sn  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re   dS 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   M/opt/python-3.10.19/usr/lib/python3.10/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        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$      
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*   r(   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-   r*   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   r*   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.   r0   r1   r2   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   r6   r   r   r   r   r3   J   s    r3   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)r6   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/   r9         is)r6   r;   r<   r   r   r   test_substrZ   s   z"TestBaseHeaderFeatures.test_substrc                 C   s   |  dd}| |jd d S r8   )r6   r;   r4   r<   r   r   r   test_has_name^   s   z$TestBaseHeaderFeatures.test_has_namec                 C   sH   |  dd}| t t||d W d    d S 1 sw   Y  d S )Nr/   r9   foo)r6   assertRaisesAttributeErrorsetattr)r   attrr   r   r   r   _test_attr_rob   s   "z$TestBaseHeaderFeatures._test_attr_roc                 C      |  d d S )Nr4   rH   r   r   r   r   test_name_read_onlyg      z*TestBaseHeaderFeatures.test_name_read_onlyc                 C   rI   )NdefectsrJ   rK   r   r   r   test_defects_read_onlyj   rM   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/   r9   r   date    )r6   r;   lenrN   r   tupler<   r   r   r   test_defects_is_tuplem   s   z,TestBaseHeaderFeatures.test_defects_is_tupleN)
r$   r%   r&   r=   rA   rB   rH   rL   rO   rU   r   r   r   r   r7   R   s    r7   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: rQ   rR   
r   r   )rS   r6   r;   assertDefectsEqualrN   foldr   default)	r   sourcedecodedr!   lrN   headerfoldedr   r   r   r   string_as_value   s   z&TestUnstructuredHeader.string_as_valuez=?utf-8?q?this_is_a_test?=r9   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&   ra   Zstring_paramsr   r   r   r   rV      s    
rV   c                	   @   s   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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 NrP   r   )r6   
datestringr;   datetimedt	utcoffsetrN   r<   r   r   r   test_parse_date   s
   zTestDateHeader.test_parse_datec                 C   s>   |  d| j}| || j | |j| j | |jd d S rj   )r6   rm   r;   rk   rl   rN   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 )NrP   rR   r   )r6   rk   r   r   ZUniqueDateHeaderr;   	max_countrN   r<   r   r   r   test_date_header_properties      z*TestDateHeader.test_date_header_propertiesc                 C   s<   |  d| j}| |tj | |jd  | |jd d S )Nzresent-dater   )r6   rk   r   r   Z
DateHeaderr;   rq   rN   r<   r   r   r   "test_resent_date_header_properties   rs   z1TestDateHeader.test_resent_date_header_propertiesc                 C   s6   |  dd}| t|jd | |jd tj d S )NrP   rQ   rR   r   )r6   r;   rS   rN   r   r   HeaderMissingRequiredValuer<   r   r   r   test_no_value_is_defect   s   z&TestDateHeader.test_no_value_is_defectc                 C   R   d}|  d|}| || | |j | t|jd | |jd tj d S )NzNot a date headerrP   rR   r   	r6   r;   assertIsNonerl   rS   rN   r   r   ZInvalidDateDefectr   sr   r   r   r   test_invalid_date_format      z'TestDateHeader.test_invalid_date_formatc                 C   rw   )NzTue, 06 Jun 2017 27:39:33 +0600rP   rR   r   rx   rz   r   r   r   test_invalid_date_value   r}   z&TestDateHeader.test_invalid_date_valuec                 C   sD   |  d| j}| t d|_W d    d S 1 sw   Y  d S )NrP   rC   )r6   rk   rD   rE   rl   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   r[   rm   r;   rk   rl   )r   mr   r   r   "test_set_date_header_from_datetime   s   
z1TestDateHeader.test_set_date_header_from_datetimeN)r$   r%   r&   rk   rl   Z	timedeltarn   timezoneZtzrm   ro   rp   rr   rt   rv   r|   r~   r   r   r   r   r   r   rd      s    
rd   c                   @   s  e Zd Zdd Zi ddddddd	ig d
fddddddd	ig d
fdd
ddddd	ifdddddi ejgfdddddi ejgfdddddi ejgfdddddi ejgfddddddddddddddd ifd!d"ddddd#ifd$d%ddddd&ifd'd(ddddd ig d)fd*d+dddd,dig d-fd.d/dddd,d0ifi d1d2dddd,d3ifd4d5dddd6d6d7ejgd8 fd9d:d;d<d=d>d?ig d@fdAdBdCdDdEdFdGdHdIg dJdKfdLdMdCdDdEdFdGdHdNdOg dMdPfdQdRdCdDdEdSdTifdUdVdCdDdEdSdWifdXdYdCdDdEdSdZig dYfd[d\d]d	d^d_d`dadbdcddejgd8 dedffdgdhdCdDdEdSdiig djfdkdldCdDdEdadmig dnfdodpd]d	d^dddd	dqdrejgdsdtfdudvddddd	ig d
fdwdxddddSdyig dzfd{d|ddddSd}iejgd~ dfdddddd	ddrejgd~ ddfddddddSdiejgd~ dfdddddSdig dfdddddSdiejgdfdddddSdiejgd~ dfdddddSdiejgd~ dfdddddSdiejgddfdddddSdig dfddddddiejgddfddddddiejgddfddddddig ddfdddddSdiejgdfdddddSdiejgd8 dfdddddSdiejgd~ dfdddddSdig ddfdZ	dS )TestContentTypeHeaderc                 G   s$  t |}|dkr|d ni }|dkr|d ng }|dkr&|d tur&|d n|}	|r,dnd}
|dkr6|d n|
|	 d }| d|}| |j| | |j| | |j| | |j| | t	 d	|jd
< W d    n1 ssw   Y  | 
|j| | ||	 | |jtjd| d S )Nr   rR      zContent-Type: rQ      rX   zContent-TypeZxyzabcr   )rS   DITTOr6   r;   content_typemaintypesubtypeparamsrD   	TypeErrorrY   rN   rZ   r   r[   )r   r\   r   r   r   r!   r^   parmdictrN   r]   r_   r`   r   r   r   r   content_type_as_value   s"    z+TestContentTypeHeader.content_type_as_value
RFC_2045_1z)text/plain; charset=us-ascii (Plain text)
text/plaintextplaincharsetzus-asciiztext/plain; charset="us-ascii"
RFC_2045_2ztext/plain; charset=us-ascii
RFC_2045_3Zno_subtype_in_content_typeztext/Zno_slash_in_content_typerC   Zjunk_text_in_content_typez<crazy "stuff">Z too_many_slashes_in_content_typezimage/jpeg/fooZunknown_content_type)	bad/namesr   ZbadnamesZmixed_case_content_type)z
ImAge/JPeg
image/jpegimagejpegZspaces_in_content_type)z  text  /  plain  r   r   r   Zcfws_in_content_type)z"(foo) text (bar)/(baz)plain(stuff)r   r   r   Zcharset_paramztext/plain; charset="utf-8"zutf-8Zcapitalized_charsetztext/plain; charset="US-ASCII"zUS-ASCIIZunknown_charsetztext/plain; charset="fOo"ZfOoZ*capitalized_charset_param_name_and_commentz*text/plain; (interjection) Charset="utf-8"ztext/plain; Charset="utf-8"Zunquoted_param_valueztext/plain; title=footitleztext/plain; title="foo"Zparam_value_with_tspecialsz!text/plain; title="(bar)foo blue"z(bar)foo blueZ"param_with_extra_quoted_whitespacez0text/plain; title="  a     loong  way 	 home   "z  a     loong  way 	 home   Z
bad_paramszblarg; baz; boorQ   )bazZboor   Zspaces_around_param_equalsz0Multipart/mixed; boundary = "CPIMSSMTPC06p5f3tG"zmultipart/mixedZ	multipartZmixedboundaryZCPIMSSMTPC06p5f3tGz.Multipart/mixed; boundary="CPIMSSMTPC06p5f3tG"Zspaces_around_semiszPimage/jpeg; name="wibble.JPG" ; x-mac-type="4A504547" ; x-mac-creator="474B4F4E"r   r   r   z
wibble.JPGZ4A504547Z474B4F4E)r4   
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"
Zlots_of_mime_paramszmimage/jpeg; name="wibble.JPG"; x-mac-type="4A504547"; x-mac-creator="474B4F4E"; x-extrastuff="make it longer"zmake it longer)r4   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semis_inside_quotesz$image/jpeg; name="Jim&amp;&amp;Jill"r4   zJim&amp;&amp;JillZsingle_quotes_inside_quotesz!image/jpeg; name="Jim 'Bob' Jill"zJim 'Bob' JillZdouble_quotes_inside_quotesz#image/jpeg; name="Jim \"Bob\" Jill"zJim "Bob" JillZnon_ascii_in_paramsu   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rfc2231_segmented_normal_valuesz(image/jpeg; name*0="abc"; name*1=".html"zabc.htmlzimage/jpeg; name="abc.html"Zquotes_inside_rfc2231_valuez.image/jpeg; bar*0="baz\"foobar"; bar*1="\"baz"zbaz"foobar"bazz"image/jpeg; bar="baz\"foobar\"baz"Znon_ascii_rfc2231_valueuG   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rfc2231_encoded_charsetz-text/plain; charset*=ansi-x3.4-1968''us-asciiZ rfc2231_encoded_no_double_quotesz\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"Z"rfc2231_encoded_with_double_quoteszvtext/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.pdfr   z<text/plain; name="This is even more ***fun*** is it not.pdf"Z)rfc2231_single_quote_inside_double_quotesztext/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!"
Z3rfc2231_single_quote_in_value_with_charset_and_langzHapplication/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
)Z)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   r      s    (08FNTZdkry 
      "
  *  4  E  Y  `  g  p

           
    (    2    @
    M
    ]
    i





    r   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r|d tur|d n|}|r"dnd}|dkr,|d n|| d }| d|}	| |	j| | |	j| | |	| | |	jtj	d| d S )	Nr   rR   zContent-Transfer-Encoding: rQ   r   rX   zContent-Transfer-Encodingr   )
rS   r   r6   r;   cterY   rN   rZ   r   r[   )
r   r\   r   r!   r^   rN   r]   r_   r`   r   r   r   r   cte_as_value&  s    z(TestContentTransferEncoding.cte_as_value)base64r   rQ   Z7bitzContent-Transfer-Encoding:
z7bit and a bunch more)
RFC_2183_1no_valueZjunk_after_cteN)r$   r%   r&   r   r   ru   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r&|d tur&|d n|}|r,dnd}|dkr6|d n|| d }	| d|}
| |
j| | |
j| | |
j| | |
| | |
jt	j
d	|	 d S )
Nr   rR   r   zContent-Disposition: rQ   r   rX   zContent-Dispositionr   )rS   r   r6   r;   content_dispositionr   rY   rN   rZ   r   r[   )r   r\   r   r!   r^   r   rN   r]   r_   r`   r   r   r   r   content_disp_as_valueN  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"
rQ   NzContent-Disposition:
zab./kzab.zab./k; filename="foo"r   rC   zaattachment; filename="=?UTF-8?Q?Schulbesuchsbest=C3=A4ttigung=2E?=               =?UTF-8?Q?pdf?="u   Schulbesuchsbestättigung.pdfr   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   ru   r   Zcontent_disp_paramsr   r   r   r   r   K  sX    	

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-VersionrW   r   zMIME-Version:rX   )
r6   r;   versionmajorminorrY   rN   rZ   r   r[   )r   r\   r]   r   r   r   rN   r   r   r   r   version_string_as_MIME_Version  s   
z4TestMIMEVersionHeader.version_string_as_MIME_Versionz1.0rR   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.1r   z1 .0z  1.0  z	1.0 <abc>z	<abc> 1.0Nz1.<abc>0z1..0z2.xrC   rQ   )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_xrC   missing)r$   r%   r&   r   r   r   ru   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<>rQ   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.comr   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.comr   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>rb   foo@example.comrC   z6The =?utf-8?q?=C3=89ric=2C?= Himself <foo@example.com>u&   "The Éric, Himself" <foo@example.com>rc   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senderrR   r   )r6   r;   rY   rN   addressr:   rS   groupslist	addressesdisplay_name	addr_specusernamedomain)r   r\   rN   r]   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   rR   )formatr6   r;   rY   rN   r   r   rS   r:   r   r   r   r   )r   r\   rN   r]   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|  q$| 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   r   r   zFred <dinsdale@python.org>rR   r   r   z'"Harry W. Hastings" <hasty@example.com>zHarry W. Hastings)r6   r;   rS   r   r   ranger:   r   )r   r5   r   ir   r   r   test_simple_address_list   s    z*TestAddressHeader.test_simple_address_listc                 C   sj  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 ]!}| |j|d  j	 | t|j|d  j
d || d  qt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      g | ]}|d  qS r   r   .0xr   r   r   
<listcomp>      z?TestAddressHeader.test_complex_address_list.<locals>.<listcomp>   z"A \"list\"": c                 S   r   r   r   r   r   r   r   r     r      z;,c                 S   r   r   r   r   r   r   r   r     r   zdummy list:;, another:;, c                 S   r   r   r   r   r   r   r   r     r   c                 S   r   r   r   r   r   r   r   r     r   z;, c                 S   r   r   r   r   r   r   r   r     r   r   ,r?   r   z
dummy listrR   ZanotherzA "list"r   )r   example_paramsvaluesjoinr6   r;   splitrS   r   r   r   r   ry   r:   r   )r   Zexamplesr\   Zexpectedr   r   r   r   r   test_complex_address_list  sZ   ** z+TestAddressHeader.test_complex_address_listc                 C   B   |  dd}| t d|_W d    d S 1 sw   Y  d S Nr   zabc@xyz.comrC   )r6   rD   rE   r   r<   r   r   r   test_address_read_only3     "z(TestAddressHeader.test_address_read_onlyc                 C   r   r   )r6   rD   rE   r   r<   r   r   r   test_addresses_read_only8  r   z*TestAddressHeader.test_addresses_read_onlyc                 C   r   r   )r6   rD   rE   r   r<   r   r   r   test_groups_read_only=  r   z'TestAddressHeader.test_groups_read_onlyc                 C   4   d}|  d|}| |jt | |jd t d S Nzme <who@example.com>r   r   )r6   r   r   rT   r	   r   r\   r   r   r   r   test_addresses_typesB     z&TestAddressHeader.test_addresses_typesc                 C   r   r   )r6   r   r   rT   r
   r   r   r   r   test_groups_typesH  r   z#TestAddressHeader.test_groups_typesc                 C   s$   |  dtddd}| |d d S )Nr   merC   r   zme <foo@example.com>r6   r	   r;   r<   r   r   r   test_set_from_AddressN  s   z'TestAddressHeader.test_set_from_Addressc                 C   s0   |  dtdddtdddg}| |d d S )Nr   r   rC   r   your   z+me <foo@example.com>, you <bar@example.com>r   r<   r   r   r   test_set_from_Address_listR  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   rC   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>
)r6   r	   r
   r;   rZ   r   r[   cloner<   r   r   r   $test_set_from_Address_and_Group_listW  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>;)r6   r
   r	   r;   r<   r   r   r   test_set_from_Group_listc  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   <  s4   
















   #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    d S 1 sw   Y  d S )NrC   )rD   rE   rF   )r   objrG   r   r   r   rH   k     "z!TestAddressAndGroup._test_attr_roc                 C      |  tdddd d S )NrC   r   r   r   rH   r	   rK   r   r   r   test_address_display_name_roo     z0TestAddressAndGroup.test_address_display_name_roc                 C   r  )NrC   r   r   r   r  rK   r   r   r   test_address_username_ror  r  z,TestAddressAndGroup.test_address_username_roc                 C   r  )NrC   r   r   r   r  rK   r   r   r   test_address_domain_rou  r  z*TestAddressAndGroup.test_address_domain_roc                 C      |  tdd d S )NrC   r   rH   r
   rK   r   r   r   test_group_display_name_rox     z.TestAddressAndGroup.test_group_display_name_roc                 C   r  )NrC   r   r  rK   r   r   r   test_group_addresses_ro{  r
  z+TestAddressAndGroup.test_group_addresses_roc                 C   X   t ddd}| |jd | |jd | |jd | |jd | t|d d S )NrC   r   r   bar@bazfoo <bar@baz>r	   r;   r   r   r   r   r:   r   r   r   r   r   !test_address_from_username_domain~     z5TestAddressAndGroup.test_address_from_username_domainc                 C   sX   t ddd}| |jd | |jd | |jd | |jd | t|d d S )NrC   r  r   r   r   r  r  r  r   r   r   test_address_from_addr_spec  r  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  rQ   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 )NrQ   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   rQ   z@buzzr  r  r   r   r   test_domain_only     
z$TestAddressAndGroup.test_domain_onlyc                 C   sV   t dd}| |jd | |jd | |jd | |jd | t|d d S )Nr  r   rQ   r  r  r   r   r   test_username_only  r  z&TestAddressAndGroup.test_username_onlyc                 C   sT   t d}| |jd | |jd | |jd | |jd | t|d d S )Nr  rQ   r   zbuzz <>r  r  r   r   r   test_display_name_only  s   z*TestAddressAndGroup.test_display_name_onlyc                 C   r  )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   r  )Nrb   Zwoku   exàmple.comu   wok@exàmple.comu   Éric <wok@exàmple.com>r  r  r   r   r   	test_il8n  r  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 ]5}| j|d% | td tdi | W d    n1 sUw   Y  W d    n1 sdw   Y  q4d 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 argumentsr   )dictZsubTestZassertRaisesRegex
ValueErrorr	   )r   casesr   r   r   r   $test_crlf_in_constructor_args_raises  s*    z8TestAddressAndGroup.test_crlf_in_constructor_args_raisesc                 C   <   |  t tddd W d    d S 1 sw   Y  d S )NrC   u   wők@example.comr  rD   r"  r	   rK   r   r   r   +test_non_ascii_username_in_addr_spec_raises  r   z?TestAddressAndGroup.test_non_ascii_username_in_addr_spec_raisesc                 C   >   |  t tdddd W d    d S 1 sw   Y  d S )NrC   r   r  )r   r   rD   r   r	   rK   r   r   r   *test_address_addr_spec_and_username_raises     "z>TestAddressAndGroup.test_address_addr_spec_and_username_raisesc                 C   r(  )NrC   r   r  )r   r   r)  rK   r   r   r   (test_address_addr_spec_and_domain_raises  r+  z<TestAddressAndGroup.test_address_addr_spec_and_domain_raisesc                 C   s@   |  t tddddd W d    d S 1 sw   Y  d S )NrC   Zbongr   r  )r   r   r   r)  rK   r   r   r   5test_address_addr_spec_and_username_and_domain_raises  s   "zITestAddressAndGroup.test_address_addr_spec_and_username_and_domain_raisesc                 C   r%  )NrC   zbad name@example.comr  r&  rK   r   r   r   'test_space_in_addr_spec_username_raises  r   z;TestAddressAndGroup.test_space_in_addr_spec_username_raisesc                 C   r%  )NrC   zname@ex[]ample.comr  r&  rK   r   r   r   test_bad_addr_sepc_raises  r   z-TestAddressAndGroup.test_bad_addr_sepc_raisesc                 C   :   t d}| |jd | |jt  | t|d d S )NrC   r   r
   r;   r   r   rT   r:   r   gr   r   r   test_empty_group     z$TestAddressAndGroup.test_empty_groupc                 C   s>   t dg d}| |jd | |jt  | t|d d S )NrC   r   r   r1  r2  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
   ry   r   r;   r   rT   r:   r2  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   rC   zfoo: b <b@c>, a <b@c>;)r	   r
   r;   r   r   rT   r:   r   addrsr3  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 )Nr9  r:  r   r6  zNone: b <b@c>, a <b@c>;r	   r
   ry   r   r;   r   rT   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 )Nr9  r:  r6  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   r0  )Nzfoo.barz"foo.bar":;r1  r2  r   r   r   test_display_name_quoting!  r5  z-TestAddressAndGroup.test_display_name_quotingc                 C   r0  )Nr   	foo bar:;r1  r2  r   r   r   #test_display_name_blanks_not_quoted'  r5  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 )NrC   r   r   r   Tor   zfoo <bar@example.com>)r	   r   r   r[   r;   r   )r   r   r   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   rD  r   rB  )r
   r   r   r[   r;   r   )r   r3  r   r   r   r   "test_set_message_header_from_group4  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 )NrC   r   r   r   )r	   r;   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 )NrC   r   r   r   r   )r	   r
   r;   rG  rH  rI  rJ  r   )r   r   r3  r   r   r   test_group_comparisonD  s   z)TestAddressAndGroup.test_group_comparisonN)%r$   r%   r&   rH   r  r  r  r	  r  r  r  r  r  r  r  r  r  r  r$  r'  r*  r,  r-  r.  r/  r4  r7  r8  r=  r?  r@  rA  rC  rE  rF  rK  rL  r   r   r   r   r   i  sF    		
	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 ]\}}|  dt|dd}| |jtjdd|  qdS )z1Test the folding and encoding of address headers.)	)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?=rD  za@b.comr  r   zTo: %s <a@b.com>
N)r6   r	   r;   rZ   r   r[   )r   r4   resultr   r   r   r   test_address_display_namesP  s   z&TestFolding.test_address_display_namesc                 C   &   |  dd}| |jtjdd d S )Nr/   r9   r   zsubject: this is a test
r6   r;   rZ   r   r[   r<   r   r   r   test_short_unstructuredh     z#TestFolding.test_short_unstructuredc                 C   rP  )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
rQ  r<   r   r   r   test_long_unstructuredm  s   z"TestFolding.test_long_unstructuredc                 C   4   |  dd}| |jtjjdddtd d S )Nr   z1this is a short header that will be folded anywayrg   r   r   z                Subject: this is a
                 short header that
                 will be folded
                 anyway
                r6   r;   rZ   r   r[   r   textwrapdedentr<   r   r   r   'test_unstructured_short_max_line_lengthv  s
   z3TestFolding.test_unstructured_short_max_line_lengthc                 C   rP  )Nr   r   r   zSubject: test
rQ  r<   r   r   r   "test_fold_unstructured_single_word  s   z.TestFolding.test_fold_unstructured_single_wordc                 C   rP  )Nr   ztest test testr   zSubject: test test test
rQ  r<   r   r   r   test_fold_unstructured_short  rS  z(TestFolding.test_fold_unstructured_shortc                 C   .   |  dd}| |jtjjdddd d S )Nr   Z5thisisaverylonglineconsistingofasinglewordthatwontfitrg   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?=
r6   r;   rZ   r   r[   r   r<   r   r   r   )test_fold_unstructured_with_overlong_word  
   z5TestFolding.test_fold_unstructured_with_overlong_wordc                 C   r\  )Nr   zXthisisaverylonglineconsistingofasinglewordthatwontfit plusanotherverylongwordthatwontfitrg   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]  r<   r   r   r   .test_fold_unstructured_with_two_overlong_words  r_  z:TestFolding.test_fold_unstructured_with_two_overlong_wordsc                 C   r\  )Nr   Z thislongwordislessthanmaxlinelen#   r   r   z+Subject:
 thislongwordislessthanmaxlinelen
r]  r<   r   r   r   .test_fold_unstructured_with_slightly_long_word  s
   z:TestFolding.test_fold_unstructured_with_slightly_long_wordc                 C   rU  )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.
                 rV  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 )NrD  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>
             )r6   r;   rZ   r   r[   rW  rX  r<   r   r   r   test_fold_address_list  s    z"TestFolding.test_fold_address_listc                 C   rP  )Nr   zSat, 2 Feb 2002 17:00:06 -0800r   z&Date: Sat, 02 Feb 2002 17:00:06 -0800
rQ  r<   r   r   r   test_fold_date_header  rS  z!TestFolding.test_fold_date_headerc                 C   rP  )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?=
rQ  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>rg   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>
r]  r<   r   r   r   $test_message_id_header_is_not_folded  s4   z0TestFolding.test_message_id_header_is_not_foldedN)r$   r%   r&   rO  rR  rT  rY  rZ  r[  r^  r`  rb  rd  re  rf  rg  ri  r   r   r   r   rM  N  s    	
rM  __main__)!rl   rW  ZunittestZemailr   r   Zemail.messager   Ztest.test_emailr   r   r   Zemail.headerregistryr	   r
   Ztest.supportr   rI  r   r   r3   r7   rV   rd   r   r   r   r   r   r   rM  r$   mainr   r   r   r   <module>   sT    :.(A    ;'R   . f 1