HEX
Server: Microsoft-IIS/10.0
System: Windows NT ITPWINWEBSVR22 10.0 build 20348 (Windows Server 2022) AMD64
User: www.conferencesearch.co.uk (0)
PHP: 8.3.30
Disabled: NONE
Upload Files
File: D:/Python311/Lib/test/test_email/__pycache__/test_email.cpython-311.pyc
�

��Vc�_���ddlZddlZddlZddlZddlZddlZddlmZmZddl	m
Z
ddlmZddl
mZddlmZddlZddlZddlmZddlmZmZmZdd	lmZmZmZdd
lmZddlm Z ddl!m"Z"dd
l#m$Z$ddl%m&Z&ddl'm(Z(ddl)m*Z*ddl+m,Z,ddl-m.Z.ddl/m0Z0ddl1m2Z2m3Z3ddlm4Z4ddlm5Z5ddlm6Z6ddlm7Z7ddlm8Z8ddlm9Z9ddl:m;Z;ddl<m=Z=ddl>m?Z?m@Z@ddl1mAZAmBZBdZCd ZDd!ZEGd"�d#e@��ZFGd$�d%ejG��ZHGd&�d'e@��ZIGd(�d)ejG��ZJGd*�d+ejG��ZKGd,�d-ejG��ZLGd.�d/ejG��ZMGd0�d1ejG��ZNGd2�d3e@��ZOGd4�d5e@��ZPGd6�d7e@��ZQGd8�d9e@��ZRGd:�d;e@��ZSGd<�d=e@��ZTGd>�d?e@��ZUGd@�dAe@��ZVGdB�dCe@��ZWGdD�dEe@��ZXGdF�dGe@��ZYGdH�dI��ZZGdJ�dKeZeT��Z[GdL�dMeZeT��Z\GdN�dOejG��Z]GdP�dQejG��Z^GdR�dSejG��Z_GdT�dUe@��Z`GdV�dWe@��ZaGdX�dYe@��ZbGdZ�d[e@��Zcedd\kreje��dSdS)]�N)�StringIO�BytesIO)�chain��choice)�Thread)�patch)�Charset)�	Generator�DecodedGenerator�BytesGenerator)�Header�
decode_header�make_header)�HeaderRegistry)�Message)�MIMEApplication)�	MIMEAudio)�MIMEBase)�	MIMEImage)�MIMEMessage)�
MIMEMultipart)�MIMENonMultipart)�MIMEText)�Parser�HeaderParser)�
base64mime)�encoders��errors)�	iterators)�
quoprimime)�utils)�threading_helper)�unlink)�openfile�
TestEmailBase)�
FeedParser�BytesFeedParser�
�� c��eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z!d �Z"d!�Z#d"�Z$d#�Z%d$�Z&d%�Z'd&�Z(d'�Z)d(�Z*d)�Z+d*�Z,d+�Z-d,�Z.d-�Z/d.�Z0d/�Z1d0�Z2d1�Z3d2�Z4d3�Z5d4�Z6d5�Z7d6�Z8d7�Z9d8�Z:d9�Z;d:�Z<d;�Z=d<�Z>d=�Z?d>�Z@d?�ZAd@�ZBdA�ZCdB�ZDdC�ZEdD�ZFdE�ZGdF�ZHdG�ZIdH�ZJdI�ZKdJ�ZLdK�ZMdL�ZNdM�ZOdN�ZPdO�ZQdP�ZRdQ�ZSdR�ZTdS�ZUdT�ZVdU�ZWdVS)W�TestMessageAPIc��|j}|�d��}||�d��gd���||�dd��d��dS)Nz
msg_20.txt�cc)zccc@zzz.orgzddd@zzz.orgzeee@zzz.org�xxzn/a)�assertEqual�_msgobj�get_all��self�eq�msgs   �.D:\Python311\Lib\test\test_email\test_email.py�test_get_allzTestMessageAPI.test_get_all9sf��
�
���l�l�<�(�(��
��3�;�;�t���K�K�K�L�L�L�
��3�;�;�t�U�#�#�U�+�+�+�+�+�c�:�|j}t��}||���d��td��}|�|��||dd��||���d��||dd��||�d��d��||dd	��||���jd��|�d��||���d��||dd��t��}d
|d<d|d
<d|d<|�|��||dd
��||dd��||dd��dS)N�
iso-8859-1�mime-versionz1.0�
text/plain�content-typez text/plain; charset="iso-8859-1"�charset�content-transfer-encoding�quoted-printablez2.0zMIME-Versionztext/x-weird�Content-Typezquinted-puntable�Content-Transfer-Encodingz"text/x-weird; charset="iso-8859-1")r2r�get_charsetr
�set_charset�get_content_type�	get_param�
input_charset�r6r7r8rAs    r9�test_getset_charsetz"TestMessageAPI.test_getset_charset?s���
�
���i�i��
��3�?�?���d�#�#�#��,�'�'������ � � �
��3�~���&�&�&�
��3���!�!�<�0�0�0�
��3�~�� B�C�C�C�
��3�=�=��#�#�\�2�2�2�
��3�*�+�-?�@�@�@�
��3�?�?���*�L�9�9�9��������
��3�?�?���d�#�#�#�
��3�~���-�-�-��i�i��#��N��,��N��+=��'�(����� � � �
��3�~���&�&�&�
��3�~�� D�E�E�E�
��3�*�+�-?�@�@�@�@�@r;c���|j}t��}|�d��||���jd��||dd��dS)N�us-asciir@�text/plain; charset="us-ascii")r2rrGrFrJr5s   r9�test_set_charset_from_stringz+TestMessageAPI.test_set_charset_from_stringYsb��
�
���i�i�����
�#�#�#�
��3�?�?���*�J�7�7�7�
��3�~�� @�A�A�A�A�Ar;c���t��}td��}|�d|��|�|���jd��dS)Nr=zThis is a string payload)rr
�set_payloadr2rFrJ)r6r8rAs   r9�test_set_payload_with_charsetz,TestMessageAPI.test_set_payload_with_charset`sV���i�i���,�'�'�����2�G�<�<�<�������*�*�8�,�G�G�G�G�Gr;c�L�d}td��}t��}|�||��|�|dd��|�|�d���|��|�|���d��dS)N�АБВ�utf-8rB�base64T��decodez	0JDQkdCS
)r
rrRr2�get_payload�r6�datarAr8s    r9�+test_set_payload_with_8bit_data_and_charsetz:TestMessageAPI.test_set_payload_with_8bit_data_and_charsetfs���*���'�"�"���i�i������g�&�&�&�����8�9�8�D�D�D���������5�5�t�<�<�<�������*�*�L�9�9�9�9�9r;c�0�d}td��}d|_t��}|�|�d��|��|�|dd��|�|�d���|��dS�NrUrVrB�8bitTrX)r
�
body_encodingrrRrYr2rZr[s    r9�>test_set_payload_with_non_ascii_and_charset_body_encoding_nonezMTestMessageAPI.test_set_payload_with_non_ascii_and_charset_body_encoding_noneos���*���'�"�"�� $����i�i��������G�,�,�g�6�6�6�����8�9�6�B�B�B���������5�5�t�<�<�<�<�<r;c�
�d}td��}d|_t��}|�||��|�|dd��|�|�d���|��dSr_)r
rarrRr2rZr[s    r9�>test_set_payload_with_8bit_data_and_charset_body_encoding_nonezMTestMessageAPI.test_set_payload_with_8bit_data_and_charset_body_encoding_nonexs��*���'�"�"�� $����i�i������g�&�&�&�����8�9�6�B�B�B���������5�5�t�<�<�<�<�<r;c��t��}|�g��|�|���g��dS�N�rrRr2rZ�r6r8s  r9�test_set_payload_to_listz'TestMessageAPI.test_set_payload_to_list�sC���i�i���������������*�*�B�/�/�/�/�/r;c���t��}d|d<|�d��tt����}|�td|j|��dS)N�multipart/mixedrDzstring payloadz[Aa]ttach.*non-multipart)rrRr�assertRaisesRegex�	TypeError�attach)r6r8�sub_msgs   r9�"test_attach_when_payload_is_stringz1TestMessageAPI.test_attach_when_payload_is_string�sg���i�i��/��N�����(�)�)�)��g�i�i�(�(�����y�*D�"�z�7�	4�	4�	4�	4�	4r;c�`�|j}|�d��}|���}||gd���|�d��}|�d��}||gd���|�d��}|���}||gd���dS)Nz
msg_08.txt)NrNr=�
iso-8859-2�koi8-rz
msg_09.txt�dingbat)rtrNr=rtrsz
msg_12.txt)NrNr=Nrrz
iso-8859-3rNrs)r2r3�get_charsets)r6r7r8�charsetss    r9�test_get_charsetsz TestMessageAPI.test_get_charsets�s���
�
���l�l�<�(�(���#�#�%�%��
��8�M�M�M�N�N�N��l�l�<�(�(���#�#�I�.�.��
��8� � � �	!�	!�	!��l�l�<�(�(���#�#�%�%��
��8�:�:�:�	;�	;�	;�	;�	;r;c�&�|j}|�d��}d�|���D��}||ddg��|�d��}|�d��}||���d��dS)N�
msg_04.txtc�6�g|]}|�����S���get_filename��.0�ps  r9�
<listcomp>z4TestMessageAPI.test_get_filename.<locals>.<listcomp>��"��A�A�A�!�Q�^�^�%�%�A�A�Ar;�msg.txt�
msg_07.txt��dingusfish.gif)r2r3rZr})r6r7r8�	filenames�subparts     r9�test_get_filenamez TestMessageAPI.test_get_filename�s���
�
���l�l�<�(�(��A�A�s���/@�/@�A�A�A�	�
��9�y�)�,�-�-�-��l�l�<�(�(���/�/�!�$�$��
��7���!�!�#3�4�4�4�4�4r;c��|j}|�d��}d�|���D��}||ddg��dS)Nz
msg_44.txtc�6�g|]}|�����Sr{r|r~s  r9r�zHTestMessageAPI.test_get_filename_with_name_parameter.<locals>.<listcomp>�r�r;r��r2r3rZ)r6r7r8r�s    r9�%test_get_filename_with_name_parameterz4TestMessageAPI.test_get_filename_with_name_parameter�sU��
�
���l�l�<�(�(��A�A�s���/@�/@�A�A�A�	�
��9�y�)�,�-�-�-�-�-r;c�z�|j}|�d��}||���d��dS)Nr��BOUNDARY)r2r3�get_boundaryr5s   r9�test_get_boundaryz TestMessageAPI.test_get_boundary�s?��
�
���l�l�<�(�(��
��3�����z�*�*�*�*�*r;c�N�|j}|�d��}|�d��|���d\}}||���d��||d��|�d��}|�d��|���d\}}||���d��||d��|�d��}|�tj|jd��dS)	N�
msg_01.txtr��r@z3text/plain; charset="us-ascii"; boundary="BOUNDARY"ryz$multipart/mixed; boundary="BOUNDARY"�
msg_03.txt)r2r3�set_boundary�items�lower�assertRaisesr �HeaderParseError)r6r7r8�header�values     r9�test_set_boundaryz TestMessageAPI.test_set_boundary�s��
�
���l�l�<�(�(������$�$�$��	�	���A��
���
��6�<�<�>�>�>�*�*�*�
��5�G�H�H�H��l�l�<�(�(������$�$�$��	�	���A��
���
��6�<�<�>�>�>�*�*�*�
��5�8�9�9�9��l�l�<�(�(�����&�1��*�J�	8�	8�	8�	8�	8r;c�,�td��}|�|���ddd��|���|�|���dddd�d��dS)Nz	form-datarr�zmultipart/form-data�!z!multipart/form-data; boundary="==)rr2r��	as_stringrhs  r9�test_make_boundaryz!TestMessageAPI.test_make_boundary�s����K�(�(��	
��������Q���*�,A�B�B�B��
�
������������Q���*�3�B�3�/�;�	=�	=�	=�	=�	=r;c��tdd���5}|���}ddd��n#1swxYwYt��}|�|��}t	��}t|dd��}|�|d��|�|���|��dS)N�
msg_46.txtrV��encodingTrF)	r&�readr�parsestrrr�flattenr2�getvalue�r6�fp�msgdata�parserr8�out�gens       r9�test_message_rfc822_onlyz'TestMessageAPI.test_message_rfc822_only�s����l�W�
5�
5�
5�	 ���g�g�i�i�G�	 �	 �	 �	 �	 �	 �	 �	 �	 �	 �	 ����	 �	 �	 �	 ������o�o�g�&�&���j�j����T�1�%�%�����C��������������1�1�1�1�1��3�7�7c���tdd���5}|����d��}ddd��n#1swxYwYtj���}|�|��}t��}tj�	|��}|�
|��|�|���|��dS)Nr�rVr��ascii)
r&r��encode�emailr��BytesHeaderParser�
parsebytesr�	generatorr
r�r2r�r�s       r9�test_byte_message_rfc822_onlyz,TestMessageAPI.test_byte_message_rfc822_only�s���
�l�W�
5�
5�
5�	0���g�g�i�i�&�&�w�/�/�G�	0�	0�	0�	0�	0�	0�	0�	0�	0�	0�	0����	0�	0�	0�	0���/�/�1�1������(�(���i�i���o�,�,�S�1�1�����C�������������1�1�1�1�1s�(A�A
�
A
c�|�|j}|�d��}||�d���d��||�d���d���d��||�d���d���d��||�d���d���d	��||�d
���d���d��||�d���d���d
��dS)Nz
msg_10.txtTrXrs This is a 7bit encoded message.
r�s-�This is a Quoted Printable encoded message!
�s!This is a Base64 encoded message.�s"This is a Base64 encoded message.
r�s/This has no Content-Transfer-Encoding: header.
r�r5s   r9�test_get_decoded_payloadz'TestMessageAPI.test_get_decoded_payload�sc��
�
���l�l�<�(�(��
��3�?�?�$�?�'�'��.�.�.�
��3�?�?�1���)�)��)�6�6�/�	1�	1�	1�	��3�?�?�1���)�)��)�6�6�?�	A�	A�	A�	��3�?�?�1���)�)��)�6�6�/�	1�	1�	1�	��3�?�?�1���)�)��)�6�6�1�	3�	3�	3�	��3�?�?�1���)�)��)�6�6�>�	@�	@�	@�	@�	@r;c��|j}t��}|�d��dD]'}||d<||�d���d���(|�d��||�d���d��dS)	Nz$begin 666 -
+:&5L;&\@=V]R;&0 
 
end
�z
x-uuencode�uuencode�uuezx-uuerBTrX�hello world�foosfoo)r2rrRrZ)r6r7r8�ctes    r9�test_get_decoded_uu_payloadz*TestMessageAPI.test_get_decoded_uu_payloads���
�
���i�i�����C�D�D�D�=�	=�	=�C�/2�C�+�,��B�s���d��+�+�^�<�<�<�<��������
��3�?�?�$�?�'�'��0�0�0�0�0r;c�d�t��}|�t|jd��dS)Nr�)rr�rmrZrhs  r9�*test_get_payload_n_raises_on_non_multipartz9TestMessageAPI.test_get_payload_n_raises_on_non_multiparts+���i�i�����)�S�_�a�8�8�8�8�8r;c�X�|j}|�d��}tdd���5}|���}ddd��n#1swxYwYt	��}t|��}|�|��||���|��dS)Nr�z
msg_17.txtrVr�)r2r3r&r�rrr�r�)r6r7r8r��text�s�gs       r9�test_decoded_generatorz%TestMessageAPI.test_decoded_generators���
�
���l�l�<�(�(��
�l�W�
5�
5�
5�	���7�7�9�9�D�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	��J�J���Q����	�	�	�#����
��1�:�:�<�<������s�A�A�Ac�>�t��}d|d<d|d<|�d|��|�d|��|�d|��|�d|��|�d|��|�d|��dS)	N�Me�From�You�to�from�FROM�To�TO)r�assertInrhs  r9�test__contains__zTestMessageAPI.test__contains__s����i�i����F����D�	��
�
�f�c�"�"�"��
�
�f�c�"�"�"��
�
�f�c�"�"�"��
�
�d�C� � � ��
�
�d�C� � � ��
�
�d�C� � � � � r;c��|�d��}tdd���5}|���}ddd��n#1swxYwY|�|t	|����|�d���}|�d��}|�|d�d����|�|t�
|d	d�����dS)
Nr�rVr�T��unixfromr*rzFrom r�)r3r&r�r2�strr��split�
assertTrue�
startswith�NL�join)r6r8r�r��fullrepr�liness      r9�test_as_stringzTestMessageAPI.test_as_string*s���l�l�<�(�(��
�l�W�
5�
5�
5�	���7�7�9�9�D�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�����s�3�x�x�(�(�(��=�=�$�=�/�/�����t�$�$������a��+�+�G�4�4�5�5�5�����r�w�w�u�Q�R�R�y�1�1�2�2�2�2�2s�A�A�Ac�J�|�d��}|j�d���}|�|���}t	��}t||���}|�|��|�||�����dS�Nr��
��linesep��policy)	r3r��cloner�rrr�r2r��r6r8�	newpolicyr�r�r�s      r9�test_as_string_policyz$TestMessageAPI.test_as_string_policy4s����l�l�<�(�(���J�$�$�V�$�4�4�	��=�=�	�=�2�2���J�J���a�	�*�*�*��	�	�	�#��������1�:�:�<�<�0�0�0�0�0r;c��tjd��}|�d��}tjd��}tj|��}|�|���|��dS)Nu�            MIME-Version: 1.0
            Content-type: text/plain; charset="iso-8859-1"

            Test if non-ascii messages with no Content-Transfer-Encoding set
            can be as_string'd:
            Föö bär
            r=a%            MIME-Version: 1.0
            Content-type: text/plain; charset="iso-8859-1"
            Content-Transfer-Encoding: quoted-printable

            Test if non-ascii messages with no Content-Transfer-Encoding set
            can be as_string'd:
            F=F6=F6 b=E4r
            )�textwrap�dedentr�r��message_from_bytesr2r��r6�m�source�expectedr8s     r9�#test_nonascii_as_string_without_ctez2TestMessageAPI.test_nonascii_as_string_without_cte=sw���O��
�
�����,�'�'���?�$�����&�v�.�.����������(�3�3�3�3�3r;c��tjd��}|�d��}|�dd��}t	j|��}|�|���|��dS)Nu�            MIME-Version: 1.0

            Test if non-ascii messages with no Content-Type nor
            Content-Transfer-Encoding set can be as_string'd:
            Föö bär
            r=r��replace)r�r�r�rYr�r�r2r�r�s     r9�4test_nonascii_as_string_without_content_type_and_ctezCTestMessageAPI.test_nonascii_as_string_without_content_type_and_cteSsr���O��
