HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //usr/local/lib/python3.7/test/test_email/__pycache__/test_headerregistry.cpython-37.opt-2.pyc
B

��gD��@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\e��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)�TestHeaderRegistrycCs2t��}|dd�}|�|tj�|�|tj�dS)N�foobar�test)r�HeaderRegistry�assertIsInstance�
BaseHeader�UnstructuredHeader)�self�factory�h�r�?/usr/local/lib/python3.7/test/test_email/test_headerregistry.py� test_arbitrary_name_unstructureds
z3TestHeaderRegistry.test_arbitrary_name_unstructuredcCs@t��}|�d|j�|dd�}|�|tj�|�|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�|�|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�}|�|tj�|�||j�dS)N)�
default_classrr)rr
r$rr)rrrrrr�test_override_default_class,s
z.TestHeaderRegistry.test_override_default_classcCs8tj|jd�}|dd�}|�|tj�|�|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�}|�|tj�|�|tj�dS)NF)Zuse_default_mapr'r)rr
rrr)rrrrrr�test_dont_use_default_map8s
z,TestHeaderRegistry.test_dont_use_default_mapcCsft��}|dd�}|�dtj�|dd�}|�|tj�|�|tj�|�|tj�|�|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@seZdZe��Zdd�ZdS)�TestHeaderBasecCs|�||�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|�dd�}|�|t�|�|d�|�t|�d�dS)Nr'zthis is a test)r.r�str�assertEqual)rrrrr�test_strSszTestBaseHeaderFeatures.test_strcCs$|�dd�}|�|dd�d�dS)Nr'zthis is a test���is)r.r1)rrrrr�test_substrYsz"TestBaseHeaderFeatures.test_substrcCs|�dd�}|�|jd�dS)Nr'zthis is a test)r.r1r,)rrrrr�
test_has_name]sz$TestBaseHeaderFeatures.test_has_namec	Cs2|�dd�}|�t��t||d�WdQRXdS)Nr'zthis is a test�foo)r.�assertRaises�AttributeError�setattr)r�attrrrrr�
_test_attr_roasz$TestBaseHeaderFeatures._test_attr_rocCs|�d�dS)Nr,)r=)rrrr�test_name_read_onlyfsz*TestBaseHeaderFeatures.test_name_read_onlycCs|�d�dS)N�defects)r=)rrrr�test_defects_read_onlyisz-TestBaseHeaderFeatures.test_defects_read_onlycCs\|�dd�}|�t|j�d�|�|jt�|�dd�}|�t|j�d�|�|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�Zddgdfddgdfdd	d
�ZdS)�TestUnstructuredHeaderc	Gs�t|�}|dkr|dng}d|r&dnd}||dkr>|dn|d}|�d|�}|�||�|�|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?=)z=?utf-8?q?=C3=89ric?=uÉric)z$The =?utf-8?q?=C3=89ric=2C?= HimselfuThe Éric, Himself)Zrfc2047_simple_quopriZrfc2047_gb2312_base64Zrfc2047_simple_nonascii_quopriZ rfc2047_quopri_with_regular_textN)rrr rRZ
string_paramsrrrrrGsrGc	@sveZdZdZejdd�Ze�e�Zejdddddd	ed
�Z	dd�Z
d
d�Zdd�Zdd�Z
dd�Zdd�Zdd�ZdS)�TestDateHeaderzSun, 23 Sep 2001 20:10:55 -0700i����)Zhoursi��	���
�7)ZtzinfocCsR|�d|j�}|�||j�|�|j|j�|�|j��|j�|�|jd�dS)NrAr)r.�
datestringr1�datetime�dt�	utcoffsetr?)rrrrr�test_parse_date�s
zTestDateHeader.test_parse_datecCs>|�d|j�}|�||j�|�|j|j�|�|jd�dS)NrAr)r.r[r1rYrZr?)rrrrr�test_set_from_datetime�sz%TestDateHeader.test_set_from_datetimecCs<|�d|j�}|�|tj�|�|jd�|�|jd�dS)NrArCr)r.rYrrZUniqueDateHeaderr1�	max_countr?)rrrrr�test_date_header_properties�sz*TestDateHeader.test_date_header_propertiescCs<|�d|j�}|�|tj�|�|jd�|�|jd�dS)Nzresent-dater)r.rYrrZ
DateHeaderr1r_r?)rrrrr�"test_resent_date_header_properties�sz1TestDateHeader.test_resent_date_header_propertiescCs6|�dd�}|�t|j�d�|�|jdtj�dS)NrArBrCr)r.r1rDr?rr�HeaderMissingRequiredValue)rrrrr�test_no_value_is_defect�sz&TestDateHeader.test_no_value_is_defectc	Cs.|�d|j�}|�t��d|_WdQRXdS)NrAr8)r.rYr9r:rZ)rrrrr�test_datetime_read_only�sz&TestDateHeader.test_datetime_read_onlycCs@ttjd�}|j|d<|�|d|j�|�|dj|j�dS)N)r�Date)rrrLr[r1rYrZ)r�mrrr�"test_set_date_header_from_datetime�s
z1TestDateHeader.test_set_date_header_from_datetimeN)rrr rYrZZ	timedeltar\ZtimezoneZtzr[r]r^r`rarcrdrgrrrrrS�s
rSc5@s�eZdZdd�Zddddddigd	fd
dddddigd	fd	dddddifddddiejgfddddiejgfd
dddiejgfddddiejgfddddddddddifddddddifddddddifddddddigdfddddddigdfddddddifd ddddd!ifd"dddd#d#d$�ejgd%fd&d'd(d)d*d+igd,fd-d.d/d0d1d2d3d4�gd5d6fd7d.d/d0d1d2d3d8d9�gd7d:fd;d.d/d0d<d=ifd>d.d/d0d<d?ifd@d.d/d0d<dAigd@fdB�dC��ddD�dEdFdGdHdIdJ�ejgd%dKdLfdMd.d/d0d<dNigdOfdPd.d/d0dGdQigdRfdS�dC��ddD�dddddTdU�ejgdVdWfdXdddddigd	fdYdddd<dZigd[fd\dddd<d]iejgd^d_fd`dddddadU�ejgd^dbdcfdddedfdgd<dhiejgd^difdjdedfdgd<dkigdlfdmdddd<dniejgdofdpdddd<dqiejgd^drfdpdddd<dqiejgd^drfdsdddd<dtiejgdudvfdwdddd<dxigdyfdzddddd{iejgd|d}fd~dddddiejgd�d�fd�dedfdgd<d�iejgd�fd�dedfdgd<d�iejgd%d�fd�dedfdgd<d�iejgd^d�fd�dedfdgd<d�igd�d�fd��.Z	d�S)��TestContentTypeHeaderc
	Gst|�}|dkr|dni}|dkr,|dng}|dkrL|dtk	rL|dn|}	|rXdnd}
