Your IP : 216.73.216.213


Current Path : /opt/alt/python35/lib64/python3.5/test/test_email/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/test/test_email/__pycache__/test_headerregistry.cpython-35.pyc



��Yf���@s�ddlZddlZddlZddlZddlmZddlmZddlmZddl	m
Z
mZddlmZddl
mZmZe�ZGdd	�d	e
�ZGd
d�de
�ZGdd
�d
e�ZeGdd�de��ZeGdd�de��ZeGdd�de��ZeGdd�de��ZeGdd�de��ZeGdd�de��ZeGdd�de��ZGdd�de
�ZGdd�de�Zed kr�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)�TestHeaderRegistrycCsEtj�}|dd�}|j|tj�|j|tj�dS)N�foobar�test)r�HeaderRegistry�assertIsInstance�
BaseHeader�UnstructuredHeader)�self�factory�h�r�H/opt/alt/python35/lib64/python3.5/test/test_email/test_headerregistry.py� test_arbitrary_name_unstructuredsz3TestHeaderRegistry.test_arbitrary_name_unstructuredcCsXtj�}|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�FooBase sr!cCsNtjd|j�}|dd�}|j||j�|j|tj�dS)NZ
base_classrr)rr
r!rr)rrrrrr� test_override_default_base_class$sz3TestHeaderRegistry.test_override_default_base_classc@seZdZejjZdS)zTestHeaderRegistry.FooDefaultN)rrr rr�parserrrr�
FooDefault*sr$cCsNtjd|j�}|dd�}|j|tj�|j||j�dS)N�
default_classrr)rr
r$rr)rrrrrr�test_override_default_class-sz.TestHeaderRegistry.test_override_default_classcCsNtjd|j�}|dd�}|j|tj�|j|tj�dS)Nr%�subjectr)rr
r$rrr)rrrrrr�2test_override_default_class_only_overrides_default3szETestHeaderRegistry.test_override_default_class_only_overrides_defaultcCsKtjdd�}|dd�}|j|tj�|j|tj�dS)NZuse_default_mapFr'r)rr
rrr)rrrrrr�test_dont_use_default_map9sz,TestHeaderRegistry.test_dont_use_default_mapcCs�tj�}|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
sr
c@s(eZdZej�Zdd�ZdS)�TestHeaderBasecCs|j||�S)N)r)r�name�valuerrr�make_headerNszTestHeaderBase.make_headerN)rrr rr
rr.rrrrr+Jsr+c@sdeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)�TestBaseHeaderFeaturescCsL|jdd�}|j|t�|j|d�|jt|�d�dS)Nr'zthis is a test)r.r�str�assertEqual)rrrrr�test_strTszTestBaseHeaderFeatures.test_strcCs0|jdd�}|j|dd�d�dS)Nr'zthis is a test���is)r.r1)rrrrr�test_substrZsz"TestBaseHeaderFeatures.test_substrcCs)|jdd�}|j|jd�dS)Nr'zthis is a test)r.r1r,)rrrrr�
test_has_name^sz$TestBaseHeaderFeatures.test_has_namecCs=|jdd�}|jt��t||d�WdQRXdS)Nr'zthis is a test�foo)r.�assertRaises�AttributeError�setattr)r�attrrrrr�
_test_attr_robsz$TestBaseHeaderFeatures._test_attr_rocCs|jd�dS)Nr,)r=)rrrr�test_name_read_onlygsz*TestBaseHeaderFeatures.test_name_read_onlycCs|jd�dS)N�defects)r=)rrrr�test_defects_read_onlyjsz-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_tuplemsz,TestBaseHeaderFeatures.test_defects_is_tupleN)
rrr r2r6r7r=r>r@rFrrrrr/Rsr/c	@sReZdZdd�Zdddgdfdddgd	fd
dd
diZdS)�TestUnstructuredHeaderc	Gs�t|�}|dkr"|dng}d|r7dnd}||dkrW|dn|d}|jd|�}|j||�|j|j|�|j|jdtj�|�dS)	NrzSubject:� rBrC�
rr)rDr.r1�assertDefectsEqualr?�foldr�default)	r�source�decodedr�lr?�header�foldedrrrr�string_as_value�s$z&TestUnstructuredHeader.string_as_valueZrfc2047_simple_quopriz=?utf-8?q?this_is_a_test?=zthis is a testZrfc2047_gb2312_base64z!=?gb2312?b?1eLKx9bQzsSy4srUo6E=?=u这是中文测试!z(=?utf-8?b?6L+Z5piv5Lit5paH5rWL6K+V77yB?=Zrfc2047_simple_nonascii_quopri�=?utf-8?q?=C3=89ric?=�ÉricZ rfc2047_quopri_with_regular_text�$The =?utf-8?q?=C3=89ric=2C?= Himself�The Éric, HimselfN)rSrT)rUrV)rrr rRZ
string_paramsrrrrrG�s"rGc	@s�eZdZdZejdd�Zeje�Zejdddddd	d
e�Z	dd�Z
d
d�Zdd�Zdd�Z
dd�Zdd�Zdd�ZdS)�TestDateHeaderzSun, 23 Sep 2001 20:10:55 -0700Zhoursr4i��	���
�7ZtzinfocCsq|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_datecCsU|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_datetimecCsR|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_propertiescCsR|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_propertiescCsI|jdd�}|jt|j�d�|j|jdtj�dS)NrArBrCr)r.r1rDr?rr�HeaderMissingRequiredValue)rrrrr�test_no_value_is_defect�sz&TestDateHeader.test_no_value_is_defectc	Cs9|jd|j�}|jt��d|_WdQRXdS)NrAr8)r.r]r9r:r^)rrrrr�test_datetime_read_only�sz&TestDateHeader.test_datetime_read_onlycCsTtdtj�}|j|d<|j|d|j�|j|dj|j�dS)Nr�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$rWc[@s�eZdZdd�Zddddddd	igd
fddddddd	igd
fd
d
ddddd	ifdddddiejgfdddddiejgfdddddiejgfdddddiejgfdd�dd�dd�d!d�d#d$ddddd%ifd&d'ddddd(ifd)d*ddddd+ifd,d-ddddd%igd.fd/d0dddd1digd2fd3d4dddd1d5ifd6d7dddd1d8ifd9d:dddd;d<d=d<iejgd>fd?d@dAdBdCdDdEigdFfdGdHddddIdJdKdLdMdNigdOdPfdQdRddddIdSifdTdUddddIdVifdWdXddddIdYigdXfdZd[ddddId\igd]fd^d_dddd`daigdbfdcddddddd	igd
fdedfddddIdgigdhdifdjdkddddIdliejgdmdndofdpdqddddd	d1driejgdmdsdtfdudvdwdxdydIdziejgdmd{d|fd}d~dwdxdydIdigd�d�fd�d�ddddId�iejgd�fd�d�ddddId�iejgdmd�d�fd�d�ddddId�iejgdmd�d�fd�d�ddddId�iejgd�d�fd�d�ddddId�igd�fd�d�ddddd�iejgd�fd�d�ddddd�iejgd�fd�d�dwdxdydId�iejgd�d�fd�d�dwdxdydId�iejgd>d�d�fd�d�dwdxdydId�iejgdmd�d�fi*Zd�S)��TestContentTypeHeaderc
Gsnt|�}|dkr"|dni}|dkr>|dng}|dkrj|dtk	rj|dn|}	|r|d
nd}
|dkr�|dn|
|d}|jd	|�}|j|j|�|j|j|�|j|j|�|j|j|�|jt	��d
|jd<WdQRX|j
|j|�|j||	�|j|jdt
j�|�dS)NrrC�z
Content-Type:rHrB�rIzContent-TypeZxyz�abcrzContent-Type: )rD�DITTOr.r1�content_type�maintype�subtype�paramsr9�	TypeErrorrJr?rKrrL)
rrMrqrrrsrrO�parmdictr?rNrPrQrrrr�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�charsetzus-asciiztext/plain; charset="us-ascii"�
RFC_2045_2ztext/plain; charset=us-ascii�
RFC_2045_3Zno_subtype_in_content_typeztext/Zno_slash_in_content_typer8Zjunk_text_in_content_typez<crazy "stuff">Z too_many_slashes_in_content_typezimage/jpeg/fooZunknown_content_type�	bad/names�bad�namesZmixed_case_content_type�
ImAge/JPeg�
image/jpeg�image�jpegZspaces_in_content_type�  text  /  plain  Zcfws_in_content_type�"(foo) text (bar)/(baz)plain(stuff)Z
charset_paramztext/plain; charset="utf-8"zutf-8Zcapitalized_charsetztext/plain; charset="US-ASCII"zUS-ASCIIZunknown_charsetztext/plain; charset="fOo"ZfOoZ*capitalized_charset_param_name_and_commentz*text/plain; (interjection) Charset="utf-8"ztext/plain; Charset="utf-8"Zunquoted_param_valueztext/plain; title=foo�titleztext/plain; title="foo"Zparam_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_paramszblarg; baz; boo�bazrBZboornZspaces_around_param_equalsz0Multipart/mixed; boundary = "CPIMSSMTPC06p5f3tG"zmultipart/mixedZ	multipartZmixed�boundaryZCPIMSSMTPC06p5f3tGz.Multipart/mixed; boundary="CPIMSSMTPC06p5f3tG"Zspaces_around_semiszPimage/jpeg; name="wibble.JPG" ; x-mac-type="4A504547" ; x-mac-creator="474B4F4E"r,z
wibble.JPGz
x-mac-typeZ4A504547z
x-mac-creatorZ474B4F4EzNimage/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"
Zsemis_inside_quotesz$image/jpeg; name="Jim&amp;&amp;Jill"zJim&amp;&amp;JillZsingle_quotes_inside_quotesz!image/jpeg; name="Jim 'Bob' Jill"zJim 'Bob' JillZdouble_quotes_inside_quotesz#image/jpeg; name="Jim \"Bob\" Jill"zJim "Bob" JillZrfc2231_segmented_normal_valuesz(image/jpeg; name*0="abc"; name*1=".html"zabc.htmlzimage/jpeg; name="abc.html"Zquotes_inside_rfc2231_valuez.image/jpeg; bar*0="baz\"foobar"; bar*1="\"baz"�barzbaz"foobar"bazz"image/jpeg; bar="baz\"foobar\"baz"Zrfc2231_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"zThis is ***fun*** is it not.pdfz2text/plain; name="This is ***fun*** is it not.pdf"zlContent-Type: text/plain;	name*0*=''This%20is%20;
	name*1*=%2A%2A%2Afun%2A%2A%2A%20;	name*2="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.pdfrmz<text/plain; name="This is even more ***fun*** is it not.pdf"z�Content-Type: text/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)rfc2231_single_quote_inside_double_quotesz�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!"z�Content-Type: 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!"