�
�����,�'�'���=�=��)�4�4���&�v�.�.����������(�3�3�3�3�3r;c�*�|�d��}tdd���5}|����d��}ddd��n#1swxYwY|�|t|����|�d���}|�d��}|�|d�	d	����|�|d�
|d
d�����dS)Nr�rVr�r�Tr��
rsFrom r�)r3r&r�r�r2�bytes�as_bytesr�r�r�r�)r6r8r�r\r�r�s      r9�
test_as_byteszTestMessageAPI.test_as_bytes`s'���l�l�<�(�(��
�l�W�
5�
5�
5�	-���7�7�9�9�#�#�G�,�,�D�	-�	-�	-�	-�	-�	-�	-�	-�	-�	-�	-����	-�	-�	-�	-�����u�S�z�z�*�*�*��<�<��<�.�.�����u�%�%������a��+�+�H�5�5�6�6�6�����u�z�z�%����)�4�4�5�5�5�5�5s�(A�A�"Ac�J�|�d��}|j�d���}|�|���}t	��}t||���}|�|��|�||�����dSr�)	r3r�r�r�rr
r�r2r�r�s      r9�test_as_bytes_policyz#TestMessageAPI.test_as_bytes_policyjs����l�l�<�(�(���J�$�$�V�$�4�4�	��<�<�y�<�1�1���I�I���1�I�.�.�.��	�	�	�#��������1�:�:�<�<�0�0�0�0�0r;c��tjd��}|�|�d��d��dS)NzContent-Type: blarg; baz; boo
�bazr+�r��message_from_stringr2rIrhs  r9�test_bad_paramzTestMessageAPI.test_bad_paramts;���'�(I�J�J��������u�-�-�r�2�2�2�2�2r;c�~�tjd��}|�|���d��dS�Nz
From: foo
�r�rr2r}rhs  r9�test_missing_filenamez$TestMessageAPI.test_missing_filenamex�:���'�
�6�6������)�)�+�+�T�2�2�2�2�2r;c�~�tjd��}|�|���d��dS)Nz%Content-Disposition: blarg; filename
r+r	rhs  r9�test_bogus_filenamez"TestMessageAPI.test_bogus_filename|s?���'�0�2�2������)�)�+�+�R�0�0�0�0�0r;c�~�tjd��}|�|���d��dSr�r�rr2r�rhs  r9�test_missing_boundaryz$TestMessageAPI.test_missing_boundary�rr;c��|j}tjd��}||�d���gd���tjd��}||�d���gd���||���d��tjd��}||�d���gd���dS)N�&X-Header: foo=one; bar=two; baz=three
�x-header�r�))r��one)�bar�two�r�threez X-Header: foo; bar=one; baz=two
))r�r+)rr)rr�"X-Header: foo; bar="one"; baz=two
)r2r�r�
get_paramsr5s   r9�test_get_paramszTestMessageAPI.test_get_params�s���
�
���'�5�7�7��
��3�>�>��>�,�,�=�=�=�	?�	?�	?��'�/�1�1��
��3�>�>��>�,�,�8�8�8�	:�	:�	:�
��3�>�>���T�"�"�"��'�1�3�3��
��3�>�>��>�,�,�8�8�8�	:�	:�	:�	:�	:r;c�~�t��}d|d<|�|�d��d��dS)Nz>Content-Type: Multipart/mixed; boundary = "CPIMSSMTPC06p5f3tG"rD�boundary�CPIMSSMTPC06p5f3tG)rr2rIrhs  r9�test_get_param_liberalz%TestMessageAPI.test_get_param_liberal�s>���i�i��^��N��������z�2�2�4H�I�I�I�I�Ir;c���|j}tjd��}||�dd���d��||�dd���d��||�d��d��tjd��}||�dd���d	��||�dd���d
��||�dd���d��dS)Nrrrrr�quuzrr�r+rr�r2r�rrIr5s   r9�test_get_paramzTestMessageAPI.test_get_param�s��
�
���'�5�7�7��
��3�=�=��z�=�2�2�E�:�:�:�
��3�=�=��
�=�3�3�T�:�:�:�
��3�=�=�� � �$�'�'�'��'�1�3�3��
��3�=�=��z�=�2�2�B�7�7�7�
��3�=�=��z�=�2�2�E�:�:�:�
��3�=�=��z�=�2�2�E�:�:�:�:�:r;c��|�d��}|�|�d���d��d��dS)Nz
msg_22.txtr��namez
wibble.JPG)r3r2rZrIrhs  r9�'test_get_param_funky_continuation_linesz6TestMessageAPI.test_get_param_funky_continuation_lines�sI���l�l�<�(�(���������+�+�5�5�f�=�=�|�L�L�L�L�Lr;c���tjd��}|�|�d��d��|�|�dd���d��dS)Nz4Content-Type: image/pjpeg; name="Jim&amp;&amp;Jill"
r&zJim&amp;&amp;JillF��unquotez"Jim&amp;&amp;Jill"rrhs  r9�#test_get_param_with_semis_in_quotesz2TestMessageAPI.test_get_param_with_semis_in_quotes�ss���'�C�E�E��������v�.�.�0C�D�D�D�������v�u��=�=�.�	0�	0�	0�	0�	0r;c��tjd��}|�|�d��d��tjd��}|�|�d��d��dS)Nz5Content-Type: foo; bar*0="baz\"foobar"; bar*1="\"baz"rzbaz"foobar"bazrrhs  r9�test_get_param_with_quotesz)TestMessageAPI.test_get_param_with_quotes�s|���'�E�G�G��������u�-�-�/?�@�@�@��'�K�M�M��������u�-�-�/?�@�@�@�@�@r;c���tjd��}|�d|��|�d|��|�d|��|�d|��dS)NzHeader: existsr�r�HEADER�headerx)r�rr��assertNotInrhs  r9�test_field_containmentz%TestMessageAPI.test_field_containment�sk���'�(8�9�9���
�
�h��$�$�$��
�
�h��$�$�$��
�
�h��$�$�$�����C�(�(�(�(�(r;c�<�|j}t��}|�dd��||�d��d��|�dd��||�d��d��||�dd���d��||���gd���||�d���gd	���|�dd
d���||�dd���d
��dS)
NrA�iso-2022-jp�
importance�
high valueFr)�"high value")�r?r+)rAr4)r5r6)r8)rAz
"iso-2022-jp")r5r7ziso-9999-xxzX-Jimmyr)r2r�	set_paramrIrr5s   r9�test_set_paramzTestMessageAPI.test_set_param�sE��
�
���i�i���
�
�i��/�/�/�
��3�=�=��#�#�]�3�3�3��
�
�l�L�1�1�1�
��3�=�=��&�&��5�5�5�
��3�=�=��u�=�5�5�~�F�F�F�
��3�>�>���<�<�<�	=�	=�	=�	��3�>�>�%�>�(�(�+G�+G�+G�	H�	H�	H�	�
�
�i��y�
�A�A�A�
��3�=�=��9�=�5�5�}�E�E�E�E�Er;c��|j}|�d��}||���gd���|�d��}|�d��||���ddg��|�d|��||���ddd|fg��dS)N�
msg_05.txt)��multipart/reportr+)�report-type�delivery-status�r�%D1690A7AC1.996856090/mail.example.comr?r=rA)r2r3rrI�	del_paramr9)r6r7r8�old_vals    r9�test_del_paramzTestMessageAPI.test_del_param�s���
�
���l�l�<�(�(��
��3�>�>���C�C�C�	D�	D�	D��-�-�
�.�.���
�
�m�$�$�$�
��3�>�>���$�A�C�	D�	D�	D�	�
�
�m�W�-�-�-�
��3�>�>���$�A�
�G�$�&�	'�	'�	'�	'�	'r;c��t��}|�ddd���|�dd��|�|dd��dS)N�Content-Disposition�
attachment�bud.gif��filenamerK�content-disposition�r�
add_headerrCr2rhs  r9�test_del_param_on_other_headerz-TestMessageAPI.test_del_param_on_other_header�s[���i�i�����,�l�Y��O�O�O��
�
�j�"7�8�8�8�����2�3�\�B�B�B�B�Br;c�N�t��}|�dd��dS)NrKrL)rrCrhs  r9�$test_del_param_on_nonexistent_headerz3TestMessageAPI.test_del_param_on_nonexistent_header�s&���i�i���
�
�j�"7�8�8�8�8�8r;c���t��}|�ddd���|d}|�dd���|�|d|��dS)NrDr?rV�rA�foobarrrM)r6r8�existing_headers   r9�test_del_nonexistent_paramz)TestMessageAPI.test_del_nonexistent_param�sd���i�i�����~�|�W��E�E�E��n�-���
�
�h�~�
�6�6�6�����^�,�o�>�>�>�>�>r;c�^�|j}t��}|�t|jd��|�d��||dd��|�dd��||dd��|�d��||dd��dS)	Nr�r?r@rArNrOz	text/htmlztext/html; charset="us-ascii")r2rr��
ValueError�set_typer9r5s   r9�
test_set_typezTestMessageAPI.test_set_type�s���
�
���i�i�����*�c�l�F�;�;�;����\�"�"�"�
��3�~���-�-�-��
�
�i��,�,�,�
��3�~�� @�A�A�A����[�!�!�!�
��3�~�� ?�@�@�@�@�@r;c��t��}d|d<|�dd��|�|dd��dS)Nr?zX-Content-Type�application/octet-streamzx-content-type)rrYr2rhs  r9�test_set_type_on_other_headerz,TestMessageAPI.test_set_type_on_other_headersO���i�i�� ,�������/�1A�B�B�B�����-�.�0J�K�K�K�K�Kr;c�r�t��}|�|���d��dS)Nr?)rr2rHrhs  r9�test_get_content_type_missingz,TestMessageAPI.test_get_content_type_missings3���i�i������-�-�/�/��>�>�>�>�>r;c��t��}|�d��|�|���d��dS)N�message/rfc822)r�set_default_typer2rHrhs  r9�/test_get_content_type_missing_with_default_typez>TestMessageAPI.test_get_content_type_missing_with_default_typesI���i�i�����-�.�.�.�����-�-�/�/�1A�B�B�B�B�Br;c��|�d��}|�|�d�����d��dS)N�
msg_30.txtrra�r3r2rZrHrhs  r9�+test_get_content_type_from_message_implicitz:TestMessageAPI.test_get_content_type_from_message_implicit�R���l�l�<�(�(���������+�+�<�<�>�>�)�	+�	+�	+�	+�	+r;c��|�d��}|�|�d�����d��dS)N�
msg_28.txtrrarfrhs  r9�+test_get_content_type_from_message_explicitz:TestMessageAPI.test_get_content_type_from_message_explicitrhr;c��|�d��}|�|���d��dS)Nr�r?�r3r2rHrhs  r9�6test_get_content_type_from_message_text_plain_implicitzETestMessageAPI.test_get_content_type_from_message_text_plain_implicit!�;���l�l�<�(�(������-�-�/�/��>�>�>�>�>r;c��|�d��}|�|���d��dS)Nr�r?rmrhs  r9�6test_get_content_type_from_message_text_plain_explicitzETestMessageAPI.test_get_content_type_from_message_text_plain_explicit%ror;c�r�t��}|�|���d��dS)Nr��rr2�get_content_maintyperhs  r9�!test_get_content_maintype_missingz0TestMessageAPI.test_get_content_maintype_missing)s3���i�i������1�1�3�3�V�<�<�<�<�<r;c��t��}|�d��|�|���d��dS)Nra�message)rrbr2rtrhs  r9�3test_get_content_maintype_missing_with_default_typezBTestMessageAPI.test_get_content_maintype_missing_with_default_type-sH���i�i�����-�.�.�.�����1�1�3�3�Y�?�?�?�?�?r;c��|�d��}|�|�d�����d��dS)Nrerrw�r3r2rZrtrhs  r9�/test_get_content_maintype_from_message_implicitz>TestMessageAPI.test_get_content_maintype_from_message_implicit2�G���l�l�<�(�(���������+�+�@�@�B�B�I�N�N�N�N�Nr;c��|�d��}|�|�d�����d��dS)Nrjrrwrzrhs  r9�/test_get_content_maintype_from_message_explicitz>TestMessageAPI.test_get_content_maintype_from_message_explicit6r|r;c��|�d��}|�|���d��dS)Nr�r��r3r2rtrhs  r9�:test_get_content_maintype_from_message_text_plain_implicitzITestMessageAPI.test_get_content_maintype_from_message_text_plain_implicit:�;���l�l�<�(�(������1�1�3�3�V�<�<�<�<�<r;c��|�d��}|�|���d��dS)Nr�r�r�rhs  r9�:test_get_content_maintype_from_message_text_plain_explicitzITestMessageAPI.test_get_content_maintype_from_message_text_plain_explicit>r�r;c�r�t��}|�|���d��dS)N�plain�rr2�get_content_subtyperhs  r9� test_get_content_subtype_missingz/TestMessageAPI.test_get_content_subtype_missingBs3���i�i������0�0�2�2�G�<�<�<�<�<r;c��t��}|�d��|�|���d��dS)Nra�rfc822)rrbr2r�rhs  r9�2test_get_content_subtype_missing_with_default_typezATestMessageAPI.test_get_content_subtype_missing_with_default_typeFsH���i�i�����-�.�.�.�����0�0�2�2�H�=�=�=�=�=r;c��|�d��}|�|�d�����d��dS)Nrerr��r3r2rZr�rhs  r9�.test_get_content_subtype_from_message_implicitz=TestMessageAPI.test_get_content_subtype_from_message_implicitK�G���l�l�<�(�(���������+�+�?�?�A�A�8�L�L�L�L�Lr;c��|�d��}|�|�d�����d��dS)Nrjrr�r�rhs  r9�.test_get_content_subtype_from_message_explicitz=TestMessageAPI.test_get_content_subtype_from_message_explicitOr�r;c��|�d��}|�|���d��dS)Nr�r��r3r2r�rhs  r9�9test_get_content_subtype_from_message_text_plain_implicitzHTestMessageAPI.test_get_content_subtype_from_message_text_plain_implicitS�;���l�l�<�(�(������0�0�2�2�G�<�<�<�<�<r;c��|�d��}|�|���d��dS)Nr�r�r�rhs  r9�9test_get_content_subtype_from_message_text_plain_explicitzHTestMessageAPI.test_get_content_subtype_from_message_text_plain_explicitWr�r;c�|�t��}d|d<|�|���d��dS)N�no-slash-in-this-stringrDr�rsrhs  r9�test_get_content_maintype_errorz.TestMessageAPI.test_get_content_maintype_error[s=���i�i��7��N������1�1�3�3�V�<�<�<�<�<r;c�|�t��}d|d<|�|���d��dS)Nr�rDr�r�rhs  r9�test_get_content_subtype_errorz-TestMessageAPI.test_get_content_subtype_error`s=���i�i��7��N������0�0�2�2�G�<�<�<�<�<r;c��|j}t��}|�dd��|�dd��|�dd��||���gd���||���gd���|�dd	��||���gd���||���gd
���|�dd��|�dd��||���gd
���||���gd���|�t|jdd��dS)N�First�One�Second�Two�Third�Three)r�r�r�)r�r�r��Twenty)r�r�r��Eleven�One Hundred)r�r�r�r�)r�r�r�r��Fourth�Missing)r2rrN�keys�values�replace_headerr��KeyErrorr5s   r9�test_replace_headerz"TestMessageAPI.test_replace_headeresx��
�
���i�i�����w��&�&�&����x��'�'�'����w��(�(�(�
��3�8�8�:�:�3�3�3�4�4�4�
��3�:�:�<�<�0�0�0�1�1�1����8�X�.�.�.�
��3�8�8�:�:�3�3�3�4�4�4�
��3�:�:�<�<�3�3�3�4�4�4����w��)�)�)����7�M�2�2�2�
��3�8�8�:�:�<�<�<�=�=�=�
��3�:�:�<�<�E�E�E�F�F�F����(�C�$6��)�L�L�L�L�Lr;c���t��}|�|�����|�ddd���|�|���d��|�dd��|�|���d��|�dd��|�|���d��dS)NrGrHz
random.avirJ�inline�InlinE)r�assertIsNone�get_content_dispositionrNr2r�rhs  r9�test_get_content_dispositionz+TestMessageAPI.test_get_content_dispositionvs����i�i�����#�5�5�7�7�8�8�8����,�l� ,�	�	.�	.�	.�����4�4�6�6��E�E�E����0�(�;�;�;�����4�4�6�6��A�A�A����0�(�;�;�;�����4�4�6�6��A�A�A�A�Ar;c��d}t��}d|d<d|d<|�|��|�|�d���d��|�|jd	tj��dS)
NzAwDp0P7//y6LwKEAcPa/6Q=9zaudio/x-midir@rWrBTrXs����.���p���r)rrRr2rZ�assertIsInstance�defectsr �InvalidBase64CharactersDefect�r6�xr8s   r9�test_broken_base64_payloadz)TestMessageAPI.test_broken_base64_payload�s���&���i�i��,��N��+3��'�(����������������5�5�7�	9�	9�	9�	
���c�k�!�n�$�B�	D�	D�	D�	D�	Dr;c���d}t��}d|d<d|d<|�|��|�|�d���t	|d����dS)	Nuthis is a bröken thing to dor?r@r`rBTrXzraw-unicode-escape)rrRr2rZr�r�s   r9�test_broken_unicode_payloadz*TestMessageAPI.test_broken_unicode_payload�sy��
.���i�i��*��N��+1��'�(����������������5�5��q�"6�7�7�	9�	9�	9�	9�	9r;c���d�d��}t��}d|d<d|d<||_|�|�d���|��dS)	Nu#this is a quéstionable thing to dorV�text/plain; charset="utf-8"r@r`rBTrX)r�r�_payloadr2rZr�s   r9�test_questionable_bytes_payloadz.TestMessageAPI.test_questionable_bytes_payload�sf��
2�8�8��A�A���i�i��;��N��+1��'�(������������5�5�q�9�9�9�9�9r;c��t��}|�ddd���|�d|d��dS)NrGrHrIrJzattachment; filename="bud.gif"�rrNr2rhs  r9�test_ascii_add_headerz$TestMessageAPI.test_ascii_add_header�s\���i�i�����,�l� )�	�	+�	+�	+����9��%�&�	(�	(�	(�	(�	(r;c��t��}|�ddd���|�d|d��dS)NrGrH�Fußballer.pptrJz/attachment; filename*=utf-8''Fu%C3%9Fballer.pptr�rhs  r9�test_noascii_add_headerz&TestMessageAPI.test_noascii_add_header�s\���i�i�����,�l�%�	�	'�	'�	'����?��%�&�	(�	(�	(�	(�	(r;c��t��}|�ddd���|�d|d��dS)NrGrH)r=r+r�rJz1attachment; filename*=iso-8859-1''Fu%DFballer.pptr�rhs  r9�#test_nonascii_add_header_via_triplez2TestMessageAPI.test_nonascii_add_header_via_triple�s\���i�i�����,�l�9�	�	;�	;�	;����A��%�&�	(�	(�	(�	(�	(r;c��t��}|�ddd���|�d|d��dS)NrGrHzwindows [filename].pptrJz-attachment; filename="windows [filename].ppt"r�rhs  r9�#test_ascii_add_header_with_tspecialz2TestMessageAPI.test_ascii_add_header_with_tspecial�s\���i�i�����,�l�-�	�	/�	/�	/����;��%�&�	(�	(�	(�	(�	(r;c��t��}|�ddd���|�d|d��dS)NrGrHuFußballer [filename].pptrJz@attachment; filename*=utf-8''Fu%C3%9Fballer%20%5Bfilename%5D.pptr�rhs  r9�&test_nonascii_add_header_with_tspecialz5TestMessageAPI.test_nonascii_add_header_with_tspecial�s\���i�i�����,�l�0�	�	2�	2�	2����N��%�&�	(�	(�	(�	(�	(r;c���dD]`}t��}d|z|d<d|d<|�d��|�|�d���d	d
|z���adS)N��latin-1r��text/plain; charset=%sr@rCrBsfoo=e6=96=87barTrX�	foo文bar�1get_payload returns wrong result with charset %s.rg�r6rAr8s   r9�test_binary_quopri_payloadz)TestMessageAPI.test_binary_quopri_payload�s���+�	O�	O�G��)�)�C�":�W�"D�C���/A�C�+�,��O�O�.�/�/�/�������t��,�,�%�C�g�M�
O�
O�
O�
O�	O�	Or;c���dD]`}t��}d|z|d<d|d<|�d��|�|�d���d	d
|z���adS)Nr�r�r@rWrBsZm9v5paHYmFyTrXr�r�rgr�s   r9�test_binary_base64_payloadz)TestMessageAPI.test_binary_base64_payload�s���+�	O�	O�G��)�)�C�":�W�"D�C���/7�C�+�,��O�O�O�,�,�,�������t��,�,�%�C�g�M�
O�
O�
O�
O�	O�	Or;c
��dD]�}dD]~}t��}d|z|d<||d<|�d��|�|�d���d	t	d
���||�������dS)Nr�r�r�r@rBs begin 666 -
)9F]OYI:'8F%R
 
end
TrXr�)z!get_payload returns wrong result z"with charset {0} and encoding {1}.)rrRr2rZr��format)r6rAr�r8s    r9�test_binary_uuencode_payloadz+TestMessageAPI.test_binary_uuencode_payload�s���+�	3�	3�G�F�

3�

3���i�i��&>��&H��N�#�3;��/�0���� G�H�H�H�� � ��O�O�4�O�0�0�)��?�@�@���w��1�1�3�3�3�3�

3�	3�	3r;c��t��}|�ddd���|�d|d��dS)NrGr�)�foo_barzinline; foo-barr�rhs  r9�$test_add_header_with_name_only_paramz3TestMessageAPI.test_add_header_with_name_only_param�sG���i�i�����,�h���E�E�E����*�C�0E�,F�G�G�G�G�Gr;c��t��}|�dd��|�d|d��dS)NzX-Statusr+r�rhs  r9�test_add_header_with_no_valuez,TestMessageAPI.test_add_header_with_no_value�s?���i�i�����z�4�(�(�(�����S��_�-�-�-�-�-r;c��t��}td��|d<|�tj|j��dS�Nzdummy
X-Injected-Header: test�Dummy)rrr�r r�r�rhs  r9�(test_embedded_header_via_Header_rejectedz7TestMessageAPI.test_embedded_header_via_Header_rejected�s>���i�i���>�?�?��G�����&�1�3�=�A�A�A�A�Ar;c�v�t��}d|d<|�tj|j��dSr�)rr�r r�r�rhs  r9�(test_embedded_header_via_string_rejectedz7TestMessageAPI.test_embedded_header_via_string_rejecteds5���i�i��7��G�����&�1�3�=�A�A�A�A�Ar;c��td��}d|d<|�t|��tjd����dS)Nzabc
uÉ test�Subjectz�            Content-Type: text/plain; charset="us-ascii"
            MIME-Version: 1.0
            Content-Transfer-Encoding: 7bit
            Subject: =?utf-8?q?=C3=89_test?=

            abc
            �rr2r�r�r��r6r�s  r9�-test_unicode_header_defaults_to_utf8_encodingz<TestMessageAPI.test_unicode_header_defaults_to_utf8_encodingsU���W���� ��)������Q�����1�!�!�	�	�	�	�	r;c��td��}|�t|��tjd����dS)NuÉ testabc
z�            Content-Type: text/plain; charset="utf-8"
            MIME-Version: 1.0
            Content-Transfer-Encoding: base64

            w4kgdGVzdGFiYwo=
            r�r�s  r9�+test_unicode_body_defaults_to_utf8_encodingz:TestMessageAPI.test_unicode_body_defaults_to_utf8_encodingsL���^�$�$������Q�����1�!�!�	�	�	�	�	r;N)X�__name__�
__module__�__qualname__r:rLrPrSr]rbrdrirprwr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrr
r
rrr r$r'r+r-r2r:rErOrQrVrZr]r_rcrgrkrnrqrurxr{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;r9r.r.8sZ������,�,�,�A�A�A�4B�B�B�H�H�H�:�:�:�=�=�=�=�=�=�0�0�0�
4�4�4�;�;�;�"	5�	5�	5�.�.�.�+�+�+�8�8�8�,=�=�=�
2�
2�
2�	2�	2�	2�@�@�@�,	1�	1�	1�9�9�9����
!�
!�
!�3�3�3�1�1�1�4�4�4�,4�4�4�6�6�6�1�1�1�3�3�3�3�3�3�1�1�1�
3�3�3�:�:�:�"J�J�J�
;�;�;�$M�M�M�
0�0�0�A�A�A�)�)�)�F�F�F�"'�'�'�"C�C�C�9�9�9�
?�?�?�	A�	A�	A�L�L�L�?�?�?�C�C�C�
+�+�+�
+�+�+�
?�?�?�?�?�?�=�=�=�@�@�@�
O�O�O�O�O�O�=�=�=�=�=�=�=�=�=�>�>�>�
M�M�M�M�M�M�=�=�=�=�=�=�=�=�=�
=�=�=�
M�M�M�"	B�	B�	B�
D�
D�
D�	9�	9�	9�:�:�:�(�(�(�(�(�(�(�(�(�(�(�(�(�(�(�	O�	O�	O�	O�	O�	O�3�3�3�H�H�H�
.�.�.�B�B�B�
B�B�B�
���	�	�	�	�	r;r.c�2�eZdZd�Zd�Zd�Zd�Zd�Zd�ZdS)�TestEncodersc�r�tdd��5}|���}ddd��n#1swxYwYtjj�|��}|���}|�d��}|�td�|D����d��dS)N�
python.gif�rbr*c�,�g|]}t|����Sr{)�len�rr�s  r9r�z;TestEncoders.test_EncodersEncode_base64.<locals>.<listcomp>(s��!:�!:�!:�a�3�q�6�6�!:�!:�!:r;�L)
r&r�r��mime�imagerrZr��assertLessEqual�max)r6r��bindata�mimed�base64edr�s      r9�test_EncodersEncode_base64z'TestEncoders.test_EncodersEncode_base64!s���
�l�D�
)�
)�	 �R��g�g�i�i�G�	 �	 �	 �	 �	 �	 �	 �	 �	 �	 �	 ����	 �	 �	 �	 ��
� �*�*�7�3�3���$�$�&�&�����t�$�$�����S�!:�!:�5�!:�!:�!:�;�;�R�@�@�@�@�@��2�6�6c�~�|j}t��}|�d��||dd��dS)NrNrB�7bit)r2rrGr5s   r9�test_encode_empty_payloadz&TestEncoders.test_encode_empty_payload*sC��
�
���i�i�����
�#�#�#�
��3�*�+�V�4�4�4�4�4r;c���|j}td��}||dd��td��}||dd��tdd���}||dd��dS)	N�hello worldrBruhello ø worldrWr=��_charsetrC)r2rr5s   r9�test_default_ctezTestEncoders.test_default_cte0s���
�
���}�%�%��
��3�*�+�V�4�4�4��)�*�*��
��3�*�+�X�6�6�6��)�L�A�A�A��
��3�*�+�-?�@�@�@�@�@r;c��|j}tdd���}||dd��||���tjd����dS)Nu文
�euc-jprrBrz�            MIME-Version: 1.0
            Content-Type: text/plain; charset="iso-2022-jp"
            Content-Transfer-Encoding: 7bit

            $BJ8(B
            )r2rr�r�r�r5s   r9�test_encode7or8bitzTestEncoders.test_encode7or8bit<sq���
���w��2�2�2��
��3�*�+�V�4�4�4�
��3�=�=�?�?�H�O�-���	�	�	�	�	r;c��tddd��}|�t|��tjd����dS)Nuáö
r�z
ISO-8859-1z�            MIME-Version: 1.0
            Content-Type: text/text; charset="iso-8859-1"
            Content-Transfer-Encoding: quoted-printable

            =E1=F6
            r�rhs  r9�test_qp_encode_latin1z"TestEncoders.test_qp_encode_latin1KsP���|�V�\�:�:������S���8�?�4�$�$�	�	�	�	�	r;c��tddd��}|�t|��tjd����dS)Nuż
r�z
ISO-8859-2z�            MIME-Version: 1.0
            Content-Type: text/text; charset="iso-8859-2"
            Content-Transfer-Encoding: quoted-printable

            =BF
            r�rhs  r9�test_qp_encode_non_latin1z&TestEncoders.test_qp_encode_non_latin1UsP���z�6�<�8�8������S���8�?�4�$�$�	�	�	�	�	r;N)	r�r�r�rrr	rrrr{r;r9r�r�st������A�A�A�5�5�5�
A�
A�
A�
�
�
����	�	�	�	�	r;r�c��eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z!d �Z"d!�Z#d"�Z$d#�Z%d$�Z&d%�Z'd&�Z(d'�Z)d(�Z*dS))�TestLongHeadersNc���|j}tjd��}t��}t	|��}|�|��||���d��dS)Nz�Subject: bug demonstration
	12345678911234567892123456789312345678941234567895123456789612345678971234567898112345678911234567892123456789112345678911234567892123456789
	more text

test
)�ndiffAssertEqualr�rrrr�r��r6r7r8�sfpr�s     r9�test_split_long_continuationz,TestLongHeaders.test_split_long_continuationfss��
�
"���'�)�����j�j���c�N�N��	�	�	�#����
��3�<�<�>�>��	�	�	�	�	r;c��|j}d}t|d���}||���d��t|�dd����}||���d��dS)Nz�bug demonstration
	12345678911234567892123456789312345678941234567895123456789612345678971234567898112345678911234567892123456789112345678911234567892123456789
	more text�	��continuation_wsr,z�bug demonstration
 12345678911234567892123456789312345678941234567895123456789612345678971234567898112345678911234567892123456789112345678911234567892123456789
 more text)rrr�r��r6r7�hstr�hs    r9�,test_another_long_almost_unsplittable_headerz<TestLongHeaders.test_another_long_almost_unsplittable_headerzs���
�
"����
�4��.�.�.��
��1�8�8�:�:��	�	�	�
�4�<�<��c�*�*�+�+��
��1�8�8�:�:��	�	�	�	�	r;c��|j}td��}td��}td��}d}d}d}t||d���}|�||��|�||��t	��}	||	d<t��}
t
|
��}|�|	��||
���d	��||�	d
���d��dS)
Nr=rrrV�Die Mieter treten hier ein werden mit einem Foerderband komfortabel den Korridor entlang, an s�dl�ndischen Wandgem�lden vorbei, gegen die rotierenden Klingen bef�rdert. �;Finan�ni metropole se hroutily pod tlakem jejich d�vtipu.. ��正確に言うと翻訳はされていません。一部はドイツ語ですが、あとはでたらめです。実際には「Wenn ist das Nunstuck git und Slotermeyer? Ja! Beiherhund das Oder die Flipperwaldt gersput.」と言っています。r���header_namea!Subject: =?iso-8859-1?q?Die_Mieter_treten_hier_ein_werden_mit_einem_Foerderb?=
 =?iso-8859-1?q?and_komfortabel_den_Korridor_entlang=2C_an_s=FCdl=FCndischen?=
 =?iso-8859-1?q?_Wandgem=E4lden_vorbei=2C_gegen_die_rotierenden_Klingen_bef?=
 =?iso-8859-1?q?=F6rdert=2E_?= =?iso-8859-2?q?Finan=E8ni_metropole_se_hrouti?=
 =?iso-8859-2?q?ly_pod_tlakem_jejich_d=F9vtipu=2E=2E_?= =?utf-8?b?5q2j56K6?=
 =?utf-8?b?44Gr6KiA44GG44Go57+76Kiz44Gv44GV44KM44Gm44GE44G+44Gb44KT44CC5LiA?=
 =?utf-8?b?6YOo44Gv44OJ44Kk44OE6Kqe44Gn44GZ44GM44CB44GC44Go44Gv44Gn44Gf44KJ?=
 =?utf-8?b?44KB44Gn44GZ44CC5a6f6Zqb44Gr44Gv44CMV2VubiBpc3QgZGFzIE51bnN0dWNr?=
 =?utf-8?b?IGdpdCB1bmQgU2xvdGVybWV5ZXI/IEphISBCZWloZXJodW5kIGRhcyBPZGVyIGRp?=
 =?utf-8?b?ZSBGbGlwcGVyd2FsZHQgZ2Vyc3B1dC7jgI3jgajoqIDjgaPjgabjgYTjgb7jgZk=?=
 =?utf-8?b?44CC?=

r���
maxlinelena	=?iso-8859-1?q?Die_Mieter_treten_hier_ein_werden_mit_einem_Foerde?=
 =?iso-8859-1?q?rband_komfortabel_den_Korridor_entlang=2C_an_s=FCdl=FCndis?=
 =?iso-8859-1?q?chen_Wandgem=E4lden_vorbei=2C_gegen_die_rotierenden_Klinge?=
 =?iso-8859-1?q?n_bef=F6rdert=2E_?= =?iso-8859-2?q?Finan=E8ni_metropole_se?=
 =?iso-8859-2?q?_hroutily_pod_tlakem_jejich_d=F9vtipu=2E=2E_?=
 =?utf-8?b?5q2j56K644Gr6KiA44GG44Go57+76Kiz44Gv44GV44KM44Gm44GE44G+44Gb?=
 =?utf-8?b?44KT44CC5LiA6YOo44Gv44OJ44Kk44OE6Kqe44Gn44GZ44GM44CB44GC44Go?=
 =?utf-8?b?44Gv44Gn44Gf44KJ44KB44Gn44GZ44CC5a6f6Zqb44Gr44Gv44CMV2VubiBp?=
 =?utf-8?b?c3QgZGFzIE51bnN0dWNrIGdpdCB1bmQgU2xvdGVybWV5ZXI/IEphISBCZWlo?=
 =?utf-8?b?ZXJodW5kIGRhcyBPZGVyIGRpZSBGbGlwcGVyd2FsZHQgZ2Vyc3B1dC7jgI0=?=
 =?utf-8?b?44Go6KiA44Gj44Gm44GE44G+44GZ44CC?=)
rr
r�appendrrrr�r�r�)r6r7r��cz�utf8�g_head�cz_head�	utf8_headrr8rs           r9�test_long_nonstringz#TestLongHeaders.test_long_nonstring�s��
�
"���L�!�!��
�\�
"�
"���w����$��$��0�	�
�6�1�)�4�4�4��	����"����	����D�!�!�!��i�i����I���j�j���c�N�N��	�	�	�#����
��3�<�<�>�>�
�
	�
	�
	�	��1�8�8�r�8�"�"�%1�	2�	2�	2�	2�	2r;c�r�|j}tdd���}||���d��dS)N�iwasnipoop; giraffes="very-long-necked-animals"; spooge="yummy"; hippos="gargantuan"; marshmallows="gooey"�X-Foobar-Spoink-Defrobnitr$�jwasnipoop; giraffes="very-long-necked-animals";
 spooge="yummy"; hippos="gargantuan"; marshmallows="gooey"�rrr��r6r7rs   r9�test_long_header_encodez'TestLongHeaders.test_long_header_encode�sV��
�
"���O�:�
<�
<�
<��	��1�8�8�:�:�>�	?�	?�	?�	?�	?r;c�t�|j}tddd���}||���d��dS)Nr0r1r�r%rr2r3r4s   r9�<test_long_header_encode_with_tab_continuation_is_just_a_hintzLTestLongHeaders.test_long_header_encode_with_tab_continuation_is_just_a_hint�sY��
�
"���O�:�#'�
)�
)�
)��	��1�8�8�:�:�>�	?�	?�	?�	?�	?r;c�t�|j}tddd���}||���d��dS)Nziwasnipoop; giraffes="very-long-necked-animals";	spooge="yummy"; hippos="gargantuan"; marshmallows="gooey"r1rr7zjwasnipoop; giraffes="very-long-necked-animals";
	spooge="yummy"; hippos="gargantuan"; marshmallows="gooey"r3r4s   r9�-test_long_header_encode_with_tab_continuationz=TestLongHeaders.test_long_header_encode_with_tab_continuation�s^��
�
"���O�:�#'�
)�
)�
)��	��1�8�8�:�:�?�	@�	@�	@�	@�	@r;c�v�tdd��}|�|���d��dS)N�文r�=?iso-2022-jp?b?GyRCSjgbKEI=?=�rr2r��r6rs  r9�0test_header_encode_with_different_output_charsetz@TestLongHeaders.test_header_encode_with_different_output_charset�s6���5�(�#�#����������%E�F�F�F�F�Fr;c��td�d��d��}d}|�|���|��dS)Ns6test-ja ����Ƥ��줿�᡼��ϻʲ�Ԥξ�ǧ���ԤäƤ��ޤ�rz�=?iso-2022-jp?b?dGVzdC1qYSAbJEIkWEVqOUYkNSRsJD8lYSE8JWskTztKMnE8VCROPjUbKEI=?=
 =?iso-2022-jp?b?GyRCRyckckJUJEMkRiQkJF4kORsoQg==?=)rrYr2r�)r6r�ress   r9�5test_long_header_encode_with_different_output_charsetzETestLongHeaders.test_long_header_encode_with_different_output_charset�sV���$�%+�F�8�$4�$4�h�
@�
@��7��	
��������S�)�)�)�)�)r;c���|j}td��}d|d<t��}t|��}|�|��||���d��dS)Nr+r0r1z�Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Foobar-Spoink-Defrobnit: wasnipoop; giraffes="very-long-necked-animals";
 spooge="yummy"; hippos="gargantuan"; marshmallows="gooey"

)rrrrr�r�rs     r9�test_header_splitterz$TestLongHeaders.test_header_splitter�sx��
�
"���r�l�l��
H�	�'�(��j�j���c�N�N��	�	�	�#����
��3�<�<�>�>��	�	�	�	�	r;c�l�|j}t��}d|d<t�d�t	d��D����|d<|�d��t
��}t|��}|�|��||�	��d��dS)N�test@dom.ainr�c3� K�|]	}d|zV��
dS)z<%d@dom.ain>Nr{)r�is  r9�	<genexpr>z@TestLongHeaders.test_no_semis_header_splitter.<locals>.<genexpr>s'����&M�&M�a�~��'9�&M�&M�&M�&M�&M�&Mr;�
�
References�Testz�From: test@dom.ain
References: <0@dom.ain> <1@dom.ain> <2@dom.ain> <3@dom.ain> <4@dom.ain>
 <5@dom.ain> <6@dom.ain> <7@dom.ain> <8@dom.ain> <9@dom.ain>

Test)
rr�SPACEr��rangerRrrr�r�rs     r9�test_no_semis_header_splitterz-TestLongHeaders.test_no_semis_header_splitters���
�
"���i�i��$��F��!�J�J�&M�&M�5��9�9�&M�&M�&M�M�M��L����������j�j���c�N�N��	�	�	�#����
��3�<�<�>�>��		�		�		�		�		r;c�n�|j}td��}||���d��dS)Nz�Subject: the first part of this is short, but_the_second_part_does_not_fit_within_maxlinelen_and_thus_should_be_on_a_line_all_by_itselfz�Subject: the first part of this is short,
 but_the_second_part_does_not_fit_within_maxlinelen_and_thus_should_be_on_a_line_all_by_itselfr3r4s   r9�"test_last_split_chunk_does_not_fitz2TestLongHeaders.test_last_split_chunk_does_not_fit�S��
�
"����
�
��	��1�8�8�:�:�b�	c�	c�	c�	c�	cr;c�n�|j}td��}||���d��dS)Nz_, but_the_second_part_does_not_fit_within_maxlinelen_and_thus_should_be_on_a_line_all_by_itselfz`,
 but_the_second_part_does_not_fit_within_maxlinelen_and_thus_should_be_on_a_line_all_by_itselfr3r4s   r9�>test_splittable_leading_char_followed_by_overlong_unsplittablezNTestLongHeaders.test_splittable_leading_char_followed_by_overlong_unsplittablerSr;c�n�|j}td��}||���d��dS)Nza, , but_the_second_part_does_not_fit_within_maxlinelen_and_thus_should_be_on_a_line_all_by_itselfzb, ,
 but_the_second_part_does_not_fit_within_maxlinelen_and_thus_should_be_on_a_line_all_by_itselfr3r4s   r9�Gtest_multiple_splittable_leading_char_followed_by_overlong_unsplittablezWTestLongHeaders.test_multiple_splittable_leading_char_followed_by_overlong_unsplittable"rSr;c�n�|j}td��}||���d��dS)NzTthis_part_does_not_fit_within_maxlinelen_and_thus_should_be_on_a_line_all_by_itself;r3r4s   r9�1test_trailing_splittable_on_overlong_unsplittablezATestLongHeaders.test_trailing_splittable_on_overlong_unsplittable+sK��
�
"���*�
+�
+��
��1�8�8�:�:�*�	+�	+�	+�	+�	+r;c�n�|j}td��}||���d��dS)NzW; this_part_does_not_fit_within_maxlinelen_and_thus_should_be_on_a_line_all_by_itself; zX;
 this_part_does_not_fit_within_maxlinelen_and_thus_should_be_on_a_line_all_by_itself; r3r4s   r9�Itest_trailing_splittable_on_overlong_unsplittable_with_leading_splittablezYTestLongHeaders.test_trailing_splittable_on_overlong_unsplittable_with_leading_splittable2sS��
�
"���+�
,�
,��	��1�8�8�:�:�Z�	[�	[�	[�	[�	[r;c�n�|j}td��}||���d��dS)NzpThis is a long line that has two whitespaces  in a row.  This used to cause truncation of the header when foldedzqThis is a long line that has two whitespaces  in a row.  This used to cause
 truncation of the header when foldedr3r4s   r9�5test_long_header_with_multiple_sequential_split_charszETestLongHeaders.test_long_header_with_multiple_sequential_split_chars;sN��
�
"���F�
G�
G��
��1�8�8�:�:�)�	*�	*�	*�	*�	*r;c�n�|j}td��}||���d��dS)N�Kthisverylongheaderhas;semicolons;and,commas,butthey;arenotlegal;fold,pointsr3r4s   r9�:test_splitter_split_on_punctuation_only_if_fws_with_headerzJTestLongHeaders.test_splitter_split_on_punctuation_only_if_fws_with_headerCsK��
�
"���+�
,�
,��
��1�8�8�:�:�2�	3�	3�	3�	3�	3r;c�n�|j}td��}||���d��dS)Nz�this is a  test where we need to have more than one line before; our final line that is just too big to fit;; this_part_does_not_fit_within_maxlinelen_and_thus_should_be_on_a_line_all_by_itself;z�this is a  test where we need to have more than one line before;
 our final line that is just too big to fit;;
 this_part_does_not_fit_within_maxlinelen_and_thus_should_be_on_a_line_all_by_itself;r3r4s   r9�Dtest_leading_splittable_in_the_middle_just_before_overlong_last_partzTTestLongHeaders.test_leading_splittable_in_the_middle_just_before_overlong_last_partJsS��
�
"���*�
+�
+��	��1�8�8�:�:�Y�	Z�	Z�	Z�	Z�	Zr;c�n�|j}td��}||���d��dS)NzTthis_part_does_not_fit_within_maxlinelen_and_thus_should_be_on_a_line_all_by_itself r3r4s   r9�/test_overlong_last_part_followed_by_split_pointz?TestLongHeaders.test_overlong_last_part_followed_by_split_pointUsK��
�
"���*�
+�
+��
��1�8�8�:�:�=�	>�	>�	>�	>�	>r;c�n�|j}td��}||���d��dS)Nz�this_is_a__test_where_we_need_to_have_more_than_one_line_before_our_final_line_; ; this_part_does_not_fit_within_maxlinelen_and_thus_should_be_on_a_line_all_by_itself; z�this_is_a__test_where_we_need_to_have_more_than_one_line_before_our_final_line_;
 ;
 this_part_does_not_fit_within_maxlinelen_and_thus_should_be_on_a_line_all_by_itself; r3r4s   r9�@test_multiline_with_overlong_parts_separated_by_two_split_pointszPTestLongHeaders.test_multiline_with_overlong_parts_separated_by_two_split_points\�S��
�
"���+�
,�
,��	��1�8�8�:�:�Z�	[�	[�	[�	[�	[r;c�n�|j}td��}||���d��dS)Nz�this is a test where we need to have more than one line before our final line; ; this_part_does_not_fit_within_maxlinelen_and_thus_should_be_on_a_line_all_by_itself; z�this is a test where we need to have more than one line before our final line;
 ;
 this_part_does_not_fit_within_maxlinelen_and_thus_should_be_on_a_line_all_by_itself; r3r4s   r9�>test_multiline_with_overlong_last_part_followed_by_split_pointzNTestLongHeaders.test_multiline_with_overlong_last_part_followed_by_split_pointgrgr;c�F�|j}t��}d|d<t�dgdz��|d<|�d��t��}t
|��}|�|��||���d��dS)NrGr�z<foo@dom.ain>  rKrLrMz�From: test@dom.ain
References: <foo@dom.ain>   <foo@dom.ain>   <foo@dom.ain>   <foo@dom.ain>
   <foo@dom.ain>   <foo@dom.ain>   <foo@dom.ain>   <foo@dom.ain>
   <foo@dom.ain>   <foo@dom.ain>  

Test�	rrrNr�rRrrr�r�rs     r9�%test_long_header_with_whitespace_runsz5TestLongHeaders.test_long_header_with_whitespace_runsrs���
�
"���i�i��$��F��!�J�J�(9�':�R�'?�@�@��L����������j�j���c�N�N��	�	�	�#����
��3�<�<�>�>��		�		�		�		�		r;c�L�|j}t��}d|d<t�dgdz��dz|d<|�d��t��}t
|��}|�|��||���d��dS)	NrGr�z
<foo@dom.ain>rKz; abcrLrMz�From: test@dom.ain
References: <foo@dom.ain> <foo@dom.ain> <foo@dom.ain> <foo@dom.ain>
 <foo@dom.ain> <foo@dom.ain> <foo@dom.ain> <foo@dom.ain> <foo@dom.ain>
 <foo@dom.ain>; abc

Testrkrs     r9�'test_long_run_with_semi_header_splitterz7TestLongHeaders.test_long_run_with_semi_header_splitter�s���
�
"���i�i��$��F��!�J�J��'8�2�'=�>�>��H��L����������j�j���c�N�N��	�	�	�#����
��3�<�<�>�>��		�		�		�		�		r;c��|j}t��}d|d<d|d<|�d��t��}t	|��}|�|��||���d��dS)NrGr�r_rLrMzrFrom: test@dom.ain
References: 
 thisverylongheaderhas;semicolons;and,commas,butthey;arenotlegal;fold,points

Test)rrrRrrr�r�rs     r9�.test_splitter_split_on_punctuation_only_if_fwsz>TestLongHeaders.test_splitter_split_on_punctuation_only_if_fws�s���
�
"���i�i��$��F��+��L����������j�j���c�N�N��	�	�	�#����
��3�<�<�>�>��		�		�		�		�		r;c���|j}d}t|��}||���d��td��}||���d��dS)Nz\References: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxz]References:
 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx�Pxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxr3rs    r9�test_no_split_long_headerz)TestLongHeaders.test_no_split_long_header�ss��
�
"��(���4�L�L��	��1�8�8�:�:�U�	V�	V�	V�
�8����
��1�8�8�:�:�i�j�j�j�j�jr;c�v�|j}d}t|d���}||���d��dS)NaWfrom babylon.socal-raves.org (localhost [127.0.0.1]); by babylon.socal-raves.org (Postfix) with ESMTP id B570E51B81; for <mailman-admin@babylon.socal-raves.org>; Sat, 2 Feb 2002 17:00:06 -0800 (PST)
	from babylon.socal-raves.org (localhost [127.0.0.1]); by babylon.socal-raves.org (Postfix) with ESMTP id B570E51B81; for <mailman-admin@babylon.socal-raves.org>; Sat, 2 Feb 2002 17:00:06 -0800 (PST)
	from babylon.socal-raves.org (localhost [127.0.0.1]); by babylon.socal-raves.org (Postfix) with ESMTP id B570E51B81; for <mailman-admin@babylon.socal-raves.org>; Sat, 2 Feb 2002 17:00:06 -0800 (PST)
rra_from babylon.socal-raves.org (localhost [127.0.0.1]);
 by babylon.socal-raves.org (Postfix) with ESMTP id B570E51B81;
 for <mailman-admin@babylon.socal-raves.org>;
 Sat, 2 Feb 2002 17:00:06 -0800 (PST)
	from babylon.socal-raves.org (localhost [127.0.0.1]);
 by babylon.socal-raves.org (Postfix) with ESMTP id B570E51B81;
 for <mailman-admin@babylon.socal-raves.org>;
 Sat, 2 Feb 2002 17:00:06 -0800 (PST)
	from babylon.socal-raves.org (localhost [127.0.0.1]);
 by babylon.socal-raves.org (Postfix) with ESMTP id B570E51B81;
 for <mailman-admin@babylon.socal-raves.org>;
 Sat, 2 Feb 2002 17:00:06 -0800 (PST)r3rs    r9�"test_splitting_multiple_long_linesz2TestLongHeaders.test_splitting_multiple_long_lines�sR��
�
"����

�4��.�.�.��
��1�8�8�:�:�)�	*�	*�	*�	*�	*r;c�z�|j}d}t|ddd���}||���d��dS)Nz�from modemcable093.139-201-24.que.mc.videotron.ca ([24.201.139.93] helo=cthulhu.gerg.ca)
	by kronos.mems-exchange.org with esmtp (Exim 4.05)
	id 17k4h5-00034i-00
	for test@mems-exchange.org; Wed, 28 Aug 2002 11:25:20 -0400�N�Receivedr)r'r%rz�from modemcable093.139-201-24.que.mc.videotron.ca ([24.201.139.93]
 helo=cthulhu.gerg.ca)
	by kronos.mems-exchange.org with esmtp (Exim 4.05)
	id 17k4h5-00034i-00
	for test@mems-exchange.org; Wed, 28 Aug 2002 11:25:20 -0400r3rs    r9�&test_splitting_first_line_only_is_longz6TestLongHeaders.test_splitting_first_line_only_is_long�sd��
�
"��A��

�4�B�J�#'�
)�
)�
)��
��1�8�8�:�:�A�	B�	B�	B�	B�	Br;c�H�|j}t��}tddd���}|�d��||�d���d��||d<||�d�	��d
��||�d�	��d��dS)
NzBritische Regierung gibtr=r�r$u-grünes Licht für Offshore-Windkraftprojekter�r&zl=?iso-8859-1?q?Britische_Regierung_gibt_gr=FCnes_Licht_f=FCr_Offs?=
 =?iso-8859-1?q?hore-Windkraftprojekte?=��maxheaderlenzwSubject: =?iso-8859-1?q?Britische_Regierung_gibt_gr=FCnes_Licht_f=FCr_Offs?=
 =?iso-8859-1?q?hore-Windkraftprojekte?=