|dkrl|dn
|
|	d}|�d|�}|�|j|�|�|j|�|�|j|�|�|j|�|�t	��d	|jd
<WdQRX|�
|j|�|�||	�|�|jt
jd�|�dS)NrrC�zContent-Type: rB�rIzContent-TypeZxyz�abc)r)rD�DITTOr.r1�content_type�maintype�subtype�paramsr9�	TypeErrorrJr?rKrrL)
rrMrmrnrorrO�parmdictr?rNrPrQrrrr�content_type_as_value�s  z+TestContentTypeHeader.content_type_as_valuez)text/plain; charset=us-ascii (Plain text)z
text/plain�text�plain�charsetzus-asciiztext/plain; charset="us-ascii"ztext/plain; charset=us-asciiztext/r8z<crazy "stuff">zimage/jpeg/foo)z	bad/namesz	bad/namesZbad�names)z
ImAge/JPegz
image/jpeg�image�jpeg)z  text  /  plain  z
text/plainrtru)z"(foo) text (bar)/(baz)plain(stuff)z
text/plainrtruztext/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)�bazZboorjz0Multipart/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
image/jpegrxryz
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)rvrzu9text/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.pdfriz<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"zrapplication/x-foo;	name="with spaceswith spaceswith spaceswith spaceswith spaceswith spaceswith spaceswith spaces"zXwith spaceswith spaceswith spaceswith spaceswith spaceswith spaceswith spaceswith spaceszrapplication/x-foo; name="with spaceswith spaceswith spaceswith spaceswith spaceswith spaceswith spaceswith spaces"z�Content-Type: application/x-foo;
 name*0*=us-ascii''with%20spaceswith%20spaceswith%20spaceswith%20spaceswith;
 name*1*=%20spaceswith%20spaceswith%20spaceswith%20spaces
).�
RFC_2045_1�
RFC_2045_2�
RFC_2045_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)
rrr rsr�InvalidHeaderDefect�encode�decodeZUndecodableBytesDefectZcontent_type_paramsrrrrrh�sP	
	







	rhc@s8eZdZdd�Zdddejgddfddejgfd�Zd	S)