Z3rfc2231_single_quote_in_value_with_charset_and_langzHapplication/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"zXContent-Type: application/x-foo;	name*0*="us-ascii'en-us'Frank's";
 name*1*=" Document"
Z)rfc2231_single_quote_in_non_encoded_valuezFapplication/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"zVContent-Type: application/x-foo;	name*0="us-ascii'en-us'Frank's";
 name*1=" Document"
Zrfc2231_no_language_or_charsetz/text/plain; NAME*0*=english_is_the_default.htmlzenglish_is_the_default.htmlz.text/plain; NAME="english_is_the_default.html"Zrfc2231_encoded_no_charsetzjtext/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"zzContent-Type: text/plain;	name*0*="''This%20is%20even%20more%20";
	name*1*="%2A%2A%2Afun%2A%2A%2A%20";	name*2="is it.pdf"
Zrfc2231_partly_encodedZrfc2231_partly_encoded_2zitext/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"zyContent-Type: text/plain;	name*0*="''This%20is%20even%20more%20";
	name*1="%2A%2A%2Afun%2A%2A%2A%20";	name*2="is it.pdf"
Z(rfc2231_unknown_charset_treated_as_asciiz1text/plain; name*0*=bogus'xx'ascii_is_the_defaultZascii_is_the_defaultz'text/plain; name="ascii_is_the_default"Z0rfc2231_bad_character_in_charset_parameter_valuez*text/plain; charset*=ascii''utf-8%F1%F2%F3uutf-8���u$text/plain; charset="utf-8���"Z9rfc2231_utf_8_in_supposedly_ascii_charset_parameter_valuez*text/plain; charset*=ascii''utf-8%E2%80%9Duutf-8”utext/plain; charset="utf-8”"Z'rfc2231_encoded_then_unencoded_segmentszUapplication/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"zeContent-Type: application/x-foo;	name*0*="us-ascii'en-us'My";
	name*1=" Document";	name*2=" For You"
Z'rfc2231_unencoded_then_encoded_segmentszTapplication/x-foo;	name*0=us-ascii'en-us'My;	name*1*=" Document";	name*2*=" For You"zdContent-Type: application/x-foo;	name*0=us-ascii'en-us'My;	name*1*=" Document"
;	name*2*=" For You"
Z.rfc2231_qouted_unencoded_then_encoded_segmentszVapplication/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"zfContent-Type: application/x-foo;	name*0="us-ascii'en-us'My";
	name*1*=" Document";	name*2*=" For You"
N)rrr�r�)r�r�r�r�)r�ryrzr{)r�ryrzr{)rrr rwr�InvalidHeaderDefectZUndecodableBytesDefectZcontent_type_paramsrrrrrl�s|												

	
				
	
										
	
rlc@sXeZdZdd�Zdddddejgddfd	d
dejgfiZdS)
�TestContentTransferEncodingc
Gs�t|�}|dkr"|dng}|dkrN|dtk	rN|dn|}|rdddnd}|dkr�|dn||d}|jd|�}	|j|	j|�|j|	j|�|j|	|�|j|	jd	tj	�|�dS)
NrrCzContent-Transfer-Encoding:rHrBrmrIzContent-Transfer-Encodingr)
rDrpr.r1�cterJr?rKrrL)
rrMr�rrOr?rNrPrQrrrr�cte_as_value�s,$z(TestContentTransferEncoding.cte_as_value�
RFC_2183_1�base64�no_valuerBZ7bitzContent-Transfer-Encoding:
Zjunk_after_ctez7bit and a bunch moreN)r�r�)rrr r�rrfr�Z
cte_paramsrrrrr��s	r�c
@s�eZdZdd�Zddddddd	d
digdd
fdddiejgddfdddiejgfdddddiejgfiZdS)�TestContentDispositioncGs(t|�}|dkr"|dni}|dkr>|dng}|dkrj|dtk	rj|dn|}|r�ddnd}|dkr�|dn||d}	|jd	|�}
|j|
j|�|j|
j|�|j|
j|�|j|
|�|j|
jd
t	j
�|	�dS)NrrCrmzContent-Disposition:rHrBrnrIzContent-Dispositionr)rDrpr.r1�content_dispositionrtrJr?rKrrL)rrMr�rrOrvr?rNrPrQrrrr�content_disp_as_values,$z,TestContentDisposition.content_disp_as_valuer��inlineZ
RFC_2183_2zWattachment; filename=genome.jpeg;  modification-date="Wed, 12 Feb 1997 16:29:51 -0500";Z
attachment�filenamezgenome.jpegzmodification-datezWed, 12 Feb 1997 16:29:51 -0500zWattachment; 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";
r�rBNzContent-Disposition:
Z
invalid_valuezab./kzab.Zinvalid_value_with_paramszab./k; filename="foo"r8)r�r�)rrr r�rrfr�Zcontent_disp_paramsrrrrr�s:			r�c#@s�eZdZdd�Zddddddgfddddddgfd	d
d
dddgfddddddgfd
dddddgfddddddgfddddddgfddddddgfddddddejgfddddddejgfddddddejgfddddddejgfdd d dddejgfd!d!d!dddejgfd"d#d#dddejgfiZdS)$�TestMIMEVersionHeadercCs�|jd|�}|j||�|j|j|�|j|j|�|j|j|�|j|j|�|r~d|}|j|jdtj	�d|d�dS)NzMIME-VersionrHrz
MIME-Version:rI)
r.r1�version�major�minorrJr?rKrrL)rrMrNr�r�r�r?rrrr�version_string_as_MIME_Version]s
z4TestMIMEVersionHeader.version_string_as_MIME_Versionrxz1.0rCrr}z1.0 (produced by MetaSend Vx.x)r~z(produced by MetaSend Vx.x) 1.0Z
RFC_2045_4z1.(produced by MetaSend Vx.x)0Z1_1z1.1Z2_1z2.1rmZ
whitespacez1 .0Z#leading_trailing_whitespace_ignoredz  1.0  Znon_comment_garbage_afterz	1.0 <abc>Znon_comment_garbage_beforez	<abc> 1.0NZnon_comment_garbage_insidez1.<abc>0Ztwo_periodsz1..0Z2_xz2.xr8ZmissingrB)rrr r�rr�rfZversion_string_paramsrrrrr�Zs�r�c%@s�eZdZddejgddddddfddgddddddfd	d
gd
dddddfdd
gd
dddddfddgddddddfddgddddddfddejgddddd dfd!d"ejgd#d$dd$d%d dfd&d'gd'dd'd(d dfd)d*ejgd+d,dd,d-d dfd.d/ejgd0d1dd1d2d dfd3d4ejgd5dd5d6d dfd7d8gd9d:d;d<d dfd=d>gd?d@d;d<d dfdAdBejgd9d:d;d<d dfiZdCdD�ZdEdF�ZdGdH�Z	dIdJ�Z
dKdL�ZdMdN�ZdOdP�Z
dQdR�ZdSdT�ZdUdV�ZdWdX�ZdYdZ�Zd[d\�ZdS)]�TestAddressHeader�emptyz<>rBNZaddress_onlyzzippy@pinhead.comZzippyzpinhead.comZname_and_addressz%Zaphrod Beblebrux <zippy@pinhead.com>zZaphrod BeblebruxZquoted_local_partz)Zaphrod Beblebrux <"foo bar"@pinhead.com>z"foo bar"@pinhead.comzfoo barZquoted_parens_in_namez'"A \(Special\) Person" <person@dom.ain>z%"A (Special) Person" <person@dom.ain>zA (Special) Personzperson@dom.ainZpersonzdom.ainZquoted_backslashes_in_namez."Arthur \\Backslash\\ Foobar" <person@dom.ain>zArthur \Backslash\ FoobarZ
name_with_dotzJohn X. Doe <jxd@example.com>z"John X. Doe" <jxd@example.com>zJohn X. Doezjxd@example.comZjxdzexample.comZquoted_strings_in_local_partz""example" example"@example.comrnz"example example"@example.comzexample exampleZ$escaped_quoted_strings_in_local_partz!"\"example\" example"@example.comz"example" exampleZescaped_escapes_in_local_partz#"\\"example\\" example"@example.comr3z#"\\example\\\\ example"@example.comz\example\\ exampleZ'spaces_in_unquoted_local_part_collapsedzmerwok  wok  @example.comrmz"merwok wok"@example.comz
merwok wokZ(spaces_around_dots_in_local_part_removedzmerwok. wok .  wok@example.comzmerwok.wok.wok@example.comzmerwok.wok.wokZrfc2047_atom_is_decodedz'=?utf-8?q?=C3=89ric?= <foo@example.com>uÉric <foo@example.com>uÉriczfoo@example.comr8Z!rfc2047_atom_in_phrase_is_decodedz6The =?utf-8?q?=C3=89ric=2C?= Himself <foo@example.com>u&"The Éric, Himself" <foo@example.com>uThe Éric, HimselfZ(rfc2047_atom_in_quoted_string_is_decodedz)"=?utf-8?q?=C3=89ric?=" <foo@example.com>c	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|�}|r$dj|�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_groupcCsd}|jd|�}|j||�|jt|j�d�|jt|j�d�x9td�D]+}|j|j|jd|j|�qgW|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_listcCs"t|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|��x_td�D]Q}|j|j|dj	�|jt
|j|dj
d�||d�q�Wxltddt|�d�D]M}|j|j|j	�|jt
|j|j
d�||dd�qiWxatt|��D]M}|jt
|j
|�||d�|j|j
|j||d�q�WdS)Nz dummy list:;, another: (empty);,z, cSsg|]}|d�qS)rr)�.0�xrrr�
<listcomp>�s	z?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��s	zdummy list:;, another:;, cSsg|]}|d�qS)rmr)r�r�rrrr��s	cSsg|]}|d�qS)rmr)r�r�rrrr��s	z;, cSsg|]}|d�qS)rmr)r�r�rrrr��s	r��,r4rz
dummy listrCZanotherzA "list"rm)r��example_params�values�joinr.r1�splitrDr�r�r�r��assertIsNoner0r�)rZexamplesrMZexpectedrr�rrr�test_complex_address_list�s,W'W'"'4$4%z+TestAddressHeader.test_complex_address_listc	Cs6|jdd�}|jt��d|_WdQRXdS)Nr�zabc@xyz.comr8)r.r9r:r�)rrrrr�test_address_read_only�sz(TestAddressHeader.test_address_read_onlyc	Cs6|jdd�}|jt��d|_WdQRXdS)Nr�zabc@xyz.comr8)r.r9r:r�)rrrrr�test_addresses_read_only�sz*TestAddressHeader.test_addresses_read_onlyc	Cs6|jdd�}|jt��d|_WdQRXdS)Nr�zabc@xyz.comr8)r.r9r:r�)rrrrr�test_groups_read_only�sz'TestAddressHeader.test_groups_read_onlycCsFd}|jd|�}|j|jt�|j|jdt�dS)Nzme <who@example.com>r�r)r.rr�rEr)rrMrrrr�test_addresses_types�sz&TestAddressHeader.test_addresses_typescCsFd}|jd|�}|j|jt�|j|jdt�dS)Nzme <who@example.com>r�r)r.rr�rEr	)rrMrrrr�test_groups_typessz#TestAddressHeader.test_groups_typescCs2|jdtddd��}|j|d�dS)Nr��mer8zexample.comzme <foo@example.com>)r.rr1)rrrrr�test_set_from_Address	sz'TestAddressHeader.test_set_from_AddresscCsD|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
Cs�|jdtddd�tdtddd�td	d
d�g�tdd
d�g�}|j|d�|j|jdtjjdd��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>r�max_line_length�(zWto: 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_lists$z6TestAddressHeader.test_set_from_Address_and_Group_listc	CsP|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_listsz*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?S)@�TestAddressAndGroupcCs+|jt��t||d�WdQRXdS)Nr8)r9r:r;)r�objr<rrrr=&sz!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_ro-sz,TestAddressAndGroup.test_address_username_rocCs |jtddd�d�dS)Nr8r�r�r�)r=r)rrrr�test_address_domain_ro0sz*TestAddressAndGroup.test_address_domain_rocCs|jtd�d�dS)Nr8r�)r=r	)rrrr�test_group_display_name_ro3sz.TestAddressAndGroup.test_group_display_name_rocCs|jtd�d�dS)Nr8r�)r=r	)rrrr�test_group_addresses_ro6sz+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_domain9sz5TestAddressAndGroup.test_address_from_username_domaincCsxtddd�}|j|jd�|j|jd�|j|jd�|j|jd�|jt|�d�dS)Nr8r�zbar@bazr�r�z
foo <bar@baz>)rr1r�r�r�r�r0)rr�rrr�test_address_from_addr_specAsz/TestAddressAndGroup.test_address_from_addr_speccCsutdd�}|j|jd�|j|jd�|j|jd�|j|jd�|jt|�d�dS)Nr�zbar@bazrBr�r�)rr1r�r�r�r�r0)rr�rrr�!test_address_with_no_display_nameIsz5TestAddressAndGroup.test_address_with_no_display_namecCsot�}|j|jd�|j|jd�|j|jd�|j|jd�|jt|�d�dS)NrBz<>)rr1r�r�r�r�r0)rr�rrr�test_null_addressQs	z%TestAddressAndGroup.test_null_addresscCsutdd�}|j|jd�|j|jd�|j|jd�|j|jd�|jt|�d�dS)Nr��buzzrBz@buzz)rr1r�r�r�r�r0)rr�rrr�test_domain_onlyYsz$TestAddressAndGroup.test_domain_onlycCsutdd�}|j|jd�|j|jd�|j|jd�|j|jd�|jt|�d�dS)Nr�r�rB)rr1r�r�r�r�r0)rr�rrr�test_username_onlybsz&TestAddressAndGroup.test_username_onlycCsrtd�}|j|jd�|j|jd�|j|jd�|j|jd�|jt|�d�dS)Nr�rBz<>zbuzz <>)rr1r�r�r�r�r0)rr�rrr�test_display_name_onlyks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_quotingss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+|jt��tddd�WdQRXdS)Nr8r�uwők@example.com)r9�
ValueErrorr)rrrr�+test_non_ascii_username_in_addr_spec_raises�sz?TestAddressAndGroup.test_non_ascii_username_in_addr_spec_raisesc
Cs1|jt��tddddd�WdQRXdS)Nr8r�r�r�zbar@baz)r9rur)rrrr�*test_address_addr_spec_and_username_raises�sz>TestAddressAndGroup.test_address_addr_spec_and_username_raisesc
Cs1|jt��tddddd�WdQRXdS)Nr8r�r�r�zbar@baz)r9rur)rrrr�(test_address_addr_spec_and_domain_raises�sz<TestAddressAndGroup.test_address_addr_spec_and_domain_raisescCs7|jt��!tddddddd�WdQRXdS)Nr8r�Zbongr�r�r�zbar@baz)r9rur)rrrr�5test_address_addr_spec_and_username_and_domain_raises�szITestAddressAndGroup.test_address_addr_spec_and_username_and_domain_raisescCs+|jt��tddd�WdQRXdS)Nr8r�zbad name@example.com)r9r�r)rrrr�'test_space_in_addr_spec_username_raises�sz;TestAddressAndGroup.test_space_in_addr_spec_username_raisescCs+|jt��tddd�WdQRXdS)Nr8r�zname@ex[]ample.com)r9r�r)rrrr�test_bad_addr_sepc_raises�sz-TestAddressAndGroup.test_bad_addr_sepc_raisescCsOtd�}|j|jd�|j|jt��|jt|�d�dS)Nr8zfoo:;)r	r1r�r�rEr0)r�grrr�test_empty_group�sz$TestAddressAndGroup.test_empty_groupcCsUtddg�}|j|jd�|j|jt��|jt|�d�dS)Nr8r�zfoo:;)r	r1r�r�rEr0)rr�rrr�test_empty_group_list�sz)TestAddressAndGroup.test_empty_group_listcCsIt�}|j|j�|j|jt��|jt|�d�dS)NzNone:;)r	r�r�r1r�rEr0)rr�rrr�test_null_group�s	z#TestAddressAndGroup.test_null_groupcCsytddd�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_addressescCsvtddd�tddd�g}td|�}|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_namecCsgtddd�g}td|�}|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_namecCsOtd�}|j|jd�|j|jt��|jt|�d�dS)Nzfoo.barz"foo.bar":;)r	r1r�r�rEr0)rr�rrr�test_display_name_quoting�sz-TestAddressAndGroup.test_display_name_quotingcCsOtd�}|j|jd�|j|jt��|jt|�d�dS)Nzfoo barz	foo bar:;)r	r1r�r�rEr0)rr�rrr�#test_display_name_blanks_not_quoted�sz7TestAddressAndGroup.test_display_name_blanks_not_quotedcCs`tddd�}tdtj�}||d<|j|dd�|j|dj|f�dS)Nr8r�zexample.comr�Tor�zfoo <bar@example.com>)rrrrLr1r�)rr�rjrrr�$test_set_message_header_from_address�s