rzdSubject: =?iso-8859-1?q?Britische_Regierung_gibt_gr=FCnes_Licht_f=FCr_Offshore-Windkraftprojekte?=

)rrrr(r�r�)r6r7r8rs    r9�test_long_8bit_headerz%TestLongHeaders.test_long_8bit_header�s���
�
"���i�i���-�|� )�
+�
+�
+��	���D�E�E�E�
��1�8�8�r�8�"�"�%,�	-�	-�	-���I��
��3�=�=�b�=�)�)�,�	�	�	�
	��3�=�=�a�=�(�(�+�	�	�	�	�	r;c��|j}t��}d}||d<||�d���d��t��}t|d���|d<||�d���d��dS)NuhBritische Regierung gibt grünes Licht für Offshore-Windkraftprojekte <a-very-long-address@example.com>zReply-Torwr{z�Reply-To: =?utf-8?q?Britische_Regierung_gibt_gr=C3=BCnes_Licht_f=C3=BCr_Offs?=
 =?utf-8?q?hore-Windkraftprojekte_=3Ca-very-long-address=40example=2Ecom=3E?=

r$)rrr�r)r6r7r8�
header_strings    r9� test_long_8bit_header_no_charsetz0TestLongHeaders.test_long_8bit_header_no_charset�s���
�
"���i�i��=�
�(��J��
��3�=�=�b�=�)�)�,�	�	�	�
�i�i�� ��-7�9�9�9��J��
��3�=�=�b�=�)�)�,�	�	�	�	�	r;c�~�|j}d}t��}||d<||�d���d��dS)Nz�"Someone Test #A" <someone@eecs.umich.edu>,<someone@eecs.umich.edu>, "Someone Test #B" <someone@umich.edu>, "Someone Test #C" <someone@eecs.umich.edu>, "Someone Test #D" <someone@eecs.umich.edu>r�rwr{z�To: "Someone Test #A" <someone@eecs.umich.edu>,<someone@eecs.umich.edu>,
 "Someone Test #B" <someone@umich.edu>,
 "Someone Test #C" <someone@eecs.umich.edu>,
 "Someone Test #D" <someone@eecs.umich.edu>

)rrr�)r6r7r�r8s    r9�test_long_to_headerz#TestLongHeaders.test_long_to_headersX��
�
"��;��
�i�i����D�	�
��3�=�=�b�=�)�)�,�	�	�	�	�	r;c��|j}d}t|��}|�d��||�d���d��dS)NzIThis is an example of string which has almost the limit of header length.zAdd another line.r�r&z\This is an example of string which has almost the limit of header length.
 Add another line.�rrr(r��r6r7r�rs    r9�test_long_line_after_appendz+TestLongHeaders.test_long_line_after_appends`��
�
"��W���1�I�I��	���$�%�%�%�
��1�8�8�r�8�"�"�%�	�	�	�	�	r;c��|j}d}t|��}|�d��||���d��dS)NzThis is a shorter line.z!Add another sentence. (Surprise?)z9This is a shorter line. Add another sentence. (Surprise?)r�r�s    r9�test_shorter_line_with_appendz-TestLongHeaders.test_shorter_line_with_appends]��
�
"��%���1�I�I��	���4�5�5�5�
��1�8�8�:�:�F�	H�	H�	H�	H�	Hr;c��|j}d}d}t|d|���}||�d���d��dS)Nz!X-Very-Very-Very-Long-Header-Nameu�Die Mieter treten hier ein werden mit einem Foerderband komfortabel den Korridor entlang, an südlündischen Wandgemälden vorbei, gegen die rotierenden Klingen befördert. r=r$r�r&a=?iso-8859-1?q?Die_Mieter_treten_hier_e?=
 =?iso-8859-1?q?in_werden_mit_einem_Foerderband_komfortabel_den_Korridor_e?=
 =?iso-8859-1?q?ntlang=2C_an_s=FCdl=FCndischen_Wandgem=E4lden_vorbei=2C_ge?=
 =?iso-8859-1?q?gen_die_rotierenden_Klingen_bef=F6rdert=2E_?=r3)r6r7�fn�gsrs     r9�test_long_field_namez$TestLongHeaders.test_long_field_name#se��
�
"��
0����
�2�|��4�4�4��
��1�8�8�r�8�"�"�%A�	B�	B�	B�	B�	Br;c��d}t��}t|d���|d<||d<|�|�d���d��dS)	Nz�from FOO.TLD (vizworld.acl.foo.tld [123.452.678.9]) by hrothgar.la.mastaler.com (tmda-ofmipd) with ESMTP; Wed, 05 Mar 2003 18:10:18 -0700rr�
Received-1�
Received-2rwr{a1Received-1: from FOO.TLD (vizworld.acl.foo.tld [123.452.678.9]) by
 hrothgar.la.mastaler.com (tmda-ofmipd) with ESMTP;
 Wed, 05 Mar 2003 18:10:18 -0700
Received-2: from FOO.TLD (vizworld.acl.foo.tld [123.452.678.9]) by
 hrothgar.la.mastaler.com (tmda-ofmipd) with ESMTP;
 Wed, 05 Mar 2003 18:10:18 -0700

�rrrr��r6rr8s   r9�test_long_received_headerz)TestLongHeaders.test_long_received_header2sl��/���i�i��"�1�d�;�;�;��L����L�����c�m�m��m�<�<�?�	�	�	�	�	r;c��d}t��}t|dd���|d<||d<|�|�d���d��dS)	Nz�<15975.17901.207240.414604@sgigritzmann1.mathematik.tu-muenchen.de> (David Bremner's message of "Thu, 6 Mar 2003 13:58:21 +0100")r�rr7r�rwr{a#Received-1: 
 <15975.17901.207240.414604@sgigritzmann1.mathematik.tu-muenchen.de> (David
 Bremner's message of "Thu, 6 Mar 2003 13:58:21 +0100")
Received-2: 
 <15975.17901.207240.414604@sgigritzmann1.mathematik.tu-muenchen.de> (David
 Bremner's message of "Thu, 6 Mar 2003 13:58:21 +0100")

r�r�s   r9�test_string_headerinst_eqz)TestLongHeaders.test_string_headerinst_eqDsu��1���i�i��"�1�,�37�9�9�9��L����L�����c�m�m��m�<�<�?�	�	�	�	�	r;c��|j}t��}d}||d<t|d���|d<d|z|d<||�d���d	��dS)
Nz�iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAGFBMVEUAAAAkHiJeRUIcGBi9
 locQDQ4zJykFBAXJfWDjAAACYUlEQVR4nF2TQY/jIAyFc6lydlG5x8Nyp1Y69wj1PN2I5gzpzFace-1zFace-2r$r,zFace-3rwr{a�Face-1: 
 iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAGFBMVEUAAAAkHiJeRUIcGBi9
 locQDQ4zJykFBAXJfWDjAAACYUlEQVR4nF2TQY/jIAyFc6lydlG5x8Nyp1Y69wj1PN2I5gzp
Face-2: 
 iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAGFBMVEUAAAAkHiJeRUIcGBi9
 locQDQ4zJykFBAXJfWDjAAACYUlEQVR4nF2TQY/jIAyFc6lydlG5x8Nyp1Y69wj1PN2I5gzp
Face-3: 
 iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAGFBMVEUAAAAkHiJeRUIcGBi9
 locQDQ4zJykFBAXJfWDjAAACYUlEQVR4nF2TQY/jIAyFc6lydlG5x8Nyp1Y69wj1PN2I5gzp

�rrrr�)r6r7r8�ts    r9�-test_long_unbreakable_lines_with_continuationz=TestLongHeaders.test_long_unbreakable_lines_with_continuationWs~��
�
"���i�i��
M����H�
��q�h�7�7�7��H�
��a���H�
�	��3�=�=�b�=�)�)�,�	�	�	�	�	r;c��|j}d}tj|��}||�d���d��dS)Nz�Received: from siimage.com ([172.25.1.3]) by zima.siliconimage.com with Microsoft SMTPSVC(5.0.2195.4905); Wed, 16 Oct 2002 07:41:11 -0700rwr{z�Received: from siimage.com ([172.25.1.3]) by zima.siliconimage.com with
 Microsoft SMTPSVC(5.0.2195.4905); Wed, 16 Oct 2002 07:41:11 -0700

)rr�rr��r6r7r�r8s    r9�"test_another_long_multiline_headerz2TestLongHeaders.test_another_long_multiline_headerosV��
�
"��/���'��*�*��
��3�=�=�b�=�)�)�,�	�	�	�	�	r;c��|j}d}t��}||d<t|d���|d<||�d���d��dS)Nz�List-Unsubscribe: <http://lists.sourceforge.net/lists/listinfo/spamassassin-talk>,        <mailto:spamassassin-talk-request@lists.sourceforge.net?subject=unsubscribe>�Listr$rwr{a_List: List-Unsubscribe:
 <http://lists.sourceforge.net/lists/listinfo/spamassassin-talk>,
        <mailto:spamassassin-talk-request@lists.sourceforge.net?subject=unsubscribe>
List: List-Unsubscribe:
 <http://lists.sourceforge.net/lists/listinfo/spamassassin-talk>,
        <mailto:spamassassin-talk-request@lists.sourceforge.net?subject=unsubscribe>

r�)r6r7rr8s    r9�%test_long_lines_with_different_headerz5TestLongHeaders.test_long_lines_with_different_header|sn��
�
"��%���i�i����F���Q�F�3�3�3��F��
��3�=�=�b�=�)�)�,�	�	�	�	�	r;c���ttjd��dd���}|�|���dztjd��dz��dS)Nz�            We're going to pretend this header is in a non-ascii character set
            	to see if line wrapping with encoded words and embedded
               folding white space worksrVrM)rAr%r*z�            =?utf-8?q?We=27re_going_to_pretend_this_header_is_in_a_non-ascii_chara?=
             =?utf-8?q?cter_set?=
             =?utf-8?q?_to_see_if_line_wrapping_with_encoded_words_and_embedded?=
             =?utf-8?q?_folding_white_space_works?=)rr�r�r2r�r?s  r9�*test_long_rfc2047_header_with_embedded_fwsz:TestLongHeaders.test_long_rfc2047_header_with_embedded_fws�s����8�?�$,�-�-�#�%�
'�
'�
'��	
��������D��(�/�;7�+8�+8�9=�	+=�	>�	>�	>�	>�	>r;)+r�r�r��maxDiffrrr.r5r8r:r@rCrErPrRrUrWrYr[r]r`rbrdrfrirlrnrprsruryr}r�r�r�r�r�r�r�r�r�r�r�r{r;r9rrbs��������G����(���"42�42�42�l?�?�?�?�?�?�@�@�@�G�G�G�*�*�*����(	�	�	� c�c�c�c�c�c�c�c�c�+�+�+�[�[�[�*�*�*�3�3�3�	Z�	Z�	Z�>�>�>�	[�	[�	[�	[�	[�	[�	�	�	�"	�	�	�"	�	�	�$
k�
k�
k�*�*�*�,B�B�B� ���(���*���"���H�H�H�
B�
B�
B����$���&���0������&>�>�>�>�>r;rc�2�eZdZd�Zd�Zd�Zd�Zd�Zd�ZdS)�TestFromManglingc�t�t��|_d|jd<|j�d��dS)Nzaaa@bbb.orgr�z(From the desk of A.A.A.:
Blah blah blah
)rr8rR�r6s r9�setUpzTestFromMangling.setUp�sB���9�9���(����������	�	�	�	�	r;c���t��}t|d���}|�|j��|�|���d��dS)NT��mangle_from_z<From: aaa@bbb.org

>From the desk of A.A.A.:
Blah blah blah
�rrr�r8r2r��r6r�r�s   r9�test_mangled_fromz"TestFromMangling.test_mangled_from�sb���J�J���a�d�+�+�+��	�	�	�$�(������������(�	�	�	�	�	r;c���t��}t|d���}|�|j��|�|���d��dS)NFr�z;From: aaa@bbb.org

From the desk of A.A.A.:
Blah blah blah
r�r�s   r9�test_dont_mangle_fromz&TestFromMangling.test_dont_mangle_from�sb���J�J���a�e�,�,�,��	�	�	�$�(������������(�	�	�	�	�	r;c�^�t��}t|d���}tjt	jd����}|�|��|�td�|�	���
d��D����d��dS)NTr�a)            From: foo@bar.com
            Mime-Version: 1.0
            Content-Type: multipart/mixed; boundary=XXX

            From somewhere unknown

            --XXX
            Content-Type: text/plain

            foo

            --XXX--

            From somewhere unknowable
            c�<�g|]}|�d���d��S)z>From r�)r�r�s  r9r�zLTestFromMangling.test_mangle_from_in_preamble_and_epilog.<locals>.<listcomp>�s8��=�=�=�A�%&�\�\�(�%;�%;�=�a�=�=�=r;r*r�)rrr�rr�r�r�r2r�r�r�)r6r�r�r8s    r9�'test_mangle_from_in_preamble_and_epilogz8TestFromMangling.test_mangle_from_in_preamble_and_epilog�s����J�J���a�d�+�+�+���'���9�)�)���� 	
�	�	�#��������=�=������);�);�D�)A�)A�=�=�=�>�>�?@�	B�	B�	B�	B�	Br;c�@�tjd���d��}tj|dz��}t��}t
|d���}|�|��|�|�	��|dz��dS)Nz�            Content-Type: text/plain; charset="utf-8"
            MIME-Version: 1.0
            Content-Transfer-Encoding: 8bit
            From: aaa@bbb.org

        rVsFrom Rölli
Tr�s
>From Rölli
)
r�r�r�r�r�rr
r�r2r�)r6r�r8�br�s     r9� test_mangled_from_with_bad_bytesz1TestFromMangling.test_mangled_from_with_bad_bytes�s�����"�
�
��V�G�_�_�
	��&�v�0F�'F�G�G���I�I���1�4�0�0�0��	�	�	�#������������v�0G�'G�H�H�H�H�Hr;c�|�tjd���d��}tj|��}dS)Nu�            From: aperson@example.com
            Content-Type: multipart/mixed; boundary="1"
            Content-Transfer-Encoding: È
        rV)r�r�r�r�r�)r6r�r8s   r9�$test_multipart_with_bad_bytes_in_ctez5TestFromMangling.test_multipart_with_bad_bytes_in_cte�s>����"�
�
��V�G�_�_�		�
�&�v�.�.���r;N)	r�r�r�r�r�r�r�r�r�r{r;r9r�r��st���������	�	�	�	�	�	�B�B�B�.I�I�I�/�/�/�/�/r;r�c�,�eZdZd�Zd�Zd�Zd�Zd�ZdS)�
TestMIMEAudioc��td|��d��5}|���|_ddd��n#1swxYwYt|j��|_dS)Nzsndhdr.r�)r&r��
_audiodatar�_au�r6�extr�s   r9�_make_audiozTestMIMEAudio._make_audio�s���
�o��o�o�t�
,�
,�	(�� �g�g�i�i�D�O�	(�	(�	(�	(�	(�	(�	(�	(�	(�	(�	(����	(�	(�	(�	(��T�_�-�-�����
�:�>�>c���ddddd����D]P\}}|�|��|�|n|}|�|j���d|�����QdS)Nzx-aiffzx-wav�basic)�aifc�aiff�wav�auzaudio/)r�r�r2r�rH�r6r��subtypes   r9�test_guess_minor_typez#TestMIMEAudio.test_guess_minor_type�s�������	
�
�
�%�'�'�	N�	N�L�C��
���S�!�!�!�$�9�c�c�'�G����T�X�6�6�8�8�:L�7�:L�:L�M�M�M�M�	N�	Nr;c���|�d��|j���}|�t	jt
|d����|j��dS)Nr�r�)r�r�rZr2rW�decodebytesr�r��r6�payloads  r9�
test_encodingzTestMIMEAudio.test_encoding�sg����������(�&�&�(�(������+�E�'�7�,C�,C�D�D���	*�	*�	*�	*�	*r;c��|�d��t|jd��}|�|���d��dS)Nr��fishz
audio/fish)r�rr�r2rH)r6r�s  r9�test_checkSetMinorz TestMIMEAudio.test_checkSetMinorsO���������
�t���
/�
/������,�,�.�.��=�=�=�=�=r;c��|�d��|j}|j�ddd���||jdd��||j�d���d	d
g��||j�dd���d��g}||j�dd���d��|�|j�d
|d���|��|�|j�d|��|��|�|j�d|d���|��dS)Nr�rGrH�	sndhdr.aurJrLz attachment; filename="sndhdr.au"r�rHr+)rKr�rKr+r���failobjr�rT)r�r2r�rNrrI�assertIs�r6r7�missings   r9�test_add_headerzTestMIMEAudio.test_add_header
s����������
�
������1�<�%0�	�	2�	2�	2�
��4�8�)�*�-�	/�	/�	/�
��4�8���&;��<�<�� 9�:�	<�	<�	<�
��4�8���j�1F��G�G��	�	�	���
��4�8���l�3H��I�I�2�N�N�N��
�
�d�h�(�(��7�(�)�*�*�+2�	4�	4�	4�	
�
�
�d�h�(�(��7�;�;�W�E�E�E��
�
�d�h�(�(��w�08�)�:�:�;B�	D�	D�	D�	D�	Dr;N)r�r�r�r�r�r�r�r�r{r;r9r�r��sg������.�.�.�
	N�	N�	N�*�*�*�>�>�>�
D�D�D�D�Dr;r�c�,�eZdZd�Zd�Zd�Zd�Zd�ZdS)�
TestMIMEImagec��td|��d��5}|���|_ddd��n#1swxYwYt|j��|_dS)Nzpython.r�)r&r��_imgdatar�_imr�s   r9�_make_imagezTestMIMEImage._make_image#s���
�o��o�o�t�
,�
,�	&���G�G�I�I�D�M�	&�	&�	&�	&�	&�	&�	&�	&�	&�	&�	&����	&�	&�	&�	&��T�]�+�+����r�c���dddddddddddddd�
���D]P\}}|�|��|�|n|}|�|j���d|�����QdS)N�jpeg�rast�rgb)
�bmp�exr�gif�jpg�pbm�pgm�png�ppm�ras�sgi�tiff�webp�xbmzimage/)r�r�r2r�rHr�s   r9r�z#TestMIMEImage.test_guess_minor_type(s����������������
�
��%�'�'�	N�	N�L�C��
���S�!�!�!�$�9�c�c�'�G����T�X�6�6�8�8�:L�7�:L�:L�M�M�M�M�#	N�	Nr;c���|�d��|j���}|�t	jt
|d����|j��dS)Nr�r�)r�r�rZr2rWr�r�r�r�s  r9r�zTestMIMEImage.test_encoding<sg����������(�&�&�(�(������+�E�'�7�,C�,C�D�D���	(�	(�	(�	(�	(r;c��|�d��t|jd��}|�|���d��dS)Nr�r�z
image/fish)r�rr�r2rH)r6�ims  r9r�z TestMIMEImage.test_checkSetMinorBsO���������
�t�}�f�
-�
-������,�,�.�.��=�=�=�=�=r;c��|�d��|j}|j�ddd���||jdd��||j�d���d	d
g��||j�dd���d��g}||j�dd���d��|�|j�d
|d���|��|�|j�d|��|��|�|j�d|d���|��dS)Nr�rGrHr�rJrLz%attachment; filename="dingusfish.gif"rr�)rKr�rKr+r�r�rT)r�r2r�rNrrIr�r�s   r9r�zTestMIMEImage.test_add_headerGs����������
�
������1�<�%5�	�	7�	7�	7�
��4�8�)�*�2�	4�	4�	4�
��4�8���&;��<�<�� >�?�	A�	A�	A�
��4�8���j�1F��G�G��	�	�	���
��4�8���l�3H��I�I�2�N�N�N��
�
�d�h�(�(���0E�)�G�G�HO�	Q�	Q�	Q�	
�
�
�d�h�(�(��7�;�;�W�E�E�E��
�
�d�h�(�(��w�08�)�:�:�;B�	D�	D�	D�	D�	Dr;N)r�r�r�r�r�r�r�r�r{r;r9r�r�"sg������,�,�,�
N�N�N�((�(�(�>�>�>�
D�D�D�D�Dr;r�c�8�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	dS)	�TestMIMEApplicationc��|j}td��}||���d��||dd��dS)N�������r\rBrW)r2rrHr5s   r9�test_headersz TestMIMEApplication.test_headers^sU��
�
���9�:�:��
��3���!�!�#=�>�>�>�
��3�*�+�X�6�6�6�6�6r;c���|j}d}t|��}||������d��||�d���|��dS)Nr�z+vv8/f7/TrX)r2rrZ�strip)r6r7�	bytesdatar8s    r9�	test_bodyzTestMIMEApplication.test_bodydsj��
�
��/�	��i�(�(��
��3�?�?���"�"�$�$�j�1�1�1�
��3�?�?�$�?�'�'��3�3�3�3�3r;c���d}t|tj���}|�|���dt|��z��|�|�d���|��|�|dd��t
��}t|��}|�|��|�	��}tj|��}|�|���dt|��z��|�|�d���|��|�|dd��dS)Nr���_encoder��TrXrEr`)rr�encode_7or8bitr2rZr�rr
r�r�r�r��r6r�r8r�r��wireform�msg2s       r9�$test_binary_body_with_encode_7or8bitz8TestMIMEApplication.test_binary_body_with_encode_7or8bitls=��/�	��i�(�2I�J�J�J��������*�*�H�s�9�~�~�,E�F�F�F���������5�5�y�A�A�A�����8�9�6�B�B�B��I�I���1����	�	�	�#�����:�:�<�<���'��1�1��������*�*�H�s�9�~�~�,E�F�F�F�����)�)��)�6�6�	�B�B�B�����9�:�F�C�C�C�C�Cr;c�|�d}t|tj���}|�|���dt|��z��|�|�d���|��t
��}t|��}|�|��|�	��}tj|��}|�|���dt|��z��|�|�d���|��dS)Nr�r�rTrX)rr�encode_noopr2rZr�rr
r�r�r�r�rs       r9�!test_binary_body_with_encode_noopz5TestMIMEApplication.test_binary_body_with_encode_noop}s��0�	��i�(�2F�G�G�G��������*�*�H�s�9�~�~�,E�F�F�F���������5�5�y�A�A�A��I�I���1����	�	�	�#�����:�:�<�<���'��1�1��������*�*�H�s�9�~�~�,E�F�F�F�����)�)��)�6�6�	�B�B�B�B�Br;c��d}t|tj���}|�|�d���|��t��}t
|��}|�|��|���}tj
|��}|�|�d���|��dS)Ns������r�TrX)rrrr2rZrr
r�r�r�r�rs       r9�0test_binary_body_with_unicode_linend_encode_noopzDTestMIMEApplication.test_binary_body_with_unicode_linend_encode_noop�s���3�	��i�(�2F�G�G�G����������5�5�y�A�A�A��I�I���1����	�	�	�#�����:�:�<�<���'��1�1������)�)��)�6�6�	�B�B�B�B�Br;c��d}t|tj���}|�|���d��|�|�d���|��|�|dd��t��}t
|��}|�|��|���}tj
|��}|�|���d��|�|�d���|��|�|dd��dS)Ns������ r�z=FA=FB=FC=FD=FE=FF=20TrXrErC)rr�
encode_quoprir2rZrr
r�r�r�r�rs       r9�#test_binary_body_with_encode_quopriz7TestMIMEApplication.test_binary_body_with_encode_quopri�s+��0�	��i�(�2H�I�I�I��������*�*�,C�D�D�D���������5�5�y�A�A�A�����8�9�;M�N�N�N��I�I���1����	�	�	�#�����:�:�<�<���'��1�1��������*�*�,C�D�D�D�����)�)��)�6�6�	�B�B�B�����9�:�<N�O�O�O�O�Or;c�<�d}t|tj���}|�|���d��|�|�d���|��t��}t
|��}|�|��|���}tj
|��}|�|���d��|�|�d���|��dS)Nr�r�z	+vv8/f7/
TrX)rr�
encode_base64r2rZrr
r�r�r�r�rs       r9�#test_binary_body_with_encode_base64z7TestMIMEApplication.test_binary_body_with_encode_base64�s���/�	��i�(�2H�I�I�I��������*�*�L�9�9�9���������5�5�y�A�A�A��I�I���1����	�	�	�#�����:�:�<�<���'��1�1��������*�*�L�9�9�9�����)�)��)�6�6�	�B�B�B�B�Br;N)
r�r�r�r�r�rr	rrrr{r;r9r�r�]s�������7�7�7�4�4�4�D�D�D�"C�C�C�"
C�
C�
C�P�P�P� C�C�C�C�Cr;r�c�j�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	e
jd��d	���Zd
S)�TestMIMETextc�.�td��|_dS�N�hello there)r�_msgr�s r9r�zTestMIMEText.setUp�s���]�+�+��	�	�	r;c�f�|j}||j���d��||j�d��d��g}|�|j�d|��|��|�|j�d|d���|��dS)Nr?rArNrTr)r2rrHrIr�r�s   r9�
test_typeszTestMIMEText.test_types�s���
�
��
��4�9�%�%�'�'��6�6�6�
��4�9���y�)�)�:�6�6�6����
�
�d�i�)�)�(�G�<�<�g�F�F�F��
�
�d�i�)�)�)�W�X�)�N�N��	�	�	�	�	r;c��|�|j���d��|�|j�����dSr)r2rrZ�assertFalse�is_multipartr�s r9�test_payloadzTestMIMEText.test_payload�sN�������.�.�0�0�-�@�@�@������/�/�1�1�2�2�2�2�2r;c��|j}tdd���}||���jd��||dd��t	d��}d|_td|���}||���jd��||dd��||���d��dS)NrrNrr@rOrVr�)r2rrFrJr
rarZrKs    r9�test_charsetzTestMIMEText.test_charset�s���
�
���}�z�:�:�:��
��3�?�?���*�J�7�7�7�
��3�~�� @�A�A�A��'�"�"�� $����}�w�7�7�7��
��3�?�?���*�G�4�4�4�
��3�~�� =�>�>�>�
��3�?�?���m�,�,�,�,�,r;c��|j}tdd���}||���jd��||dd��dS)NrrNrr@rO)r2rrFrJr5s   r9�test_7bit_inputzTestMIMEText.test_7bit_input�sY��
�
���}�z�:�:�:��
��3�?�?���*�J�7�7�7�
��3�~�� @�A�A�A�A�Ar;c���|j}td��}||���d��||dd��|�d|�����dS)NrrNr@rO)r2rrFr�r�r5s   r9�test_7bit_input_no_charsetz'TestMIMEText.test_7bit_input_no_charset�sm��
�
���}�%�%��
��3�?�?���j�)�)�)�
��3�~�� @�A�A�A��
�
�m�S�]�]�_�_�5�5�5�5�5r;c�
�d}|j}t|d���}||���jd��||dd��||�d���|�d����dS)N�кирилицаrVrr@r�TrX)r2rrF�output_charsetrZr�)r6�teststrr7r8s    r9�test_utf8_inputzTestMIMEText.test_utf8_input�s���D��
�
���w��1�1�1��
��3�?�?���+�W�5�5�5�
��3�~�� =�>�>�>�
��3�?�?�$�?�'�'�����)@�)@�A�A�A�A�Ar;zBcan't fix because of backward compat in email5, will fix in email6c�L�d}|�tt|��dS)Nr%)r��UnicodeEncodeErrorr)r6r's  r9�test_utf8_input_no_charsetz'TestMIMEText.test_utf8_input_no_charset�s)��E�����,�h��@�@�@�@�@r;N)
r�r�r�r�rrrr!r#r(�unittest�skipr+r{r;r9rr�s�������,�,�,����3�3�3�-�-�-�B�B�B�6�6�6�B�B�B��X�]����A�A���A�A�Ar;rc��eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�ZdS)�
TestMultipartc��tdd��5}|���}ddd��n#1swxYwYtddd���}t|d���}|�d	d
d���td��}|�|��|�|��d
|d<d|d<d|d<d}tj|��}|ddkr
tj	}ntj
}|dkrd}	nd}	d|	|dzfz}
tjdtj|����|
z|d<||_||_
||_dS)Nr�r��	multipart�mixedr��rr�)r&rLrHrJz$Hi there,

This is the dingus fish.
zBarry <barry@digicool.com>r�z)Dingus Lovers <cravindogs@cravindogs.com>r�zHere is your dingus fishr�g�4F�cp�A���r�-�+z %s%04d�$z%a, %d %b %Y %H:%M:%S�Date)r&r�rrrNrrn�time�	localtime�timezone�altzone�strftimerr��_txt)r6r�r\�	containerr��intro�now�	timetuple�tzsecs�sign�tzoffsets           r9r�zTestMultipart.setUp�s���
�l�D�
)�
)�	�R��7�7�9�9�D�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	��[�'�J�G�G�G�	��$�%5�6�6�6��
���.��"2�	�	4�	4�	4������
	��������������8�	�&��E�	�$��9�	�)�� ���N�3�'�'�	��R�=�A��	"��]�F�F��\�F��A�:�	��D�D��D���f�r�k�2�2�� �M�#��N�3���!�!�#+�,�	�&����	������	�	�	rc���|j}|j}|j}|�|�����||���d��|t
|�����d��|t|jd��|�d��}|�d��}|�	||j
��|�	||j��||���||g��|�|�����|�|�����dS)Nrkr�rr�)
r2r�rr�rrHr�rZ�
IndexErrorr�r>r�r)r6r7�raisesr��m0�m1s      r9�test_hierarchyzTestMultipart.test_hierarchys:��
�
���"���I��������(�(�)�)�)�
��1�����!2�3�3�3�
��3�q�}�}������#�#�#���z�1�=�!�,�,�,�
�]�]�1�
�
��
�]�]�1�
�
���
�
�b�$�)�$�$�$��
�
�b�$�(�#�#�#�
��1�=�=�?�?�R��H�%�%�%�������*�*�+�+�+�������*�*�+�+�+�+�+r;c��d}t���|��}|�||�����dS)Nz�Content-Type: multipart/mixed; boundary="BOUNDARY"
MIME-Version: 1.0
Subject: A subject
To: aperson@dom.ain
From: bperson@dom.ain


--BOUNDARY


--BOUNDARY--
)rr�rr�)r6r�r8s   r9�test_empty_multipart_idempotentz-TestMultipart.test_empty_multipart_idempotent,sF�����h�h����%�%�����d�C�M�M�O�O�4�4�4�4�4r;c��tdd��}d|d<d|d<d|d<|�d	��|�|���d
��dS)Nr1r2�	A subjectr��aperson@dom.ainr��bperson@dom.ainr�r�z�Content-Type: multipart/mixed; boundary="BOUNDARY"
MIME-Version: 1.0
Subject: A subject
To: aperson@dom.ain
From: bperson@dom.ain

--BOUNDARY

--BOUNDARY--
)rr�rr��r6�outers  r9�/test_no_parts_in_a_multipart_with_none_epiloguez=TestMultipart.test_no_parts_in_a_multipart_with_none_epilogue=st����g�.�.��&��i��'��d��)��f�
�
���:�&�&�&����e�o�o�/�/�
2�
	�
	�
	�
	�
	r;c���tdd��}d|d<d|d<d|d<d	|_d	|_|�d
��|�|���d��dS)Nr1r2rOr�rPr�rQr�r+r�z�Content-Type: multipart/mixed; boundary="BOUNDARY"
MIME-Version: 1.0
Subject: A subject
To: aperson@dom.ain
From: bperson@dom.ain


--BOUNDARY

--BOUNDARY--
)r�preamble�epiloguer�rr�rRs  r9�0test_no_parts_in_a_multipart_with_empty_epiloguez>TestMultipart.test_no_parts_in_a_multipart_with_empty_epilogueOs�����g�.�.��&��i��'��d��)��f�
�������
���:�&�&�&����e�o�o�/�/�2�	�	�	�	�	r;c��|j}tdd��}d|d<d|d<d|d<|�d	��td
��}|�|��||���d��dS)Nr1r2rOr�rPr�rQr�r�r�Content-Type: multipart/mixed; boundary="BOUNDARY"
MIME-Version: 1.0
Subject: A subject
To: aperson@dom.ain
From: bperson@dom.ain

--BOUNDARY
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit

hello world
--BOUNDARY--
)rrr�rrnr��r6r7rSr8s    r9�test_one_part_in_a_multipartz*TestMultipart.test_one_part_in_a_multipartds���
�
"����g�.�.��&��i��'��d��)��f�
�
���:�&�&�&��}�%�%��
���S����
��5�?�?����	�	�	�	�	r;c��|j}tdd��}d|d<d|d<d|d<d	|_td
��}|�|��|�d��||���d��dS)
Nr1r2rOr�rPr�rQr�r+rr�aContent-Type: multipart/mixed; boundary="BOUNDARY"
MIME-Version: 1.0
Subject: A subject
To: aperson@dom.ain
From: bperson@dom.ain


--BOUNDARY
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit

hello world
--BOUNDARY--
�rrrVrrnr�r�r[s    r9�1test_seq_parts_in_a_multipart_with_empty_preamblez?TestMultipart.test_seq_parts_in_a_multipart_with_empty_preamble}s���
�
"����g�.�.��&��i��'��d��)��f�
�����}�%�%��
���S����
���:�&�&�&�
��5�?�?����	�	�	�	�	r;c��|j}tdd��}d|d<d|d<d|d<d|_td	��}|�|��|�d
��||���d��dS�Nr1r2rOr�rPr�rQr�rr�rZr^r[s    r9�0test_seq_parts_in_a_multipart_with_none_preamblez>TestMultipart.test_seq_parts_in_a_multipart_with_none_preamble����
�
"����g�.�.��&��i��'��d��)��f�
�����}�%�%��
���S����
���:�&�&�&�
��5�?�?����	�	�	�	�	r;c��|j}tdd��}d|d<d|d<d|d<d|_td	��}|�|��|�d
��||���d��dSra�rrrWrrnr�r�r[s    r9�0test_seq_parts_in_a_multipart_with_none_epiloguez>TestMultipart.test_seq_parts_in_a_multipart_with_none_epilogue�rcr;c��|j}tdd��}d|d<d|d<d|d<d	|_td
��}|�|��|�d��||���d��dS)
Nr1r2rOr�rPr�rQr�r+rr�rZrer[s    r9�1test_seq_parts_in_a_multipart_with_empty_epiloguez?TestMultipart.test_seq_parts_in_a_multipart_with_empty_epilogue�s���
�
"����g�.�.��&��i��'��d��)��f�
�����}�%�%��
���S����
���:�&�&�&�
��5�?�?����	�	�	�	�	r;c��|j}tdd��}d|d<d|d<d|d<d	|_td
��}|�|��|�d��||���d��dS)
Nr1r2rOr�rPr�rQr�r*rr�aContent-Type: multipart/mixed; boundary="BOUNDARY"
MIME-Version: 1.0
Subject: A subject
To: aperson@dom.ain
From: bperson@dom.ain

--BOUNDARY
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit

hello world
--BOUNDARY--

rer[s    r9�.test_seq_parts_in_a_multipart_with_nl_epiloguez<TestMultipart.test_seq_parts_in_a_multipart_with_nl_epilogue�s���
�
"����g�.�.��&��i��'��d��)��f�
�����}�%�%��
���S����
���:�&�&�&�
��5�?�?����	�	�	�	�	r;c�v�|j}|�d��}|t|�����d��|�d��}||���d��|t|�����d��|���D]~}||���d��|t|�����d��|�d��}||���d���dS)N�
msg_36.txtr�r�zmultipart/alternativezmessage/external-bodyrr?)r2r3r�rZrH)r6r7r8�msg1r��
subsubparts      r9�test_message_external_bodyz(TestMultipart.test_message_external_bodys3��
�
���l�l�<�(�(��
��3�s��� � �!�!�1�%�%�%����q�!�!��
��4� � �"�"�$;�<�<�<�
��3�t���!�!�"�"�A�&�&�&��'�'�)�)�	<�	<�G��B�w�'�'�)�)�+B�C�C�C��B�s�7�&�&�(�(�)�)�1�-�-�-� �,�,�Q�/�/�J��B�z�*�*�,�,�l�;�;�;�;�		<�	<r;c��|�d��}|�t|�����d��dS)Nz
msg_37.txtr�)r3r2r�rZrhs  r9�test_double_boundaryz"TestMultipart.test_double_boundarysC���l�l�<�(�(������S�_�_�.�.�/�/��3�3�3�3�3r;c��|j}|�d��}t��}tj||��||���d��dS)Nz
msg_38.txtz�multipart/mixed
    multipart/mixed
        multipart/alternative
            text/plain
        text/plain
    text/plain
    text/plain
�rr3rr!�
_structurer��r6r7r8rs    r9�)test_nested_inner_contains_outer_boundaryz7TestMultipart.test_nested_inner_contains_outer_boundarysf��
�
"��
�l�l�<�(�(���j�j����S�#�&�&�&�
��3�<�<�>�>��	�	�	�	�	r;c��|j}|�d��}t��}tj||��||���d��dS)Nz
msg_39.txtz�multipart/mixed
    multipart/mixed
        multipart/alternative
        application/octet-stream
        application/octet-stream
    text/plain
rsrus    r9�test_nested_with_same_boundaryz,TestMultipart.test_nested_with_same_boundary,sf��
�
"���l�l�<�(�(���j�j����S�#�&�&�&�
��3�<�<�>�>��	�	�	�	�	r;c��|�d��}|�|���d��dS)Nz
msg_40.txtz�MIME-Version: 1.0
Content-Type: text/html; boundary="--961284236552522269"

----961284236552522269
Content-Type: text/html;
Content-Transfer-Encoding: 7Bit

<html></html>

----961284236552522269--
)r3r2r�rhs  r9�test_boundary_in_non_multipartz,TestMultipart.test_boundary_in_non_multipart=sD���l�l�<�(�(����������+�	�	�	�	�	r;c��|j}tjd��}|�|�����||���d��|t
|�����d��dS)Nz�MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="    XXXX"

--    XXXX
Content-Type: text/plain


--    XXXX
Content-Type: text/plain

--    XXXX--
z    XXXXr�)r2r�rr�rr�r�rZr5s   r9� test_boundary_with_leading_spacez.TestMultipart.test_boundary_with_leading_spaceLs���
�
���'�)����	
����(�(�*�*�+�+�+�
��3�����z�*�*�*�
��3�s��� � �!�!�1�%�%�%�%�%r;c��t���d��}|�|�d�����d��dS)Nz�Content-Type: multipart/mixed; boundary="===============0012394164=="
MIME-Version: 1.0

--===============0012394164==
Content-Type: image/file1.jpg
MIME-Version: 1.0
Content-Transfer-Encoding: base64

YXNkZg==
--===============0012394164==--rzYXNkZg==)rr�r2rZr�s  r9�&test_boundary_without_trailing_newlinez4TestMultipart.test_boundary_without_trailing_newline_sV���H�H���
#�

$�

$��	
������q�)�)�5�5�7�7��D�D�D�D�Dr;c�z�tdd��}|�|jtjj��dS)Nr1r2)rr�r�r��compat32r�s  r9�test_mimebase_default_policyz*TestMultipart.test_mimebase_default_policyms2���[�'�*�*���
�
�a�h��� 5�6�6�6�6�6r;c��tddtjj���}|�|jtjj��dS)Nr1r2r�)rr�r��defaultr�r�s  r9�test_mimebase_custom_policyz)TestMultipart.test_mimebase_custom_policyqs<���[�'�%�,�2F�G�G�G���
�
�a�h��� 4�5�5�5�5�5r;N)r�r�r�r�rKrMrTrXr\r_rbrfrhrjrorqrvrxrzr|r~r�r�r{r;r9r/r/�sD������"�"�"�H,�,�,�$5�5�5�"���$���*���2���8���6���6���6���6<�<�<�4�4�4����&���"
�
�
�&�&�&�&E�E�E�7�7�7�6�6�6�6�6r;r/c�|�eZdZd�Zd�Zd�Zejd��Zd�Z	d�Z
d�Zd�Zd	�Z
d
�Zd�Zd�Zd
�Zd�ZdS)�TestNonConformantc���|j}|�d��}||���d��||���d��||���d��dS)Nz
msg_14.txtr?r�r�)r2r3rHrtr�r5s   r9�test_parse_missing_minor_typez/TestNonConformant.test_parse_missing_minor_typexs{��
�
���l�l�<�(�(��
��3���!�!�<�0�0�0�
��3�#�#�%�%�v�.�.�.�
��3�"�"�$�$�g�.�.�.�.�.r;c�F�|�d��}|�d��}|�t|d����|�t|j��d��|�|jdtj	��dS)N�
msg_15.txtrr�r�)
r3rZr��hasattrr2r�r�r�r �StartBoundaryNotFoundDefect)r6r8�inners   r9�test_same_boundary_inner_outerz0TestNonConformant.test_same_boundary_inner_outer�s����l�l�<�(�(������"�"�������y�1�1�2�2�2�����U�]�+�+�Q�/�/�/����e�m�A�.�$�@�	B�	B�	B�	B�	Br;c��|�d��}|�|���t��|�t|j��d��|�|jdtj��|�|jdtj	��dS)Nz
msg_25.txtr�rr�)
r3r�rZr�r2r�r�r �NoBoundaryInMultipartDefect�!MultipartInvariantViolationDefectrhs  r9�test_multipart_no_boundaryz,TestNonConformant.test_multipart_no_boundary�s����l�l�<�(�(�����c�o�o�/�/��5�5�5�����S�[�)�)�1�-�-�-����c�k�!�n�$�@�	B�	B�	B����c�k�!�n�$�F�	H�	H�	H�	H�	Hr;a^        Date: Wed, 14 Nov 2007 12:56:23 GMT
        From: foo@bar.invalid
        To: foo@bar.invalid
        Subject: Content-Transfer-Encoding: base64 and multipart
        MIME-Version: 1.0
        Content-Type: multipart/mixed;
            boundary="===============3344438784458119861=="{}

        --===============3344438784458119861==
        Content-Type: text/plain

        Test message

        --===============3344438784458119861==
        Content-Type: application/octet-stream
        Content-Transfer-Encoding: base64

        YWJj

        --===============3344438784458119861==--
        c��|�|j�d����}|�t	|j��d��|�|jdtj��dS)Nz"
Content-Transfer-Encoding: base64r�r)	�_str_msg�
multipart_msgr�r2r�r�r�r �-InvalidMultipartContentTransferEncodingDefectrhs  r9�test_multipart_invalid_ctez,TestNonConformant.test_multipart_invalid_cte�s����m�m���%�%�&K�L�L�N�N������S�[�)�)�1�-�-�-����c�k�!�n��@�	B�	B�	B�	B�	Br;c��|�|j�d����}|�t	|j��d��dS)Nr+r�r�r�r�r2r�r�rhs  r9�test_multipart_no_cte_no_defectz1TestNonConformant.test_multipart_no_cte_no_defect�sJ���m�m�D�.�5�5�b�9�9�:�:������S�[�)�)�1�-�-�-�-�-r;c���dD]j}|�|j�d�|������}|�t	|j��d���kdS)N)rr`�BINaryz
Content-Transfer-Encoding: {}rr�)r6r�r8s   r9�"test_multipart_valid_cte_no_defectz4TestNonConformant.test_multipart_valid_cte_no_defect�s~��-�	2�	2�C��-�-��"�)�)�5�<�<�S�A�A�C�C�D�D�C�
���S���-�-�q�1�1�1�1�		2�	2r;c�`�|j}|j}t��}d|d<||���d��||���d��||���d��|d=d|d<||���d��||���d��||���d��t
��}t|��}|�|��||�	��d��dS)Nr�rDr�r?r@r�zContent-Type: foo

)
r2rrrtr�rHrrr�r�)r6r7�neqr8r�r�s      r9�test_invalid_content_typez+TestNonConformant.test_invalid_content_type�s/��
�
���#���i�i��$��N��
��3�#�#�%�%�v�.�.�.�
��3�"�"�$�$�g�.�.�.�
��3���!�!�<�0�0�0����#��N��
��3�#�#�%�%�v�.�.�.�
��3�"�"�$�$�g�.�.�.�
��3���!�!�<�0�0�0��J�J���a�L�L��	�	�	�#������A�J�J�L�L�1�2�2�2�2�2r;c�z�|j}|�d��}||���d��dS)N�
msg_31.txtzm--BOUNDARY
Content-Type: text/plain

message 1

--BOUNDARY
Content-Type: text/plain

message 2

--BOUNDARY--
)rr3rZr5s   r9�test_no_start_boundaryz(TestNonConformant.test_no_start_boundary�sJ��
�
"���l�l�<�(�(��
��3�?�?����	�	�	�	�	r;c�z�|j}|�d��}||���d��dS)Nz
msg_35.txtz�From: aperson@dom.ain
To: bperson@dom.ain
Subject: here's something interesting

counter to RFC 2822, there's no separating newline here
)rr3r�r5s   r9�test_no_separating_blank_linez/TestNonConformant.test_no_separating_blank_line�sH��
�
"���l�l�<�(�(��
��3�=�=�?�?��	�	�	�	�	r;c�r�|�d��}|�t|d����|�t	|j��d��|�|jdtj��|�|jdtj	��dS)Nz
msg_41.txtr�r�rr�)
r3r�r�r2r�r�r�r r�r�rhs  r9�test_lying_multipartz&TestNonConformant.test_lying_multipart�s����l�l�<�(�(�������Y�/�/�0�0�0�����S�[�)�)�1�-�-�-����c�k�!�n�$�@�	B�	B�	B����c�k�!�n�$�F�	H�	H�	H�	H�	Hr;c�&�|�d��}|�d���d��}|�t|j��d��|�|jdtj��dS)Nz
msg_42.txtr�r)r3rZr2r�r�r�r r�)r6rS�bads   r9�test_missing_start_boundaryz-TestNonConformant.test_missing_start_boundary�s������\�*�*������"�"�.�.�q�1�1������S�[�)�)�1�-�-�-����c�k�!�n�$�@�	B�	B�	B�	B�	Br;c�z�|j}d}tj|��}||���dg��||���d��|t|j��d��|�|jtj	g��||jdj
d��dS)Nz Line 1
Subject: test

bodyr��bodyr�rz Line 1
)r2r�rr�rZr�r��assertDefectsEqualr �#FirstHeaderLineIsContinuationDefect�liner�s    r9�&test_first_line_is_continuation_headerz8TestNonConformant.test_first_line_is_continuation_header	s���
�
��,���'��*�*��
��3�8�8�:�:�	�{�#�#�#�
��3�?�?���f�%�%�%�
��3�s�{���Q���������"(�"L�!M�	O�	O�	O�
��3�;�q�>���,�,�,�,�,r;c��|�d��}|�|���dg��|�|���d��|�|jtjg��dS)Nz&Subject: test
not a header
To: abc

b
r�znot a header
To: abc

b
)r�r2r�rZr�r�r � MissingHeaderBodySeparatorDefectrhs  r9�"test_missing_header_body_separatorz4TestNonConformant.test_missing_header_body_separator	s���
�m�m�I�J�J����������i�[�1�1�1�������*�*�,J�K�K�K������!'�!H� I�	K�	K�	K�	K�	Kr;N)r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r{r;r9r�r�vs������/�/�/�B�B�B�H�H�H�$�H�O�%�
�
�M�0B�B�B�.�.�.�
2�2�2�3�3�3�*���"	�	�	�H�H�H�
B�
B�
B� 	-�	-�	-�	K�	K�	K�	K�	Kr;r�c�n�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�ZdS)�TestRFC2047c��|j}d}t|��}||gd���t|��}|t|��d��|�|�d���d��dS)NzVRe: =?mac-iceland?q?r=8Aksm=9Arg=8Cs?= baz
 foo bar =?mac-iceland?q?r=8Aksm=9Arg=8Cs?=))sRe: N�s
r�ksm�rg�szmac-iceland)s
 baz foo bar Nr�u+Re: räksmörgås baz foo bar räksmörgåsr�r&ziRe: =?mac-iceland?q?r=8Aksm=9Arg=8Cs?= baz foo bar =?mac-iceland?q?r=8Aksm?=
 =?mac-iceland?q?=9Arg=8Cs?=)r2rrr�rr��r6r7r��dhr�s     r9�test_rfc2047_multilinez"TestRFC2047.test_rfc2047_multiline&	s���
�
��
/��
�1�
�
��
��2�5�5�5�	6�	6�	6�
�R����
��3�v�;�;�D�	F�	F�	F����f�m�m�r�m�:�:�= �	!�	!�	!�	!�	!r;c��|j}d}t|��}||ddg��tt|����}||d��dS)Nz0=?ISO-8859-1?Q?Andr=E9?= Pirard <pirard@dom.ain>)sAndr�r=)s Pirard <pirard@dom.ain>NuAndré Pirard <pirard@dom.ain>�r2rr�rr�s     r9�test_whitespace_keeper_unicodez*TestRFC2047.test_whitespace_keeper_unicode7	si��
�
��>��
�1�
�
��
��2�+�3�5�	6�	6�	6��[��_�_�%�%��
��6�5�6�6�6�6�6r;c��|j}d}t|��}||gd���tt|����}||d��dS)NzWThe =?iso-8859-1?b?cXVpY2sgYnJvd24gZm94?= jumped over the =?iso-8859-1?b?bGF6eSBkb2c=?=))sThe N)squick brown foxr=)s jumped over the N)slazy dogr=z,The quick brown fox jumped over the lazy dogr�)r6r7r�r��hus     r9� test_whitespace_keeper_unicode_2z,TestRFC2047.test_whitespace_keeper_unicode_2@	ss��
�
��e��
�1�
�
��
��2�K�K�K�	L�	L�	L�
��R���
!�
!��
��2�=�>�>�>�>�>r;c�X�d}t|��}|�|gd���dS)Nz3Sm=?ISO-8859-1?B?9g==?=rg=?ISO-8859-1?B?5Q==?=sbord))sSmN���r=)srgN���r=)ssbordN�rr2�r6r�r�s   r9�test_rfc2047_missing_whitespacez+TestRFC2047.test_rfc2047_missing_whitespaceI	sG��A��
�1�
�
������0�0�0�	1�	1�	1�	1�	1r;c�X�d}t|��}|�|gd���dS)Nz7Sm =?ISO-8859-1?B?9g==?= rg =?ISO-8859-1?B?5Q==?= sbord))sSm Nr�)s rg Nr�)s sbordNr�r�s   r9�test_rfc2047_with_whitespacez(TestRFC2047.test_rfc2047_with_whitespaceP	sG��E��
�1�
�
������1�1�1�	2�	2�	2�	2�	2r;c�x�d}gd�}|D]0\}}t||z��}|�||dfg���1dS)Nz=?iso-8859-1?B?%s?=))zdm==�v)zdm=r�)�dmr�)zdmk=�vi)�dmkr�r=r�)r6r�r\�q�ar�s      r9�test_rfc2047_B_bad_paddingz&TestRFC2047.test_rfc2047_B_bad_paddingW	si��!�������	6�	6�D�A�q��q�1�u�%�%�B����R�1�l�"3�!4�5�5�5�5�	6�	6r;c�R�d}|�t|��dg��dS)Nz=?iso-8859-1?Q?andr=e9=zz?=)sandr�=zzr=�r2r�r6r�s  r9�test_rfc2047_Q_invalid_digitsz)TestRFC2047.test_rfc2047_Q_invalid_digitsa	s9��)������q�)�)�7�8�	:�	:�	:�	:�	:r;c�T�d}|�t|��gd���dS)Nz(=?ISO-8859-1?Q?a?=))��(N��ar=��)Nr�r�s  r9�test_rfc2047_rfc2047_1z"TestRFC2047.test_rfc2047_rfc2047_1g	sA��"������q�)�)�>�>�>�	@�	@�	@�	@�	@r;c�T�d}|�t|��gd���dS)Nz(=?ISO-8859-1?Q?a?= b))r�r�)s b)Nr�r�s  r9�test_rfc2047_rfc2047_2z"TestRFC2047.test_rfc2047_rfc2047_2m	�A��$������q�)�)�@�@�@�	B�	B�	B�	B�	Br;c�T�d}|�t|��gd���dS)Nz'(=?ISO-8859-1?Q?a?= =?ISO-8859-1?Q?b?=)�r�)sabr=r�r�r�s  r9�test_rfc2047_rfc2047_3z"TestRFC2047.test_rfc2047_rfc2047_3s	sA��5������q�)�)�?�?�?�	A�	A�	A�	A�	Ar;c�T�d}|�t|��gd���dS)Nz((=?ISO-8859-1?Q?a?=  =?ISO-8859-1?Q?b?=)r�r�r�s  r9�test_rfc2047_rfc2047_4z"TestRFC2047.test_rfc2047_rfc2047_4y	sA��6������q�)�)�?�?�?�	A�	A�	A�	A�	Ar;c�T�d}|�t|��gd���dS)Nz,(=?ISO-8859-1?Q?a?=
    =?ISO-8859-1?Q?b?=)r�r�r�s  r9�test_rfc2047_rfc2047_5az#TestRFC2047.test_rfc2047_rfc2047_5a	sA��<������q�)�)�?�?�?�	A�	A�	A�	A�	Ar;c�T�d}|�t|��gd���dS)Nz+(=?ISO-8859-1?Q?a?=
    =?ISO-8859-1?Q?b?=)r�r�r�s  r9�test_rfc2047_rfc2047_5bz#TestRFC2047.test_rfc2047_rfc2047_5b�	sA��:������q�)�)�?�?�?�	A�	A�	A�	A�	Ar;c�T�d}|�t|��gd���dS)Nz(=?ISO-8859-1?Q?a_b?=))r�)sa br=r�r�r�s  r9�test_rfc2047_rfc2047_6z"TestRFC2047.test_rfc2047_rfc2047_6�	r�r;c	�v�d}|�t|��gd���|�tt|�������|�����|�ttt|������d��dS)Nz((=?ISO-8859-1?Q?a?= =?ISO-8859-2?Q?_b?=))r�r�)s brrr�z(a b))r2rrr�r�r�r�s  r9�test_rfc2047_rfc2047_7z"TestRFC2047.test_rfc2047_rfc2047_7�	s���6������q�)�)�
�
�
�	�	�	�	
����]�1�%5�%5�6�6�=�=�?�?������K�K�K�����[��q�)9�)9�:�:�;�;�W�E�E�E�E�Er;c	��d}|�t|��ddg��|�tt|�������d�|�������|�t
tt|������d��dS)Nz9=?windows-1252?q?=22M=FCller_T=22?=
 <T.Mueller@xxx.com>)s
"M�ller T"zwindows-1252)s<T.Mueller@xxx.com>Nr+u"Müller T" <T.Mueller@xxx.com>)r2rrr�r��
splitlinesr�r�s  r9�test_multiline_headerz!TestRFC2047.test_multiline_header�	s���I������q�)�)�
/�
+�
-�	.�	.�	.�	
����]�1�%5�%5�6�6�=�=�?�?���������0�0�	2�	2�	2�����[��q�)9�)9�:�:�;�;�:�	<�	<�	<�	<�	<r;N)r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r{r;r9r�r�%	s������!�!�!�"7�7�7�?�?�?�1�1�1�2�2�2�6�6�6�:�:�:�@�@�@�B�B�B�A�A�A�A�A�A�A�A�A�A�A�A�B�B�B�F�F�F�<�<�<�<�<r;r�c�n�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�ZdS)�TestMIMEMessagec��tdd���5}|���|_ddd��dS#1swxYwYdS)N�
msg_11.txtrVr�)r&r��_text�r6r�s  r9r�zTestMIMEMessage.setUp�	s���
�l�W�
5�
5�
5�	#�������D�J�	#�	#�	#�	#�	#�	#�	#�	#�	#�	#�	#�	#����	#�	#�	#�	#�	#�	#s
�9�=�=c�H�|�ttd��dS)Nza plain string)r�rmrr�s r9�test_type_errorzTestMIMEMessage.test_type_error�	s!�����)�[�2B�C�C�C�C�Cr;c��|j}d}t��}||d<t|��}||���d��|���}|�|t��|t|��d��|d}|�||��||d|��dS)Nz
A sub-messager�rar�r�subject)	r2rrrHrZr��listr�r�)r6r7r�r��rr�r�s       r9�test_valid_argumentz#TestMIMEMessage.test_valid_argument�	s���
�
��!���I�I����)����N�N��
��1�����!1�2�2�2��-�-�/�/�����g�t�,�,�,�
��3�w�<�<������!�*���
�
�g�q�!�!�!�
��7�9��w�'�'�'�'�'r;c��t��}d|d<t��}d|d<t|��}|�tj|j|��dS)N�	subpart 1r�z	subpart 2)rrr�r �MultipartConversionErrorrn)r6rmrr�s    r9�test_bad_multipartz"TestMIMEMessage.test_bad_multipart�	sV���y�y��%��Y���y�y��%��Y����������&�9�1�8�T�J�J�J�J�Jr;c�2�t��}d|d<|�d��t|��}d|d<t��}t	|��}|�|��|�|���d��dS)N�An enclosed messager��!Here is the body of the message.
zThe enclosing messagez�Content-Type: message/rfc822
MIME-Version: 1.0
Subject: The enclosing message

Subject: An enclosed message

Here is the body of the message.
)rrRrrrr�r2r�)r6r�r�r�r�s     r9�
test_generatezTestMIMEMessage.test_generate�	s����I�I��,��)��	�
�
�:�;�;�;���N�N��.��)���J�J���a�L�L��	�	�	�!������������(�	�	�	�	�	r;c��|j}|�d��}||���d��|���}|�|t
��|t
|��d��|d}|�|t��||dd��||���d��dS)Nr�rar�rr�rr)r2r3rHrZr�r�r�r)r6r7r8r��submsgs     r9�test_parse_message_rfc822z)TestMIMEMessage.test_parse_message_rfc822�	s���
�
���l�l�<�(�(��
��3���!�!�#3�4�4�4��/�/�#�#�����g�t�,�,�,�
��3�w�<�<������������f�g�.�.�.�
��6�)��3�4�4�4�
��6�����!E�F�F�F�F�Fr;c�*�|j}|�d��}||���d��|�|�����|t|�����d��|�d��}||���d��||���d��|�d��}||���d��|t|�����d	��|�d��}|�|t��||d
d��||�	dd
���d��||�	dd
���d��|�d��}|�|t��||dd��||�
d���ddg��||�	dd���d��|�d	��}||���d��|���}|�|t��|t|��d��|d}|�|t��||���d��||dd��dS)N�
msg_16.txtr>r�rr?a�This report relates to a message you sent with the following header fields:

  Message-id: <002001c144a6$8752e060$56104586@oxy.edu>
  Date: Sun, 23 Sep 2001 20:10:55 -0700
  From: "Ian T. Henry" <henryi@oxy.edu>
  To: SoCal Raves <scr@socal-raves.org>
  Subject: [scr] yeah for Ians!!

Your message cannot be delivered to the following recipients:

  Recipient address: jangel1@cougar.noc.ucla.edu
  Reason: recipient reached disk quota

r�zmessage/delivery-statusr�zoriginal-envelope-idz"0GK500B4HD0888@cougar.noc.ucla.edu�dnsz
reporting-mtarr+�nsd�action�failedzoriginal-recipient)r�r+)zjangel1@cougar.noc.ucla.edur+r�zfinal-recipientra�
message-idz(<002001c144a6$8752e060$56104586@oxy.edu>)r2r3rHr�rr�rZr�rrIrr�)r6r7r8r��dsn1�dsn2r�rns        r9�test_dsnzTestMIMEMessage.test_dsn�	s��
�
���l�l�<�(�(��
��3���!�!�#5�6�6�6�����(�(�*�*�+�+�+�
��3�s��� � �!�!�1�%�%�%��/�/�!�$�$��
��7�#�#�%�%�|�4�4�4�
��7��� � �#�	�	�	�$�/�/�!�$�$��
��7�#�#�%�%�'@�A�A�A�
��3�w�"�"�$�$�%�%�q�)�)�)��"�"�1�%�%�����d�G�,�,�,�
��4�&�'�)M�N�N�N�
��4�>�>�%��>�8�8�"�=�=�=�
��4�>�>�%��>�8�8�$�?�?�?��"�"�1�%�%�����d�G�,�,�,�
��4��>�8�$�$�$�
��4�?�?�"6�?�7�7��?�@�	B�	B�	B�
��4�>�>�(�+<�>�=�=�r�B�B�B��/�/�!�$�$��
��7�#�#�%�%�'7�8�8�8��%�%�'�'�����g�t�,�,�,�
��3�w�<�<������Q�Z�
����j�'�2�2�2�
��:�&�&�(�(�,�7�7�7�
��:�l�#�5�	7�	7�	7�	7�	7r;c�D�|j}tdd���5}|���}ddd��n#1swxYwYt��}d|d<d|d<d|d	<d
|_d|_t
d��}t
d
��}|�ddd���|�|��|�|��t��}t|��}|�|��||���|��dS)N�
msg_21.txtrVr�rPr�rQr�rMr��MIME messagezEnd of MIME message
r�r�rDrkr�r3)
rr&r�rrVrWrrNrnrrr�r�)	r6r7r�r�r8rmrrr�s	         r9�
test_epiloguezTestMIMEMessage.test_epilogue
sD��
�
"��
�l�W�
5�
5�
5�	���7�7�9�9�D�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	��i�i��'��F��%��D�	���I��%���.����������������~�'8�:��N�N�N��
�
�4�����
�
�4�����j�j���c�N�N��	�	�	�#����
��3�<�<�>�>�4� � � � � �
�:�>�>c�f�|j}t��}d|d<d|d<d|d<d|_d|_t	d	��}t	d
��}|�ddd
���|�|��|�|��||���d��dS)NrPr�rQr�rMr�rr+r�r�rDrkr�r3adFrom: aperson@dom.ain
To: bperson@dom.ain
Subject: Test
Content-Type: multipart/mixed; boundary="BOUNDARY"

MIME message
--BOUNDARY
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit

One
--BOUNDARY
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit

Two
--BOUNDARY--
)rrrVrWrrNrnr�)r6r7r8rmrs     r9�test_no_nl_preamblez#TestMIMEMessage.test_no_nl_preamble1
s���
�
"���i�i��'��F��%��D�	���I��%�������������������~�'8�:��N�N�N��
�
�4�����
�
�4����
��3�=�=�?�?��	�	�	�	�	r;c��|j}tdd���5}tj|��}ddd��n#1swxYwY|�d��}||���d��||���d��|�d��}||���d��||���d��|�d��}||���d��||���d��|�d��}||���d��||���d��dS)NrerVr�rrar�r?�r2r&r��message_from_filerZ�get_default_typerH�r6r7r�r8�
container1�
container2�container1a�container2as        r9�test_default_typez!TestMIMEMessage.test_default_typeT
���
�
��
�l�W�
5�
5�
5�	.���)�"�-�-�C�	.�	.�	.�	.�	.�	.�	.�	.�	.�	.�	.����	.�	.�	.�	.��_�_�Q�'�'�
�
��:�&�&�(�(�*:�;�;�;�
��:�&�&�(�(�*:�;�;�;��_�_�Q�'�'�
�
��:�&�&�(�(�*:�;�;�;�
��:�&�&�(�(�*:�;�;�;� �,�,�Q�/�/��
��;�'�'�)�)�<�8�8�8�
��;�'�'�)�)�<�8�8�8� �,�,�Q�/�/��
��;�'�'�)�)�<�8�8�8�
��;�'�'�)�)�<�8�8�8�8�8rc��|j}tdd���5}tj|��}ddd��n#1swxYwY|�d��}||���d��||���d��|�d��}||���d��||���d��|�d��}||���d��||���d��|�d��}||���d��||���d��dS)NrjrVr�rrar�r?rrs        r9�.test_default_type_with_explicit_container_typez>TestMIMEMessage.test_default_type_with_explicit_container_typee
r%rc��|j}|j}tdd��}d|_t	d��}t	d��}t|��}t|��}|�|��|�|��||���d��||���d��||���d��||���d��||�	d��d��|d	=|d
=|d	=|d
=||���d��||���d��||���d��||���d��||�	d��d��dS)N�digestr�r+�
message 1
�
message 2
rara�Content-Type: multipart/digest; boundary="BOUNDARY"
MIME-Version: 1.0

--BOUNDARY
Content-Type: message/rfc822
MIME-Version: 1.0

Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit

message 1

--BOUNDARY
Content-Type: message/rfc822
MIME-Version: 1.0

Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit

message 2

--BOUNDARY--
r@r>aBContent-Type: multipart/digest; boundary="BOUNDARY"
MIME-Version: 1.0

--BOUNDARY

Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit

message 1

--BOUNDARY

Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit

message 2

--BOUNDARY--
)
r2rrrWrrrnrHrr�)r6r7r�r?�	subpart1a�	subpart2a�subpart1�subpart2s        r9�test_default_type_non_parsedz,TestMIMEMessage.test_default_type_non_parsedv
s���
�
���#��!�(�J�7�7�	��	���]�+�+�	��]�+�+�	��y�)�)���y�)�)������"�"�"�����"�"�"�
��8�$�$�&�&�(8�9�9�9�
��8�$�$�&�&�(8�9�9�9�
��8�$�$�&�&�(8�9�9�9�
��8�$�$�&�&�(8�9�9�9���I����"�"�%�	�	�	�4
�^�$��^�$��^�$��^�$�
��8�$�$�&�&�(8�9�9�9�
��8�$�$�&�&�(8�9�9�9�
��8�$�$�&�&�(8�9�9�9�
��8�$�$�&�&�(8�9�9�9���I����"�"�%�	�	�	�	�	r;c�F�|j}td��}td��}t||f���}|t|�����d��||�d��|��||�d��|��dS)Nr+)�	_subpartsr�rr�)r2rrr�rZ)r6r7�text1�text2r8s     r9�$test_mime_attachments_in_constructorz4TestMIMEMessage.test_mime_attachments_in_constructor�
s���
�
�������������u�e�n�5�5�5��
��3�s��� � �!�!�1�%�%�%�
��3�?�?�1���u�%�%�%�
��3�?�?�1���u�%�%�%�%�%r;c�p�t��}|�|�����dSrf)rr�rrhs  r9�"test_default_multipart_constructorz2TestMIMEMessage.test_default_multipart_constructor�
s/���o�o������(�(�*�*�+�+�+�+�+r;c��t��}d|d<d|d<|�|�d��ddg��dS)N�a@b.comr��c@d.comr�)rr2r4rhs  r9�test_multipart_default_policyz-TestMIMEMessage.test_multipart_default_policy�
sJ���o�o����D�	���D�	�������T�*�*�Y�	�,B�C�C�C�C�Cr;c��ttjj���}d|d<|�t
��5}d|d<ddd��n#1swxYwY|�t|j��d��dS)Nr�r9r�r:z.There may be at most 1 To headers in a message)	rr�r�r�r�rXr2r��	exception)r6r8�cms   r9�test_multipart_custom_policyz,TestMIMEMessage.test_multipart_custom_policy�
s����5�<�#7�8�8�8����D�	�
�
�
�z�
*�
*�	"�b�!�C��I�	"�	"�	"�	"�	"�	"�	"�	"�	"�	"�	"����	"�	"�	"�	"�����R�\�*�*�I�	K�	K�	K�	K�	Ks�A�A�AN)r�r�r�r�r�r�rrr	rrrr$r'r0r5r7r;r?r{r;r9r�r��	s������#�#�#�D�D�D�(�(�(�K�K�K����(
G�
G�
G�77�77�77�r!�!�!�(!�!�!�F9�9�9�"9�9�9�"H�H�H�T&�&�&�,�,�,�D�D�D�K�K�K�K�Kr;r�c��eZdZd�Zd�ZdS)�TestNonMultipartc�t�tdd��}|�|�����dS)Nr�r�)rrrrhs  r9�"test_nonmultipart_is_not_multipartz3TestNonMultipart.test_nonmultipart_is_not_multipart�
s7���v�w�/�/������)�)�+�+�,�,�,�,�,r;c��t��}d|d<tdd��}|�tj|j|��dS)Nrr�r�r�)rrr�r rrn)r6r8r�s   r9�test_attach_raises_exceptionz-TestNonMultipart.test_attach_raises_exception�
sF���i�i��$��I���V�W�-�-�����&�9�1�8�S�I�I�I�I�Ir;N)r�r�r�rCrEr{r;r9rArA�
s7������-�-�-�J�J�J�J�Jr;rAc��eZdZdZd�Zdd�Zd�Zd�Zd�Zd�Z	d	�Z
d
�Zd�Zd�Z
d
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�ZdS)�TestIdempotentr*c��t|d���5}|���}ddd��n#1swxYwYtj|��}||fS�NrVr��r&r�r�r�r6rKr�r\r8s     r9r3zTestIdempotent._msgobj�
s���
�h��
1�
1�
1�	�R��7�7�9�9�D�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	��'��-�-���D�y�r�Fc��|j}t��}t|d���}|�||���|||�����dS)Nrr{r�)rrrr�r�)r6r8r�r�r7r�r�s       r9�_idempotentzTestIdempotent._idempotent�
s[��
�
"���J�J���a�a�(�(�(��	�	�	�#��	�)�)�)�
��4����������r;c���|j}|�d��\}}||���d��||���d��||���d��||���dd��||�d��d��||jd��||jd��|�	||��dS)	Nr�r?r�r�r�)rArNrArN)
r2r3rHrtr�rrIrVrWrM�r6r7r8r�s    r9�test_parse_text_messagez&TestIdempotent.test_parse_text_message�
s���
�
���L�L��.�.�	��T�
��3���!�!�<�0�0�0�
��3�#�#�%�%�v�.�.�.�
��3�"�"�$�$�g�.�.�.�
��3�>�>���A�� 7�8�8�8�
��3�=�=��#�#�Z�0�0�0�
��3�<�����
��3�<���������d�#�#�#�#�#r;c�&�|j}|�d��\}}||���d��||���d��||�d��d��|�||��dS)Nr�r?rA)r2r3rHrrIrMrOs    r9�test_parse_untyped_messagez)TestIdempotent.test_parse_untyped_messages���
�
���L�L��.�.�	��T�
��3���!�!�<�0�0�0�
��3�>�>���T�"�"�"�
��3�=�=��#�#�T�*�*�*�����d�#�#�#�#�#r;c�b�|�d��\}}|�||��dS)Nry�r3rM�r6r8r�s   r9�test_simple_multipartz$TestIdempotent.test_simple_multipart�3���L�L��.�.�	��T�����d�#�#�#�#�#r;c�b�|�d��\}}|�||��dS)N�
msg_02.txtrTrUs   r9�test_MIME_digestzTestIdempotent.test_MIME_digestrWr;c�b�|�d��\}}|�||��dS)Nz
msg_27.txtrTrUs   r9�test_long_headerzTestIdempotent.test_long_headerrWr;c�b�|�d��\}}|�||��dS)NrjrTrUs   r9�"test_MIME_digest_with_part_headersz1TestIdempotent.test_MIME_digest_with_part_headersrWr;c�b�|�d��\}}|�||��dS)N�
msg_06.txtrTrUs   r9�test_mixed_with_imagez$TestIdempotent.test_mixed_with_image#rWr;c�b�|�d��\}}|�||��dS)Nr<rTrUs   r9�test_multipart_reportz$TestIdempotent.test_multipart_report'rWr;c�b�|�d��\}}|�||��dS)NrrTrUs   r9rzTestIdempotent.test_dsn+rWr;c�b�|�d��\}}|�||��dS)NrrTrUs   r9�test_preamble_epiloguez%TestIdempotent.test_preamble_epilogue/rWr;c�b�|�d��\}}|�||��dS)Nz
msg_23.txtrTrUs   r9�test_multipart_one_partz&TestIdempotent.test_multipart_one_part3rWr;c�b�|�d��\}}|�||��dS)Nz
msg_24.txtrTrUs   r9�test_multipart_no_partsz&TestIdempotent.test_multipart_no_parts7rWr;c�b�|�d��\}}|�||��dS)Nr�rTrUs   r9r�z%TestIdempotent.test_no_start_boundary;rWr;c�b�|�d��\}}|�||��dS)N�
msg_32.txtrTrUs   r9�test_rfc2231_charsetz#TestIdempotent.test_rfc2231_charset?rWr;c�b�|�d��\}}|�||��dS)Nz
msg_33.txtrTrUs   r9�test_more_rfc2231_parametersz+TestIdempotent.test_more_rfc2231_parametersCrWr;c�b�|�d��\}}|�||��dS)Nz
msg_34.txtrTrUs   r9�%test_text_plain_in_a_multipart_digestz4TestIdempotent.test_text_plain_in_a_multipart_digestGrWr;c�b�|�d��\}}|�||��dS)Nzmsg_12a.txtrTrUs   r9�test_nested_multipart_mixedsz+TestIdempotent.test_nested_multipart_mixedsKs3���L�L��/�/�	��T�����d�#�#�#�#�#r;c�b�|�d��\}}|�||��dS)NrlrTrUs   r9�%test_message_external_body_idempotentz4TestIdempotent.test_message_external_body_idempotentOrWr;c�f�|�d��\}}|�||d���dS)N�
msg_43.txtTr�rTrUs   r9�test_message_delivery_statusz+TestIdempotent.test_message_delivery_statusSs8���L�L��.�.�	��T�����d�T��2�2�2�2�2r;c�b�|�d��\}}|�||��dS�N�
msg_45.txtrTrUs   r9�test_message_signed_idempotentz-TestIdempotent.test_message_signed_idempotentWrWr;c���|j}|�d��\}}||���d��i}|���D]
\}}|||<�||dd��||dd��||jd|jz��||j|j��|t|�����d��|�d	��}||���d
��||���d|jz��|�d��}||���d
��||���d|jz��|�d
��}	||	���d��|�	|	t��|	���}
|�	|
t��|t|
��d��|
d	}|�	|t��||���d|jz��dS)Nr<r>r?r@rrBz$This is a MIME-encapsulated message.r�rr?zYadda yadda yaddar�r�ra)r2r3rHrrVr�rWr�rZr�rr�)r6r7r8r��params�pk�pvrmr�msg3r��msg4s            r9�test_content_typez TestIdempotent.test_content_type[sk��
�
���L�L��.�.�	��T�
��3���!�!�#5�6�6�6����n�n�&�&�	�	�F�B���F�2�J�J�
��6�-� �"3�4�4�4�
��6�*��F�G�G�G�
��3�<�?�$�,�N�O�O�O�
��3�<���&�&�&�
��3�s��� � �!�!�1�%�%�%����q�!�!��
��4� � �"�"�L�1�1�1�
��4�����2�T�\�A�B�B�B����q�!�!��
��4� � �"�"�L�1�1�1�
��4�����2�T�\�A�B�B�B����q�!�!��
��4� � �"�"�$4�5�5�5����d�G�,�,�,��"�"�$�$�����g�t�,�,�,�
��3�w�<�<������q�z�����d�G�,�,�,�
��4�����2�T�\�A�B�B�B�B�Br;c�2�|j}|�d��\}}||���d��|���}|�|t
��|t
|��d��|d}|�|t��||���d��|�|���t��||���|j	��dS)Nr`rar�rr?)
r2r3rHrZr�r�r�rr�r�)r6r7r8r�r�rms      r9�test_parserzTestIdempotent.test_parserzs��
�
���L�L��.�.�	��T�
��3���!�!�#3�4�4�4��/�/�#�#�����g�t�,�,�,�
��3�w�<�<������q�z�����d�G�,�,�,�
��4� � �"�"�L�1�1�1����d�.�.�0�0�#�6�6�6�
��4�����t�|�,�,�,�,�,r;N�F)r�r�r�r�r3rMrPrRrVrZr\r^rarcrrfrhrjr�rnrprrrtrvryr}r�r�r{r;r9rGrG�
s��������G��������
$�
$�
$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�3�3�3�$�$�$�C�C�C�>-�-�-�-�-r;rGc�|�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z!d �Z"d!�Z#d"�Z$d#�Z%d$�Z&d%�Z'd&�Z(d'�Z)d(�Z*d)�Z+e,j-��d*���Z.d+�Z/d,�Z0d-�Z1d.�Z2d/�Z3d0�Z4d1�Z5d2�Z6d3�Z7d4�Z8d5�Z9d6�Z:d7S)8�TestMiscellaneousc�`�tdd���5}|���}ddd��n#1swxYwYtj|��}t	��}t|d���}|�|��|�||�����dS�Nr�rVr�rr{�	r&r�r�rrrr�r2r��r6r�r�r8r�r�s      r9�test_message_from_stringz*TestMiscellaneous.test_message_from_string�s���
�l�W�
5�
5�
5�	���7�7�9�9�D�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	��'��-�-���J�J��
�a�a�(�(�(��	�	�	�#��������q�z�z�|�|�,�,�,�,�,r�c��tdd���5}|���}|�d��tj|��}t��}t
|d���}|�|��|�||�	����ddd��dS#1swxYwYdSr�)
r&r��seekr�rrrr�r2r�r�s      r9�test_message_from_filez(TestMiscellaneous.test_message_from_file�s���
�l�W�
5�
5�
5�		1���7�7�9�9�D��G�G�A�J�J�J��)�"�-�-�C��
�
�A��!�!�,�,�,�A�
�I�I�c�N�N�N����T�1�:�:�<�<�0�0�0�		1�		1�		1�		1�		1�		1�		1�		1�		1�		1�		1�		1����		1�		1�		1�		1�		1�		1s�BB9�9B=�B=c��tdd���5}|���}ddd��n#1swxYwYGd�dt��}tj||��}|�||��tdd���5}|���}ddd��n#1swxYwYtj||��}|���D]}|�||���dS)Nr�rVr�c��eZdZdS)�HTestMiscellaneous.test_message_from_string_with_class.<locals>.MyMessageN�r�r�r�r{r;r9�	MyMessager����������Dr;r�rY)r&r�rr�rr��walk)r6r�r�r�r8r�s      r9�#test_message_from_string_with_classz5TestMiscellaneous.test_message_from_string_with_class�s���
�l�W�
5�
5�
5�	���7�7�9�9�D�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	�	�	�	�	��	�	�	��'��i�8�8�����c�9�-�-�-�
�l�W�
5�
5�
5�	���7�7�9�9�D�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	��'��i�8�8���x�x�z�z�	6�	6�G��!�!�'�9�5�5�5�5�	6�	6s�3�7�7�
B.�.B2�5B2c��Gd�dt��}tdd���5}tj||��}ddd��n#1swxYwY|�||��tdd���5}tj||��}ddd��n#1swxYwY|���D]}|�||���dS)Nc��eZdZdS)�FTestMiscellaneous.test_message_from_file_with_class.<locals>.MyMessageNr�r{r;r9r�r��r�r;r�r�rVr�rY)rr&r�rr�r�)r6r�r�r8r�s     r9�!test_message_from_file_with_classz3TestMiscellaneous.test_message_from_file_with_class�sl��	�	�	�	�	��	�	�	��l�W�
5�
5�
5�	9���)�"�i�8�8�C�	9�	9�	9�	9�	9�	9�	9�	9�	9�	9�	9����	9�	9�	9�	9����c�9�-�-�-�
�l�W�
5�
5�
5�	9���)�"�i�8�8�C�	9�	9�	9�	9�	9�	9�	9�	9�	9�	9�	9����	9�	9�	9�	9��x�x�z�z�	6�	6�G��!�!�'�9�5�5�5�5�	6�	6s#�A�A�A�9B�B�"Bc��Gd�dt��}|�d|��}|�||��dS)Nc���eZdZ�fd�Z�xZS)�STestMiscellaneous.test_custom_message_does_not_require_arguments.<locals>.MyMessagec�H��t�����dSrf)�super�__init__)r6�	__class__s �r9r�z\TestMiscellaneous.test_custom_message_does_not_require_arguments.<locals>.MyMessage.__init__�s������ � �"�"�"�"�"r;)r�r�r�r��
__classcell__)r�s@r9r�r��s8�������
#�
#�
#�
#�
#�
#�
#�
#�
#r;r�zSubject: test