�TestContentTransferEncodingc
Gs�t|�}|dkr|dng}|dkr8|dtk	r8|dn|}|rDdnd}|dkrX|dn
||d}|�d|�}	|�|	j|�|�|	j|�|�|	|�|�|	jtj	d�|�dS)	NrrCzContent-Transfer-Encoding: rBrirIzContent-Transfer-Encoding)r)
rDrlr.r1�cterJr?rKrrL)
rrMr�rrOr?rNrPrQrrrr�cte_as_value	s z(TestContentTransferEncoding.cte_as_value)�base64r�rBZ7bitzContent-Transfer-Encoding:
z7bit and a bunch more)�
RFC_2183_1�no_valueZjunk_after_cteN)rrr r�rrbr�Z
cte_paramsrrrrr�sr�c@s�eZdZdd�Zdddddd�gd	d
fddiejgdd
fddiejgfddddiejgfddddiejgdddfddddiejgddfd�ZdS)�TestContentDispositioncGs�t|�}|dkr|dni}|dkr,|dng}|dkrL|dtk	rL|dn|}|rXdnd}|dkrl|dn
||d}	|�d|�}
|�|
j|�|�|
j|�|�|
j|�|�|
|�|�|
jt	j
d	�|	�dS)
NrrCrizContent-Disposition: rBrjrIzContent-Disposition)r)rDrlr.r1�content_dispositionrprJr?rKrrL)rrMr�rrOrrr?rNrPrQrrrr�content_disp_as_value1s z,TestContentDisposition.content_disp_as_value)�inliner�zWattachment; 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�r8zaattachment; filename="=?UTF-8?Q?Schulbesuchsbest=C3=A4ttigung=2E?=               =?UTF-8?Q?pdf?="uSchulbesuchsbestättigung.pdfrju4attachment; 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"zFile 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_valueZinvalid_value_with_paramsZ+invalid_parameter_value_with_fws_between_ewZ'parameter_value_with_fws_between_tokens)rrr r�rrbr�Zcontent_disp_paramsrrrrr�.sF
r�c@seZdZdd�Zdddddgfdddddgfdddddgfdddddgfd	d	d	ddgfd
d
d
ddgfdddddgfd
d
dddgfdddddejgfdddddejgfdddddejgfdddddejgfdddddejgfdddddejgfdddddejgfd�ZdS)�TestMIMEVersionHeadercCs~|�d|�}|�||�|�|j|�|�|j|�|�|j|�|�|j|�|r\d|}|�|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_Version�s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.1riz1 .0z  1.0  z	1.0 <abc>z	<abc> 1.0Nz1.<abc>0z1..0z2.xr8rB)rr�r�Z
RFC_2045_4Z1_1Z2_1Z
whitespaceZ#leading_trailing_whitespace_ignoredZnon_comment_garbage_afterZnon_comment_garbage_beforeZnon_comment_garbage_insideZtwo_periodsZ2_xr8�missing)rrr r�rr�rbZversion_string_paramsrrrrr��s�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/ddfd3ejejgd,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.comrjz"example example"@example.comzexample examplez!"\"example\" example"@example.comz"example" examplez#"\\"example\\" example"@example.comr3z#"\\example\\\\ example"@example.comz\example\\ examplezmerwok  wok  @example.comriz"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�|�d|�}	|�|	|�|�|	j|�|	j}
|�t|
�|�|�t|	j�d�|�|
gt|	jdj	��|�|
gt|	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�d�|�}|rd�|�nd}	|�d|�}
|�|
|	�|�|
j|�|�|
jdj|
j�|�t|
j�d�|�t|
j�d�|
jd}|�t|�|�|�|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}|�d|�}|�||�|�t|j�d�|�t|j�d�x.td�D]"}|�|j|jd|j|�qJW|�t|jd�d�|�t|jd�d�|�t|jd�d	�|�|jdjd
�dS)NzTFred <dinsdale@python.org>, foo@example.com, "Harry W. Hastings" <hasty@example.com>r�rjrzFred <dinsdale@python.org>rCzfoo@example.comriz'"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|j���}dd�dd�|dd�D��ddd�dd�|dd�D��d	d�d
d�|dd�D��}dd�dd�|dd�D��ddd�d
d�|dd�D��dd�dd�|dd�D��}|�d|�}|�|�d�|�d��|�||�|�t|j�dt|�d�|�|jdj	d�|�|jdj	d�|�|jdj	d�|�t|j
�t|��xPtd�D]D}|�|j|dj	�|�t
|j|dj
d�||d��q�WxZtddt|�d�D]@}|�|j|j	�|�t
|j|j
d�||dd��q�WxPtt|��D]@}|�t
|j
|�||d�|�|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)rir)r�r�rrrr��scSsg|]}|d�qS)rir)r�r�rrrr�sz;, cSsg|]}|d�qS)rir)r�r�rrrr�sr��,r4rz
dummy listrCZanotherzA "list"ri)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,|�dd�}|�t��d|_WdQRXdS)Nr�zabc@xyz.comr8)r.r9r:r�)rrrrr�test_address_read_onlysz(TestAddressHeader.test_address_read_onlyc	Cs,|�dd�}|�t��d|_WdQRXdS)Nr�zabc@xyz.comr8)r.r9r:r�)rrrrr�test_addresses_read_onlysz*TestAddressHeader.test_addresses_read_onlyc	Cs,|�dd�}|�t��d|_WdQRXdS)Nr�zabc@xyz.comr8)r.r9r:r�)rrrrr�test_groups_read_only sz'TestAddressHeader.test_groups_read_onlycCs4d}|�d|�}|�|jt�|�|jdt�dS)Nzme <who@example.com>r�r)r.rr�rEr)rrMrrrr�test_addresses_types%sz&TestAddressHeader.test_addresses_typescCs4d}|�d|�}|�|jt�|�|jdt�dS)Nzme <who@example.com>r�r)r.rr�rEr	)rrMrrrr�test_groups_types+sz#TestAddressHeader.test_groups_typescCs$|�dtddd��}|�|d�dS)Nr��mer8zexample.comzme <foo@example.com>)r.rr1)rrrrr�test_set_from_Address1sz'TestAddressHeader.test_set_from_AddresscCs0|�dtddd�tddd�g�}|�|d�dS)Nr�r�r8zexample.com�your~z+me <foo@example.com>, you <bar@example.com>)r.rr1)rrrrr�test_set_from_Address_list5sz,TestAddressHeader.test_set_from_Address_listcCsj|�dtddd�tdtddd�td	d
d�g�tdd
d�g�}|�|d�|�|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|�dtdtddd�tddd�g�g�}|�|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_listFsz*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�TestAddressAndGroupc	Cs&|�t��t||d�WdQRXdS)Nr8)r9r:r;)r�objr<rrrr=Nsz!TestAddressAndGroup._test_attr_rocCs|�tddd�d�dS)Nr8r~r{r�)r=r)rrrr�test_address_display_name_roRsz0TestAddressAndGroup.test_address_display_name_rocCs|�tddd�d�dS)Nr8r~r{r�)r=r)rrrr�test_address_username_roUsz,TestAddressAndGroup.test_address_username_rocCs|�tddd�d�dS)Nr8r~r{r�)r=r)rrrr�test_address_domain_roXsz*TestAddressAndGroup.test_address_domain_rocCs|�td�d�dS)Nr8r�)r=r	)rrrr�test_group_display_name_ro[sz.TestAddressAndGroup.test_group_display_name_rocCs|�td�d�dS)Nr8r�)r=r	)rrrr�test_group_addresses_ro^sz+TestAddressAndGroup.test_group_addresses_rocCsXtddd�}|�|jd�|�|jd�|�|jd�|�|jd�|�t|�d�dS)Nr8r~r{zbar@bazz
foo <bar@baz>)rr1r�r�r�r�r0)rr�rrr�!test_address_from_username_domainasz5TestAddressAndGroup.test_address_from_username_domaincCsXtddd�}|�|jd�|�|jd�|�|jd�|�|jd�|�t|�d�dS)Nr8zbar@baz)r�r~r{z
foo <bar@baz>)rr1r�r�r�r�r0)rr�rrr�test_address_from_addr_specisz/TestAddressAndGroup.test_address_from_addr_speccCsVtdd�}|�|jd�|�|jd�|�|jd�|�|jd�|�t|�d�dS)Nzbar@baz)r�rBr~r{)rr1r�r�r�r�r0)rr�rrr�!test_address_with_no_display_nameqs
z5TestAddressAndGroup.test_address_with_no_display_namecCsRt�}|�|jd�|�|jd�|�|jd�|�|jd�|�t|�d�dS)NrBz<>)rr1r�r�r�r�r0)rr�rrr�test_null_addressysz%TestAddressAndGroup.test_null_addresscCsVtdd�}|�|jd�|�|jd�|�|jd�|�|jd�|�t|�d�dS)N�buzz)r�rBz@buzz)rr1r�r�r�r�r0)rr�rrr�test_domain_only�s
z$TestAddressAndGroup.test_domain_onlycCsVtdd�}|�|jd�|�|jd�|�|jd�|�|jd�|�t|�d�dS)Nr�)r�rB)rr1r�r�r�r�r0)rr�rrr�test_username_only�s
z&TestAddressAndGroup.test_username_onlycCsTtd�}|�|jd�|�|jd�|�|jd�|�|jd�|�t|�d�dS)Nr�rBz<>zbuzz <>)rr1r�r�r�r�r0)rr�rrr�test_display_name_only�sz*TestAddressAndGroup.test_display_name_onlycCsXtddd�}|�|jd�|�|jd�|�|jd�|�|jd�|�t|�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�}|�|jd�|�|jd�|�|jd�|�|jd�|�t|�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��(|�td��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_raisesc	Cs&|�t��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(|�t��tdddd�WdQRXdS)Nr8r�zbar@baz)r�r�)r9rqr)rrrr�*test_address_addr_spec_and_username_raises�sz>TestAddressAndGroup.test_address_addr_spec_and_username_raisesc	Cs(|�t��tdddd�WdQRXdS)Nr8r�zbar@baz)r�r�)r9rqr)rrrr�(test_address_addr_spec_and_domain_raises�sz<TestAddressAndGroup.test_address_addr_spec_and_domain_raisesc	Cs*|�t��tddddd�WdQRXdS)Nr8Zbongr�zbar@baz)r�r�r�)r9rqr)rrrr�5test_address_addr_spec_and_username_and_domain_raises�szITestAddressAndGroup.test_address_addr_spec_and_username_and_domain_raisesc	Cs&|�t��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_raisesc	Cs&|�t��tddd�WdQRXdS)Nr8zname@ex[]ample.com)r�)r9r�r)rrrr�test_bad_addr_sepc_raises�sz-TestAddressAndGroup.test_bad_addr_sepc_raisescCs:td�}|�|jd�|�|jt��|�t|�d�dS)Nr8zfoo:;)r	r1r�r�rEr0)r�grrr�test_empty_group�sz$TestAddressAndGroup.test_empty_groupcCs>tdgd�}|�|jd�|�|jt��|�t|�d�dS)Nr8)r�zfoo:;)r	r1r�r�rEr0)rr�rrr�test_empty_group_list�sz)TestAddressAndGroup.test_empty_group_listcCs6t�}|�|j�|�|jt��|�t|�d�dS)NzNone:;)r	r�r�r1r�rEr0)rr�rrr�test_null_group�sz#TestAddressAndGroup.test_null_groupcCsVtddd�tddd�g}td|�}|�|jd�|�|jt|��|�t|�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�|�|jt|��|�t|�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�|�|jt|��|�t|�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�}|�|jd�|�|jt��|�t|�d�dS)Nzfoo.barz"foo.bar":;)r	r1r�r�rEr0)rr�rrr�test_display_name_quotingsz-TestAddressAndGroup.test_display_name_quotingcCs:td�}|�|jd�|�|jt��|�t|�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<|�|dd�|�|dj|f�dS)Nr8r~zexample.com)r�Tor�zfoo <bar@example.com>)rrrrLr1r�)rr�rfrrr�$test_set_message_header_from_addresss
z8TestAddressAndGroup.test_set_message_header_from_addresscCsDtd�}ttjd�}||d<|�|dd�|�|dj|j�dS)Nzfoo bar)rr�r�z	foo bar:;)r	rrrLr1r�)rr�rfrrr�"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�Ls@		

