Your IP : 216.73.216.213


Current Path : /opt/alt/python36/lib64/python3.6/test/test_email/__pycache__/
Upload File :
Current File : //opt/alt/python36/lib64/python3.6/test/test_email/__pycache__/test_headerregistry.cpython-36.pyc

3

� f���@s`ddlZddlZddlZddlmZddlmZddlmZddlm	Z	m
Z
ddlmZddlm
Z
mZe�ZGdd	�d	e	�ZGd
d�de	�ZGdd
�d
e�Ze
Gdd�de��Ze
Gdd�de��Ze
Gdd�de��Ze
Gdd�de��Ze
Gdd�de��Ze
Gdd�de��Ze
Gdd�de��ZGdd�de	�ZGdd�de�Zed k�r\ej�dS)!�N)�errors)�policy)�Message)�
TestEmailBase�parameterize)�headerregistry)�Address�Groupc@s`eZdZdd�Zdd�ZGdd�d�Zdd�ZGd	d
�d
�Zdd�Zd
d�Z	dd�Z
dd�ZdS)�TestHeaderRegistrycCs2tj�}|dd�}|j|tj�|j|tj�dS)N�foobar�test)r�HeaderRegistry�assertIsInstance�
BaseHeader�UnstructuredHeader)�self�factory�h�r�H/opt/alt/python36/lib64/python3.6/test/test_email/test_headerregistry.py� test_arbitrary_name_unstructureds
z3TestHeaderRegistry.test_arbitrary_name_unstructuredcCs@tj�}|jd|j�|dd�}|j|tj�|j|tj�dS)N�Subjectr)rr
ZassertNotIn�registryrr�UniqueUnstructuredHeader)rrrrrr�test_name_case_ignoreds

z)TestHeaderRegistry.test_name_case_ignoredc@seZdZdd�ZdS)zTestHeaderRegistry.FooBasecOsdS)Nr)r�args�kwrrr�__init__ sz#TestHeaderRegistry.FooBase.__init__N)�__name__�
__module__�__qualname__rrrrr�FooBasesr!cCs8tj|jd�}|dd�}|j||j�|j|tj�dS)N)Z
base_classrr)rr
r!rr)rrrrrr� test_override_default_base_class#s
z3TestHeaderRegistry.test_override_default_base_classc@seZdZejjZdS)zTestHeaderRegistry.FooDefaultN)rrr rr�parserrrr�
FooDefault)sr$cCs8tj|jd�}|dd�}|j|tj�|j||j�dS)N)�
default_classrr)rr
r$rr)rrrrrr�test_override_default_class,s
z.TestHeaderRegistry.test_override_default_classcCs8tj|jd�}|dd�}|j|tj�|j|tj�dS)N)r%�subjectr)rr
r$rrr)rrrrrr�2test_override_default_class_only_overrides_default2s
zETestHeaderRegistry.test_override_default_class_only_overrides_defaultcCs6tjdd�}|dd�}|j|tj�|j|tj�dS)NF)Zuse_default_mapr'r)rr
rrr)rrrrrr�test_dont_use_default_map8s
z,TestHeaderRegistry.test_dont_use_default_mapcCsftj�}|dd�}|jdtj�|dd�}|j|tj�|j|tj�|j|tj�|j|tj�dS)Nrr)rr
Zmap_to_typerrrr)rrZh1Zh2rrr�test_map_to_type>s