test)rr�r�)r6r�r8s   r9�.test_custom_message_does_not_require_argumentsz@TestMiscellaneous.test_custom_message_does_not_require_arguments�s^��	#�	#�	#�	#�	#��	#�	#�	#��m�m�3�Y�?�?�����c�9�-�-�-�-�-r;c�x�td��}|�t|j��gd���dS)Nr�)rrArr �
feedparserr�r�r!rw�message_from_binary_filer�rrr�r�r"r#)�
__import__r2�sorted�__all__)r6�modules  r9�test__all__zTestMiscellaneous.test__all__�sL���G�$�$��������/�/�2�2�2�	�	�	�	�	r;c���tj��}|�tjtj|����dd�tj|��dd���dS)N�)r9r2r#�	parsedate�
formatdate�gmtime�r6rAs  r9�test_formatdatez!TestMiscellaneous.test_formatdate�se���i�k�k��������)9�#�)>�)>�?�?����C���S�)�)�"�1�"�-�	/�	/�	/�	/�	/r;c���tj��}|�tjtj|d�����dd�tj|��dd���dS)NT�r:r�)r9r2r#r�r�r:r�s  r9�test_formatdate_localtimez+TestMiscellaneous.test_formatdate_localtime�sk���i�k�k������O�E�,�S�D�A�A�A�B�B�2�A�2�F��N�3������#�	%�	%�	%�	%�	%r;c	�j�tj��}|�tj|d���tjdtj|������|�tj|dd���tjdtj|������dS)NFr�z%a, %d %b %Y %H:%M:%S -0000T)r:�usegmtz%a, %d %b %Y %H:%M:%S GMT)r9r2r#r�r=r�r�s  r9�test_formatdate_usegmtz(TestMiscellaneous.test_formatdate_usegmt�s����i�k�k�������S�E�2�2�2��M�7���S�9I�9I�J�J�	L�	L�	L�	
�����S�E�$�?�?�?��M�5�t�{�3�7G�7G�H�H�	J�	J�	J�	J�	Jr;c��gd�}|D]~}|�|���5|�tj|����|�tj|����ddd��n#1swxYwY�|�tjd����|�tjd����dS)N)	r+r,�0zA Complete Waste of Timez Wed, 3 Apr 2002 12.34.56.78+0800z17 June , 2022zFriday, -Nov-82 16:14:55 ESTzFriday, Nov--82 16:14:55 ESTzFriday, 19-Nov- 16:14:55 EST)�dtstr)�subTestr�r#r��parsedate_tz)r6�
invalid_datesr�s   r9�/test_parsedate_returns_None_for_invalid_stringszATestMiscellaneous.test_parsedate_returns_None_for_invalid_strings�s��

�

�

�
�#�	=�	=�E����E��*�*�
=�
=��!�!�%�/�%�"8�"8�9�9�9��!�!�%�"4�U�";�";�<�<�<�
=�
=�
=�
=�
=�
=�
=�
=�
=�
=�
=����
=�
=�
=�
=��	
���%�/�$�/�/�0�0�0����%�,�T�2�2�3�3�3�3�3s�AA:�:A>	�A>	c��|�tjd��d��|�tjd��d��|�tjd��d��dS)NzWed, 3 Apr 2002 14:58:26 +0800�
��r�r���:�rr�r4�pzWed,3 Apr 2002 14:58:26 +0800zWed 3 Apr 2002 14:58:26 +0800�r2r#r�r�s r9�test_parsedate_compactz(TestMiscellaneous.test_parsedate_compacts�������+�,L�M�M�B�	D�	D�	D�	
����+�,K�L�L�B�	D�	D�	D�	
����+�,K�L�L�B�	D�	D�	D�	D�	Dr;c��|j}|tjd��d��|tjd��d��dS)N�5 Feb 2003 13:47:26 -0800�
��r���
�/r�rr�r4透��zFebruary 5, 2003 13:47:26 -0800r��r6r7s  r9�test_parsedate_no_dayofweekz-TestMiscellaneous.test_parsedate_no_dayofweek
s^��
�
��
��5��9�:�:�5�	7�	7�	7�
��5��?�@�@�5�	7�	7�	7�	7�	7r;c�V�|�tjd��d��dS)NzWed, 3 Apr 2002 14:58:26+0800r�r�r�s r9�.test_parsedate_no_space_before_positive_offsetz@TestMiscellaneous.test_parsedate_no_space_before_positive_offsets5������+�,K�L�L�4�	6�	6�	6�	6�	6r;c�V�|�tjd��d��dS)NzWed, 3 Apr 2002 14:58:26-0800)
r�r�r�r�r�r�rr�r4r�r�r�s r9�.test_parsedate_no_space_before_negative_offsetz@TestMiscellaneous.test_parsedate_no_space_before_negative_offsets5������+�,K�L�L�5�	7�	7�	7�	7�	7r;c��|j}|tjd��d��|tjd��d��dS)Nz5 Feb 2003 13.47.26 -0800r�z5 Feb 2003 13.47 -0800)
r�r�r�r�r�rrr�r4r�r�r�s  r9�%test_parsedate_accepts_time_with_dotsz7TestMiscellaneous.test_parsedate_accepts_time_with_dotss^��
�
��
��5��9�:�:�5�	7�	7�	7�
��5��6�7�7�4�	6�	6�	6�	6�	6r;c�V�|�tjd��d��dS)NzFriday, 19-Nov-82 16:14:55 EST)
i����r��7rr�r4i����r�r�s r9�test_parsedate_rfc_850z(TestMiscellaneous.test_parsedate_rfc_850!s5������+�,L�M�M�7�	9�	9�	9�	9�	9r;c�V�|�tjd��d��dS)NzWed, 3 Apr 2002 14:58 +0800�
r�r�r�r�r�rrr�r4r�r�r�s r9�test_parsedate_no_secondsz+TestMiscellaneous.test_parsedate_no_seconds%s:������+�,I�J�J�A�	C�	C�	C�	C�	Cr;c��|�tjd��d��|�tjd��d��dS)NzWed, 3 Apr 2002 14.58.26 +0800r�zWed, 3 Apr 2002 14.58 +0800r�r�r�s r9�!test_parsedate_dot_time_delimiterz3TestMiscellaneous.test_parsedate_dot_time_delimiter)sf������+�,L�M�M�B�	D�	D�	D�����+�,I�J�J�A�	C�	C�	C�	C�	Cr;c
�p�|j}tjd��}tt	j|����}|t	j|��dd�|dd���|tt	jd|����d��tjd��}tt	j|dd�����}|t	j|��dd�|dd���|tt	jd|dd�����d��dS)Nr�r�z%Yr��	)	r2r#r��intr9�mktimer:r=r�)r6r7�timetupr�s    r9�+test_parsedate_acceptable_to_time_functionsz=TestMiscellaneous.test_parsedate_acceptable_to_time_functions/s��
�
���/�"=�>�>�����G�$�$�%�%��
��4�>�!���R�a�R� �'�"�1�"�+�.�.�.�
��3�t�}�T�7�+�+�,�,�d�3�3�3��$�%@�A�A�����G�B�Q�B�K�(�(�)�)��
��4�>�!���R�a�R� �'�"�1�"�+�.�.�.�
��3�t�}�T�7�2�A�2�;�/�/�0�0�$�7�7�7�7�7r;c��|�tjd��d��|�tjd��d��dS)N)
�r�r�rrrr4r4r4rr)
r�r�r�rrrr4r4r4i�i.���)r2r#�	mktime_tzr�s r9�test_mktime_tzz TestMiscellaneous.test_mktime_tz:sm�������*9�:�:�;<�	>�	>�	>������*<�=�=�>C�	E�	E�	E�	E�	Er;c���|�tjd��tjd����|�tjd��tjd����dS)aTest for parsing a date with a two-digit year.

        Parsing a date with a two-digit year should return the correct
        four-digit year. RFC822 allows two-digit years, but RFC2822 (which
        obsoletes RFC822) requires four-digit years.

        z25 Feb 03 13:47:26 -0800z25 Feb 2003 13:47:26 -0800z25 Feb 71 13:47:26 -0800z25 Feb 1971 13:47:26 -0800Nr�r�s r9�test_parsedate_y2kz$TestMiscellaneous.test_parsedate_y2k@s���	
����+�,F�G�G��+�,H�I�I�	K�	K�	K�����+�,F�G�G��+�,H�I�I�	K�	K�	K�	K�	Kr;c���|�tjd��d��|�tjtjd����d��dS)Nz<>�r+r+r+�r2r#�	parseaddr�
formataddrr�s r9�test_parseaddr_emptyz&TestMiscellaneous.test_parseaddr_emptyMsS��������.�.��9�9�9�����)�%�/�$�*?�*?�@�@�"�E�E�E�E�Er;c��|�tjd��d��|�tjd��d��|�tjd��d��dS)Nza@b@cr�za@b.c@cza@172.17.0.1@c�r2r#r�r�s r9�test_parseaddr_multiple_domainsz1TestMiscellaneous.test_parseaddr_multiple_domainsQs�������O�G�$�$��	
�	
�	
�	
����O�I�&�&��	
�	
�	
�	
����O�,�-�-��	
�	
�	
�	
�	
r;c�V�|�tjd��d��dS)N)zA Silly Person�person@dom.ainzA Silly Person <person@dom.ain>�r2r#r�r�s r9�test_noquote_dumpz#TestMiscellaneous.test_noquote_dump_s6�������A�B�B�-�	/�	/�	/�	/�	/r;c�*�|�tjd��d��|�tjd��d��d}d}|�tjtj||f����||f��dS)N)zA (Very) Silly Personr�z("A (Very) Silly Person" <person@dom.ain>z*"A \(Very\) Silly Person" <person@dom.ain>zA \(Special\) Personr��r2r#r�r��r6r�r�s   r9�test_escape_dumpz"TestMiscellaneous.test_escape_dumpds��������H�I�I�7�	9�	9�	9�	
����O�I�J�J�7�	9�	9�	9�
$����������)9�1�a�&�)A�)A�B�B�Q��F�K�K�K�K�Kr;c���|�tjd��d��d}d}|�tjtj||f����||f��dS)N)�Arthur \Backslash\ Foobarr�z."Arthur \\Backslash\\ Foobar" <person@dom.ain>rr�rrs   r9�test_escape_backslashesz)TestMiscellaneous.test_escape_backslashesosq�������M�N�N�=�	?�	?�	?�
)����������)9�1�a�&�)A�)A�B�B�Q��F�K�K�K�K�Kr;c��d}d}d}d}|�tj||f��|��|�tj||fd��|��dS)N�Häns Würstr��-=?utf-8?b?SMOkbnMgV8O8cnN0?= <person@dom.ain>z0=?iso-8859-1?q?H=E4ns_W=FCrst?= <person@dom.ain>r=r�)r6r&�addr�utf8_base64�
latin1_quopris     r9�test_quotes_unicode_namesz+TestMiscellaneous.test_quotes_unicode_nameswss��%����E��J�
�����)�4��,�7�7��E�E�E�����)�4��,��E�E��	�	�	�	�	r;c� ��d}d}d}d�G�fd�d��}|��}��d|�d�}|�tj||f|��|��|�tj||ftd	����|��dS)
Nrr�r	�FOOBARc���eZdZ�fd�ZdS)�KTestMiscellaneous.test_accepts_any_charset_like_object.<locals>.CharsetMockc����Srfr{)r6�stringrTs  �r9�
header_encodezYTestMiscellaneous.test_accepts_any_charset_like_object.<locals>.CharsetMock.header_encode�s����
r;N)r�r�r�r)rTs�r9�CharsetMockr�s.�������
�
�
�
�
�
�
r;rz <�>rV)r2r#r�r
)r6r&r
rr�mock�
mock_expectedrTs       @r9�$test_accepts_any_charset_like_objectz6TestMiscellaneous.test_accepts_any_charset_like_object�s����%����E����	�	�	�	�	�	�	�	�	�	��{�}�}��%+�V�V�T�T�T�2�
�����)�4��,��=�=�}�M�M�M�����)�4��,���8H�8H�I�I��	�	�	�	�	r;c�|�d}d}t��}|�ttj||f|��dS)Nrr�)�objectr��AttributeErrorr#r�)r6r&r
�bad_charsets    r9�-test_invalid_charset_like_object_raises_errorz?TestMiscellaneous.test_invalid_charset_like_object_raises_error�sG��%�����h�h�����.�%�*:�T�4�L��	�	�	�	�	r;c��d}|�ttjd|f��|�ttjd|f��dS)Nupersön@dom.in�Name)r��UnicodeErrorr#r�)r6r
s  r9�!test_unicode_address_raises_errorz3TestMiscellaneous.test_unicode_address_raises_error�sK��#�����,��(8�4��,�G�G�G����,��(8�6�4�.�I�I�I�I�Ir;c��d}d}d\}}|�tj|��||f��|�tj|��||f��|�tj||f��|��dS)NzJohn X. Doe <jxd@example.com>z"John X. Doe" <jxd@example.com>)zJohn X. Doezjxd@example.comr�)r6r��yr�r�s     r9�test_name_with_dotz$TestMiscellaneous.test_name_with_dot�s���+��-��1���1�������+�+�a��V�4�4�4�������+�+�a��V�4�4�4�����)�1�a�&�1�1�1�5�5�5�5�5r;c���|j}|tjd��d��|tjd��d��|tjd��d��dS)N�""example" example"@example.com)r+r'�!"\"example\" example"@example.com)r+r(�#"\\"example\\" example"@example.com)r+r)r�r�s  r9�2test_parseaddr_preserves_quoted_pairs_in_addresseszDTestMiscellaneous.test_parseaddr_preserves_quoted_pairs_in_addresses�s����
��
��5�?�<�=�=�
1�	3�	3�	3�
��5�?�@�A�A�
5�	7�	7�	7�
��5�?�D�E�E�
9�	;�	;�	;�	;�	;r;c��|�dtjd����|�dtjd����|�dtjd����|�dtjd����|�dtjd	����dS)
N)r+�merwok wok@xample.comr,)r+�merwok  wok@xample.comr-z merwok  wok  @xample.com)r+�merwok"wok"  wok@xample.comr.)r+zmerwok.wok.wok@xample.comzmerwok. wok .  wok@xample.comr�r�s r9�-test_parseaddr_preserves_spaces_in_local_partz?TestMiscellaneous.test_parseaddr_preserves_spaces_in_local_part�s���	
���6��O�3�4�4�	6�	6�	6����7��O�4�5�5�	7�	7�	7����7��O�7�8�8�	:�	:�	:����<��O�9�:�:�	<�	<�	<����:��O�;�<�<�	>�	>�	>�	>�	>r;c��d}d}|�tj|��|��|�tj|��|��dS)N)z#'foo@example.com' (foo@example.com)�foo@example.comz7"'foo@example.com' (foo@example.com)" <foo@example.com>r�)r6r
�addrstrs   r9�6test_formataddr_does_not_quote_parens_in_quoted_stringzHTestMiscellaneous.test_formataddr_does_not_quote_parens_in_quoted_string�sX��#��C��������1�1�4�8�8�8�����)�$�/�/��9�9�9�9�9r;c�Z�d}|�tj|��d��dS)NzFoo
	Bar <foo@example.com>)zFoo Barr1r�)r6r�s  r9�test_multiline_from_commentz-TestMiscellaneous.test_multiline_from_comment�s2��
��	
������+�+�-K�L�L�L�L�Lr;c�V�|�tjd��d��dS)N)zA Silly; Personr�z""A Silly; Person" <person@dom.ain>r�r�s r9�test_quote_dumpz!TestMiscellaneous.test_quote_dump�s6�������B�C�C�1�	3�	3�	3�	3�	3r;c��|j}|j}t��}t��}||d��||d��||d��|d|��|d|��|d|��||d��||d��||d��|d|��|d|��|d|��|||��|||��dS)NrN�US-ASCIIzUs-AsCiI�usascii�USASCII�UsAsCiI)r2�assertNotEqualr
)r6r7�ne�cset1�cset2s     r9�test_charset_richcomparisonsz.TestMiscellaneous.test_charset_richcomparisons�s&��
�
��
�
 ���	�	���	�	��
��5�*����
��5�*����
��5�*����
��:�u����
��:�u����
��:�u����
��5�)����
��5�)����
��5�)����
��9�e����
��9�e����
��9�e����
��5�%����
��5�%�����r;c�X�|j}|tjddg��ddg��dS)Nzaperson@dom.ain (Al Person)zBud Person <bperson@dom.ain>)z	Al PersonrP)z
Bud PersonrQ�r2r#�getaddressesr�s  r9�test_getaddressesz#TestMiscellaneous.test_getaddresses�sO��
�
��
��5��<�=�?�@�@�,�-�/�	0�	0�	0�	0�	0r;c���|j}|tjdg��dg��|tjdg��gd���|tjddg��ddg��dS)Nzfoo: ;r�z	[]*-- =~$)r�r�)r+z*--z#"Jason R. Mastaler" <jason@dom.ain>)zJason R. Mastalerz
jason@dom.ainrCr�s  r9�test_getaddresses_nastyz)TestMiscellaneous.test_getaddresses_nasty�s���
�
��
��5��x�j�)�)�H�:�6�6�6�
��5���=���,�,�,�	.�	.�	.�	��5���;�<�>�>��<�=�	?�	?�	?�	?�	?r;c�n�|j}tjdg��}||ddd��dS)z(Test proper handling of a nested commentz%User ((nested comment)) <foo@bar.com>rr��foo@bar.comNrC)r6r7�addrss   r9�"test_getaddresses_embedded_commentz4TestMiscellaneous.test_getaddresses_embedded_comment
s>��
�
���"�$K�#L�M�M��
��5��8�A�;�
�&�&�&�&�&r;c��tjtd��g��}|�|ddd��dS)z%Test the handling of a Header object.zAl Person <aperson@dom.ain>rr�rPN)r#rDrr2)r6rJs  r9�test_getaddresses_header_objz.TestMiscellaneous.test_getaddresses_header_obj
sC���"�F�+H�$I�$I�#J�K�K������q��!��&7�8�8�8�8�8r;c�l��Gd�dt����fd�td��D��}tj|��5	ddd��n#1swxYwYt	d�|D��g��}|�t
t|����t
|����dS)Nc��eZdZd�ZdS)�BTestMiscellaneous.test_make_msgid_collisions.<locals>.MsgidsThreadc���g|_|jj}tj}tj}|��dz}|��|kr%||d�����|��|k�#dSdS)Ng@�testdomain-string��domain)�msgidsr(r#�
make_msgidr9�	monotonic)r6r(rV�clock�tfins     r9�runzFTestMiscellaneous.test_make_msgid_collisions.<locals>.MsgidsThread.run
s��� �����+��"�-�
�����u�w�w��}���e�g�g��n�C��F�:�:�-@�A�A�A�B�B�B��e�g�g��n�C�C�C�C�Cr;N)r�r�r�rZr{r;r9�MsgidsThreadrP
s(������
C�
C�
C�
C�
Cr;r[c�$��g|]}�����
Sr{r{)rrIr[s  �r9r�z@TestMiscellaneous.test_make_msgid_collisions.<locals>.<listcomp>
s���4�4�4�a�<�<�>�>�4�4�4r;r�c��g|]	}|j��
Sr{)rU)rr�s  r9r�z@TestMiscellaneous.test_make_msgid_collisions.<locals>.<listcomp>!
s��1�1�1�A�q�x�1�1�1r;)rrOr$�
start_threads�sumr2r��set)r6�threads�all_idsr[s   @r9�test_make_msgid_collisionsz,TestMiscellaneous.test_make_msgid_collisions
s
���		C�		C�		C�		C�		C�6�		C�		C�		C�5�4�4�4�5��8�8�4�4�4��
�
+�G�
4�
4�	�	��	�	�	�	�	�	�	�	�	�	�	����	�	�	�	��1�1��1�1�1�2�6�6������S��\�\�*�*�C��L�L�9�9�9�9�9s�A�A�Ac��|j}t��}|�ddd���||���d��dS)NrLrHzfoo\wacky"namerJ)r2rrNr}r5s   r9�test_utils_quote_unquotez*TestMiscellaneous.test_utils_quote_unquote$
s[��
�
���i�i�����,�l� 1�	�	3�	3�	3�
��3�����0�1�1�1�1�1r;c�t�td��}|�|���d��dS)Nz
not a charsetrW�r
r2�get_body_encoding�r6rAs  r9�)test_get_body_encoding_with_bogus_charsetz;TestMiscellaneous.test_get_body_encoding_with_bogus_charset+
s7���/�*�*������2�2�4�4�h�?�?�?�?�?r;c��|j}t��}d|d<||dd��|���}|t|��d��||dd��t	|d��}||���d��|�d|�	��||���d
��||�d���d��||d
d��t��}d|d<|���}|t|��d��||dd��t	|d��}||���tj	��|�d|�	��||���d��||d
d��dS)Nztext/plain; charset=UTF-8rDr@r�rrVrWr�rS�aGVsbG8gd29ybGQ=
TrXrBztext/plain; charset="US-ASCII"rNrr)
r2rrur�r
rhrRrZrr)r6r7r8rvrAs     r9�-test_get_body_encoding_with_uppercase_charsetz?TestMiscellaneous.test_get_body_encoding_with_uppercase_charset/
s���
�
���i�i��9��N��
��3�~�� ;�<�<�<��#�#�%�%��
��3�x�=�=�!����
��8�A�;�� � � ��(�1�+�&�&��
��7�$�$�&�&��1�1�1�������8�8�8�
��3�?�?���2�3�3�3�
��3�?�?�$�?�'�'��8�8�8�
��3�*�+�X�6�6�6��i�i��>��N���#�#�%�%��
��3�x�=�=�!����
��8�A�;�
�#�#�#��(�1�+�&�&��
��7�$�$�&�&��(?�@�@�@����
�w��7�7�7�
��3�?�?���m�,�,�,�
��3�*�+�V�4�4�4�4�4r;c��td��}td��}|�|���|�����dS)NrNr9rg)r6�lc�ucs   r9�test_charsets_case_insensitivez0TestMiscellaneous.test_charsets_case_insensitiveI
sP��
�Z�
 �
 ��
�Z�
 �
 ������-�-�/�/��1E�1E�1G�1G�H�H�H�H�Hr;c��|j}|�d��}t��}tj||��||���d��dS)NrxaBmultipart/report
    text/plain
    message/delivery-status
        text/plain
        text/plain
        text/plain
        text/plain
        text/plain
        text/plain
        text/plain
        text/plain
        text/plain
        text/plain
        text/plain
        text/plain
        text/plain
        text/plain
        text/plain
        text/plain
        text/plain
        text/plain
        text/plain
        text/plain
        text/plain
        text/plain
        text/plain
        text/plain
        text/plain
        text/plain
    text/rfc822-headers
rsrus    r9�1test_partial_falls_inside_message_delivery_statuszCTestMiscellaneous.test_partial_falls_inside_message_delivery_statusN
sf��
�
"��
�l�l�<�(�(���j�j����S�#�&�&�&�
��3�<�<�>�>��	�	�	�	�	r;c�~�|�tj�d���dd�d��dS)NrRrSi��z@testdomain-string>�r2r�r#rVr�s r9�test_make_msgid_domainz(TestMiscellaneous.test_make_msgid_domainx
sG������K�"�"�*=�"�>�>�s�t�t�D�!�	#�	#�	#�	#�	#r;c��|�tj�dd���dd�d��dS)Nz
test-idstringrR)�idstringrTi���z!.test-idstring@testdomain-string>rur�s r9�test_make_msgid_idstringz*TestMiscellaneous.test_make_msgid_idstring}
sR������K�"�"�O�*�
#�
,�
,�,/�D�D�
2�/�	1�	1�	1�	1�	1r;c��td��5}dx|_}|�tj����d|zdz����ddd��dS#1swxYwYdS)Nzsocket.getfqdnzpythontest.example.com�@r)r	�return_valuer�r�r#rV�endswith)r6�mock_getfqdnrTs   r9�test_make_msgid_default_domainz0TestMiscellaneous.test_make_msgid_default_domain�
s���
�#�
$�
$�	)��1I�I�L�%���O�O���&�&�(�(�1�1��&�L�3�&�(�(�
)�
)�
)�	)�	)�	)�	)�	)�	)�	)�	)�	)�	)�	)�	)����	)�	)�	)�	)�	)�	)s�AA1�1A5�8A5c��tddd���5}|���}ddd��n#1swxYwY|�dd��}tj|��}t��}tj�|��}|�|��|�	|�
��|��dS)N�
msg_26.txtrVr*�r��newliner�)r&r�r�r�rrr�rr�r2r��r6�f�msgtxt�	msgtxt_nlr8r�r�s       r9�test_Generator_linendz'TestMiscellaneous.test_Generator_linend�
s���
�l�W�d�
C�
C�
C�	�q��V�V�X�X�F�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	��N�N�6�4�0�0�	��'��/�/���J�J���O�%�%�a�(�(��	�	�	�#������������y�1�1�1�1�1��4�8�8c���tddd���5}|���}ddd��n#1swxYwY|�dd��}tj|��}t��}tj�|��}|�|d���|�	|�
���d��|��dS)Nr�rVr*r�r�r�r�)r&r�r�r�rrr�r
r�r2r�rYr�s       r9�test_BytesGenerator_linendz,TestMiscellaneous.test_BytesGenerator_linend�
s���
�l�W�d�
C�
C�
C�	�q��V�V�X�X�F�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	��N�N�6�4�0�0�	��'�	�2�2���I�I���O�*�*�1�-�-��	�	�	�#�v�	�&�&�&���������,�,�W�5�5�v�>�>�>�>�>r�c���tdd��5}|���}ddd��n#1swxYwY|�dd��}|�dd��}tj|��}t��}tj�|��}|�|d���|�	|�
��|��dS)	Nr�r�swith attachmentsfo��
r�r�r�)r&r�r�r�r�rr�r
r�r2r�r�s       r9�)test_BytesGenerator_linend_with_non_asciiz;TestMiscellaneous.test_BytesGenerator_linend_with_non_ascii�
s��
�l�D�
)�
)�	�Q��V�V�X�X�F�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	���� 2�I�>�>���N�N�7�E�2�2�	��&�y�1�1���I�I���O�*�*�1�-�-��	�	�	�#�v�	�&�&�&���������v�.�.�.�.�.rc�8�tdd��5}|���}ddd��n#1swxYwYtdd��5}|���}ddd��n#1swxYwYtdft|fft|fft
t
��fftdftdfg}|D]�\}}|�	|j
d���5||�}|�|jtjj��ddd��n#1swxYwY|�	|j
d���5||d	tjji�}|�|jtjj��ddd��n#1swxYwY��dS)
Nr�r�r�)r+)r1r2r�)�clsr�r�r�)r&r�rrrrrrrr�r�r�r�r�r�r�)r6r��	audiodatar��classesr��constructorr�s        r9�!test_mime_classes_policy_argumentz3TestMiscellaneous.test_mime_classes_policy_argument�
s|��
�k�4�
(�
(�	"�B����	�	�I�	"�	"�	"�	"�	"�	"�	"�	"�	"�	"�	"����	"�	"�	"�	"�
�l�D�
)�
)�	 �R��g�g�i�i�G�	 �	 �	 �	 �	 �	 �	 �	 �	 �	 �	 ����	 �	 �	 �	 ��e�$�
���%�
��
�#�
�7�9�9�,�'�
�5�6�
�u��

��!(�	>�	>��C�����#�,�z��B�B�
?�
?��C��%���
�
�a�h���(=�>�>�>�
?�
?�
?�
?�
?�
?�
?�
?�
?�
?�
?����
?�
?�
?�
?����#�,�y��A�A�
>�
>��C��B�U�\�-A�B�B���
�
�a�h���(<�=�=�=�
>�
>�
>�
>�
>�
>�
>�
>�
>�
>�
>����
>�
>�
>�
>��		>�	>sC�2�6�6�
A.�.A2�5A2�0D�D	� D	�AF�F	�F	N);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�rrr
rrr"r%r*r/r3r5r7rArErGrKrMr$�requires_working_threadingrcrerjrmrqrsrvryrr�r�r�r�r{r;r9r�r��s������	-�	-�	-�
1�
1�
1�6�6�6�"6�6�6�.�.�.����/�/�/�
%�%�%�J�J�J�4�4�4�,D�D�D�7�7�7�6�6�6�7�7�7�
6�6�6�9�9�9�C�C�C�C�C�C�	8�	8�	8�E�E�E�K�K�K�F�F�F�
�
�
�/�/�/�
	L�	L�	L�L�L�L����
�
�
����J�J�J�6�6�6�;�;�;�$>�>�>�$:�:�:�M�M�M�3�3�3�
���(0�0�0�?�?�?�'�'�'�9�9�9�
1��0�2�2�:�:�3�2�:�&2�2�2�@�@�@�5�5�5�4I�I�I�
(�(�(�T#�#�#�
1�1�1�)�)�)�	2�	2�	2�	?�	?�	?�
/�
/�
/�>�>�>�>�>r;r�c�,�eZdZd�Zd�Zd�Zd�Zd�ZdS)�
TestIteratorsc��|j}|j}|�d��}tj|��}t|��}|t
|��d��|t�|��|�	����|�d��}tj|��}t|��}|t
|��d��tdd���5}|t�|��|�����ddd��dS#1swxYwYdS)Nr�r�rY�+z
msg_19.txtrVr�)r2rr3r!�body_line_iteratorr�r��EMPTYSTRINGr�rZr&r�)r6r7r�r8�itr�r�s       r9�test_body_line_iteratorz%TestIterators.test_body_line_iterator�
s`��
�
���#���l�l�<�(�(��
�
)�#�
.�
.���R����
��3�u�:�:�q������K���U�#�#�S�_�_�%6�%6�7�7�7��l�l�<�(�(��
�
)�#�
.�
.���R����
��3�u�:�:�r����
�l�W�
5�
5�
5�	4���C�� � ��'�'������3�3�3�	4�	4�	4�	4�	4�	4�	4�	4�	4�	4�	4�	4����	4�	4�	4�	4�	4�	4s�87D<�<E�Ec�2�|j}|�d��}tj|d��}g}d}|D].}|dz
}|�|������/||d��|t�|��d��dS)Nryr�rr�r�z`a simple kind of mirror
to reflect upon our own
a simple kind of mirror
to reflect upon our own
�r2r3r!�typed_subpart_iteratorr(rZr�r��r6r7r8r�r��subpartsr�s       r9�test_typed_subpart_iteratorz)TestIterators.test_typed_subpart_iterator�
s���
�
���l�l�<�(�(��
�
-�c�6�
:�
:�������	0�	0�G���M�H��L�L��,�,�.�.�/�/�/�/�
��8�Q����
��;���E�"�"�%�	�	�	�	�	r;c�4�|j}|�d��}tj|dd��}g}d}|D].}|dz
}|�|������/||d��|t�|��d��dS)Nr�r�r�rr�z%
Hi,