r�c@steZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�ZdS)�TestFoldingcCsDx>dD]6\}}|�dt|dd��}|�|jtjd�d|�qWdS)N)	)zFoo Bar, Francez"Foo Bar, France")zFoo Bar (France)z"Foo Bar (France)")uFoo Bar, Españaz"Foo =?utf-8?q?Bar=2C_Espa=C3=B1a?=)uFoo Bar (España)z Foo Bar =?utf-8?b?KEVzcGHDsWEp?=)uFoo, Bar Españaz"=?utf-8?q?Foo=2C_Bar_Espa=C3=B1a?=)uFoo, Bar [España]z(=?utf-8?q?Foo=2C_Bar_=5BEspa=C3=B1a=5D?=)uFoo Bär, Francez"Foo =?utf-8?q?B=C3=A4r=2C?= France)uFoo Bär <France>z%Foo =?utf-8?q?B=C3=A4r_=3CFrance=3E?=)urLôrem ipsum dôlôr sit amet, cônsectetuer adipiscing. Suspendisse pôtenti. Aliquam nibh. Suspendisse pôtenti.z�=?utf-8?q?L=C3=B4rem_ipsum_d=C3=B4l=C3=B4r_sit_amet=2C_c=C3=B4nsectetuer?=
 =?utf-8?q?adipiscing=2E_Suspendisse_p=C3=B4tenti=2E_Aliquam_nibh=2E?=
 Suspendisse =?utf-8?q?p=C3=B4tenti=2E?=r�za@b.com)r�)rzTo: %s <a@b.com>
)r.rr1rKrrL)rr,�resultrrrr�test_address_display_names!s
z&TestFolding.test_address_display_namescCs&|�dd�}|�|jtjd�d�dS)Nr'zthis is a test)rzsubject: this is a test
)r.r1rKrrL)rrrrr�test_short_unstructured9sz#TestFolding.test_short_unstructuredcCs&|�dd�}|�|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_unstructured>sz"TestFolding.test_long_unstructuredcCs4|�dd�}|�|jtjjdd�d�t�d��dS)Nrz1this is a short header that will be folded anywayrV)r�)rz�                Subject: this is a
                 short header that
                 will be folded
                 anyway
                )r.r1rKrrLr��textwrap�dedent)rrrrr�'test_unstructured_short_max_line_lengthGs