z#TestHeaderRegistry.test_map_to_typeN)rrr rrr!r"r$r&r(r)r*rrrrr
sr
c@seZdZej�Zdd�ZdS)�TestHeaderBasecCs|j||�S)N)r)r�name�valuerrr�make_headerMszTestHeaderBase.make_headerN)rrr rr
rr.rrrrr+Isr+c@sDeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)�TestBaseHeaderFeaturescCs8|jdd�}|j|t�|j|d�|jt|�d�dS)Nr'zthis is a test)r.r�str�assertEqual)rrrrr�test_strSszTestBaseHeaderFeatures.test_strcCs$|jdd�}|j|dd�d�dS)Nr'zthis is a test���is)r.r1)rrrrr�test_substrYsz"TestBaseHeaderFeatures.test_substrcCs|jdd�}|j|jd�dS)Nr'zthis is a test)r.r1r,)rrrrr�
test_has_name]sz$TestBaseHeaderFeatures.test_has_namecCs2|jdd�}|jt��t||d�WdQRXdS)Nr'zthis is a test�foo)r.�assertRaises�AttributeError�setattr)r�attrrrrr�
_test_attr_roasz$TestBaseHeaderFeatures._test_attr_rocCs|jd�dS)Nr,)r=)rrrr�test_name_read_onlyfsz*TestBaseHeaderFeatures.test_name_read_onlycCs|jd�dS)N�defects)r=)rrrr�test_defects_read_onlyisz-TestBaseHeaderFeatures.test_defects_read_onlycCs\|jdd�}|jt|j�d�|j|jt�|jdd�}|jt|j�d�|j|jt�dS)Nr'zthis is a testr�date��)r.r1�lenr?r�tuple)rrrrr�test_defects_is_tuplelsz,TestBaseHeaderFeatures.test_defects_is_tupleN)
rrr r2r6r7r=r>r@rFrrrrr/Qsr/c@s2eZdZdd�Zddgdfddgdfddd�Zd
S)�TestUnstructuredHeaderc	Gs�t|�}|dkr|dng}d|r&dnd}||dkr>|dn|d}|jd|�}|j||�|j|j|�|j|jtjd�|�dS)	NrzSubject:� rBrC�
r)r)rDr.r1�assertDefectsEqualr?�foldr�default)	r�source�decodedr�lr?�header�foldedrrrr�string_as_value�sz&TestUnstructuredHeader.string_as_valuez=?utf-8?q?this_is_a_test?=zthis is a testz!=?gb2312?b?1eLKx9bQzsSy4srUo6E=?=u这是中文测试!z(=?utf-8?b?6L+Z5piv5Lit5paH5rWL6K+V77yB?=�=?utf-8?q?=C3=89ric?=�Éric�$The =?utf-8?q?=C3=89ric=2C?= Himself�The Éric, Himself)Zrfc2047_simple_quopriZrfc2047_gb2312_base64Zrfc2047_simple_nonascii_quopriZ rfc2047_quopri_with_regular_textN)rSrT)rUrV)rrr rRZ
string_paramsrrrrrGsrGc	@sveZdZdZejdd�Zeje�Zejdddddd	ed
�Z	dd�Z
d
d�Zdd�Zdd�Z
dd�Zdd�Zdd�ZdS)�TestDateHeaderzSun, 23 Sep 2001 20:10:55 -0700r4)Zhoursi��	���
�7)ZtzinfocCsR|jd|j�}|j||j�|j|j|j�|j|jj�|j�|j|jf�dS)NrA)r.�
datestringr1�datetime�dt�	utcoffsetr?)rrrrr�test_parse_date�s
zTestDateHeader.test_parse_datecCs>|jd|j�}|j||j�|j|j|j�|j|jf�dS)NrA)r.r_r1r]r^r?)rrrrr�test_set_from_datetime�sz%TestDateHeader.test_set_from_datetimecCs<|jd|j�}|j|tj�|j|jd�|j|jf�dS)NrArC)r.r]rrZUniqueDateHeaderr1�	max_countr?)rrrrr�test_date_header_properties�sz*TestDateHeader.test_date_header_propertiescCs<|jd|j�}|j|tj�|j|jd�|j|jf�dS)Nzresent-date)r.r]rrZ
DateHeaderr1rcr?)rrrrr�"test_resent_date_header_properties�sz1TestDateHeader.test_resent_date_header_propertiescCs6|jdd�}|jt|j�d�|j|jdtj�dS)NrArBrCr)r.r1rDr?rr�HeaderMissingRequiredValue)rrrrr�test_no_value_is_defect�sz&TestDateHeader.test_no_value_is_defectc	Cs.|jd|j�}|jt��d|_WdQRXdS)NrAr8)r.r]r9r:r^)rrrrr�test_datetime_read_only�sz&TestDateHeader.test_datetime_read_onlycCs@ttjd�}|j|d<|j|d|j�|j|dj|j�dS)N)r�Date)rrrLr_r1r]r^)r�mrrr�"test_set_date_header_from_datetime�s
z1TestDateHeader.test_set_date_header_from_datetimeNi����)rrr r]r^Z	timedeltar`ZtimezoneZtzr_rarbrdrergrhrkrrrrrW�s
rWc6@s�eZdZdd�Zddddddigd	fd
dddddigd	fd	dddddifddddiejgfddddiejgfd
dddiejgfddddiejgfd�d�d�d�ddddddifddddddifddddddifddddddigdfd dddd!digd"fd#dddd!d$ifd%dddd!d&ifd'dddd(d(d)�ejgd*fd+d,d-d.d/d0igd1fd2dddd3d4d5d6�gd7d8fd9dddd3d4d5d:d;�gd9d<fd=dddd>d?ifd@dddd>dAifdBdddd>dCigdBfdDjdE�jddF�dGdHdIdJdKdL�ejgd*dMdNfdOdddd>dPigdQfdRddddIdSigdTfdUjdE�jddF�dddddVdW�ejgdXdYfdZdddddigd	fd[dddd>d\igd]fd^dddd>d_iejgd`dafdbdddddcdW�ejgd`dddefdfdgdhdid>djiejgd`dkfdldgdhdid>dmigdnfdodddd>dpiejgdqfdrdddd>dsiejgd`dtfdrdddd>dsiejgd`dtfdudddd>dviejgdwdxfdydddd>dzigd{fd|ddddd}iejgd~dfd�ddddd�iejgd�d�fd�dgdhdid>d�iejgd�fd�dgdhdid>d�iejgd*d�fd�dgdhdid>d�iejgd`d�fd�d�d�d�dgdhdid>d�d�igd�d�d�d�d�fd��.Z	d�S)��TestContentTypeHeaderc
Gst|�}|dkr|dni}|dkr,|dng}|dkrL|dtk	rL|dn|}	|rXd
nd}
|dkrl|dn
|
|	d}|jd	|�}|j|j|�|j|j|�|j|j|�|j|j|�|jt	��d
|jd<WdQRX|j
|j|�|j||	�|j|jt
jd�|�dS)NrrC�z
Content-Type:rHrB�rIzContent-TypeZxyz�abc)rzContent-Type: )rD�DITTOr.r1�content_type�maintype�subtype�paramsr9�	TypeErrorrJr?rKrrL)
rrMrqrrrsrrO�parmdictr?rNrPrQrrrr�content_type_as_value�s  z+TestContentTypeHeader.content_type_as_valuez)text/plain; charset=us-ascii (Plain text)�
text/plain�text�plain�charsetzus-asciiztext/plain; charset="us-ascii"ztext/plain; charset=us-asciiztext/r8z<crazy "stuff">zimage/jpeg/foo�	bad/names�bad�names�
ImAge/JPeg�
image/jpeg�image�jpeg�  text  /  plain  �"(foo) text (bar)/(baz)plain(stuff)ztext/plain; charset="utf-8"zutf-8ztext/plain; charset="US-ASCII"zUS-ASCIIztext/plain; charset="fOo"ZfOoz*text/plain; (interjection) Charset="utf-8"ztext/plain; Charset="utf-8"ztext/plain; title=foo�titleztext/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   zblarg; baz; boorB)�bazZboornz0Multipart/mixed; boundary = "CPIMSSMTPC06p5f3tG"zmultipart/mixedZ	multipartZmixed�boundaryZCPIMSSMTPC06p5f3tGz.Multipart/mixed; boundary="CPIMSSMTPC06p5f3tG"zPimage/jpeg; name="wibble.JPG" ; x-mac-type="4A504547" ; x-mac-creator="474B4F4E"z
wibble.JPGZ4A504547Z474B4F4E)r,z
x-mac-typez
x-mac-creatorzNimage/jpeg; name="wibble.JPG"; x-mac-type="4A504547"; x-mac-creator="474B4F4E"z^Content-Type: image/jpeg; name="wibble.JPG"; x-mac-type="4A504547";
 x-mac-creator="474B4F4E"
zmimage/jpeg; name="wibble.JPG"; x-mac-type="4A504547"; x-mac-creator="474B4F4E"; x-extrastuff="make it longer"zmake it longer)r,z
x-mac-typez
x-mac-creatorzx-extrastuffz}Content-Type: image/jpeg; name="wibble.JPG"; x-mac-type="4A504547";
 x-mac-creator="474B4F4E"; x-extrastuff="make it longer"
z$image/jpeg; name="Jim&amp;&amp;Jill"r,zJim&amp;&amp;Jillz!image/jpeg; name="Jim 'Bob' Jill"zJim 'Bob' Jillz#image/jpeg; name="Jim \"Bob\" Jill"zJim "Bob" Jillufoo§/bar; b§r=two; baz=thr§ezlatin-1�surrogateescapeu
foo�/barufoo��barZtwouthr�e)ub�rr�u&foo�/bar; b�r="two"; baz="thr�e"uVContent-Type: =?unknown-8bit?q?foo=A7?=/bar; b�r="two";
 baz*=unknown-8bit''thr%A7e
z(image/jpeg; name*0="abc"; name*1=".html"zabc.htmlzimage/jpeg; name="abc.html"z.image/jpeg; bar*0="baz\"foobar"; bar*1="\"baz"zbaz"foobar"bazz"image/jpeg; bar="baz\"foobar\"baz"uGtext/plain; charset=us-ascii; title*=us-ascii'en'This%20is%20not%20f§nuThis is not f�n)r{r�u9text/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"zThis 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.pdfrmz<text/plain; name="This is even more ***fun*** is it not.pdf"z�text/plain; charset=us-ascii;	title*0*="us-ascii'en'This%20is%20really%20";	title*1*="%2A%2A%2Afun%2A%2A%2A%20";	title*2="isn't it!"z"This is really ***fun*** isn't it!zJtext/plain; charset="us-ascii"; title="This is really ***fun*** isn't it!"zZContent-Type: text/plain; charset="us-ascii";
 title="This is really ***fun*** isn't it!"
zHapplication/x-foo;	name*0*="us-ascii'en-us'Frank's"; name*1*=" Document"zapplication/x-fooZapplicationzx-foozFrank's Documentz*application/x-foo; name="Frank's Document"zFapplication/x-foo;	name*0="us-ascii'en-us'Frank's"; name*1=" Document"zus-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.htmlzenglish_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_defaultZascii_is_the_defaultz'text/plain; name="ascii_is_the_default"z*text/plain; charset*=ascii''utf-8%F1%F2%F3uutf-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%9Duutf-8”utext/plain; charset="utf-8”"z@Content-Type: text/plain; charset*=unknown-8bit''utf-8%E2%80%9D
zUapplication/x-foo;	name*0*="us-ascii'en-us'My";	name*1=" Document";	name*2=" For You"zMy 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"zapplication/x-foo;	name="zwith spaces��"zapplication/x-foo; name="z�Content-Type: application/x-foo;
 name*0*=us-ascii''with%20spaceswith%20spaceswith%20spaceswith%20spaceswith;
 name*1*=%20spaceswith%20spaceswith%20spaceswith%20spaces
).�
RFC_2045_1�
RFC_2045_2�
RFC_2045_3Zno_subtype_in_content_typeZno_slash_in_content_typeZjunk_text_in_content_typeZ too_many_slashes_in_content_typeZunknown_content_typeZmixed_case_content_typeZspaces_in_content_typeZcfws_in_content_typeZ
charset_paramZcapitalized_charsetZunknown_charsetZ*capitalized_charset_param_name_and_commentZunquoted_param_valueZparam_value_with_tspecialsZ"param_with_extra_quoted_whitespaceZ
bad_paramsZspaces_around_param_equalsZspaces_around_semisZlots_of_mime_paramsZsemis_inside_quotesZsingle_quotes_inside_quotesZdouble_quotes_inside_quotesZnon_ascii_in_paramsZrfc2231_segmented_normal_valuesZquotes_inside_rfc2231_valueZnon_ascii_rfc2231_valueZrfc2231_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_valueZrfc2231_no_language_or_charsetZrfc2231_encoded_no_charsetZrfc2231_partly_encodedZrfc2231_partly_encoded_2Z(rfc2231_unknown_charset_treated_as_asciiZ0rfc2231_bad_character_in_charset_parameter_valueZ8rfc2231_utf8_in_supposedly_ascii_charset_parameter_valueZ'rfc2231_encoded_then_unencoded_segmentsZ'rfc2231_unencoded_then_encoded_segmentsZ.rfc2231_quoted_unencoded_then_encoded_segmentsZ+rfc2231_folded_segments_correctly_formattedN)r|r|r}r~)rr�r�r�)r�rxryrz)r�rxryrz)
rrr rwr�InvalidHeaderDefect�encode�decodeZUndecodableBytesDefectZcontent_type_paramsrrrrrl�sh		







	
rlc@s8eZdZdd�Zd
ddejgddfddejgfd�Zd	S)�TestContentTransferEncodingc
Gs�t|�}|dkr|dng}|dkr8|dtk	r8|dn|}|rDd
nd}|dkrX|dn
||d}|jd|�}	|j|	j|�|j|	j|�|j|	|�|j|	jtj	d	�|�dS)NrrCzContent-Transfer-Encoding:rHrBrmrIzContent-Transfer-Encoding)rzContent-Transfer-Encoding: )
rDrpr.r1�cterJr?rKrrL)
rrMr�rrOr?rNrPrQrrrr�cte_as_value	s z(TestContentTransferEncoding.cte_as_value�base64rBZ7bitzContent-Transfer-Encoding:
z7bit and a bunch more)�
RFC_2183_1�no_valueZjunk_after_cteN)r�r�)rrr r�rrfr�Z
cte_paramsrrrrr�sr�c@sbeZdZdd�Zdddddd�gd	d
fddiejgdd
fddiejgfddddiejgfd�ZdS)�TestContentDispositioncGs�t|�}|dkr|dni}|dkr,|dng}|dkrL|dtk	rL|dn|}|rXdnd}|dkrl|dn
||d}	|jd	|�}
|j|
j|�|j|
j|�|j|
j|�|j|
|�|j|
jt	j
d
�|	�dS)NrrCrmzContent-Disposition:rHrBrnrIzContent-Disposition)rzContent-Disposition: )rDrpr.r1�content_dispositionrtrJr?rKrrL)rrMr�rrOrvr?rNrPrQrrrr�content_disp_as_value1s z,TestContentDisposition.content_disp_as_value�inlinezWattachment; filename=genome.jpeg;  modification-date="Wed, 12 Feb 1997 16:29:51 -0500";Z
attachmentzgenome.jpegzWed, 12 Feb 1997 16:29:51 -0500)�filenamezmodification-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"
rBNzContent-Disposition:
zab./kzab.zab./k; filename="foo"r�r8)r�Z
RFC_2183_2r�Z
invalid_valueZinvalid_value_with_params)r�r�)rrr r�rrfr�Zcontent_disp_paramsrrrrr�.s0r�c@seZdZdd�Zdddddgfdddddgfdddddgfdddddgfd	d	d	ddgfd
d
d
ddgfdddddgfd
d
dddgfdddddejgfdddddejgfdddddejgfdddddejgfdddddejgfdddddejgfdddddejgfd�ZdS)�TestMIMEVersionHeadercCs~|jd|�}|j||�|j|j|�|j|j|�|j|j|�|j|j|�|r\d|}|j|jtj	d�d|d�dS)NzMIME-VersionrH)rz
MIME-Version:rI)
r.r1�version�major�minorrJr?rKrrL)rrMrNr�r�r�r?rrrr�version_string_as_MIME_Versionqsz4TestMIMEVersionHeader.version_string_as_MIME_Versionz1.0rCrz1.0 (produced by MetaSend Vx.x)z(produced by MetaSend Vx.x) 1.0z1.(produced by MetaSend Vx.x)0z1.1z2.1rmz1 .0z  1.0  z	1.0 <abc>z	<abc> 1.0Nz1.<abc>0z1..0z2.xr8rB)r�r�r�Z
RFC_2045_4Z1_1Z2_1Z
whitespaceZ#leading_trailing_whitespace_ignoredZnon_comment_garbage_afterZnon_comment_garbage_beforeZnon_comment_garbage_insideZtwo_periodsZ2_xr8Zmissing)rrr r�rr�rfZversion_string_paramsrrrrr�ns�r�c@s�eZdZdejgddddddfdgddddddfdgddddddfd	gd	dd
dddfdgd
dddddfdgddddddfdejgddddddfdejgdddddddfdgddddddfd ejgd!d"dd"d#ddfd$ejgd%d&dd&d'ddfd(ejgd)dd)d*ddfd+gd,d-d.d/ddfd0gd1d2d.d/ddfd3ejgd,d-d.d/ddfd4�Zd5d6�Zd7d8�Zd9d:�Z	d;d<�Z
d=d>�Zd?d@�ZdAdB�Z
dCdD�ZdEdF�ZdGdH�ZdIdJ�ZdKdL�ZdMdN�ZdS)O�TestAddressHeaderz<>rBNzzippy@pinhead.comZzippyzpinhead.comz%Zaphrod Beblebrux <zippy@pinhead.com>zZaphrod Beblebruxz)Zaphrod Beblebrux <"foo bar"@pinhead.com>z"foo bar"@pinhead.comzfoo barz'"A \(Special\) Person" <person@dom.ain>z%"A (Special) Person" <person@dom.ain>zA (Special) Personzperson@dom.ainZpersonzdom.ainz."Arthur \\Backslash\\ Foobar" <person@dom.ain>zArthur \Backslash\ FoobarzJohn X. Doe <jxd@example.com>z"John X. Doe" <jxd@example.com>zJohn X. Doezjxd@example.comZjxdzexample.comz""example" example"@example.comrnz"example example"@example.comzexample examplez!"\"example\" example"@example.comz"example" examplez#"\\"example\\" example"@example.comr3z#"\\example\\\\ example"@example.comz\example\\ examplezmerwok  wok  @example.comrmz"merwok wok"@example.comz
merwok wokzmerwok. wok .  wok@example.comzmerwok.wok.wok@example.comzmerwok.wok.wokz'=?utf-8?q?=C3=89ric?= <foo@example.com>uÉric <foo@example.com>uÉriczfoo@example.comr8z6The =?utf-8?q?=C3=89ric=2C?= Himself <foo@example.com>u&"The Éric, Himself" <foo@example.com>uThe Éric, Himselfz)"=?utf-8?q?=C3=89ric?=" <foo@example.com>)�emptyZaddress_onlyZname_and_addressZquoted_local_partZquoted_parens_in_nameZquoted_backslashes_in_nameZ
name_with_dotZquoted_strings_in_local_partZ$escaped_quoted_strings_in_local_partZescaped_escapes_in_local_partZ'spaces_in_unquoted_local_part_collapsedZ(spaces_around_dots_in_local_part_removedZrfc2047_atom_is_decodedZ!rfc2047_atom_in_phrase_is_decodedZ(rfc2047_atom_in_quoted_string_is_decodedc	Cs�|jd|�}	|j|	|�|j|	j|�|	j}
|jt|
�|�|jt|	j�d�|j|
gt|	jdj	��|j|
gt|	j	��|j|
j
|�|j|
j|�|j|
j|�|j|
j
|�dS)N�senderrCr)r.r1rJr?�addressr0rD�groups�list�	addresses�display_name�	addr_spec�username�domain)rrMr?rNr�r�r�r��commentr�arrr�example_as_address�sz$TestAddressHeader.example_as_addressc	Cs�dj|�}|rdj|�nd}	|jd|�}
|j|
|	�|j|
j|�|j|
jdj|
j�|jt|
j�d�|jt|
j�d�|
jd}|jt|�|�|j|j	|�|j|j
|�|j|j|�|j|j|�dS)Nzfoo: {};zfoo:;�torrC)
�formatr.r1rJr?r�r�rDr0r�r�r�r�)rrMr?rNr�r�r�r�r�Zgdecodedrr�rrr�example_as_group�s

z"TestAddressHeader.example_as_groupcCs�d}|jd|�}|j||�|jt|j�d�|jt|j�d�x.td�D]"}|j|j|jd|j|�qJW|jt|jd�d�|jt|jd�d�|jt|jd�d	�|j|jdjd
�dS)NzTFred <dinsdale@python.org>, foo@example.com, "Harry W. Hastings" <hasty@example.com>r�rnrzFred <dinsdale@python.org>rCzfoo@example.comrmz'"Harry W. Hastings" <hasty@example.com>zHarry W. Hastings)r.r1rDr�r��ranger0r�)rr-r�irrr�test_simple_address_list�s"z*TestAddressHeader.test_simple_address_listcCszt|jj��}ddjdd�|dd�D��dddjdd�|dd�D��d	djd
d�|dd�D��}ddjdd�|dd�D��dddjd
d�|dd�D��ddjdd�|dd�D��}|jd|�}|j|jd�|jd��|j||�|jt|j�dt|�d�|j|jdj	d�|j|jdj	d�|j|jdj	d�|jt|j
�t|��xPtd�D]D}|j|j|dj	�|jt
|j|dj
d�||d��q�WxZtddt|�d�D]@}|j|j|j	�|jt
|j|j
d�||dd��q�WxPtt|��D]@}|jt
|j
|�||d�|j|j
|j||d��q2WdS)Nz dummy list:;, another: (empty);,z, cSsg|]}|d�qS)rr)�.0�xrrr�
<listcomp>�sz?TestAddressHeader.test_complex_address_list.<locals>.<listcomp>�z"A \"list\"": cSsg|]}|d�qS)rr)r�r�rrrr��s�z;,cSsg|]}|d�qS)rr)r�r�rrrr��szdummy list:;, another:;, cSsg|]}|d�qS)rmr)r�r�rrrr��scSsg|]}|d�qS)rmr)r�r�rrrr��sz;, cSsg|]}|d�qS)rmr)r�r�rrrr��sr��,r4rz
dummy listrCZanotherzA "list"rm)r��example_params�values�joinr.r1�splitrDr�r�r�r��assertIsNoner0r�)rZexamplesrMZexpectedrr�rrr�test_complex_address_list�s,FF..z+TestAddressHeader.test_complex_address_listc	Cs,|jdd�}|jt��d|_WdQRXdS)Nr�zabc@xyz.comr8)r.r9r:r�)rrrrr�test_address_read_onlysz(TestAddressHeader.test_address_read_onlyc	Cs,|jdd�}|jt��d|_WdQRXdS)Nr�zabc@xyz.comr8)r.r9r:r�)rrrrr�test_addresses_read_onlysz*TestAddressHeader.test_addresses_read_onlyc	Cs,|jdd�}|jt��d|_WdQRXdS)Nr�zabc@xyz.comr8)r.r9r:r�)rrrrr�test_groups_read_onlysz'TestAddressHeader.test_groups_read_onlycCs4d}|jd|�}|j|jt�|j|jdt�dS)Nzme <who@example.com>r�r)r.rr�rEr)rrMrrrr�test_addresses_typessz&TestAddressHeader.test_addresses_typescCs4d}|jd|�}|j|jt�|j|jdt�dS)Nzme <who@example.com>r�r)r.rr�rEr	)rrMrrrr�test_groups_typessz#TestAddressHeader.test_groups_typescCs$|jdtddd��}|j|d�dS)Nr��mer8zexample.comzme <foo@example.com>)r.rr1)rrrrr�test_set_from_Addresssz'TestAddressHeader.test_set_from_AddresscCs0|jdtddd�tddd�g�}|j|d�dS)Nr�r�r8zexample.com�your�z+me <foo@example.com>, you <bar@example.com>)r.rr1)rrrrr�test_set_from_Address_list!sz,TestAddressHeader.test_set_from_Address_listc
Csj|jdtddd�tdtddd�td	d
d�g�tdd
d�g�}|j|d�|j|jtjjdd�d�d�dS)Nr�r�r8zexample.com�bing�fiz�zzb.com�zif�fzc.comr�r�zPme <foo@example.com>, bing: fiz <z@b.com>, zif <f@c.com>;, you <bar@example.com>�()�max_line_length)rzWto: me <foo@example.com>,
 bing: fiz <z@b.com>, zif <f@c.com>;,
 you <bar@example.com>
)r.rr	r1rKrrL�clone)rrrrr�$test_set_from_Address_and_Group_list&sz6TestAddressHeader.test_set_from_Address_and_Group_listc	Cs8|jdtdtddd�tddd�g�g�}|j|d	�dS)
Nr�r�r�r�zb.comr�r�zc.comz#bing: fiz <z@b.com>, zif <f@c.com>;)r.r	rr1)rrrrr�test_set_from_Group_list2sz*TestAddressHeader.test_set_from_Group_list)rrr rr�ZObsoleteHeaderDefectr�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrr�s




#r�c@seZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Zd7d8�Zd9d:�Zd;d<�Z d=d>�Z!d?d@�Z"dAS)B�TestAddressAndGroupcCs&|jt��t||d�WdQRXdS)Nr8)r9r:r;)r�objr<rrrr=:sz!TestAddressAndGroup._test_attr_rocCs|jtddd�d�dS)Nr8r�r�r�)r=r)rrrr�test_address_display_name_ro>sz0TestAddressAndGroup.test_address_display_name_rocCs|jtddd�d�dS)Nr8r�r�r�)r=r)rrrr�test_address_username_roAsz,TestAddressAndGroup.test_address_username_rocCs|jtddd�d�dS)Nr8r�r�r�)r=r)rrrr�test_address_domain_roDsz*TestAddressAndGroup.test_address_domain_rocCs|jtd�d�dS)Nr8r�)r=r	)rrrr�test_group_display_name_roGsz.TestAddressAndGroup.test_group_display_name_rocCs|jtd�d�dS)Nr8r�)r=r	)rrrr�test_group_addresses_roJsz+TestAddressAndGroup.test_group_addresses_rocCsXtddd�}|j|jd�|j|jd�|j|jd�|j|jd�|jt|�d�dS)Nr8r�r�zbar@bazz
foo <bar@baz>)rr1r�r�r�r�r0)rr�rrr�!test_address_from_username_domainMsz5TestAddressAndGroup.test_address_from_username_domaincCsXtddd�}|j|jd�|j|jd�|j|jd�|j|jd�|jt|�d�dS)Nr8zbar@baz)r�r�r�z
foo <bar@baz>)rr1r�r�r�r�r0)rr�rrr�test_address_from_addr_specUsz/TestAddressAndGroup.test_address_from_addr_speccCsVtdd�}|j|jd�|j|jd�|j|jd�|j|jd�|jt|�d�dS)Nzbar@baz)r�rBr�r�)rr1r�r�r�r�r0)rr�rrr�!test_address_with_no_display_name]s
z5TestAddressAndGroup.test_address_with_no_display_namecCsRt�}|j|jd�|j|jd�|j|jd�|j|jd�|jt|�d�dS)NrBz<>)rr1r�r�r�r�r0)rr�rrr�test_null_addressesz%TestAddressAndGroup.test_null_addresscCsVtdd�}|j|jd�|j|jd�|j|jd�|j|jd�|jt|�d�dS)N�buzz)r�rBz@buzz)rr1r�r�r�r�r0)rr�rrr�test_domain_onlyms
z$TestAddressAndGroup.test_domain_onlycCsVtdd�}|j|jd�|j|jd�|j|jd�|j|jd�|jt|�d�dS)Nr�)r�rB)rr1r�r�r�r�r0)rr�rrr�test_username_onlyvs
z&TestAddressAndGroup.test_username_onlycCsTtd�}|j|jd�|j|jd�|j|jd�|j|jd�|jt|�d�dS)Nr�rBz<>zbuzz <>)rr1r�r�r�r�r0)rr�rrr�test_display_name_onlysz*TestAddressAndGroup.test_display_name_onlycCsXtddd�}|j|jd�|j|jd�|j|jd�|j|jd�|jt|�d�dS)NzSara J.zbad namezexample.comz"bad name"@example.comz""Sara J." <"bad name"@example.com>)rr1r�r�r�r�r0)rr�rrr�test_quoting�sz TestAddressAndGroup.test_quotingcCsXtddd�}|j|jd�|j|jd�|j|jd�|j|jd�|jt|�d�dS)NuÉricZwokuexàmple.comuwok@exàmple.comuÉric <wok@exàmple.com>)rr1r�r�r�r�r0)rr�rrr�	test_il8n�szTestAddressAndGroup.test_il8ncCs�tdd�tdd�tdd�tdd�tdd�tdd�td	d
�tdd
�tdd
�td
d�tdd�tdd�f}xF|D]>}|j|d��(|jtd��tf|�WdQRXWdQRXqjWdS)Nzfoo
)r�zfoo
zfoo
zexample.com
)r�zexample.com
z
example.com
zwok
)r�zwok
zwok
zwok@example.com
)r�zwok@example.com
zwok@example.com
)�kwargszinvalid arguments)�dictZsubTestZassertRaisesRegex�
ValueErrorr)rZcasesr�rrr�$test_crlf_in_constructor_args_raises�s
z8TestAddressAndGroup.test_crlf_in_constructor_args_raisescCs&|jt��tddd�WdQRXdS)Nr8uwők@example.com)r�)r9r�r)rrrr�+test_non_ascii_username_in_addr_spec_raises�sz?TestAddressAndGroup.test_non_ascii_username_in_addr_spec_raisescCs(|jt��tdddd�WdQRXdS)Nr8r�zbar@baz)r�r�)r9rur)rrrr�*test_address_addr_spec_and_username_raises�sz>TestAddressAndGroup.test_address_addr_spec_and_username_raisescCs(|jt��tdddd�WdQRXdS)Nr8r�zbar@baz)r�r�)r9rur)rrrr�(test_address_addr_spec_and_domain_raises�sz<TestAddressAndGroup.test_address_addr_spec_and_domain_raisesc
Cs*|jt��tddddd�WdQRXdS)Nr8Zbongr�zbar@baz)r�r�r�)r9rur)rrrr�5test_address_addr_spec_and_username_and_domain_raises�szITestAddressAndGroup.test_address_addr_spec_and_username_and_domain_raisescCs&|jt��tddd�WdQRXdS)Nr8zbad name@example.com)r�)r9r�r)rrrr�'test_space_in_addr_spec_username_raises�sz;TestAddressAndGroup.test_space_in_addr_spec_username_raisescCs&|jt��tddd�WdQRXdS)Nr8zname@ex[]ample.com)r�)r9r�r)rrrr�test_bad_addr_sepc_raises�sz-TestAddressAndGroup.test_bad_addr_sepc_raisescCs:td�}|j|jd�|j|jt��|jt|�d�dS)Nr8zfoo:;)r	r1r�r�rEr0)r�grrr�test_empty_group�sz$TestAddressAndGroup.test_empty_groupcCs>tdgd�}|j|jd�|j|jt��|jt|�d�dS)Nr8)r�zfoo:;)r	r1r�r�rEr0)rr�rrr�test_empty_group_list�sz)TestAddressAndGroup.test_empty_group_listcCs6t�}|j|j�|j|jt��|jt|�d�dS)NzNone:;)r	r�r�r1r�rEr0)rr�rrr�test_null_group�sz#TestAddressAndGroup.test_null_groupcCsVtddd�tddd�g}td|�}|j|jd�|j|jt|��|jt|�d�dS)N�b�cr�r8zfoo: b <b@c>, a <b@c>;)rr	r1r�r�rEr0)r�addrsr�rrr�test_group_with_addresses�s

z-TestAddressAndGroup.test_group_with_addressescCsTtddd�tddd�g}t|d�}|j|j�|j|jt|��|jt|�d�dS)Nr�r�r�)r�zNone: b <b@c>, a <b@c>;)rr	r�r�r1r�rEr0)rr�r�rrr�)test_group_with_addresses_no_display_name�s

z=TestAddressAndGroup.test_group_with_addresses_no_display_namecCsJtddd�g}t|d�}|j|j�|j|jt|��|jt|�d�dS)Nr�r�)r�zb <b@c>)rr	r�r�r1r�rEr0)rr�r�rrr�+test_group_with_one_address_no_display_name�s

z?TestAddressAndGroup.test_group_with_one_address_no_display_namecCs:td�}|j|jd�|j|jt��|jt|�d�dS)Nzfoo.barz"foo.bar":;)r	r1r�r�rEr0)rr�rrr�test_display_name_quoting�sz-TestAddressAndGroup.test_display_name_quotingcCs:td�}|j|jd�|j|jt��|jt|�d�dS)Nzfoo barz	foo bar:;)r	r1r�r�rEr0)rr�rrr�#test_display_name_blanks_not_quoted�sz7TestAddressAndGroup.test_display_name_blanks_not_quotedcCsHtddd�}ttjd�}||d<|j|dd�|j|dj|f�dS)Nr8r�zexample.com)r�Tor�zfoo <bar@example.com>)rrrrLr1r�)rr�rjrrr�$test_set_message_header_from_address�s
z8TestAddressAndGroup.test_set_message_header_from_addresscCsDtd�}ttjd�}||d<|j|dd�|j|dj|j�dS)Nzfoo bar)rr�r�z	foo bar:;)r	rrrLr1r�)rr�rjrrr�"test_set_message_header_from_groups
z6TestAddressAndGroup.test_set_message_header_from_groupN)#rrr 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�rrrrr�8s@		

r�c@sleZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�ZdS)�TestFoldingcCs&|jdd�}|j|jtjd�d�dS)Nr'zthis is a test)rzsubject: this is a test
)r.r1rKrrL)rrrrr�test_short_unstructured
sz#TestFolding.test_short_unstructuredcCs&|jdd�}|j|jtjd�d�dS)NrzhThis is a long header line that will need to be folded into two lines and will demonstrate basic folding)rzsSubject: This is a long header line that will need to be folded into two lines
 and will demonstrate basic folding
)r.r1rKrrL)rrrrr�test_long_unstructuredsz"TestFolding.test_long_unstructuredcCs4|jdd�}|j|jtjjdd�d�tjd��dS)Nrz1this is a short header that will be folded anywayrZ)r�)rz�                Subject: this is a
                 short header that
                 will be folded
                 anyway
                )r.r1rKrrLr��textwrap�dedent)rrrrr�'test_unstructured_short_max_line_lengths
z3TestFolding.test_unstructured_short_max_line_lengthcCs&|jdd�}|j|jtjd�d�dS)Nrr)rzSubject: test
)r.r1rKrrL)rrrrr�"test_fold_unstructured_single_word'sz.TestFolding.test_fold_unstructured_single_wordcCs&|jdd�}|j|jtjd�d�dS)Nrztest test test)rzSubject: test test test
)r.r1rKrrL)rrrrr�test_fold_unstructured_short+sz(TestFolding.test_fold_unstructured_shortcCs.|jdd�}|j|jtjjdd�d�d�dS)NrZ5thisisaverylonglineconsistingofasinglewordthatwontfitrZ)r�)rz�Subject: 
 =?utf-8?q?thisisa?=
 =?utf-8?q?verylon?=
 =?utf-8?q?glineco?=
 =?utf-8?q?nsistin?=
 =?utf-8?q?gofasin?=
 =?utf-8?q?gleword?=
 =?utf-8?q?thatwon?=
 =?utf-8?q?tfit?=
)r.r1rKrrLr�)rrrrr�)test_fold_unstructured_with_overlong_word0sz5TestFolding.test_fold_unstructured_with_overlong_wordcCs.|jdd�}|j|jtjjdd�d�d�dS)NrzXthisisaverylonglineconsistingofasinglewordthatwontfit plusanotherverylongwordthatwontfitrZ)r�)raSubject: 
 =?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.r1rKrrLr�)rrrrr�.test_fold_unstructured_with_two_overlong_words@sz:TestFolding.test_fold_unstructured_with_two_overlong_wordscCs.|jdd�}|j|jtjjdd�d�d�dS)NrZ thislongwordislessthanmaxlinelen�#)r�)rz+Subject:
 thislongwordislessthanmaxlinelen
)r.r1rKrrLr�)rrrrr�.test_fold_unstructured_with_slightly_long_wordWsz:TestFolding.test_fold_unstructured_with_slightly_long_wordcCs4|jdd�}|j|jtjjdd�d�tjd��dS)Nrz�This header is intended to demonstrate, in a fairly succinct way, that we now do not give a , special treatment in unstructured headers.�<)r�)rz�                Subject: This header is intended to demonstrate, in a fairly
                 succinct way, that we now do not give a , special treatment
                 in unstructured headers.
                 )r.r1rKrrLr�rr)rrrrr�"test_fold_unstructured_with_commas]s
z.TestFolding.test_fold_unstructured_with_commascCs,|jdd�}|j|jtjd�tjd��dS)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>)rz�            To: "Theodore H. Perfect" <yes@man.com>,
             "My address is very long because my name is long" <foo@bar.com>,
             "Only A. Friend" <no@yes.com>
             )r.r1rKrrLrr)rrrrr�test_fold_address_listjsz"TestFolding.test_fold_address_listcCs&|jdd�}|j|jtjd�d�dS)NrizSat, 2 Feb 2002 17:00:06 -0800)rz&Date: Sat, 02 Feb 2002 17:00:06 -0800
)r.r1rKrrL)rrrrr�test_fold_date_headertsz!TestFolding.test_fold_date_headercCs&|jdd�}|j|jtjd�d�dS)NzX-Report-Abusez]<https://www.mailitapp.com/report_abuse.php?mid=xxx-xxx-xxxxxxxxxxxxxxxxxxxxxxxx==-xxx-xx-xx>)rz�X-Report-Abuse: =?utf-8?q?=3Chttps=3A//www=2Emailitapp=2Ecom/report=5Fabuse?=
 =?utf-8?q?=2Ephp=3Fmid=3Dxxx-xxx-xxxxxxxxxxxxxxxxxxxxxxxx=3D=3D-xxx-xx-xx?=
 =?utf-8?q?=3E?=
)r.r1rKrrL)rrrrr�&test_fold_overlong_words_using_RFC2047ysz2TestFolding.test_fold_overlong_words_using_RFC2047N)rrr rrrrrrrr
rr
rrrrrrr�s	

r��__main__)r^rZunittestZemailrrZ
email.messagerZtest.test_emailrrrZemail.headerregistryrr	�objectrpr
r+r/rGrWrlr�r�r�r�r�r�r�mainrrrr�<module>sL:.(1/'?-T|