Do you like this message?

-Me
r�r�s       r9�(test_typed_subpart_iterator_default_typez6TestIterators.test_typed_subpart_iterator_default_type�
s���
�
���l�l�<�(�(��
�
-�c�6�7�
C�
C�������	0�	0�G���M�H��L�L��,�,�.�.�/�/�/�/�
��8�Q����
��;���E�"�"�%�	�	�	�	�	r;c���gd�}ddlm}m}|��}g}d}|D]i\}}|�|��||z
}d}	t	|j|��D]}
|�|
��|	dz
}	�|�||	���j|�t|��|��|�d�	d�|D����d�	|����dS)z�FeedParser BufferedSubFile.push() assumed it received complete
           line endings.  A CR ending one push() followed by a LF starting
           the next push() added an empty line.
        ))za
 
r�)r�r)zc
r�)r+r)zd
r�)ze
r)z
fr�)r�r�r��BufferedSubFile�NeedMoreDatar�r+c��g|]\}}|��Sr{r{)r�il�ns   r9r�z0TestIterators.test_pushCR_LF.<locals>.<listcomp>s��!6�!6�!6���Q�"�!6�!6�!6r;N)
�email.feedparserr�r��push�iter�readliner(r2r�r�)r6�imtr�r��bsf�om�ntr�r��n1�ols           r9�test_pushCR_LFzTestIterators.test_pushCR_LF�
s ��
	�	�	��	C�B�B�B�B�B�B�B��o����
��
���	$�	$�E�B���H�H�R�L�L�L��!�G�B��B��3�<��6�6�
�
���	�	�"�
�
�
��a�������Q��#�#�#�#�����R���"�%�%�%�������!6�!6�#�!6�!6�!6�7�7�������E�E�E�E�Er;c����ddlm}m}d}d}d�d��fd�t	|��D����dz}|�d	��}|��}g}t	dt
|��|��D]L}	||	|	|z�}
|�|
��|�t|j
|�����M|�||��dS)
Nrr�i'r�zabcd 	
r+c3�6�K�|]}t���V��dSrfr)rrI�charss  �r9rJz1TestIterators.test_push_random.<locals>.<genexpr>s)�����4�4�a�F�5�M�M�4�4�4�4�4�4r;r*T)r�r�r�r�rOr�r�r��extendr�r�r2)r6r�r�r��	chunksizer��targetr�r�rI�chunkr�s           @r9�test_push_randomzTestIterators.test_push_randoms����B�B�B�B�B�B�B�B����	����G�G�4�4�4�4�5��8�8�4�4�4�4�4�t�;�����d�#�#���o�������q�#�a�&�&�)�,�,�	;�	;�A��a��)��m�$�E��H�H�U�O�O�O��L�L��c�l�L�9�9�:�:�:�:������'�'�'�'�'r;N)r�r�r�r�r�r�r�r�r{r;r9r�r��
sb������4�4�4�"���"���&F�F�F�<(�(�(�(�(r;r�c�&�eZdZd�Zd�Zd�Zd�ZdS)�TestFeedParsersc�z�t��}|D]}|�|���|���Srf)r(�feed�close)r6�chunksr�r�s    r9�parsezTestFeedParsers.parse,sA���\�\�
��	#�	#�E��O�O�E�"�"�"�"����!�!�!r;c��|�d��}|�|dd��|�|dd��dS)NzFirst: val
: bad
Second: valr��valr�)r�r2rhs  r9�test_empty_header_name_handledz.TestFeedParsers.test_empty_header_name_handled2sN���j�j�9�:�:������W��u�-�-�-�����X���.�.�.�.�.r;c��|�dg��}|�|���gd���|�dg��}|�|���gd���|�ddg��}|�|���ddg��|�dd	g��}|�|���dd
g��|�ddg��}|�|���dd
g��|�dg��}|�|���d
g��|�gd���}|�|���ddg��dS)Nz
a:
b:
c:
d:
)r�r��c�dza:
b:
c:
d:za:
b�c:
r��bc�a:
zb:
r�z
b:
ua:…b:
c:
)r�u	…b:
c:)r�ub:…r��r�r+)r�u…c:)r�r2r�r�r�s  r9�
test_newlineszTestFeedParsers.test_newlines8s����J�J�,�-�.�.����������#7�#7�#7�8�8�8��J�J�*�+�,�,����������#7�#7�#7�8�8�8��J�J���(�)�)����������C��;�/�/�/��J�J���'�(�(����������C��:�.�.�.��J�J���)�*�*����������C��:�.�.�.�
�J�J�,�-�.�.����������%<�$=�>�>�>��J�J�1�1�1�2�2����������Y��$@�A�A�A�A�Ar;c��d\}}|�dgd|zg|zz��}|�|���dg��|�|���d|z|z��|�dgd|zg|zz��}|�|���dg��|�|���d|z|z��|�dgd|zdzg|zz��}|�|���dg��|�|���d|zdz|z��|�ddgd|zg|zz��}|�|���d	d
d|z|zfg��dS)N)i�i Nza:b

r�)r�r�za:b

�…r�zb: r�r�)r�r2r�rZ)r6�M�Nr�s    r9�test_long_lineszTestFeedParsers.test_long_linesJs������1��J�J�	�{�c�!�e�W�q�[�0�1�1����������Z�L�1�1�1���������#�a�%��'�2�2�2��J�J�	�{�c�!�e�W�q�[�0�1�1����������Z�L�1�1�1���������#�a�%��'�2�2�2��J�J�	�{�c�!�e�F�l�^�a�%7�7�8�8����������Z�L�1�1�1���������3�q�5��<��*:�;�;�;��J�J����#�a�%��1��4�5�5����������Y��c�!�e�A�g��$?�@�@�@�@�@r;N)r�r�r�r�r�r�r�r{r;r9r�r�*sX������"�"�"�/�/�/�B�B�B�$
A�
A�
A�
A�
Ar;r�c�x�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�ZdZ
d�Zd
�Zd�Zd�Zd�Zd�Zd�ZdS)�TestParsersc���|j}tdd���5}t���|��}ddd��n#1swxYwY||dd��||dd��||���d��|�|�����|�|���t��dS)	NrYrVr�r��ppp-request@zzz.orgr��ppp@zzz.orgrk)
r2r&rr�rHrrr�rZr��r6r7r�r8s    r9�test_header_parserzTestParsers.test_header_parser\s��
�
��
�l�W�
5�
5�
5�	+���.�.�&�&�r�*�*�C�	+�	+�	+�	+�	+�	+�	+�	+�	+�	+�	+����	+�	+�	+�	+�
��3�v�;�-�.�.�.�
��3�t�9�m�$�$�$�
��3���!�!�#4�5�5�5�����)�)�+�+�,�,�,����c�o�o�/�/��5�5�5�5�5s�"A�A�Ac�P�|j}tdd��5}tj����|��}ddd��n#1swxYwY||dd��||dd��||���d��|�|�����|�	|�
��t��|�	|�
d�	��t��dS)
NrYr�r�r�r�r�rkTrX)
r2r&r�r�r�r�rHrrr�rZr�r�r�s    r9�test_bytes_header_parserz$TestParsers.test_bytes_header_parsergsC��
�
��
�l�D�
)�
)�	=�R��,�0�0�2�2�8�8��<�<�C�	=�	=�	=�	=�	=�	=�	=�	=�	=�	=�	=����	=�	=�	=�	=�
��3�v�;�-�.�.�.�
��3�t�9�m�$�$�$�
��3���!�!�#4�5�5�5�����)�)�+�+�,�,�,����c�o�o�/�/��5�5�5����c�o�o�T�o�:�:�E�B�B�B�B�Bs�2A�A�Ac���tdd��5}tj����|��|�|j��ddd��dS#1swxYwYdS)NrYr�)r&r�r��BytesParserr�r�closedr�s  r9�%test_bytes_parser_does_not_close_filez1TestParsers.test_bytes_parser_does_not_close_filess���
�l�D�
)�
)�	(�R��L�$�$�&�&�,�,�R�0�0�0����R�Y�'�'�'�	(�	(�	(�	(�	(�	(�	(�	(�	(�	(�	(�	(����	(�	(�	(�	(�	(�	(s�AA*�*A.�1A.c�6�tdd��5}tjj}|�tjj|tjj���j	|��|�
|j��ddd��dS#1swxYwYdS)Nr�r�r�)r&r�r�r�r�r r�r��strictr�rr�)r6r��bytesParsers   r9�2test_bytes_parser_on_exception_does_not_close_filez>TestParsers.test_bytes_parser_on_exception_does_not_close_filexs���
�l�D�
)�
)�	(�R��,�2�K����e�l�F�)�k���1D�E�E�E�K� �
"�
"�
"�
���R�Y�'�'�'�	(�	(�	(�	(�	(�	(�	(�	(�	(�	(�	(�	(����	(�	(�	(�	(�	(�	(s�A0B�B�Bc���tdd���5}tj����|��|�|j��ddd��dS#1swxYwYdS)NrYrVr�)r&r�r�rr�rr�r�s  r9�test_parser_does_not_close_filez+TestParsers.test_parser_does_not_close_file�s���
�l�W�
5�
5�
5�	(���L���!�!�'�'��+�+�+����R�Y�'�'�'�	(�	(�	(�	(�	(�	(�	(�	(�	(�	(�	(�	(����	(�	(�	(�	(�	(�	(s�AA+�+A/�2A/c�8�tdd���5}tjj}|�tjj|tjj���j	|��|�
|j��ddd��dS#1swxYwYdS)Nr�rVr�r�)r&r�r�rr�r r�r�r�r�rr�)r6r�r�s   r9�,test_parser_on_exception_does_not_close_filez8TestParsers.test_parser_on_exception_does_not_close_file�s���
�l�W�
5�
5�
5�	(���\�(�F����e�l�F�$�f�E�L�,?�@�@�@�F��
L�
L�
L����R�Y�'�'�'�		(�	(�	(�	(�	(�	(�	(�	(�	(�	(�	(�	(����	(�	(�	(�	(�	(�	(s�A0B�B�Bc��|j}tjd��}||dd��||dd��||���d��dS)Nz�From: aperson@dom.ain
To: bperson@dom.ain
Subject: the next line has a space on it
 
Date: Mon, 8 Apr 2002 15:09:19 -0400
Message-ID: spam

Here's the message body
r��!the next line has a space on it
 r�spam�Here's the message body
�r2r�rrZr5s   r9�test_whitespace_continuationz(TestParsers.test_whitespace_continuation��v��
�
���'�	)�	�	��	��3�y�>�?�@�@�@�
��3�|��f�%�%�%�
��3�?�?���9�:�:�:�:�:r;c��|j}tjd��}||dd��||dd��||���d��dS)Nz�From: aperson@dom.ain
To: bperson@dom.ain
Date: Mon, 8 Apr 2002 15:09:19 -0400
Message-ID: spam
Subject: the next line has a space on it
 

Here's the message body
r�r�rr�r�r�r5s   r9�(test_whitespace_continuation_last_headerz4TestParsers.test_whitespace_continuation_last_header�r�r;c��|j}tddd���5}t���|��}ddd��n#1swxYwY|t	|�����d��|�d��}||���d��||���d��|�d	��}||���d
��dS)Nr�rVr*r�r�rr?z!Simple email with attachment.

r�zapplication/riscos)r2r&rr�r�rZrH)r6r7r�r8�part1�part2s      r9�test_crlf_separationz TestParsers.test_crlf_separation�s.��
�
��
�l�W�d�
C�
C�
C�	%�r��(�(�.�.��$�$�C�	%�	%�	%�	%�	%�	%�	%�	%�	%�	%�	%����	%�	%�	%�	%�
��3�s��� � �!�!�1�%�%�%�����"�"��
��5�!�!�#�#�\�2�2�2�
��5����� G�H�H�H�����"�"��
��5�!�!�#�#�%9�:�:�:�:�:s�"A�A�Ac�b�tddd���5}|���}ddd��n#1swxYwYtj|��}t	��}t|��}|�|d���|�|���|��dS)Nr�rVr*r�r�r�r�r�s      r9�test_crlf_flattenzTestParsers.test_crlf_flatten�s���
�l�W�d�
C�
C�
C�	�r��7�7�9�9�D�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	��'��-�-���J�J���a�L�L��	�	�	�#�v�	�&�&�&���������t�,�,�,�,�,r�Nc���|j}|j}tdd���5}tj|��}ddd��n#1swxYwY||���d��|t
|�����d��|�d��}||���d��||���d��|t
|�����d��|�d��}||���d��||���d��||���d	��|�d��}||���d��||���d��|t
|�����d��|�d��}||���d��||���d��||���d
��dS)NrjrVr�r�r�rrar?r*r+)	r2rr&r�rrr�rZrH)	r6r7r�r�r8r��part1ar��part2as	         r9�-test_multipart_digest_with_extra_mime_headersz9TestParsers.test_multipart_digest_with_extra_mime_headers�s���
�
���#��
�l�W�
5�
5�
5�	.���)�"�-�-�C�	.�	.�	.�	.�	.�	.�	.�	.�	.�	.�	.����	.�	.�	.�	.�	��3�����q�!�!�!�
��3�s��� � �!�!�1�%�%�%�����"�"��
��5�!�!�#�#�%5�6�6�6�
��5������#�#�#�
��3�u� � �"�"�#�#�Q�'�'�'��"�"�1�%�%��
��6��� � �!�$�$�$�
��6�"�"�$�$�l�3�3�3���F��� � �-�0�0�0�����"�"��
��5�!�!�#�#�%5�6�6�6�
��5������#�#�#�
��3�u� � �"�"�#�#�Q�'�'�'��"�"�1�%�%��
��6��� � �!�$�$�$�
��6�"�"�$�$�l�3�3�3���F��� � �-�0�0�0�0�0s�A�A�Ac��gd�}tjt�|����}|�|dd��dS)N)z$From: Andrew Person <aperson@dom.ainz
Subject: Testz%Date: Tue, 20 Aug 2002 16:43:45 +1000�datezTue, 20 Aug 2002 16:43:45 +1000)r�rr�r�r2)r6r�r8s   r9�test_three_lineszTestParsers.test_three_lines�sP��:�:�:���'�������7�7������V��&G�H�H�H�H�Hr;c���|j}d}d}d|�d|�d�}tj|��}||�d��|��||�d��|��dS)Nr�z	more textzHeader: z
Next-Header: z

Body

rzNext-Header)r2r�r�get)r6r7�value1�value2r�r8s      r9�3test_strip_line_feed_and_carriage_return_in_headersz?TestParsers.test_strip_line_feed_and_carriage_return_in_headers�s|��
�
��������F�F�F�F�F�
���'��*�*��
��3�7�7�8���f�%�%�%�
��3�7�7�=�!�!�6�*�*�*�*�*r;c��|j}d}tj|��}|t|��d��|t	d�|D����gd���||���d��dS)Nz(>From: foo
From: bar
!"#QUX;~: zoo

bodyr�c3�K�|]}|V��dSrfr{)r�fields  r9rJz9TestParsers.test_rfc2822_header_syntax.<locals>.<genexpr>�s"����)�)�E�%�)�)�)�)�)�)r;)z!"#QUX;~z>Fromr�r�)r2r�rr�r�rZr�s    r9�test_rfc2822_header_syntaxz&TestParsers.test_rfc2822_header_syntax�s���
�
��:���'��*�*��
��3�s�8�8�Q����
��6�)�)�S�)�)�)�)�)�+H�+H�+H�I�I�I�
��3�?�?���f�%�%�%�%�%r;c��|j}d}tj|��}|t|�����d��dS)Nz<>From foo@example.com 11:25:53
From: bar
!"#QUX;~: zoo

bodyr)r2r�rr�r�r�s    r9�(test_rfc2822_space_not_allowed_in_headerz4TestParsers.test_rfc2822_space_not_allowed_in_headersE��
�
��N���'��*�*��
��3�s�x�x�z�z�?�?�A�����r;c���|j}d}tj|��}|���}|���||gd���||���d��dS)Nz7A: first header
B: second header
CC: third header

body)�A�B�CCr�)r2r�rr��sortrZ)r6r7r�r8�headerss     r9�!test_rfc2822_one_character_headerz-TestParsers.test_rfc2822_one_character_headerst��
�
��I���'��*�*���(�(�*�*��������
��7�$�$�$�%�%�%�
��3�?�?���f�%�%�%�%�%r;c���d}tj|��}|�|�d������d����dS)Nz�From: foo@bar.com
To: baz
Mime-Version: 1.0
Content-Type: multipart/mixed; boundary=BOUNDARY

--BOUNDARY
Content-Type: text/plain

body ending with CRLF newline

--BOUNDARY--
rr�)r�rr�rZr}�r6r�r8s   r9�test_CRLFLF_at_end_of_partz&TestParsers.test_CRLFLF_at_end_of_parts\��

�	
��'��*�*���������*�*�6�6�8�8�A�A�&�I�I�J�J�J�J�Jr;)r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrr
rrrr{r;r9r�r�Zs%������	6�	6�	6�
C�
C�
C�(�(�(�
(�(�(�(�(�(�
(�(�(�;�;�;�$;�;�;�$	;�	;�	;�-�-�-��G�1�1�1�>I�I�I�	+�	+�	+�&�&�&����&�&�&�K�K�K�K�Kr;r�c��eZdZejd��Zd�Zd�Zd�Zd�Z	d�Z
d�ZdZd	�
d
�eD����dz�d��Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zejd���d��Zd�Zd�Zejd��Zd�Zd�Z d�Z!e�"d	��Z#dge#d d!�<d	�
e#��Z#d"�Z$ejd#���d$��Z%ejd%��Z&d&�Z'd'�Z(d(�Z)d)�Z*d*�Z+d+�Z,d,�Z-d-Z.d-S).�Test8BitBytesHandlingz�        From: foo@bar.com
        To: baz
        Mime-Version: 1.0
        Content-Type: text/plain; charset={charset}
        Content-Transfer-Encoding: {cte}

        {bodyline}
        c�X�|j�ddd����d��}tj|��}|�|���d��|�|�d���d�d����dS)NrVr`�pöstal�rAr��bodyline�pöstal
TrX��bodytest_msgr�r�r�r�r2rZrs   r9�test_known_8bit_CTEz)Test8BitBytesHandling.test_known_8bit_CTE7s�����$�$�W�)/�.7�
%�
9�
9�9?�����	
��&�q�)�)��������*�*�K�8�8�8���������5�5�$�+�+�G�4�4�	6�	6�	6�	6�	6r;c�X�|j�ddd����d��}tj|��}|�|���d��|�|�d���d	�d����dS)
N�notavalidcharsetr`rrrVup��stal
TrXrrrs   r9�test_unknown_8bit_CTEz+Test8BitBytesHandling.test_unknown_8bit_CTE@s�����$�$�-?�)/�.7�
%�
9�
9�9?�����	
��&�q�)�)��������*�*�,A�B�B�B���������5�5�$�+�+�G�4�4�	6�	6�	6�	6�	6r;c�X�|j�ddd����d��}tj|��}|�|���d��|�|�d���d�d����dS)	NrVrC�p=C3=B6stálru
p=C3=B6stál
TrX�	pöstál
rrs   r9�test_8bit_in_quopri_bodyz.Test8BitBytesHandling.test_8bit_in_quopri_bodyIs���
��$�$�W�);�.<�
%�
>�
>�>D�f�W�o�o�	
��&�q�)�)��������*�*�,<�=�=�=���������5�5�%�,�,�W�5�5�	7�	7�	7�	7�	7r;c�X�|j�ddd����d��}tj|��}|�|���d��|�|�d���d	�d����dS)
Nr�rCr%rrVup=C3=B6st��l
TrXr&rrs   r9�.test_invalid_8bit_in_non_8bit_cte_uses_replacezDTest8BitBytesHandling.test_invalid_8bit_in_non_8bit_cte_uses_replace[s���
��$�$�W�);�.<�
%�
>�
>�>D�f�W�o�o�	
��&�q�)�)��������*�*�,F�G�G�G���������5�5�$�+�+�G�4�4�	6�	6�	6�	6�	6r;c�^�|j�ddd����d��}tj|��}|�|�d���d�d����|�|jdtj
��dS)	NrVrWu
cMO2c3RhbAá=rTrXrr)rr�r�r�r�r2rZr�r�r r�rs   r9�test_8bit_in_base64_bodyz.Test8BitBytesHandling.test_8bit_in_base64_bodyks���
��$�$�W�)1�.=�
%�
?�
?�?E�v�g���	
��&�q�)�)����������5�5�"�)�)�'�2�2�	4�	4�	4����c�k�!�n�$�B�	D�	D�	D�	D�	Dr;c��|j�ddd����d��}tj|��}|�|�d���d�d����dS)NrVr�u
<,.V<W1A; á rTrXu<,.V<W1A; á 
rrs   r9�test_8bit_in_uuencode_bodyz0Test8BitBytesHandling.test_8bit_in_uuencode_bodyxs���
��$�$�W�)3�.=�
%�
?�
?�?E�v�g���	
��&�q�)�)����������5�5�*�1�1�'�:�:�	<�	<�	<�	<�	<r;))zFrom: foo@bar.com�r�rI)uTo: báz)r�z=?unknown-8bit?q?b=C3=A1z?=)uVSubject: Maintenant je vous présente mon collègue, le pouf célèbre
	Jean de Baddie)r�z�=?unknown-8bit?q?Maintenant_je_vous_pr=C3=A9sente_mon_coll=C3=A8gue=2C_le_pouf_c=C3=A9l=C3=A8bre?=
 =?unknown-8bit?q?_Jean_de_Baddie?=)uFrom: göst)r�z=?unknown-8bit?b?Z8O2c3Q=?=r*c��g|]\}}|��Sr{r{)r�src�_s   r9r�z Test8BitBytesHandling.<listcomp>�s�� H� H� H��#�q�� H� H� Hr;z
Yes, they are flying.
rVc��tj|j��}|�t	|�d����d��|�t	|d��d��dS)Nr��b��z)r�r��headertest_msgr2r�rrhs  r9�test_get_8bit_headerz*Test8BitBytesHandling.test_get_8bit_header�se���&�t�':�;�;������S�W�W�T�]�]�+�+�-=�>�>�>�����S��Y���)9�:�:�:�:�:r;c���tj|j��}|�t	|��tjd��jd�|jD�����dS)Nz�                            From: {}
                            To: {}
                            Subject: {}
                            From: {}

                            Yes, they are flying.
                            c�$�g|]
\}}|d��S)r�r{)rr1r�s   r9r�zATest8BitBytesHandling.test_print_8bit_headers.<locals>.<listcomp>�s2��*A�*A�*A�-�1�h�(�1�+�*A�*A�*Ar;)	r�r�r4r2r�r�r�r��headertest_headersrhs  r9�test_print_8bit_headersz-Test8BitBytesHandling.test_print_8bit_headers�s����&�t�':�;�;������S���(���* �!�!�"(�*A�*A�(,�(?�*A�*A�*A�B�		C�		C�		C�		C�		Cr;c��tj|j��}|�d�|���D��gd���dS)Nc�,�g|]}t|����Sr{�r�r�s  r9r�zGTest8BitBytesHandling.test_values_with_8bit_headers.<locals>.<listcomp>�s��;�;�;��c�!�f�f�;�;�;r;)rIr3�]Maintenant je vous pr��sente mon coll��gue, le pouf c��l��bre
	Jean de Baddie�	g��st)r�r�r4�assertListEqualr�rhs  r9�test_values_with_8bit_headersz3Test8BitBytesHandling.test_values_with_8bit_headers�s_���&�t�':�;�;�����;�;�c�j�j�l�l�;�;�;�2�2�2�	3�	3�	3�	3�	3r;c��tj|j��}|�d�|���D��gd���dS)Nc�P�g|]#\}}t|��t|��f��$Sr{r<)rr�r$s   r9r�zFTest8BitBytesHandling.test_items_with_8bit_headers.<locals>.<listcomp>�s-��I�I�I�6�A�q�s�1�v�v�s�1�v�v�.�I�I�Ir;)r.)r�r3)r�r=)r�r>)r�r�r4r?r�rhs  r9�test_items_with_8bit_headersz2Test8BitBytesHandling.test_items_with_8bit_headers�s_���&�t�':�;�;�����I�I�S�Y�Y�[�[�I�I�I�<�<�<�	=�	=�	=�	=�	=r;c��tj|j��}|�d�|�d��D��ddg��dS)Nc�,�g|]}t|����Sr{r<r�s  r9r�zHTest8BitBytesHandling.test_get_all_with_8bit_headers.<locals>.<listcomp>�s��B�B�B��c�!�f�f�B�B�Br;r�rIr>)r�r�r4r?r4rhs  r9�test_get_all_with_8bit_headersz4Test8BitBytesHandling.test_get_all_with_8bit_headers�s_���&�t�':�;�;�����B�B�c�k�k�&�.A�.A�B�B�B�,�0�2�	3�	3�	3�	3�	3r;c�h�tjtjd���d����}|�|���d��|�|���d��|�|���d��dS)NuA            Content-Type: text/pl§in; charset=utf-8
            r�utext/pl�inr�upl�in)	r�r�r�r�r�r2rHrtr�rhs  r9�test_get_content_type_with_8bitz5Test8BitBytesHandling.test_get_content_type_with_8bit�s����&�x��8�(�(���	�"�"�$�$��	
����-�-�/�/�1B�C�C�C�����1�1�3�3�V�<�<�<�����0�0�2�2�L�A�A�A�A�Ar;c�X�tjd�d����}|�|�d���gd���|�|�dd���d��|�|�dd���d��dS)	Nu(X-Header: foo=§ne; b§r=two; baz=three
r�rr))r���ne)ub�rrr�FoorJub§r)r�r�r�r2rrIrhs  r9�test_get_params_with_8bitz/Test8BitBytesHandling.test_get_params_with_8bit�s����&�;�B�B�9�M�M�O�O��������z��:�:�G�G�G�	I�	I�	I�������u�Z��@�@�*�M�M�M�������x�
��C�C�T�J�J�J�J�Jr;c���tjtjd���d����}|�|�d��d��dS)N�n            Content-Type: text/plain; charset=us-ascii;
             title*=us-ascii'en'This%20is%20not%20f§nr��title)rN�enuThis is not f�n)r�r�r�r�r�r2rIrhs  r9�!test_get_rfc2231_params_with_8bitz7Test8BitBytesHandling.test_get_rfc2231_params_with_8bit�sk���&�x��8<�(�(��v�i� � �"�"��	
������w�/�/�6�	8�	8�	8�	8�	8r;c��tjtjd���d����}|�dd��|�|�d��d��dS)NrNr�rO�test)r�r�r�r�r�r9r2rIrhs  r9�!test_set_rfc2231_params_with_8bitz7Test8BitBytesHandling.test_set_rfc2231_params_with_8bit�st���&�x��8<�(�(��v�i� � �"�"��	�
�
�g�v�&�&�&�������w�/�/��8�8�8�8�8r;c�D�tjtjd���d����}|�d��|�|�d��d��|�|���d��dS)NrNr�rOr�)	r�r�r�r�r�rCr2rIrtrhs  r9�!test_del_rfc2231_params_with_8bitz7Test8BitBytesHandling.test_del_rfc2231_params_with_8bit�s����&�x��8<�(�(��v�i� � �"�"��	�
�
�g����������w�/�/��6�6�6�����1�1�3�3�V�<�<�<�<�<r;c��tjtjd���d����}|�|���d��|�|�d���d��dS)Nu�            Content-Transfer-Encoding: b§se64
            Content-Type: text/plain; charset=latin-1

            payload
            r�zpayload
TrXspayload
)r�r�r�r�r�r2rZrhs  r9�%test_get_payload_with_8bit_cte_headerz;Test8BitBytesHandling.test_get_payload_with_8bit_cte_header�s����&�x��8�(�(�
��	�"�"�$�$��	
������*�*�K�8�8�8���������5�5�|�D�D�D�D�Dr;u0        From: foo@bar.com
        To: báz
        Subject: Maintenant je vous présente mon collègue, le pouf célèbre
        	Jean de Baddie
        Mime-Version: 1.0
        Content-Type: text/plain; charset="utf-8"
        Content-Transfer-Encoding: 8bit

        Да, они летят.
        c��tj|j��}t��}tj�|���|��|�|���|j��dSrf)	r�r��non_latin_bin_msgrr�r
r�r2r��r6r8r�s   r9�test_bytes_generatorz*Test8BitBytesHandling.test_bytes_generatorsi���&�t�'=�>�>���i�i��
��&�&�s�+�+�3�3�C�8�8�8����������)?�@�@�@�@�@r;c��tj���}t��}tj�|���|��|�|���d��dS)Nr�)	r�rwrrr�r
r�r2r�r[s   r9�&test_bytes_generator_handles_None_bodyz<Test8BitBytesHandling.test_bytes_generator_handles_None_bodysf���m�#�#�%�%���i�i��
��&�&�s�+�+�3�3�C�8�8�8����������/�/�/�/�/r;a�        From: foo@bar.com
        To: =?unknown-8bit?q?b=C3=A1z?=
        Subject: =?unknown-8bit?q?Maintenant_je_vous_pr=C3=A9sente_mon_coll=C3=A8gue?=
         =?unknown-8bit?q?=2C_le_pouf_c=C3=A9l=C3=A8bre?=
         =?unknown-8bit?q?_Jean_de_Baddie?=
        Mime-Version: 1.0
        Content-Type: text/plain; charset="utf-8"
        Content-Transfer-Encoding: base64

        0JTQsCwg0L7QvdC4INC70LXRgtGP0YIuCg==
        c��tj|j��}t��}tj�|���|��|�|���|j	��dSrf)
r�r�rZrr�rr�r2r�� non_latin_bin_msg_as7bit_wrappedr[s   r9�test_generator_handles_8bitz1Test8BitBytesHandling.test_generator_handles_8bitsi���&�t�'=�>�>���j�j��
��!�!�#�&�&�.�.�s�3�3�3����������)N�O�O�O�O�Or;c���tj|j��}t��}t	|���|��|���}tt�����|��t��}t	|���|��|�	|���|��dSrf)
r�r�rZrr
r�r�rrr2)r6r8r��
orig_values    r9�;test_str_generator_should_not_mutate_msg_when_handling_8bitzQTest8BitBytesHandling.test_str_generator_should_not_mutate_msg_when_handling_8bit!s����&�t�'=�>�>���i�i���s���#�#�C�(�(�(��\�\�^�^�
��(�*�*���%�%�c�*�*�*��i�i���s���#�#�C�(�(�(����������4�4�4�4�4r;c���tj|j��}t��}tj�|���|d���|����d��}|�	|d���dd��|�	d�
|dd���|j��dS)NTr�r�rsFromr�)r�r�rZrr�r
r�r�r�r2r�)r6r8r�r�s    r9�#test_bytes_generator_with_unix_fromz9Test8BitBytesHandling.test_bytes_generator_with_unix_from+s����&�t�'=�>�>���i�i��
��&�&�s�+�+�3�3�C�$�3�G�G�G������$�$�U�+�+������q����)�)�!�,�g�6�6�6�������E�!�"�"�I�.�.��0F�G�G�G�G�Gr;zkSubject: =?unknown-8bit?q?Maintenant_je_vous_pr=C3=A9sente_mon_coll=C3=A8gue=2C_le_pouf_c=C3=A9l=C3=A8bre?=r�r�c���d}|�t|��t|d��5}|�|j��ddd��n#1swxYwYt|d��5}t
j����|��}ddd��n#1swxYwY|�	t|��|j��dS)Nztest.msg�wbr�)�
addCleanupr%�open�writerZr�r�r�r�r2r��non_latin_bin_msg_as7bit)r6r��testfiler�s    r9�test_message_from_binary_filez3Test8BitBytesHandling.test_message_from_binary_file<s6��
�������#�#�#�
�"�d�^�^�	3�x��N�N�4�1�2�2�2�	3�	3�	3�	3�	3�	3�	3�	3�	3�	3�	3����	3�	3�	3�	3�
�"�d�^�^�	;�x���(�(�*�*�0�0��:�:�A�	;�	;�	;�	;�	;�	;�	;�	;�	;�	;�	;����	;�	;�	;�	;�����Q����!>�?�?�?�?�?s#�A�A�A�02B.�.B2�5B2u        From: foo@bar.com
        To: Dinsdale
        Subject: Nudge nudge, wink, wink
        Mime-Version: 1.0
        Content-Type: text/plain; charset="latin-1"
        Content-Transfer-Encoding: 8bit

        oh là là, know what I mean, know what I mean?
        r�a         From: foo@bar.com
        To: Dinsdale
        Subject: Nudge nudge, wink, wink
        Mime-Version: 1.0
        Content-Type: text/plain; charset="iso-8859-1"
        Content-Transfer-Encoding: quoted-printable

        oh l=E0 l=E0, know what I mean, know what I mean?
        c��tj|j��}|�t	|��|j��dSrf)r�r��
latin_bin_msgr2r��latin_bin_msg_as7bitr�s  r9�:test_string_generator_reencodes_to_quopri_when_appropriatezPTest8BitBytesHandling.test_string_generator_reencodes_to_quopri_when_appropriate[s:���$�T�%7�8�8������Q����!:�;�;�;�;�;r;c�>�tj|j��}t��}tj�|���|��|�|���|j�	d��dz��dS)Nr�r*)
r�r�rprr�rr�r2r�rY)r6r�r�s   r9�)test_decoded_generator_emits_unicode_bodyz?Test8BitBytesHandling.test_decoded_generator_emits_unicode_body_s����$�T�%7�8�8���j�j��
��(�(��-�-�5�5�a�8�8�8�	
����������%�%�i�0�0��5�	7�	7�	7�	7�	7r;c�P�tj���}tdt	|j��d��D]'}|�|j||dz����(|���}|�t|��|j
��dS)NrrK)r�r�r)rOr�rpr�r�r2r�rq)r6�bfprIr�s    r9�test_bytes_feedparserz+Test8BitBytesHandling.test_bytes_feedparseris�����.�.�0�0���q�#�d�0�1�1�2�6�6�	1�	1�A��H�H�T�'��!�B�$��/�0�0�0�0��I�I�K�K������Q����!:�;�;�;�;�;r;c�~�tdd��5}|���}ddd��n#1swxYwYtj|��}t	��}tj�|��}|�|d���|�|�	��|��dS)Nr�r�r�r�)
r&r�r�r�rr�r
r�r2r�r�s      r9r�z'Test8BitBytesHandling.test_crlf_flattenps���
�l�D�
)�
)�	�R��7�7�9�9�D�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	��&�t�,�,���I�I���O�*�*�1�-�-��	�	�	�#�v�	�&�&�&���������t�,�,�,�,�,rc�P�tjd���d��}tj|��}t��}tj�|��}|�|��|�	|�
��|��dS)Nuo            Date: Fri, 18 Mar 2011 17:15:43 +0100
            To: foo@example.com
            From: foodwatch-Newsletter <bar@example.com>
            Subject: Aktuelles zu Japan, Klonfleisch und Smiley-System
            Message-ID: <76a486bee62b0d200f33dc2ca08220ad@localhost.localdomain>
            MIME-Version: 1.0
            Content-Type: multipart/alternative;
                    boundary="b1_76a486bee62b0d200f33dc2ca08220ad"

            --b1_76a486bee62b0d200f33dc2ca08220ad
            Content-Type: text/plain; charset="utf-8"
            Content-Transfer-Encoding: 8bit

            Guten Tag, ,

            mit großer Betroffenheit verfolgen auch wir im foodwatch-Team die
            Nachrichten aus Japan.


            --b1_76a486bee62b0d200f33dc2ca08220ad
            Content-Type: text/html; charset="utf-8"
            Content-Transfer-Encoding: 8bit

            <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                "http://www.w3.org/TR/html4/loose.dtd">
            <html lang="de">
            <head>
                    <title>foodwatch - Newsletter</title>
            </head>
            <body>
              <p>mit gro&szlig;er Betroffenheit verfolgen auch wir im foodwatch-Team
                 die Nachrichten aus Japan.</p>
            </body>
            </html>
            --b1_76a486bee62b0d200f33dc2ca08220ad--

            rV)r�r�r�r�r�rr�r