z3TestFolding.test_unstructured_short_max_line_lengthcCs&|�dd�}|�|jtjd�d�dS)Nrr)rzSubject: test
)r.r1rKrrL)rrrrr�"test_fold_unstructured_single_wordSsz.TestFolding.test_fold_unstructured_single_wordcCs&|�dd�}|�|jtjd�d�dS)Nrztest test test)rzSubject: test test test
)r.r1rKrrL)rrrrr�test_fold_unstructured_shortWsz(TestFolding.test_fold_unstructured_shortcCs.|�dd�}|�|jtjjdd�d�d�dS)NrZ5thisisaverylonglineconsistingofasinglewordthatwontfitrV)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_word\sz5TestFolding.test_fold_unstructured_with_overlong_wordcCs.|�dd�}|�|jtjjdd�d�d�dS)NrzXthisisaverylonglineconsistingofasinglewordthatwontfit plusanotherverylongwordthatwontfitrV)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_wordslsz:TestFolding.test_fold_unstructured_with_two_overlong_wordscCs.|�dd�}|�|jtjjdd�d�d�dS)NrZ thislongwordislessthanmaxlinelen�#)r�)rz+Subject:
 thislongwordislessthanmaxlinelen
)r.r1rKrrLr�)rrrrr�.test_fold_unstructured_with_slightly_long_word�sz:TestFolding.test_fold_unstructured_with_slightly_long_wordcCs4|�dd�}|�|jtjjdd�d�t�d��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�r�r�)rrrrr�"test_fold_unstructured_with_commas�s
z.TestFolding.test_fold_unstructured_with_commascCs,|�dd�}|�|jtjd�t�d��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�sz"TestFolding.test_fold_address_listcCs&|�dd�}|�|jtjd�d�dS)NrezSat, 2 Feb 2002 17:00:06 -0800)rz&Date: Sat, 02 Feb 2002 17:00:06 -0800
)r.r1rKrrL)rrrrr�test_fold_date_header�sz!TestFolding.test_fold_date_headercCs&|�dd�}|�|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_RFC2047�sz2TestFolding.test_fold_overlong_words_using_RFC2047N)rrr r�r�r�r�r�r�r�r�rrrrrrrrrr�s	

r��__main__)rZr�ZunittestZemailrrZ
email.messagerZtest.test_emailrrrZemail.headerregistryrr	�objectrlr
r+r/rGrSrhr�r�r�r�r�r�r�mainrrrr�<module>sN:.(1/'R.T