z8TestAddressAndGroup.test_set_message_header_from_addresscCsZtd�}tdtj�}||d<|j|dd�|j|dj|j�dS)Nzfoo barrr�r�z	foo bar:;)r	rrrLr1r�)rr�rjrrr�"test_set_message_header_from_group�s

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�rrrrr�$s>		

r�c@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dS)�TestFoldingcCs5|jdd�}|j|jdtj�d�dS)Nr'zthis is a testrzsubject: this is a test
)r.r1rKrrL)rrrrr�test_short_unstructured�sz#TestFolding.test_short_unstructuredcCs5|jdd�}|j|jdtj�d�dS)NrzhThis is a long header line that will need to be folded into two lines and will demonstrate basic foldingrzsSubject: 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_unstructured�sz"TestFolding.test_long_unstructuredcCsJ|jdd�}|j|jdtjjdd��tjd��dS)Nrz1this is a short header that will be folded anywayrr�rZz�                Subject: this is a
                 short header that
                 will be folded
                 anyway
                )r.r1rKrrLr��textwrap�dedent)rrrrr�'test_unstructured_short_max_line_length�s
z3TestFolding.test_unstructured_short_max_line_lengthcCs5|jdd�}|j|jdtj�d�dS)NrrrzSubject: test
)r.r1rKrrL)rrrrr�"test_fold_unstructured_single_wordsz.TestFolding.test_fold_unstructured_single_wordcCs5|jdd�}|j|jdtj�d�dS)Nrztest test testrzSubject: test test test
)r.r1rKrrL)rrrrr�test_fold_unstructured_shortsz(TestFolding.test_fold_unstructured_shortcCsA|jdd�}|j|jdtjjdd��d�dS)NrZ5thisisaverylonglineconsistingofasinglewordthatwontfitrr�rZz?Subject: thisisaverylonglineconsistingofasinglewordthatwontfit
)r.r1rKrrLr�)rrrrr�)test_fold_unstructured_with_overlong_word	sz5TestFolding.test_fold_unstructured_with_overlong_wordcCsA|jdd�}|j|jdtjjdd��d�dS)NrzXthisisaverylonglineconsistingofasinglewordthatwontfit plusanotherverylongwordthatwontfitrr�rZzcSubject: thisisaverylonglineconsistingofasinglewordthatwontfit
 plusanotherverylongwordthatwontfit
)r.r1rKrrLr�)rrrrr�.test_fold_unstructured_with_two_overlong_wordssz:TestFolding.test_fold_unstructured_with_two_overlong_wordscCsA|jdd�}|j|jdtjjdd��d�dS)NrZ thislongwordislessthanmaxlinelenrr��#z+Subject:
 thislongwordislessthanmaxlinelen
)r.r1rKrrLr�)rrrrr�.test_fold_unstructured_with_slightly_long_wordsz:TestFolding.test_fold_unstructured_with_slightly_long_wordcCsJ|jdd�}|j|jdtjjdd��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.rr��<z�                Subject: This header is intended to demonstrate, in a fairly
                 succinct way, that we now do not give a , special treatment
                 in unstructured headers.
                 )r.r1rKrrLr�r�r�)rrrrr�"test_fold_unstructured_with_commass
z.TestFolding.test_fold_unstructured_with_commascCs>|jdd�}|j|jdtj�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.r1rKrrLr�r�)rrrrr�test_fold_address_list+sz"TestFolding.test_fold_address_listcCs5|jdd�}|j|jdtj�d�dS)NrizSat, 2 Feb 2002 17:00:06 -0800rz&Date: Sat, 02 Feb 2002 17:00:06 -0800
)r.r1rKrrL)rrrrr�test_fold_date_header5sz!TestFolding.test_fold_date_headerN)rrr r�r�r�r�r�r�rrrrrrrrrr��s	

r��__main__) r^r�Zunittest�typesZemailrrZ
email.messagerZtest.test_emailrrrZemail.headerregistryrr	�objectrpr
r+r/rGrWrlr�r�r�r�r�r�r�mainrrrr�<module>sD	:.(1��'?��,�X