r�r2r�)r6r�r8r�r�s     r9�test_8bit_multipartz)Test8BitBytesHandling.test_8bit_multipartys�����%"�%�%�J�����K	�L�&�v�.�.���I�I���O�*�*�1�-�-��	�	�	�#������������v�.�.�.�.�.r;c��t��}td��|d<t��}tj�|��}|�|d���|�|���d��dS)N�žluťoučký kůňr�r�r�s5Subject: =?utf-8?b?xb5sdcWlb3XEjWvDvSBrxa/FiA==?=

)	rrrr�r�r
r�r2r��r6r�r�r�s    r9�'test_bytes_generator_b_encoding_linesepz=Test8BitBytesHandling.test_bytes_generator_b_encoding_linesep�s����I�I���3�4�4��)���I�I���O�*�*�1�-�-��	�	�	�!�V�	�$�$�$����
�J�J�L�L�H�	J�	J�	J�	J�	Jr;c��t��}td��|d<t��}tj�|��}|�|d���|�|���d��dS)Nr|r�r�r�z5Subject: =?utf-8?b?xb5sdcWlb3XEjWvDvSBrxa/FiA==?=

)	rrrr�r�rr�r2r�r}s    r9�!test_generator_b_encoding_linesepz7Test8BitBytesHandling.test_generator_b_encoding_linesep�s����I�I���3�4�4��)���J�J���O�%�%�a�(�(��	�	�	�!�V�	�$�$�$����
�J�J�L�L�G�	I�	I�	I�	I�	Ir;N)/r�r�r�r�r�rr r#r'r)r+r-r8r�r�r4r5r9r@rCrFrHrLrQrTrVrXrZr\r^r`rardrfr�rlrnrprqrrrtrwr�rzr~r�r�r{r;r9rr$s"������#�8�?�$�
�
�L�6�6�6�6�6�6�7�7�7�$
6�
6�
6� D�D�D�<�<�<�	
���i�i� H� H�5G� H� H� H�I�I�#�$�%+�V�G�_�_��;�;�;�
C�C�C�	3�	3�	3�
=�
=�
=�3�3�3�B�B�B�K�K�K�8�8�8�9�9�9�=�=�=�E�E�E�(���
)�

�

��V�G�_�_��A�A�A�0�0�0�(7�x��8�(
�(
�$�P�P�P�5�5�5�	H�	H�	H� @�E�E�d�K�K��	8�%9��Q�q�S�!� $�y�y�)A�B�B��@�@�@�$�H�O�	%�	
�	
��V�I�
�
��+�8�?�	,�	
�	
��<�<�<�7�7�7�<�<�<�-�-�-�,/�,/�,/�\
J�
J�
J�
I�
I�
I��G�G�Gr;rc� �eZdZdZd�Zdd�ZdS)� BaseTestBytesGeneratorIdempotentNc���t|d��5}|���}ddd��n#1swxYwY|j�|j|��}tj|��}||fS)Nr�)r&r��normalize_linesep_regex�sub�blinesepr�r�rKs     r9r3z(BaseTestBytesGeneratorIdempotent._msgobj�s���
�h��
%�
%�	���7�7�9�9�D�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	��+�/�/��
�t�D�D���&�t�,�,���D�y�rFc���t��}tj�|d���}|�|||j���|�||�����dS)Nrr{)r�r�)rr�r�r
r�r�r2r�)r6r8r\r�r�r�s      r9rMz,BaseTestBytesGeneratorIdempotent._idempotent�sc���I�I���O�*�*�1�1�*�=�=��	�	�	�#��$�,�	�?�?�?�����q�z�z�|�|�,�,�,�,�,r;r�)r�r�r�r�r3rMr{r;r9r�r��s<�������G����-�-�-�-�-�-r;r�c�6�eZdZdZdZejd��ZdS)�TestBytesGeneratorIdempotentNLr*r�s\r\nN�r�r�r�r�r��re�compiler�r{r;r9r�r��s,�������G��H�(�b�j��2�2���r;r�c�6�eZdZdZdZejd��ZdS)� TestBytesGeneratorIdempotentCRLFr�r�s	(?<!\r)\nNr�r{r;r9r�r��s,�������G��H�(�b�j��7�7���r;r�c�&�eZdZd�Zd�Zd�Zd�ZdS)�
TestBase64c	�V�|j}|tjd��ttjdd�������td��D]R}|dkrd}n&|dkrd}n|d	krd
}n|dkrd}n|dkrd
}nd}|tjd|z��|���SdS)N�hello�hellor+��eol�rr�r�r��r��r��r�)r2r�
header_lengthr��body_encoderO)r6r7�size�bsizes    r9�test_lenzTestBase64.test_len�s���
�
��
��:�#�G�,�,��z�%�h�B�7�7�7�8�8�	:�	:�	:��"�I�I�	<�	<�D����
(�Q�U�U����
(�Q�U�U����
(�Q�U�U����
(�R�U�U����
(�R�U�U�%'�U��B�z�'��d�
�3�3�U�;�;�;�;�	<�	<r;c��|j}|tjd��d��|tjd��d��dS)Nr+r;zaGVsbG8=r�)r2rrYr�s  r9�test_decodezTestBase64.test_decode�sJ��
�
��
��:��R� � �#�&�&�&�
��:��Z�(�(�(�3�3�3�3�3r;c�J�|j}|tjd��d��|tjd��d��|tjd��d��|tjdd�	��d
��|tjddd���d
��dS)Nr;r+r�z	aGVsbG8=
shello
z	aGVsbG8K
sdxxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx �(r&z�eHh4eCB4eHh4IHh4eHggeHh4eCB4eHh4IHh4eHgg
eHh4eCB4eHh4IHh4eHggeHh4eCB4eHh4IHh4eHgg
eHh4eCB4eHh4IHh4eHggeHh4eCB4eHh4IHh4eHgg
eHh4eCB4eHh4IA==
r��r'r�z�eHh4eCB4eHh4IHh4eHggeHh4eCB4eHh4IHh4eHgg
eHh4eCB4eHh4IHh4eHggeHh4eCB4eHh4IHh4eHgg
eHh4eCB4eHh4IHh4eHggeHh4eCB4eHh4IHh4eHgg
eHh4eCB4eHh4IA==
)r2rr�r�s  r9�test_encodezTestBase64.test_encode�s���
�
��
��:�!�#�&�&��+�+�+�
��:�!�(�+�+�\�:�:�:�
��:�!�*�-�-�|�<�<�<�
��:�!�-�B�?�?�?�B�	�	�	�	��:�!�-�B�F�K�K�K��	�	�	�	�	r;c��|j}tj}||d��d��||d��d��||d��d��||dd���d	��||d��d��dS)
Nr�z=?iso-8859-1?b?aGVsbG8=?=�hello
worldz!=?iso-8859-1?b?aGVsbG8NCndvcmxk?=�hello
worldz!=?iso-8859-1?b?aGVsbG8Kd29ybGQ=?=rrrSz=?iso-8859-2?b?aGVsbG8=?=)r2rr)r6r7�hes   r9�test_header_encodezTestBase64.test_header_encodes���
�
��
�
%��
��2�2�g�;�;�3�4�4�4�
��2�2����!D�E�E�E�
��2�2�n���B�C�C�C�
��2�2�g�|�,�,�,�.I�J�J�J�
��2�2�n���B�C�C�C�C�Cr;N)r�r�r�r�r�r�r�r{r;r9r�r��sU������<�<�<�4�4�4�
���,D�D�D�D�Dr;r�c��eZdZd�Zd�Zd�Zd�Zd�Zd�ZdEd�Z	d	�Z
d
�Zd�Zd�Z
d
�Zd�Zd�Zd�Zd�Zd�Zd�ZdEd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z d �Z!d!�Z"d"�Z#d#�Z$d$�Z%d%�Z&d&�Z'd'�Z(d(�Z)d)�Z*d*�Z+d+�Z,dFd,�Z-d-�Z.d.�Z/d/�Z0d0�Z1d1�Z2d2�Z3d3�Z4d4�Z5d5�Z6d6�Z7d7�Z8d8�Z9d9�Z:d:�Z;d;�Z<d<�Z=d=�Z>d>�Z?d?�Z@d@�ZAdA�ZBdB�ZCdC�ZDdD�ZEdS)G�
TestQuopric���ttttd��td��dz��ttd��td��dz��ttd��td��dz��d�d	D�������_�fd
�td��D���_t
�j��t
�j��zdksJ�tttd��td
��dz�����_�j�td�����j�	td�����fd�td��D���_
t
�j��t
�j
��zdksJ�dS)Nr��zr�r�Zr��9c3�K�|]}|V��dSrfr{)rr�s  r9rJz#TestQuopri.setUp.<locals>.<genexpr>s"����!�!�1�Q�!�!�!�!�!�!r;s!*+-/c�&��g|]
}|�jv�|��Sr{)�hlit�rr�r6s  �r9r�z$TestQuopri.setUp.<locals>.<listcomp>!�%���A�A�A�1�a�t�y�.@�A�Q�A�A�Ar;�r,�~r�=c�&��g|]
}|�jv�|��Sr{)�blitr�s  �r9r�z$TestQuopri.setUp.<locals>.<listcomp>*r�r;)r�rrO�ordr��hnonr�r�r(�remove�bnonr�s`r9r�zTestQuopri.setUps�������#�c�(�(�C��H�H�q�L�)�)��#�c�(�(�C��H�H�q�L�)�)��#�c�(�(�C��H�H�q�L�)�)�!�!��!�!�!�	#�#�$�$��	�B�A�A�A��c�
�
�A�A�A��	��4�9�~�~��D�I���.�#�5�5�5�5���s�3�x�x��S���A��6�6�7�7��	��	����T���#�#�#��	����S���"�"�"�B�A�A�A��c�
�
�A�A�A��	��4�9�~�~��D�I���.�#�5�5�5�5�5�5r;c��|jD]:}|�tj|��dt	|��z���;|jD]:}|�tj|��dt	|��z���;dS)Nz'Should not be header quopri encoded: %sz#Should be header quopri encoded: %s)r�rr"�header_check�chrr�r��r6r�s  r9�test_quopri_header_checkz#TestQuopri.test_quopri_header_check-s�����	L�	L�A����Z�4�Q�7�7�A�C��F�F�J�
L�
L�
L�
L���	L�	L�A��O�O�J�3�A�6�6�A�C��F�F�J�
L�
L�
L�
L�	L�	Lr;c��|jD]:}|�tj|��dt	|��z���;|jD]:}|�tj|��dt	|��z���;dS)Nz%Should not be body quopri encoded: %sz!Should be body quopri encoded: %s)r�rr"�
body_checkr�r�r�r�s  r9�test_quopri_body_checkz!TestQuopri.test_quopri_body_check5s�����	J�	J�A����Z�2�1�5�5�?�#�a�&�&�H�
J�
J�
J�
J���	J�	J�A��O�O�J�1�!�4�4�?�#�a�&�&�H�
J�
J�
J�
J�	J�	Jr;c	��|j}|tjd��d��|ttjdd�����tjd��dz��|tjd��d��|ttjdd�����tjd��dz��|jD]?}|tjt
|g����dd	t|��z���@|jD]S}|td
��kr�|tjt
|g����ddt|��z���T|tjd
��d��dS)Nr�r��xxxrSrKs
h@e@l@l@o@r�r�zexpected length 1 for %rr,r�zexpected length 3 for %r� )
r2r"r�r�rr�r�r�r�r��r6r7r�s   r9�test_header_quopri_lenz!TestQuopri.test_header_quopri_len=s���
�
��
��:�#�H�-�-�q�1�1�1�
��3�z�'��%�@�@�@�A�A��#�H�-�-�
��	�	�	�	��:�#�M�2�2�B�7�7�7�
��3�z�'�
�u�E�E�E�F�F��#�M�2�2�
��	�	�	���	4�	4�A��B�z�'��q�c�
�
�3�3�Q�)�C��F�F�2�
4�
4�
4�
4���	4�	4�A��C��H�H�}�
���B�z�'��q�c�
�
�3�3�Q�)�C��F�F�2�
4�
4�
4�
4�
��:�#�D�)�)�1�-�-�-�-�-r;c���|j}|jD].}|tjt	|g����d���/|jD].}|tjt	|g����d���/dS)Nr�r�)r2r�r"�body_lengthr�r�r�s   r9�test_body_quopri_lenzTestQuopri.test_body_quopri_lenVs���
�
����	6�	6�A��B�z�%�e�Q�C�j�j�1�1�1�5�5�5�5���	6�	6�A��B�z�%�e�Q�C�j�j�1�1�1�5�5�5�5�	6�	6r;c��td��D]K}t|��}|�tjtj|����|���LdS)Nr�)rOr�r2r"r*�quote)r6r�r�s   r9�test_quote_unquote_idempotentz(TestQuopri.test_quote_unquote_idempotent]s_���s���	I�	I�A��A���A����Z�/�
�0@��0C�0C�D�D�a�H�H�H�H�	I�	Ir;Nc��|�tj|��}ntj||��}|�||��dSrf)r"rr2)r6r��expected_encoded_headerrA�encoded_headers     r9�_test_header_encodezTestQuopri._test_header_encodebsL���	G�'�5�f�=�=�N�N�'�5�f�g�F�F�N�����)@�A�A�A�A�Ar;c�2�|�dd��dS)Nr;r+�r�r�s r9�test_header_encode_nullz"TestQuopri.test_header_encode_nullis��� � ��b�)�)�)�)�)r;c�2�|�dd��dS)Nr�z=?iso-8859-1?q?hello?=r�r�s r9�test_header_encode_one_wordz&TestQuopri.test_header_encode_one_wordls��� � ��+C�D�D�D�D�Dr;c�2�|�dd��dS)Nshello
worldz=?iso-8859-1?q?hello=0Aworld?=r�r�s r9�test_header_encode_two_linesz'TestQuopri.test_header_encode_two_linesos.��� � �� @�	B�	B�	B�	B�	Br;c�2�|�dd��dS)Nshello�therez=?iso-8859-1?q?hello=C7there?=r�r�s r9�test_header_encode_non_asciiz'TestQuopri.test_header_encode_non_asciiss/��� � �!2� @�	B�	B�	B�	B�	Br;c�6�|�ddd���dS)Nr�z=?iso-8859-2?q?hello?=rrrSr�r�s r9�test_header_encode_alt_charsetz)TestQuopri.test_header_encode_alt_charsetws1��� � ��+C�$�	!�	&�	&�	&�	&�	&r;c�Z�tj|��}|�||��dSrf)r"�
header_decoder2)r6r��expected_decoded_header�decoded_headers    r9�_test_header_decodezTestQuopri._test_header_decode{s/��#�1�.�A�A������)@�A�A�A�A�Ar;c�2�|�dd��dS�Nr+�r�r�s r9�test_header_decode_nullz"TestQuopri.test_header_decode_nulls��� � ��R�(�(�(�(�(r;c�2�|�dd��dS�Nr�r�r�s r9�test_header_decode_one_wordz&TestQuopri.test_header_decode_one_word�s��� � ��'�2�2�2�2�2r;c�2�|�dd��dS)Nz
hello=0Aworldr�r�r�s r9�test_header_decode_two_linesz'TestQuopri.test_header_decode_two_lines�s��� � ��.�A�A�A�A�Ar;c�2�|�dd��dS)Nz
hello=C7thereuhelloÇtherer�r�s r9�test_header_decode_non_asciiz'TestQuopri.test_header_decode_non_ascii�s��� � ��2B�C�C�C�C�Cr;c�V�|�tjd��d��dS)Na=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30�00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000)r2r"r�r�s r9�test_header_decode_re_bug_18380z*TestQuopri.test_header_decode_re_bug_18380�s)������1�+�>�>�	�J�J�J�J�Jr;c��|�tj|��}ntj||���}|�||��dS)Nr�)r"rYr2)r6�encoded�expected_decodedr��decodeds     r9�_test_decodezTestQuopri._test_decode�sN���	:� �'��0�0�G�G� �'��S�9�9�9�G�����"2�3�3�3�3�3r;c�2�|�dd��dSr��r�r�s r9�test_decode_null_wordz TestQuopri.test_decode_null_word�������"�b�!�!�!�!�!r;c�2�|�dd��dS)Nr�r*r�r�s r9�test_decode_null_line_null_wordz*TestQuopri.test_decode_null_line_null_word�s�����&�$�'�'�'�'�'r;c�2�|�dd��dSr�r�r�s r9�test_decode_one_wordzTestQuopri.test_decode_one_word�s�����'�7�+�+�+�+�+r;c�6�|�ddd���dS)Nr��Xr�r�r�s r9�test_decode_one_word_eolz#TestQuopri.test_decode_one_word_eol�s#�����'�7���4�4�4�4�4r;c�2�|�dd��dS�N�hello
�hello
r�r�s r9�test_decode_one_linezTestQuopri.test_decode_one_line�������+�y�1�1�1�1�1r;c�2�|�dd��dS�Nrr�r�s r9�test_decode_one_line_lfz"TestQuopri.test_decode_one_line_lf�������)�Y�/�/�/�/�/r;c�2�|�dd��dS)Nzhello
rr�r�s r9�test_decode_one_line_crz"TestQuopri.test_decode_one_line_cr�rr;c�6�|�ddd���dS)Nr�helloXrr�r�r�s r9�test_decode_one_line_nlz"TestQuopri.test_decode_one_line_nl�s#�����)�X�3��7�7�7�7�7r;c�6�|�ddd���dS)Nrrrr�r�r�s r9�test_decode_one_line_crnlz$TestQuopri.test_decode_one_line_crnl�s#�����+�x�S��9�9�9�9�9r;c�2�|�dd��dS)Nr�r�r�r�s r9�test_decode_one_line_one_wordz(TestQuopri.test_decode_one_line_one_word�s�����*�N�;�;�;�;�;r;c�6�|�ddd���dS)Nr��helloXworldrr�r�r�s r9�!test_decode_one_line_one_word_eolz,TestQuopri.test_decode_one_line_one_word_eol�s$�����*�M�s��C�C�C�C�Cr;c�2�|�dd��dS)N�hello
world
�hello
world
r�r�s r9�test_decode_two_linesz TestQuopri.test_decode_two_lines�s �����.�0@�A�A�A�A�Ar;c�6�|�ddd���dS)Nr�helloXworldXrr�r�r�s r9�test_decode_two_lines_eolz$TestQuopri.test_decode_two_lines_eol�s$�����.��C��H�H�H�H�Hr;c�2�|�dd��dS)N��SpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamr�r�s r9�test_decode_one_long_linez$TestQuopri.test_decode_one_long_line�s�����,��5�5�5�5�5r;c�2�|�dd��dS)Nr,r+r�r�s r9�test_decode_one_spacez TestQuopri.test_decode_one_space�s�����#�r�"�"�"�"�"r;c�2�|�dd��dS)Nz     r+r�r�s r9�test_decode_multiple_spacesz&TestQuopri.test_decode_multiple_spaces�s�����'�2�&�&�&�&�&r;c�2�|�dd��dS)Nzhello    
rr�r�s r9�$test_decode_one_line_trailing_spacesz/TestQuopri.test_decode_one_line_trailing_spaces�s�����/�9�5�5�5�5�5r;c�2�|�dd��dS)Nzhello    
world   
rr�r�s r9�%test_decode_two_lines_trailing_spacesz0TestQuopri.test_decode_two_lines_trailing_spaces�s �����5�7G�H�H�H�H�Hr;c�2�|�dd��dS)Nz=22quoted=20words=22z"quoted words"r�r�s r9�test_decode_quoted_wordz"TestQuopri.test_decode_quoted_word�s �����0�2B�C�C�C�C�Cr;c�2�|�dd��dS)Nzab=CD=EF�abÍïr�r�s r9�test_decode_uppercase_quotingz(TestQuopri.test_decode_uppercase_quoting�������*�l�3�3�3�3�3r;c�2�|�dd��dS)Nzab=cd=efr.r�r�s r9�test_decode_lowercase_quotingz(TestQuopri.test_decode_lowercase_quoting�r0r;c�2�|�dd��dS)Nzsoft line=
breakzsoft linebreakr�r�s r9�test_decode_soft_line_breakz&TestQuopri.test_decode_soft_line_break�s �����/�1A�B�B�B�B�Br;c�2�|�dd��dS)NzA=1,B=A ==> A+B==2r�r�s r9�test_decode_false_quotingz$TestQuopri.test_decode_false_quoting�s �����.�0D�E�E�E�E�Er;c��i}|�d}n||d<|�d}n||d<tj|fi|��}|�||��|dks|dkr:|���D]'}|�t|��|���&dSdS)Nr�r'r*r�r�)r"r�r2r�r�r�)r6r��expected_encoded_bodyr'r��kwargs�encoded_bodyr�s        r9�_test_encodezTestQuopri._test_encode�s������	.��J�J�#-�F�<� ��	 ��C�C��F�5�M�!�-�d�=�=�f�=�=������'<�=�=�=��$�;�	<�#��-�	<�%�/�/�1�1�
<�
<���$�$�S��Y�Y�
�;�;�;�;�		<�	<�
<�
<r;c�2�|�dd��dSr��r;r�s r9�test_encode_nullzTestQuopri.test_encode_null�r�r;c�2�|�dd��dS)Nz

r=r�s r9�test_encode_null_linesz!TestQuopri.test_encode_null_lines�s�����&�&�)�)�)�)�)r;c�2�|�dd��dSr
r=r�s r9�test_encode_one_linezTestQuopri.test_encode_one_line�rr;c�2�|�dd��dSrr=r�s r9�test_encode_one_line_crlfz$TestQuopri.test_encode_one_line_crlf�rr;c�6�|�ddd���dS)Nrrr�r�r=r�s r9�test_encode_one_line_eolz#TestQuopri.test_encode_one_line_eol�s#�����)�[�f��=�=�=�=�=r;c��|�d�d���d��dd���dS)Nuhelloυ
rV�latin1z
hello=CF=85
r�r�)r;r�rYr�s r9�(test_encode_one_line_eol_after_non_asciiz3TestQuopri.test_encode_one_line_eol_after_non_ascii�sL�����/�0�0��9�9�@�@��J�J�+��	�	9�	9�	9�	9�	9r;c�2�|�dd��dS)Nr,z=20r=r�s r9�test_encode_one_spacez TestQuopri.test_encode_one_spaces�����#�u�%�%�%�%�%r;c�2�|�dd��dS)Nz 
z=20
r=r�s r9�test_encode_one_line_one_spacez)TestQuopri.test_encode_one_line_one_spaces�����%��)�)�)�)�)r;c�2�|�dd��dS)Nz 
 
z=20
=20
r=r�s r9�test_encode_two_lines_one_spacez*TestQuopri.test_encode_two_lines_one_spaces�����(�L�1�1�1�1�1r;c�2�|�dd��dS)Nzhello   z
hello  =20r=r�s r9�$test_encode_one_word_trailing_spacesz/TestQuopri.test_encode_one_word_trailing_spacesr0r;c�2�|�dd��dS)Nz	hello   
zhello  =20
r=r�s r9�$test_encode_one_line_trailing_spacesz/TestQuopri.test_encode_one_line_trailing_spacess�����,��7�7�7�7�7r;c�2�|�dd��dS)Nzhello  	z
hello  =09r=r�s r9�!test_encode_one_word_trailing_tabz,TestQuopri.test_encode_one_word_trailing_tabs�����+�|�4�4�4�4�4r;c�2�|�dd��dS)Nz	hello  	
zhello  =09
r=r�s r9�!test_encode_one_line_trailing_tabz,TestQuopri.test_encode_one_line_trailing_tabs�����-��8�8�8�8�8r;c�6�|�ddd���dS)N�
abcd 
1234zabcd =

1234r�r&r=r�s r9�,test_encode_trailing_space_before_maxlinelenz7TestQuopri.test_encode_trailing_space_before_maxlinelens$�����-�)9�a��H�H�H�H�Hr;c�6�|�ddd���dS)NrYzabcd=
=20
1234r�r&r=r�s r9�(test_encode_trailing_space_at_maxlinelenz3TestQuopri.test_encode_trailing_space_at_maxlinelen �$�����-�);���J�J�J�J�Jr;c�6�|�ddd���dS)NrYzabc=
d=20
1234r�r&r=r�s r9�,test_encode_trailing_space_beyond_maxlinelenz7TestQuopri.test_encode_trailing_space_beyond_maxlinelen#r]r;c�2�|�dd��dS)Nz
 
 
 
 
 
z=20
=20
=20
=20
=20
r=r�s r9�test_encode_whitespace_linesz'TestQuopri.test_encode_whitespace_lines&s�����)�[�1�1�1�1�1r;c�2�|�dd��dS)Nza = bza =3D br=r�s r9�test_encode_quoted_equalsz$TestQuopri.test_encode_quoted_equals)s�����'�9�-�-�-�-�-r;c�2�|�dd��dS)N�dxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxzfxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx=
xxxxxxxxxxxxxxxxxxxxxxxxxr=r�s r9�test_encode_one_long_stringz&TestQuopri.test_encode_one_long_string,s�����)�%@�A�A�A�A�Ar;c�2�|�dd��dS)Nzexxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
zgxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx=
xxxxxxxxxxxxxxxxxxxxxxxxx
r=r�s r9�test_encode_one_long_linez$TestQuopri.test_encode_one_long_line/s �����*�,N�O�O�O�O�Or;c�2�|�dd��dS)Nz�xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
z�xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx=
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx=
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
r=r�s r9�test_encode_one_very_long_linez)TestQuopri.test_encode_one_very_long_line2s*�����*�8�	:�	:�	:�	:�	:r;c�6�|�ddd���dS)Nz=====z=3D=
=3D=
=3D=
=3D=
=3Dr�r&r=r�s r9�test_encode_shortest_maxlinelenz*TestQuopri.test_encode_shortest_maxlinelen6s$�����'�#7�A��F�F�F�F�Fr;c�N�|�t|jddd���dS)Nr+r�r&)r�rXr;r�s r9� test_encode_maxlinelen_too_smallz+TestQuopri.test_encode_maxlinelen_too_small9s*�����*�d�&7��R�A��N�N�N�N�Nr;c��|j}|tjd��d��|tjd��d��|tjd��d��|tjdd���d��|tjddd	�
��d��|tjd��d��dS)
Nr+r�r�r��dxxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx r�r&zjxxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx=
 xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxx=
x xxxx xxxx xxxx xxxx=20r�r�zlxxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx=
 xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxx=
x xxxx xxxx xxxx xxxx=20zone line

two line)r2r"r�r�s  r9r�zTestQuopri.test_encode<s���
�
��
��:�!�"�%�%�r�*�*�*�
��:�!�'�*�*�G�4�4�4�
��:�!�"2�3�3�^�D�D�D�
��:�!�,�2�>�>�>�A�	�	�	�
	��:�!�,�2�6�J�J�J��	�	�	�
	��:�!�#�
�
��	
�	
�	
�	
�	
r;rf)NN)Fr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrrrrrrr"r$r&r(r*r,r/r2r4r6r;r>r@rBrDrFrIrKrMrOrQrSrUrWrZr\r_rarcrfrhrjrlrnr�r{r;r9r�r�s\������6�6�6�,L�L�L�J�J�J�.�.�.�26�6�6�I�I�I�
B�B�B�B�*�*�*�E�E�E�B�B�B�B�B�B�&�&�&�B�B�B�)�)�)�3�3�3�B�B�B�D�D�D�K�K�K�4�4�4�4�"�"�"�(�(�(�,�,�,�5�5�5�2�2�2�0�0�0�0�0�0�8�8�8�:�:�:�<�<�<�D�D�D�B�B�B�I�I�I�6�6�6�#�#�#�'�'�'�6�6�6�I�I�I�D�D�D�4�4�4�4�4�4�C�C�C�F�F�F�<�<�<�<�("�"�"�*�*�*�0�0�0�2�2�2�>�>�>�9�9�9�
&�&�&�*�*�*�2�2�2�4�4�4�8�8�8�5�5�5�9�9�9�I�I�I�K�K�K�K�K�K�2�2�2�.�.�.�B�B�B�P�P�P�:�:�:�G�G�G�O�O�O�
�
�
�
�
r;r�c�&�eZdZd�Zd�Zd�Zd�ZdS)�TestCharsetc�F�ddlm}	|jd=dS#t$rYdSwxYw)NrrS�fake)r�rA�CHARSETSr�)r6�
CharsetModules  r9�tearDownzTestCharset.tearDownYsL��2�2�2�2�2�2�	��&�v�.�.�.���	�	�	��D�D�	���s��
 � c��|j}td��}||�d��d��d}|�t|j|��td��}||�|��d��dS)NrN�Hello World!u¤¢¤¤¤¦¤¨¤ªrVz(=?utf-8?b?wqTCosKkwqTCpMKmwqTCqMKkwqo=?=)r2r
rr�r!)r6r7r�r�s    r9�test_codec_encodeablez!TestCharset.test_codec_encodeable`s���
�
���J����
��1�?�?�>�*�*�N�;�;�;�6�����,����;�;�;��G����
��1�?�?�1���I�J�J�J�J�Jr;c���|j}td��}|d|�d����td��}|d|�d����td��}|d|�d����td	��}d
dlm}|�d|jdd��td��}|d|�d����dS)
Nr=z
hello w=F6rlduhello wörldrVrlr�rNrrrrSrt)r2r
r�r�rA�add_charset�QP)r6r7r�rvs    r9�test_body_encodezTestCharset.test_body_encodeks���
�
���L�!�!��
��?�A�M�M�*:�;�;�<�<�<��G����
������~�!>�!>�?�?�?��J����
��=�!�-�-�
�6�6�7�7�7��H����	3�2�2�2�2�2��!�!�&�-�*:�D�'�J�J�J��F�O�O��
��=�!�-�-�
�6�6�7�7�7�7�7r;c��td��}|�t|��d��|�tjtd��dS)NrNuascÿii)r
r2r�r�r �CharsetErrorris  r9�test_unicode_charset_namez%TestCharset.test_unicode_charset_name�sL���*�%�%������W���z�2�2�2����&�-�w��D�D�D�D�Dr;N)r�r�r�rwrzr~r�r{r;r9rrrrXsX���������	K�	K�	K�8�8�8�>E�E�E�E�Er;rrc��eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�ZdS)�
TestHeaderc���|j}td��}||���d��|�d��||���d��dS)Nryz Goodbye World!zHello World!  Goodbye World!�rrr�r(r4s   r9�test_simplezTestHeader.test_simple�se��
�
"���>�"�"��
��1�8�8�:�:�~�&�&�&�	���"�#�#�#�
��1�8�8�:�:�5�6�6�6�6�6r;c���|j}td��}||���d��|�d��||���d��dS)NryzGoodbye World!zHello World! Goodbye World!r�r4s   r9�test_simple_surprisezTestHeader.test_simple_surprise�se��
�
"���>�"�"��
��1�8�8�:�:�~�&�&�&�	���!�"�"�"�
��1�8�8�:�:�4�5�5�5�5�5r;c�V�d}|�t|��|dfg��dS)Nzno decoding neededr�r?s  r9�test_header_needs_no_decodingz(TestHeader.test_header_needs_no_decoding�s1�� ������q�)�)�Q��I�;�7�7�7�7�7r;c���tdd���}|�d����d��D]%}|�t	|��d���&dS)Na�I am the very model of a modern Major-General; I've information vegetable, animal, and mineral; I know the kings of England, and I quote the fights historical from Marathon to Waterloo, in order categorical; I'm very well acquainted, too, with matters mathematical; I understand equations, both the simple and quadratical; about binomial theorem I'm teeming with a lot o' news, with many cheerful facts about the square of the hypotenuse.r�r&r,)�
splitcharsz
 )rr�r�r�r�)r6r�ls   r9�	test_longzTestHeader.test_long�ss���L� �
"�
"�
"�����S��)�)�/�/��6�6�	-�	-�A�� � ��Q����,�,�,�,�	-�	-r;c���|j}td��}td��}td��}d}d}d}t||��}|�||��|�||��|�d���}	||	d	��t|	��}
|t
|
��d
��||
d|df��||
d|df��||
d
|�d��df��t|��}||d�d����tt|	����}|||��dS)Nr=rrrVr!r"r#r�r&a=?iso-8859-1?q?Die_Mieter_treten_hier_ein_werden_mit_einem_Foerderband_kom?=
 =?iso-8859-1?q?fortabel_den_Korridor_entlang=2C_an_s=FCdl=FCndischen_Wand?=
 =?iso-8859-1?q?gem=E4lden_vorbei=2C_gegen_die_rotierenden_Klingen_bef=F6r?=
 =?iso-8859-1?q?dert=2E_?= =?iso-8859-2?q?Finan=E8ni_metropole_se_hroutily?=
 =?iso-8859-2?q?_pod_tlakem_jejich_d=F9vtipu=2E=2E_?= =?utf-8?b?5q2j56K6?=
 =?utf-8?b?44Gr6KiA44GG44Go57+76Kiz44Gv44GV44KM44Gm44GE44G+44Gb44KT44CC?=
 =?utf-8?b?5LiA6YOo44Gv44OJ44Kk44OE6Kqe44Gn44GZ44GM44CB44GC44Go44Gv44Gn?=
 =?utf-8?b?44Gf44KJ44KB44Gn44GZ44CC5a6f6Zqb44Gr44Gv44CMV2VubiBpc3QgZGFz?=
 =?utf-8?b?IE51bnN0dWNrIGdpdCB1bmQgU2xvdGVybWV5ZXI/IEphISBCZWloZXJodW5k?=
 =?utf-8?b?IGRhcyBPZGVyIGRpZSBGbGlwcGVyd2FsZHQgZ2Vyc3B1dC7jgI3jgajoqIA=?=
 =?utf-8?b?44Gj44Gm44GE44G+44GZ44CC?=r�rr�r�s�Die Mieter treten hier ein werden mit einem Foerderband komfortabel den Korridor entlang, an südlündischen Wandgemälden vorbei, gegen die rotierenden Klingen befördert. Finančni metropole se hroutily pod tlakem jejich důvtipu.. 正確に言うと翻訳はされていません。一部はドイツ語ですが、あとはでたらめです。実際には「Wenn ist das Nunstuck git und Slotermeyer? Ja! Beiherhund das Oder die Flipperwaldt gersput.」と言っています。)
rr
rr(r�rr�r�rYr)
r6r7r�r)r*r+r,r-r�encr��ustr�newhs
             r9�test_multilingualzTestHeader.test_multilingual�s���
�
"���L�!�!��
�\�
"�
"���w����B��$��0�	�
�6�1����	����"����	����D�!�!�!��h�h�"�h�%�%��
��3�)�	*�	*�	*� ��$�$��
��3�w�<�<�����
��7�1�:���-�.�.�.�
��7�1�:���.�/�/�/�
��7�1�:�	�(�(��1�1�7�;�<�<�<��1�v�v��
��4�
D� �f�W�o�o�#	�	�	�&�=��-�-�.�.��
��4������r;c�r�t��}|�|���d��dSr�r>r?s  r9�test_empty_header_encodez#TestHeader.test_empty_header_encode�s/���H�H����������R�(�(�(�(�(r;c��|j}t��}||d��|�dtd����||d��dS)Nr+r�r=)rrr(r
r4s   r9�test_header_ctor_default_argsz(TestHeader.test_header_ctor_default_args�sQ��
�
"���H�H��
��1�b�	�	�	�	������-�-�.�.�.�
��1�e�����r;c���|j}d}t|��}||���d��|t|��|��t|d���}||���d��|t|��|��t|dd���}||���|��|t|��|��dS)Nz|A very long line that must get split to something other than at the 76th character boundary to test the non-default behaviorz}A very long line that must get split to something other than at the 76th
 character boundary to test the non-default behaviorr�r$z}A very long line that must get split to something other than at the
 76th character boundary to test the non-default behaviori)r'r%)rrr�r�rs    r9�test_explicit_maxlinelenz#TestHeader.test_explicit_maxlinelen�s���
�
"����
�4�L�L��
��1�8�8�:�:�8�	9�	9�	9�	��3�q�6�6�4�����4�Y�/�/�/��
��1�8�8�:�:�=�	>�	>�	>�	��3�q�6�6�4�����4�D�i�@�@�@��
��1�8�8�:�:�t����
��3�q�6�6�4�����r;c
��|j}tdd���}d}|�|��|���}||d��||t	tt
|��������tdd���}|�d��|���}||d��||t	tt
|��������dS)Nr=r��rAr'rpa=?iso-8859-1?q?xxx?=
 =?iso-8859-1?q?x_?=
 =?iso-8859-1?q?xx?=
 =?iso-8859-1?q?xx?=
 =?iso-8859-1?q?_x?=
 =?iso-8859-1?q?xx?=
 =?iso-8859-1?q?x_?=
 =?iso-8859-1?q?xx?=
 =?iso-8859-1?q?xx?=
 =?iso-8859-1?q?_x?=
 =?iso-8859-1?q?xx?=
 =?iso-8859-1?q?x_?=
 =?iso-8859-1?q?xx?=
 =?iso-8859-1?q?xx?=
 =?iso-8859-1?q?_x?=
 =?iso-8859-1?q?xx?=
 =?iso-8859-1?q?x_?=
 =?iso-8859-1?q?xx?=
 =?iso-8859-1?q?xx?=
 =?iso-8859-1?q?_x?=
 =?iso-8859-1?q?xx?=
 =?iso-8859-1?q?x_?=
 =?iso-8859-1?q?xx?=
 =?iso-8859-1?q?xx?=
 =?iso-8859-1?q?_x?=
 =?iso-8859-1?q?xx?=
 =?iso-8859-1?q?x_?=
 =?iso-8859-1?q?xx?=
 =?iso-8859-1?q?xx?=
 =?iso-8859-1?q?_x?=
 =?iso-8859-1?q?xx?=
 =?iso-8859-1?q?x_?=
 =?iso-8859-1?q?xx?=
 =?iso-8859-1?q?xx?=
 =?iso-8859-1?q?_x?=
 =?iso-8859-1?q?xx?=
 =?iso-8859-1?q?x_?=
 =?iso-8859-1?q?xx?=
 =?iso-8859-1?q?xx?=
 =?iso-8859-1?q?_x?=
 =?iso-8859-1?q?xx?=
 =?iso-8859-1?q?x_?=
 =?iso-8859-1?q?xx?=
 =?iso-8859-1?q?xx?=
 =?iso-8859-1?q?_x?=
 =?iso-8859-1?q?xx?=
 =?iso-8859-1?q?x_?=
 =?iso-8859-1?q?xx?=
 =?iso-8859-1?q?xx?=
 =?iso-8859-1?q?_?=r�z�=?iso-8859-1?q?xxxx_xxxx_xxxx_xxxx_xxx?=
 =?iso-8859-1?q?x_xxxx_xxxx_xxxx_xxxx_?=
 =?iso-8859-1?q?xxxx_xxxx_xxxx_xxxx_xx?=
 =?iso-8859-1?q?xx_xxxx_xxxx_xxxx_xxxx?=
 =?iso-8859-1?q?_xxxx_xxxx_?=�rrr(r�r�rr�r6r7rr�r�s     r9�test_quopri_splittablez!TestHeader.test_quopri_splittables��
�
"���<�B�7�7�7����	�������
�H�H�J�J��
��1�2�2	�2	�2	�f	��1�c�+�m�A�.�.�/�/�0�0�1�1�1��<�B�7�7�7��	�������
�H�H�J�J��
��1�!�	"�	"�	"�	��1�c�+�m�A�.�.�/�/�0�0�1�1�1�1�1r;c
��|j}tdd���}d}|�|��|���}||d��||t	tt
|��������tdd���}|�|��|���}||d��||t	tt
|��������dS)Nrsr�r�rpa�=?koi8-r?b?eHh4?=
 =?koi8-r?b?eCB4?=
 =?koi8-r?b?eHh4?=
 =?koi8-r?b?IHh4?=
 =?koi8-r?b?eHgg?=
 =?koi8-r?b?eHh4?=
 =?koi8-r?b?eCB4?=
 =?koi8-r?b?eHh4?=
 =?koi8-r?b?IHh4?=
 =?koi8-r?b?eHgg?=
 =?koi8-r?b?eHh4?=
 =?koi8-r?b?eCB4?=
 =?koi8-r?b?eHh4?=
 =?koi8-r?b?IHh4?=
 =?koi8-r?b?eHgg?=
 =?koi8-r?b?eHh4?=
 =?koi8-r?b?eCB4?=
 =?koi8-r?b?eHh4?=
 =?koi8-r?b?IHh4?=
 =?koi8-r?b?eHgg?=
 =?koi8-r?b?eHh4?=
 =?koi8-r?b?eCB4?=
 =?koi8-r?b?eHh4?=
 =?koi8-r?b?IHh4?=
 =?koi8-r?b?eHgg?=
 =?koi8-r?b?eHh4?=
 =?koi8-r?b?eCB4?=
 =?koi8-r?b?eHh4?=
 =?koi8-r?b?IHh4?=
 =?koi8-r?b?eHgg?=
 =?koi8-r?b?eHh4?=
 =?koi8-r?b?eCB4?=
 =?koi8-r?b?eHh4?=
 =?koi8-r?b?IA==?=r�z�=?koi8-r?b?eHh4eCB4eHh4IHh4eHggeHh4?=
 =?koi8-r?b?eCB4eHh4IHh4eHggeHh4eCB4?=
 =?koi8-r?b?eHh4IHh4eHggeHh4eCB4eHh4?=
 =?koi8-r?b?IHh4eHggeHh4eCB4eHh4IHh4?=
 =?koi8-r?b?eHggeHh4eCB4eHh4IHh4eHgg?=
 =?koi8-r?b?eHh4eCB4eHh4IA==?=r�r�s     r9�test_base64_splittablez!TestHeader.test_base64_splittableMs��
�
"���8��3�3�3����	�������
�H�H�J�J��
��1�"�"	�"	�"	�F	��1�c�+�m�A�.�.�/�/�0�0�1�1�1��8��3�3�3��	�������
�H�H�J�J��
��1�"�	#�	#�	#�	��1�c�+�m�A�.�.�/�/�0�0�1�1�1�1�1r;c��|j}d}t|��}||dg��t|��}|||�����dS)Nr�)r�N�r2rrr�)r6r7r�r�rs     r9�test_us_ascii_headerzTestHeader.test_us_ascii_header�s\��
�
�����!����
��1��� � � ���N�N��
��1�a�h�h�j�j�����r;c�t�|j}t��}|�dd��||d��dS)Nr�r=)r2rr(r4s   r9�test_string_charsetzTestHeader.test_string_charset�s:��
�
���H�H��	����,�'�'�'�
��1�g�����r;c���|j}tdd��}||���d��tdd��}||���d��dS)NrrVz=?utf-8?q?p=C3=B6stal?=u菊地時夫z=?utf-8?b?6I+K5Zyw5pmC5aSr?=�r2rr�r4s   r9�test_utf8_shortestzTestHeader.test_utf8_shortest�se��
�
���;��(�(��
��1�8�8�:�:�0�1�1�1��-�w�7�7��
��1�8�8�:�:�5�6�6�6�6�6r;c�z�|j}|j}d}|tt|��t��}|t|j|��|�dd��}|t
t|d�����|��|�|d���|t
|��|��dS)N�0Ynwp4dUEbay Auction Semiar- No Charge � Earn BigrVr�r)r�r2r!rr(rYr�)r6rHr7r�r�es      r9�test_bad_8bit_headerzTestHeader.test_bad_8bit_header�s����"��
�
��B����|�V�Q�'�'�'��H�H����|�Q�X�q�)�)�)�
�H�H�W�i�(�(��
��3�v�a�	�*�*�*�+�+�Q�/�/�/�	����9��%�%�%�
��3�q�6�6�1�
�
�
�
�
r;c�(�d}|�dd��}t|tjj���}|�t
|��d��|�tj�|��|dfg��dS)Nr�r��surrogateescaperS�2Ynwp4dUEbay Auction Semiar- No Charge � Earn Big�unknown-8bit)	rYrr�rA�UNKNOWN8BITr2r�r�r)r6r�r�rs    r9�test_escaped_8bit_headerz#TestHeader.test_escaped_8bit_header�s���B��
�H�H�W�/�0�0���1�e�m�7�8�8�8������Q���O�	Q�	Q�	Q������3�3�A�6�6�!�^�9L�8M�N�N�N�N�Nr;c��d}t|tjj���}|�t|��d��|�tj�|��|dfg��dS�Nr�rSr�r�)rr�rAr�r2r�r�r)r6r�rs   r9�&test_header_handles_binary_unknown8bitz1TestHeader.test_header_handles_binary_unknown8bit�sx��B���1�e�m�7�8�8�8������Q���O�	Q�	Q�	Q������3�3�A�6�6�!�^�9L�8M�N�N�N�N�Nr;c�t�d}t|tjj���}tj�tj�|����}|�t|��d��|�tj�|��|dfg��dSr�)	rr�rAr�r�rrr2r�)r6r�r�h2s    r9�+test_make_header_handles_binary_unknown8bitz6TestHeader.test_make_header_handles_binary_unknown8bit�s���B���1�e�m�7�8�8�8��
�\�
%�
%�e�l�&@�&@��&C�&C�
D�
D������R���O�	Q�	Q�	Q������3�3�B�7�7�1�n�:M�9N�O�O�O�O�Or;c���td��}tj�|��}|�d��|�t
|��d��dS)NrS)r��test2)rr�r�rr(r2r�)r6rr�s   r9�0test_modify_returned_list_does_not_change_headerz;TestHeader.test_modify_returned_list_does_not_change_header�sW���6�N�N����+�+�A�.�.���
�
�(�)�)�)�����Q����(�(�(�(�(r;c�:�|j}t��}|�dd��|�d��|���}||d��t	t|����}||���|��dS)Nr�r=�worldz=?iso-8859-1?q?hello?= world)r2rr(r�rr)r6r7rr�s    r9� test_encoded_adjacent_nonencodedz+TestHeader.test_encoded_adjacent_nonencoded�s���
�
���H�H��	����,�'�'�'�	�������
�H�H�J�J��
��1�,�-�-�-��
�a�(�(�)�)��
��1�8�8�:�:�q�����r;c��|j}d}t|��}||gd���t|��}||���d��dS)NzGSubject: =?koi8-r?b?8NLP18XSy8EgzsEgxsnOwczYztk=?= =?koi8-r?q?=CA?= zz.))s	Subject: N)s������� � ��������rs)s zz.Nz6Subject: =?koi8-r?b?8NLP18XSy8EgzsEgxsnOwczYztnK?= zz.r�)r6r7r��parts�hdrs     r9�test_whitespace_keeperz!TestHeader.test_whitespace_keeper�s���
�
��U���a� � ��
��5�Y�Y�Y�	Z�	Z�	Z��%� � ��
��3�:�:�<�<�C�	E�	E�	E�	E�	Er;c�P�|j}d}|tjt|��dS)NzXSubject: =?EUC-KR?B?CSixpLDtKSC/7Liuvsax4iC6uLmwMcijIKHaILzSwd/H0SC8+LCjwLsgv7W/+Mj3I ?=)r�r r�r)r6rHr�s   r9�test_broken_base64_headerz$TestHeader.test_broken_base64_header�s,���"��f����v�&�
�q�9�9�9�9�9r;c�x�tdd���}|�|���d��dS)Nr<�	shift_jisrSr=r>r?s  r9�test_shift_jis_charsetz!TestHeader.test_shift_jis_charset�s9���5�+�.�.�.����������%E�F�F�F�F�Fr;c�t�tjd��}|�t|��d��dS)NzEmptyHeader:zEmptyHeader: 

)r�rr2r�rhs  r9�!test_flatten_header_with_no_valuez,TestHeader.test_flatten_header_with_no_value�s7���'��7�7������S���#6�7�7�7�7�7r;c�r�t��}d|d<|�t|��d��dS)Nz   value with leading ws�
SomeHeaderz&SomeHeader:    value with leading ws

)rr2r�rhs  r9�)test_encode_preserves_leading_ws_on_valuez4TestHeader.test_encode_preserves_leading_ws_on_value�s8���i�i��6��L������S���#M�N�N�N�N�Nr;c�p�|�td�����d��dS)Nr,r�r�s r9�test_whitespace_headerz!TestHeader.test_whitespace_header�s0���������+�+�-�-�s�3�3�3�3�3r;N)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;r9r�r��s�������7�7�7�6�6�6�8�8�8�-�-�-�=�=�=�~)�)�)�������&C2�C2�C2�J42�42�42�l������7�7�7�
�
�
�O�O�O�O�O�O�P�P�P�)�)�)����E�E�E�:�:�:�
G�G�G�8�8�8�O�O�O�
4�4�4�4�4r;r�c���eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z dS) �TestRFC2231c��|j}|�d��}||�d��d��||�dd���d��dS)Nz
msg_29.txtrO�rNrP�%This is even more ***fun*** isn't it!Fr))rNrPz'"This is even more ***fun*** isn't it!")r2r3rIr5s   r9r$zTestRFC2231.test_get_param�s{��
�
���l�l�<�(�(��
��3�=�=��!�!�G�	I�	I�	I�
��3�=�=��%�=�0�0�I�	K�	K�	K�	K�	Kr;c��|j}t��}|�ddd���||�d��d��|�dddd���||�d��d��|�d	��}|�dddd���||�d
���d��dS)
NrOr�rNrS)rNr+r�rP�rA�languager�r�rwr{a"Return-Path: <bbb@zzz.org>
Delivered-To: bbb@zzz.org
Received: by mail.zzz.org (Postfix, from userid 889)
	id 27CEAD38CC; Fri,  4 May 2001 14:05:44 -0400 (EDT)
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Message-ID: <15090.61304.110929.45684@aaa.zzz.org>
From: bbb@ddd.com (John X. Doe)
To: bbb@zzz.org
Subject: This is a test message
Date: Fri, 4 May 2001 14:05:44 -0400
Content-Type: text/plain; charset=us-ascii;
 title*=us-ascii'en'This%20is%20even%20more%20%2A%2A%2Afun%2A%2A%2A%20isn%27t%20it%21


Hi,

Do you like this message?

-Me
)rrr9rIr3r�r5s   r9r:zTestRFC2231.test_set_params��
�
"���i�i���
�
�g�G�(�	�	*�	*�	*�
��3�=�=��!�!�E�	G�	G�	G��
�
�g�G�(�4�	�	9�	9�	9�
��3�=�=��!�!�G�	I�	I�	I��l�l�<�(�(���
�
�g�G�(�4�	�	9�	9�	9�
��3�=�=�b�=�)�)�,�	�	�	�	�	r;c�V�t��}|�dd��|�|dd��|�ddd���|�|dd��|�dd	d���|�|dd
��dS)NrOr�r@ztext/plain; title="foo"rF)�requoteztext/plain; title=barz	(bar)bellztext/plain; title="(bar)bell")rr9r2rhs  r9�test_set_param_requotez"TestRFC2231.test_set_param_requote)s����i�i���
�
�g�u�%�%�%�����^�,�.G�H�H�H��
�
�g�u�e�
�4�4�4�����^�,�.E�F�F�F��
�
�g�{�E�
�:�:�:�����^�,�.M�N�N�N�N�Nr;c��|j}|�d��}|�dddd���|�dddd���|�dd	�
��||�d���d
��dS)Nr�r�rrNrPr�rOr�rDrrwr{a$Return-Path: <bbb@zzz.org>
Delivered-To: bbb@zzz.org
Received: by mail.zzz.org (Postfix, from userid 889)
	id 27CEAD38CC; Fri,  4 May 2001 14:05:44 -0400 (EDT)
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Message-ID: <15090.61304.110929.45684@aaa.zzz.org>
From: bbb@ddd.com (John X. Doe)
To: bbb@zzz.org
Subject: This is a test message
Date: Fri, 4 May 2001 14:05:44 -0400
Content-Type: text/plain; charset="us-ascii";
 title*=us-ascii'en'This%20is%20even%20more%20%2A%2A%2Afun%2A%2A%2A%20isn%27t%20it%21


Hi,

Do you like this message?

-Me
)rr3r9rCr�r5s   r9rEzTestRFC2231.test_del_param3s���
�
"���l�l�<�(�(���
�
�e�U�J��
�F�F�F��
�
�g�G���	�	/�	/�	/��
�
�e�N�
�3�3�3�
��3�=�=�b�=�)�)�,�	�	�	�	�	r;c�z�|j}|�d��}||���d��dS)NrmrN)r2r3�get_content_charsetr5s   r9� test_rfc2231_get_content_charsetz,TestRFC2231.test_rfc2231_get_content_charsetTs?��
�
���l�l�<�(�(��
��3�"�"�$�$�j�1�1�1�1�1r;c��tjd��}tj|��}|�|���d��|�||�����dS)Nz�            Content-Disposition: inline;
            	filename*0*=''This%20is%20even%20more%20;
            	filename*1*=%2A%2A%2Afun%2A%2A%2A%20;
            	filename*2="is it not.pdf"

            �)This is even more ***fun*** is it not.pdf�r�r�r�rr2r}r�rs   r9�test_rfc2231_parse_rfc_quotingz*TestRFC2231.test_rfc2231_parse_rfc_quotingZ�z���O��
�
���'��*�*������)�)�+�+�D�	F�	F�	F�����C�M�M�O�O�,�,�,�,�,r;c��tjd��}tj|��}|�|���d��|�||�����dS)Nz�            Content-Disposition: inline;
            	filename*0*="''This%20is%20even%20more%20";
            	filename*1*="%2A%2A%2Afun%2A%2A%2A%20";
            	filename*2="is it not.pdf"

            r�r�rs   r9� test_rfc2231_parse_extra_quotingz,TestRFC2231.test_rfc2231_parse_extra_quotinghr�r;c��d}tj|��}|�d��}|�|t��|�|d��dS)NaContent-Transfer-Encoding: 8bit
Content-Disposition: inline; filename="file____C__DOCUMENTS_20AND_20SETTINGS_FABIEN_LOCAL_20SETTINGS_TEMP_nsmail.htm"
Content-Type: text/html; NAME*0=file____C__DOCUMENTS_20AND_20SETTINGS_FABIEN_LOCAL_20SETTINGS_TEM; NAME*1=P_nsmail.htm

�NAMEzMfile____C__DOCUMENTS_20AND_20SETTINGS_FABIEN_LOCAL_20SETTINGS_TEMP_nsmail.htm�r�rrI�assertNotIsInstance�tupler2�r6r�r8�params    r9�#test_rfc2231_no_language_or_charsetz/TestRFC2231.test_rfc2231_no_language_or_charsetxso��
���'��*�*���
�
�f�%�%��� � ���.�.�.�����[�	]�	]�	]�	]�	]r;c��d}tj|��}|�|���d��dS�Nz�Content-Disposition: inline;
	filename*0*="''This%20is%20even%20more%20";
	filename*1*="%2A%2A%2Afun%2A%2A%2A%20";
	filename*2="is it not.pdf"

r�r	rs   r9�/test_rfc2231_no_language_or_charset_in_filenamez;TestRFC2231.test_rfc2231_no_language_or_charset_in_filename��S��
���'��*�*������)�)�+�+�D�	F�	F�	F�	F�	Fr;c��d}tj|��}|�|���d��dSr�r	rs   r9�7test_rfc2231_no_language_or_charset_in_filename_encodedzCTestRFC2231.test_rfc2231_no_language_or_charset_in_filename_encoded�r�r;c��d}tj|��}|�|���d��dS)Nz�Content-Disposition: inline;
	filename*0="''This%20is%20even%20more%20";
	filename*1*="%2A%2A%2Afun%2A%2A%2A%20";
	filename*2="is it not.pdf"

z1This%20is%20even%20more%20***fun*** is it not.pdfr	rs   r9�test_rfc2231_partly_encodedz'TestRFC2231.test_rfc2231_partly_encoded�sT��
���'��*�*����������?�	A�	A�	A�	A�	Ar;c��d}tj|��}|�|���d��dS)Nz�Content-Disposition: inline;
	filename*0="This%20is%20even%20more%20";
	filename*1="%2A%2A%2Afun%2A%2A%2A%20";
	filename*2="is it not.pdf"

z?This%20is%20even%20more%20%2A%2A%2Afun%2A%2A%2A%20is it not.pdfr	rs   r9�test_rfc2231_partly_nonencodedz*TestRFC2231.test_rfc2231_partly_nonencoded�sT��
���'��*�*����������M�	O�	O�	O�	O�	Or;c��d}tj|��}|�|���d��dS)Nz�Content-Type: multipart/alternative;
	boundary*0*="''This%20is%20even%20more%20";
	boundary*1*="%2A%2A%2Afun%2A%2A%2A%20";
	boundary*2="is it not.pdf"

r�rrs   r9�/test_rfc2231_no_language_or_charset_in_boundaryz;TestRFC2231.test_rfc2231_no_language_or_charset_in_boundary�r�r;c��d}tj|��}|�|���d��dS)Nz�Content-Type: text/plain;
	charset*0*="This%20is%20even%20more%20";
	charset*1*="%2A%2A%2Afun%2A%2A%2A%20";
	charset*2="is it not.pdf"

z)this is even more ***fun*** is it not.pdf�r�rr2r�rs   r9�.test_rfc2231_no_language_or_charset_in_charsetz:TestRFC2231.test_rfc2231_no_language_or_charset_in_charset�sS��
���'��*�*������0�0�2�2�D�	F�	F�	F�	F�	Fr;c��d}tj|��}|�|���d��dS)Nz�Content-Disposition: inline;
	filename*0*="bogus'xx'This%20is%20even%20more%20";
	filename*1*="%2A%2A%2Afun%2A%2A%2A%20";
	filename*2="is it not.pdf"

r�r	rs   r9�%test_rfc2231_bad_encoding_in_filenamez1TestRFC2231.test_rfc2231_bad_encoding_in_filename�r�r;c��d}tj|��}|�|���d��dS)Nz:Content-Type: text/plain; charset*=bogus''utf-8%E2%80%9D

r�rs   r9�$test_rfc2231_bad_encoding_in_charsetz0TestRFC2231.test_rfc2231_bad_encoding_in_charset��E��
���'��*�*��	
����0�0�2�2�D�9�9�9�9�9r;c��d}tj|��}|�|���d��dS)Nz:Content-Type: text/plain; charset*=ascii''utf-8%E2%80%9D

r�rs   r9�%test_rfc2231_bad_character_in_charsetz1TestRFC2231.test_rfc2231_bad_character_in_charset�rr;c��d}tj|��}|�|���d��dS)Nz�Content-Disposition: inline;
	filename*0*="ascii'xx'This%20is%20even%20more%20";
	filename*1*="%2A%2A%2Afun%2A%2A%2A%20";
	filename*2*="is it not.pdf%E2"

u,This is even more ***fun*** is it not.pdf�r	rs   r9�&test_rfc2231_bad_character_in_filenamez2TestRFC2231.test_rfc2231_bad_character_in_filename�sS��
���'��*�*������)�)�+�+�J�	L�	L�	L�	L�	Lr;c��d}tj|��}|�|���d��dS)Nz^Content-Transfer-Encoding: 8bit
Content-Disposition: inline; filename*=X-UNKNOWN''myfile.txt

�
myfile.txtr	rs   r9�test_rfc2231_unknown_encodingz)TestRFC2231.test_rfc2231_unknown_encoding�C��
��
�'��*�*������)�)�+�+�\�:�:�:�:�:r;c��d}tj|��}|�|���d��dS)NucContent-Transfer-Encoding: 8bit
Content-Disposition: inline; filename*=utf-8���''myfile.txt

rr	rs   r9�&test_rfc2231_bad_character_in_encodingz2TestRFC2231.test_rfc2231_bad_character_in_encodingrr;c��|j}d}tj|��}|�d��\}}}||d��||d��||d��dS)NzJContent-Type: application/x-foo;
	name*0*="Frank's"; name*1*=" Document"

r&�Frank's Documentr#�r6r7r�r8rAr�r�s       r9�-test_rfc2231_single_tick_in_filename_extendedz9TestRFC2231.test_rfc2231_single_tick_in_filename_extendedsx��
�
��
��
�'��*�*��"�}�}�V�4�4����1�
��7�D����
��8�T����
��1� �!�!�!�!�!r;c��d}tj|��}|�d��}|�|t��|�|d��dS)NzGContent-Type: application/x-foo; name*0="Frank's"; name*1=" Document"

r&rr�r�s    r9�$test_rfc2231_single_tick_in_filenamez0TestRFC2231.test_rfc2231_single_tick_in_filename"s_��
���'��*�*���
�
�f�%�%��� � ���.�.�.����� 2�3�3�3�3�3r;c��d}tj|��}|�|���d��dS)NzAContent-Disposition: inline;
	filename*0*="'This%20is%20broken";
z'This is brokenr	rs   r9�test_rfc2231_missing_tickz%TestRFC2231.test_rfc2231_missing_tick,sO��
���'��*�*�����������	�	�	�	�	r;c��d}tj|��}|�|���d��dS)NzAContent-Disposition: inline;
	filename*0*="'This%20is%E2broken";
u'This is�brokenr	rs   r9�0test_rfc2231_missing_tick_with_encoded_non_asciiz<TestRFC2231.test_rfc2231_missing_tick_with_encoded_non_ascii6sO��
���'��*�*����������"�	$�	$�	$�	$�	$r;c��|j}d}tj|��}|�d��\}}}||d��||d��||d��dS)NzYContent-Type: application/x-foo;
	name*0*="us-ascii'en-us'Frank's"; name*1*=" Document"

r&rN�en-usrr#r
s       r9�!test_rfc2231_tick_attack_extendedz-TestRFC2231.test_rfc2231_tick_attack_extendedAsx��
�
��
��
�'��*�*��"�}�}�V�4�4����1�
��7�J����
��8�W����
��1� �!�!�!�!�!r;c��d}tj|��}|�d��}|�|t��|�|d��dS)NzWContent-Type: application/x-foo;
	name*0="us-ascii'en-us'Frank's"; name*1=" Document"

r&zus-ascii'en-us'Frank's Documentr�r�s    r9�test_rfc2231_tick_attackz$TestRFC2231.test_rfc2231_tick_attackOs_��
��
�'��*�*���
�
�f�%�%��� � ���.�.�.����� A�B�B�B�B�Br;c�~�|j}d}tj|��}||�d��d��dS)Nz:Content-Type: application/x-foo; name="Frank's Document"

r&rr#r�s    r9�test_rfc2231_no_extended_valuesz+TestRFC2231.test_rfc2231_no_extended_values[sH��
�
��
���'��*�*��
��3�=�=�� � �"4�5�5�5�5�5r;c��|j}d}tj|��}|�d��\}}}||d��||d��||d��dS)NziContent-Type: application/x-foo;
	name*0*="us-ascii'en-us'My";
	name*1=" Document";
	name*2*=" For You"

r&rNr�My Document For Your#r
s       r9�,test_rfc2231_encoded_then_unencoded_segmentsz8TestRFC2231.test_rfc2231_encoded_then_unencoded_segmentse�x��
�
��
���'��*�*��"�}�}�V�4�4����1�
��7�J����
��8�W����
��1�#�$�$�$�$�$r;c��|j}d}tj|��}|�d��\}}}||d��||d��||d��dS)NziContent-Type: application/x-foo;
	name*0="us-ascii'en-us'My";
	name*1*=" Document";
	name*2*=" For You"

r&rNrrr#r
s       r9�,test_rfc2231_unencoded_then_encoded_segmentsz8TestRFC2231.test_rfc2231_unencoded_then_encoded_segmentsvrr;c��ddg}|D]D}|�|���5tj|��}ddd��n#1swxYwY�EdS)Nz�From: user@host.com
To: user@host.com
Bad-Header:
 =?us-ascii?Q?LCSwrV11+IB0rSbSker+M9vWR7wEDSuGqmHD89Gt=ea0nJFSaiz4vX3XMJPT4vrE?=
 =?us-ascii?Q?xGUZeOnp0o22pLBB7CYLH74Js=wOlK6Tfru2U47qR?=
 =?us-ascii?Q?72OfyEY2p2=2FrA9xNFyvH+fBTCmazxwzF8nGkK6D?=

Hello!
u�From: ����� �������� <xxx@xxx>
To: "xxx" <xxx@xxx>
Subject:   ��� ���������� ����� ����� � ��������� �� ����
MIME-Version: 1.0
Content-Type: text/plain; charset="windows-1251";
Content-Transfer-Encoding: 8bit

�� ����� � ���� ������ ��� ��������
)r�)r�r�r)r6�messagesr�r8s    r9�+test_should_not_hang_on_invalid_ew_messagesz7TestRFC2231.test_should_not_hang_on_invalid_ew_messages�s�������"�	3�	3�A������"�"�
3�
3��/��2�2��
3�
3�
3�
3�
3�
3�
3�
3�
3�
3�
3����
3�
3�
3�
3��	3�	3s�A�A	�A	N)!r�r�r�r$r:r�rEr�r�r�r�r�r�r�r�r�r�r�r�rrrr
rrrrrrrrr!r$r{r;r9r�r��s�������K�K�K�#�#�#�JO�O�O����B2�2�2�-�-�-�-�-�-� ]�]�]�
F�
F�
F�
F�
F�
F�A�A�A�O�O�O�
F�
F�
F�F�F�F�
F�
F�
F�:�:�:�:�:�:�
L�
L�
L�;�;�;�;�;�;�"�"�"�4�4�4����$�$�$�"�"�"�	C�	C�	C�6�6�6�
%�
%�
%�"
%�
%�
%�3�3�3�3�3r;r�c�,�eZdZd�Zd�Zd�Zd�Zd�ZdS)�
TestSignedc��t|d���5}|���}tj|��}ddd��n#1swxYwY||fSrIrJ)r6rKr��originalr8s     r9�_msg_and_objzTestSigned._msg_and_obj�s���
�h��
1�
1�
1�	6�R��w�w�y�y�H��+�H�5�5�C�	6�	6�	6�	6�	6�	6�	6�	6�	6�	6�	6����	6�	6�	6�	6���}�s�)A�A�Ac��ddl}|jd|j|jz��}|�|���d��}|�|���d��}|�||��dS)Nrz^--([^\n]+)\n(.*?)\n--\1$r�)r�r��Sr��search�groupr2)r6r(�resultr��repart�inpart�outparts       r9�_signed_parts_eqzTestSigned._signed_parts_eq�s����	�	�	����8�"�$���+�F�F�����x�(�(�.�.�q�1�1���-�-��'�'�-�-�a�0�0������&�)�)�)�)�)r;c��|�d��\}}|���}|�||��dSr{�r)r�r2�r6r(r8r.s    r9�test_long_headers_as_stringz&TestSigned.test_long_headers_as_string�sB���)�)�,�7�7�
��#����������h��/�/�/�/�/r;c��|�d��\}}|�d���}|�||��dS)Nr|�<r{r4r5s    r9�(test_long_headers_as_string_maxheaderlenz3TestSigned.test_long_headers_as_string_maxheaderlen�sH���)�)�,�7�7�
��#����B��/�/�����h��/�/�/�/�/r;c���|�d��\}}t��}t|���|��|���}|�||��dSr{)r)rrr�r�r2)r6r(r8r�r.s     r9�test_long_headers_flattenz$TestSigned.test_long_headers_flatten�se���)�)�,�7�7�
��#�
�Z�Z���"�
�
���c�"�"�"����������h��/�/�/�/�/r;N)r�r�r�r)r2r6r9r;r{r;r9r&r&�s_���������*�*�*�0�0�0�
0�0�0�
0�0�0�0�0r;r&c��eZdZd�ZdS)�TestHeaderRegistryc��t��}|dd��}|�|jdtj��dS)NrGzattachment; 0*00="foo"r)rr�r�r �InvalidHeaderDefect)r6�regr�s   r9�test_HeaderRegistryz&TestHeaderRegistry.test_HeaderRegistry�sE�������C�%�'?�@�@�����a�i��l�F�,F�G�G�G�G�Gr;N)r�r�r�rAr{r;r9r=r=�s(������H�H�H�H�Hr;r=�__main__)fr�r9rWr,r��warnings�iorr�	itertoolsr�randomr�	threadingr�
unittest.mockr	r��email.policy�
email.charsetr
�email.generatorrrr
�email.headerrrr�email.headerregistryr�
email.messager�email.mime.applicationr�email.mime.audior�email.mime.baser�email.mime.imager�email.mime.messager�email.mime.multipartr�email.mime.nonmultipartr�email.mime.textr�email.parserrrrrr r!r"r#�test.supportr$�test.support.os_helperr%�test.test_emailr&r'r(r)r�r�rNr.�TestCaser�rr�r�r�r�rr/r�r�r�rArGr�r�r�r�rr�r�r�r�r�rrr�r�r&r=r��mainr{r;r9�<module>r]s���

�	�	�	�����
�
�
�
������������� � � � � � � � ���������������������������������!�!�!�!�!�!�G�G�G�G�G�G�G�G�G�G�;�;�;�;�;�;�;�;�;�;�/�/�/�/�/�/�!�!�!�!�!�!�2�2�2�2�2�2�&�&�&�&�&�&�$�$�$�$�$�$�&�&�&�&�&�&�*�*�*�*�*�*�.�.�.�.�.�.�4�4�4�4�4�4�$�$�$�$�$�$�-�-�-�-�-�-�-�-�������������������������������������)�)�)�)�)�)�)�)�)�)�)�)�3�3�3�3�3�3�3�3�5�4�4�4�4�4�4�4�	������c�c�c�c�c�]�c�c�c�N?�?�?�?�?�8�$�?�?�?�Fx>�x>�x>�x>�x>�m�x>�x>�x>�zK/�K/�K/�K/�K/�x�(�K/�K/�K/�^/D�/D�/D�/D�/D�H�%�/D�/D�/D�h7D�7D�7D�7D�7D�H�%�7D�7D�7D�vXC�XC�XC�XC�XC�(�+�XC�XC�XC�x7A�7A�7A�7A�7A�8�$�7A�7A�7A�x~6�~6�~6�~6�~6�M�~6�~6�~6�BkK�kK�kK�kK�kK�
�kK�kK�kK�^}<�}<�}<�}<�}<�-�}<�}<�}<�BsK�sK�sK�sK�sK�m�sK�sK�sK�n		J�	J�	J�	J�	J�}�	J�	J�	J�"Z-�Z-�Z-�Z-�Z-�]�Z-�Z-�Z-�~r>�r>�r>�r>�r>�
�r>�r>�r>�ld(�d(�d(�d(�d(�M�d(�d(�d(�N-A�-A�-A�-A�-A�m�-A�-A�-A�`GK�GK�GK�GK�GK�-�GK�GK�GK�T[�[�[�[�[�M�[�[�[�|-�-�-�-�-�-�-�-�$3�3�3�3�3�%E�$2�3�3�3�8�8�8�8�8�'G�'5�8�8�8�1D�1D�1D�1D�1D��"�1D�1D�1D�h}
�}
�}
�}
�}
��"�}
�}
�}
�D
5E�5E�5E�5E�5E�(�#�5E�5E�5E�ta4�a4�a4�a4�a4��a4�a4�a4�La3�a3�a3�a3�a3�-�a3�a3�a3�N
0�0�0�0�0��0�0�0�BH�H�H�H�H��H�H�H��z����H�M�O�O�O�O�O��r;