Your IP : 216.73.216.213


Current Path : /opt/alt/python311/lib64/python3.11/test/test_email/__pycache__/
Upload File :
Current File : //opt/alt/python311/lib64/python3.11/test/test_email/__pycache__/test_email.cpython-311.opt-2.pyc

�

�0�i�q���ddlZddlZddlZddlZddlZddlZddlmZmZddl	m
Z
ddlmZddl
mZddlmZddlZddlZddlZddlmZddlmZmZmZdd	lmZmZmZdd
lmZddl m!Z!ddl"m#Z#dd
l$m%Z%ddl&m'Z'ddl(m)Z)ddl*m+Z+ddl,m-Z-ddl.m/Z/ddl0m1Z1ddl2m3Z3m4Z4ddlm5Z5ddlm6Z6ddlm7Z7ddlm8Z8ddlm9Z9ddlm:Z:ddl;m<Z<ddl=m>Z>ddl?m@Z@ddlAmBZBmCZCddl2mDZDmEZEd ZFd!ZGd"ZHGd#�d$eC��ZIGd%�d&ejJ��ZKGd'�d(eC��ZLGd)�d*ejJ��ZMGd+�d,ejJ��ZNGd-�d.ejJ��ZOGd/�d0ejJ��ZPGd1�d2ejJ��ZQGd3�d4eC��ZRGd5�d6eC��ZSGd7�d8eC��ZTGd9�d:eC��ZUGd;�d<eC��ZVGd=�d>eC��ZWGd?�d@eC��ZXGdA�dBeC��ZYGdC�dDeC��ZZGdE�dFeC��Z[GdG�dHeC��Z\GdI�dJ��Z]GdK�dLe]eW��Z^GdM�dNe]eW��Z_GdO�dPejJ��Z`GdQ�dRejJ��ZaGdS�dTejJ��ZbGdU�dVeC��ZcGdW�dXeC��ZdGdY�dZeC��ZeGd[�d\eC��Zfegd]krejh��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)�support)�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�ZWdV�ZXdW�ZYdXS)Y�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   �A/opt/alt/python311/lib64/python3.11/test/test_email/test_email.py�test_get_allzTestMessageAPI.test_get_all;sf��
�
���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")r3r�get_charsetr
�set_charset�get_content_type�	get_param�
input_charset�r7r8r9rBs    r:�test_getset_charsetz"TestMessageAPI.test_getset_charsetAs���
�
���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-asciirA�text/plain; charset="us-ascii")r3rrHrGrKr6s   r:�test_set_charset_from_stringz+TestMessageAPI.test_set_charset_from_string[sb��
�
���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_payloadr3rGrK)r7r9rBs   r:�test_set_payload_with_charsetz,TestMessageAPI.test_set_payload_with_charsetbsV���i�i���,�'�'�����2�G�<�<�<�������*�*�8�,�G�G�G�G�Gr<c�L�d}td��}t��}|�||��|�|dd��|�|�d���|��|�|���d��dS)N�АБВ�utf-8rC�base64T��decodez	0JDQkdCS
)r
rrSr3�get_payload�r7�datarBr9s    r:�+test_set_payload_with_8bit_data_and_charsetz:TestMessageAPI.test_set_payload_with_8bit_data_and_charseths���*���'�"�"���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�NrVrWrC�8bitTrY)r
�
body_encodingrrSrZr3r[r\s    r:�>test_set_payload_with_non_ascii_and_charset_body_encoding_nonezMTestMessageAPI.test_set_payload_with_non_ascii_and_charset_body_encoding_noneqs���*���'�"�"�� $����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
rbrrSr3r[r\s    r:�>test_set_payload_with_8bit_data_and_charset_body_encoding_nonezMTestMessageAPI.test_set_payload_with_8bit_data_and_charset_body_encoding_nonezs��*���'�"�"�� $����i�i������g�&�&�&�����8�9�6�B�B�B���������5�5�t�<�<�<�<�<r<c��t��}|�g��|�|���g��dS�N�rrSr3r[�r7r9s  r:�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/mixedrEzstring payloadz[Aa]ttach.*non-multipart)rrSr�assertRaisesRegex�	TypeError�attach)r7r9�sub_msgs   r:�"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)NrOr>�
iso-8859-2�koi8-rz
msg_09.txt�dingbat)rurOr>rurtz
msg_12.txt)NrOr>Nrsz
iso-8859-3rOrt)r3r4�get_charsets)r7r8r9�charsetss    r:�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  r:�
<listcomp>z4TestMessageAPI.test_get_filename.<locals>.<listcomp>��"��A�A�A�!�Q�^�^�%�%�A�A�Ar<�msg.txt�
msg_07.txt��dingusfish.gif)r3r4r[r~)r7r8r9�	filenames�subparts     r:�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}rs  r:r�zHTestMessageAPI.test_get_filename_with_name_parameter.<locals>.<listcomp>�r�r<r��r3r4r[)r7r8r9r�s    r:�%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)r3r4�get_boundaryr6s   r:�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��rAz3text/plain; charset="us-ascii"; boundary="BOUNDARY"rzz$multipart/mixed; boundary="BOUNDARY"�
msg_03.txt)r3r4�set_boundary�items�lower�assertRaisesr �HeaderParseError)r7r8r9�header�values     r:�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="==)rr3r��	as_stringris  r:�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.txtrW��encodingTrF)	r'�readr�parsestrrr�flattenr3�getvalue�r7�fp�msgdata�parserr9�out�gens       r:�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�rWr��ascii)
r'r��encode�emailr��BytesHeaderParser�
parsebytesr�	generatorr
r�r3r�r�s       r:�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.txtTrYrs 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�r6s   r:�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-uuerCTrY�hello world�foosfoo)r3rrSr[)r7r8r9�ctes    r:�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�rnr[ris  r:�*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.txtrWr�)r3r4r'r�rrr�r�)r7r8r9r��text�s�gs       r:�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�assertInris  r:�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�rWr�T��unixfromr+rzFrom r�)r4r'r�r3�strr��split�
assertTrue�
startswith�NL�join)r7r9r�r��fullrepr�liness      r:�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)	r4r��cloner�rrr�r3r��r7r9�	newpolicyr�r�r�s      r:�test_as_string_policyz$TestMessageAPI.test_as_string_policy6s����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_bytesr3r��r7�m�source�expectedr9s     r:�#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
            Content-type: text/plain; charset="us-ascii"
            Content-Transfer-Encoding: 8bit

            Test if non-ascii messages with no Content-Transfer-Encoding set
            can be as_string'd:
            Föö bär
            r>r��replace�r�r�r�rZr�r�r3r�r�s     r:�*test_nonascii_as_string_with_ascii_charsetz9TestMessageAPI.test_nonascii_as_string_with_ascii_charsetUsr���O��
�
�����,�'�'���=�=��)�4�4���&�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�r�r�r�s     r:�4test_nonascii_as_string_without_content_type_and_ctezCTestMessageAPI.test_nonascii_as_string_without_content_type_and_ctedsr���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�rWr�r�Tr��
rsFrom r�)r4r'r�r�r3�bytes�as_bytesr�r�r�r�)r7r9r�r]r�r�s      r:�
test_as_byteszTestMessageAPI.test_as_bytesqs'���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�)	r4r�r�rrr
r�r3r�r�s      r:�test_as_bytes_policyz#TestMessageAPI.test_as_bytes_policy{s����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_stringr3rJris  r:�test_bad_paramzTestMessageAPI.test_bad_param�s;���'�(I�J�J��������u�-�-�r�2�2�2�2�2r<c�~�tjd��}|�|���d��dS�Nz
From: foo
�r�r	r3r~ris  r:�test_missing_filenamez$TestMessageAPI.test_missing_filename��:���'�
�6�6������)�)�+�+�T�2�2�2�2�2r<c�~�tjd��}|�|���d��dS)Nz%Content-Disposition: blarg; filename
r,r
ris  r:�test_bogus_filenamez"TestMessageAPI.test_bogus_filename�s?���'�0�2�2������)�)�+�+�R�0�0�0�0�0r<c�~�tjd��}|�|���d��dSr�r�r	r3r�ris  r:�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
)r3r�r	�
get_paramsr6s   r:�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"rE�boundary�CPIMSSMTPC06p5f3tG)rr3rJris  r:�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�r3r�r	rJr6s   r:�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)r4r3r[rJris  r:�'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"rris  r:�#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"bazrris  r:�test_get_param_with_quotesz)TestMessageAPI.test_get_param_with_quotes�s|���'�E�G�G��������u�-�-�/?�@�@�@��'�K�M�M��������u�-�-�/?�@�@�@�@�@r<c	�4�d}dD]�\}}|�|||���5|�d�|dz
z|z}tj�|��}|�t|��|��|�tt
|����d��|�|d|��ddd��n#1swxYwY��dd|dz
zz}tj�|��}|�||g��dS)Ni��)�r,r,)�foo=barr4)z FOO = bar    r4)r��r�N�;r�rzs=")�subTestr��message�_parseparamr3�len�set)r7r6r�r5�src�res�	malformeds       r:� test_get_param_linear_complexityz/TestMessageAPI.test_get_param_linear_complexity�s[��
��
�
	,�
	,�D�A�q�
����Q�!��,�,�
,�
,��g�g�g��Q��'�!�+���m�/�/��4�4��� � ��S���1�-�-�-�� � ��S��X�X����2�2�2�� � ��Q���+�+�+�
,�
,�
,�
,�
,�
,�
,�
,�
,�
,�
,����
,�
,�
,�
,���C�1�q�5�M�)�	��m�'�'�	�2�2������y�k�*�*�*�*�*s�BC�C	�C	c���tjd��}|�d|��|�d|��|�d|��|�d|��dS)NzHeader: existsr�r�HEADER�headerx)r�r	r��assertNotInris  r:�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)
NrB�iso-2022-jp�
importance�
high valueFr-�"high value")�r@r,)rBrG)rHrI)rK)rBz
"iso-2022-jp")rHrJziso-9999-xxzX-Jimmyr)r3r�	set_paramrJrr6s   r:�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.comrRrPrT)r3r4rrJ�	del_paramrL)r7r8r9�old_vals    r:�test_del_paramzTestMessageAPI.test_del_params���
�
���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��filenamer^�content-disposition�r�
add_headerrVr3ris  r:�test_del_param_on_other_headerz-TestMessageAPI.test_del_param_on_other_headers[���i�i�����,�l�Y��O�O�O��
�
�j�"7�8�8�8�����2�3�\�B�B�B�B�Br<c�N�t��}|�dd��dS)Nr^r_)rrVris  r:�$test_del_param_on_nonexistent_headerz3TestMessageAPI.test_del_param_on_nonexistent_headers&���i�i���
�
�j�"7�8�8�8�8�8r<c���t��}|�ddd���|d}|�dd���|�|d|��dS)NrEr@rW�rB�foobarrr`)r7r9�existing_headers   r:�test_del_nonexistent_paramz)TestMessageAPI.test_del_nonexistent_paramsd���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@rArBrOrPz	text/htmlztext/html; charset="us-ascii")r3rr��
ValueError�set_typerLr6s   r:�
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)rrlr3ris  r:�test_set_type_on_other_headerz,TestMessageAPI.test_set_type_on_other_header.sO���i�i�� ,�������/�1A�B�B�B�����-�.�0J�K�K�K�K�Kr<c�r�t��}|�|���d��dS)Nr@)rr3rIris  r:�test_get_content_type_missingz,TestMessageAPI.test_get_content_type_missing4s3���i�i������-�-�/�/��>�>�>�>�>r<c��t��}|�d��|�|���d��dS)N�message/rfc822)r�set_default_typer3rIris  r:�/test_get_content_type_missing_with_default_typez>TestMessageAPI.test_get_content_type_missing_with_default_type8sI���i�i�����-�.�.�.�����-�-�/�/�1A�B�B�B�B�Br<c��|�d��}|�|�d�����d��dS)N�
msg_30.txtrrt�r4r3r[rIris  r:�+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.txtrrtryris  r:�+test_get_content_type_from_message_explicitz:TestMessageAPI.test_get_content_type_from_message_explicitBr{r<c��|�d��}|�|���d��dS)Nr�r@�r4r3rIris  r:�6test_get_content_type_from_message_text_plain_implicitzETestMessageAPI.test_get_content_type_from_message_text_plain_implicitG�;���l�l�<�(�(������-�-�/�/��>�>�>�>�>r<c��|�d��}|�|���d��dS)Nr�r@r�ris  r:�6test_get_content_type_from_message_text_plain_explicitzETestMessageAPI.test_get_content_type_from_message_text_plain_explicitKr�r<c�r�t��}|�|���d��dS)Nr��rr3�get_content_maintyperis  r:�!test_get_content_maintype_missingz0TestMessageAPI.test_get_content_maintype_missingOs3���i�i������1�1�3�3�V�<�<�<�<�<r<c��t��}|�d��|�|���d��dS)Nrtr9)rrur3r�ris  r:�3test_get_content_maintype_missing_with_default_typezBTestMessageAPI.test_get_content_maintype_missing_with_default_typeSsH���i�i�����-�.�.�.�����1�1�3�3�Y�?�?�?�?�?r<c��|�d��}|�|�d�����d��dS)Nrxrr9�r4r3r[r�ris  r:�/test_get_content_maintype_from_message_implicitz>TestMessageAPI.test_get_content_maintype_from_message_implicitX�G���l�l�<�(�(���������+�+�@�@�B�B�I�N�N�N�N�Nr<c��|�d��}|�|�d�����d��dS)Nr}rr9r�ris  r:�/test_get_content_maintype_from_message_explicitz>TestMessageAPI.test_get_content_maintype_from_message_explicit\r�r<c��|�d��}|�|���d��dS)Nr�r��r4r3r�ris  r:�: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�ris  r:�:test_get_content_maintype_from_message_text_plain_explicitzITestMessageAPI.test_get_content_maintype_from_message_text_plain_explicitdr�r<c�r�t��}|�|���d��dS)N�plain�rr3�get_content_subtyperis  r:� test_get_content_subtype_missingz/TestMessageAPI.test_get_content_subtype_missinghs3���i�i������0�0�2�2�G�<�<�<�<�<r<c��t��}|�d��|�|���d��dS)Nrt�rfc822)rrur3r�ris  r:�2test_get_content_subtype_missing_with_default_typezATestMessageAPI.test_get_content_subtype_missing_with_default_typelsH���i�i�����-�.�.�.�����0�0�2�2�H�=�=�=�=�=r<c��|�d��}|�|�d�����d��dS)Nrxrr��r4r3r[r�ris  r:�.test_get_content_subtype_from_message_implicitz=TestMessageAPI.test_get_content_subtype_from_message_implicitq�G���l�l�<�(�(���������+�+�?�?�A�A�8�L�L�L�L�Lr<c��|�d��}|�|�d�����d��dS)Nr}rr�r�ris  r:�.test_get_content_subtype_from_message_explicitz=TestMessageAPI.test_get_content_subtype_from_message_explicitur�r<c��|�d��}|�|���d��dS)Nr�r��r4r3r�ris  r:�9test_get_content_subtype_from_message_text_plain_implicitzHTestMessageAPI.test_get_content_subtype_from_message_text_plain_implicity�;���l�l�<�(�(������0�0�2�2�G�<�<�<�<�<r<c��|�d��}|�|���d��dS)Nr�r�r�ris  r:�9test_get_content_subtype_from_message_text_plain_explicitzHTestMessageAPI.test_get_content_subtype_from_message_text_plain_explicit}r�r<c�|�t��}d|d<|�|���d��dS)N�no-slash-in-this-stringrEr�r�ris  r:�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�rEr�r�ris  r:�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)r3rra�keys�values�replace_headerr��KeyErrorr6s   r:�test_replace_headerz"TestMessageAPI.test_replace_header�sx��
�
���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)NrZr[z
random.avir]�inline�InlinE)r�assertIsNone�get_content_dispositionrar3r�ris  r:�test_get_content_dispositionz+TestMessageAPI.test_get_content_disposition�s����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-midirArXrCTrYs����.���p���r)rrSr3r[�assertIsInstance�defectsr �InvalidBase64CharactersDefect�r7�xr9s   r:�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@rArarCTrYzraw-unicode-escape)rrSr3r[rr�s   r:�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 dorW�text/plain; charset="utf-8"rArarCTrY)r�r�_payloadr3r[r�s   r:�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)NrZr[r\r]zattachment; filename="bud.gif"�rrar3ris  r:�test_ascii_add_headerz$TestMessageAPI.test_ascii_add_header�s\���i�i�����,�l� )�	�	+�	+�	+����9��%�&�	(�	(�	(�	(�	(r<c��t��}|�ddd���|�d|d��dS)NrZr[�Fußballer.pptr]z/attachment; filename*=utf-8''Fu%C3%9Fballer.pptr�ris  r:�test_noascii_add_headerz&TestMessageAPI.test_noascii_add_header�s\���i�i�����,�l�%�	�	'�	'�	'����?��%�&�	(�	(�	(�	(�	(r<c��t��}|�ddd���|�d|d��dS)NrZr[)r>r,r�r]z1attachment; filename*=iso-8859-1''Fu%DFballer.pptr�ris  r:�#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)NrZr[zwindows [filename].pptr]z-attachment; filename="windows [filename].ppt"r�ris  r:�#test_ascii_add_header_with_tspecialz2TestMessageAPI.test_ascii_add_header_with_tspecial�s\���i�i�����,�l�-�	�	/�	/�	/����;��%�&�	(�	(�	(�	(�	(r<c��t��}|�ddd���|�d|d��dS)NrZr[uFußballer [filename].pptr]z@attachment; filename*=utf-8''Fu%C3%9Fballer%20%5Bfilename%5D.pptr�ris  r:�&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=%srArDrCsfoo=e6=96=87barTrY�	foo文bar�1get_payload returns wrong result with charset %s.rh�r7rBr9s   r:�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�rArXrCsZm9v5paHYmFyTrYr�r�rhr�s   r:�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�rArCs begin 666 -
)9F]OYI:'8F%R
 
end
TrYr�)z!get_payload returns wrong result z"with charset {0} and encoding {1}.)rrSr3r[r��format)r7rBr�r9s    r:�test_binary_uuencode_payloadz+TestMessageAPI.test_binary_uuencode_payloads���+�	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)NrZr�)�foo_barzinline; foo-barr�ris  r:�$test_add_header_with_name_only_paramz3TestMessageAPI.test_add_header_with_name_only_paramsG���i�i�����,�h���E�E�E����*�C�0E�,F�G�G�G�G�Gr<c��t��}|�dd��|�d|d��dS)NzX-Statusr,r�ris  r:�test_add_header_with_no_valuez,TestMessageAPI.test_add_header_with_no_values?���i�i�����z�4�(�(�(�����S��_�-�-�-�-�-r<c��t��}td��|d<|�tj|j��dS�Nzdummy
X-Injected-Header: test�Dummy)rrr�r r�r�ris  r:�(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�ris  r:�(test_embedded_header_via_string_rejectedz7TestMessageAPI.test_embedded_header_via_string_rejected&s5���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
            �rr3r�r�r��r7r�s  r:�-test_unicode_header_defaults_to_utf8_encodingz<TestMessageAPI.test_unicode_header_defaults_to_utf8_encoding+sU���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  r:�+test_unicode_body_defaults_to_utf8_encodingz:TestMessageAPI.test_unicode_body_defaults_to_utf8_encoding8sL���^�$�$������Q�����1�!�!�	�	�	�	�	r<N)Z�__name__�
__module__�__qualname__r;rMrQrTr^rcrerjrqrxr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrr
rrrr r$r(r+r/r1r@rErMrXrbrdrirmrprrrvrzr~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�r�r�r�r|r<r:r/r/:sx������,�,�,�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�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|)r;�r�r�s  r:r�z;TestEncoders.test_EncodersEncode_base64.<locals>.<listcomp>Ns��!:�!:�!:�a�3�q�6�6�!:�!:�!:r<�L)
r'r�r��mime�imagerr[r��assertLessEqual�max)r7r��bindata�mimed�base64edr�s      r:�test_EncodersEncode_base64z'TestEncoders.test_EncodersEncode_base64Gs���
�l�D�
)�
)�	 �R��g�g�i�i�G�	 �	 �	 �	 �	 �	 �	 �	 �	 �	 �	 ����	 �	 �	 �	 ��
� �*�*�7�3�3���$�$�&�&�����t�$�$�����S�!:�!:�5�!:�!:�!:�;�;�R�@�@�@�@�@��2�6�6c�~�|j}t��}|�d��||dd��dS)NrOrC�7bit)r3rrHr6s   r:�test_encode_empty_payloadz&TestEncoders.test_encode_empty_payloadPsC��
�
���i�i�����
�#�#�#�
��3�*�+�V�4�4�4�4�4r<c���|j}td��}||dd��td��}||dd��tdd���}||dd��dS)	N�hello worldrCruhello ø worldrXr>��_charsetrD)r3rr6s   r:�test_default_ctezTestEncoders.test_default_cteVs���
�
���}�%�%��
��3�*�+�V�4�4�4��)�*�*��
��3�*�+�X�6�6�6��)�L�A�A�A��
��3�*�+�-?�@�@�@�@�@r<c��|j}tdd���}||dd��||���tjd����dS)Nu文
�euc-jprrCrz�            MIME-Version: 1.0
            Content-Type: text/plain; charset="iso-2022-jp"
            Content-Transfer-Encoding: 7bit

            $BJ8(B
            )r3rr�r�r�r6s   r:�test_encode7or8bitzTestEncoders.test_encode7or8bitbsq���
���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�ris  r:�test_qp_encode_latin1z"TestEncoders.test_qp_encode_latin1qsP���|�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�ris  r:�test_qp_encode_non_latin1z&TestEncoders.test_qp_encode_non_latin1{sP���z�6�<�8�8������S���8�?�4�$�$�	�	�	�	�	r<N)	r�rrrrrrrr!r|r<r:rrEst������A�A�A�5�5�5�
A�
A�
A�
�
�
����	�	�	�	�	r<rc��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�r	rrr�r��r7r8r9�sfpr�s     r:�test_split_long_continuationz,TestLongHeaders.test_split_long_continuation�ss��
�
"���'�)�����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)r%rr�r��r7r8�hstr�hs    r:�,test_another_long_almost_unsplittable_headerz<TestLongHeaders.test_another_long_almost_unsplittable_header�s���
�
"����
�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>rsrW�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?=)
r%r
r�appendrrrr�r�r�)r7r8r��cz�utf8�g_head�cz_head�	utf8_headr/r9r's           r:�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-Defrobnitr5�jwasnipoop; giraffes="very-long-necked-animals";
 spooge="yummy"; hippos="gargantuan"; marshmallows="gooey"�r%rr��r7r8r/s   r:�test_long_header_encodez'TestLongHeaders.test_long_header_encode�sV��
�
"���O�:�
<�
<�
<��	��1�8�8�:�:�>�	?�	?�	?�	?�	?r<c�t�|j}tddd���}||���d��dS)NrArBr*�r6r,rCrDrEs   r:�<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"rBr*rHzjwasnipoop; giraffes="very-long-necked-animals";
	spooge="yummy"; hippos="gargantuan"; marshmallows="gooey"rDrEs   r:�-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=?=�rr3r��r7r/s  r:�0test_header_encode_with_different_output_charsetz@TestLongHeaders.test_header_encode_with_different_output_charsets6���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==?=)rrZr3r�)r7r/r>s   r:�5test_long_header_encode_with_different_output_charsetzETestLongHeaders.test_long_header_encode_with_different_output_charsetsV���$�%+�F�8�$4�$4�h�
@�
@��7��	
��������S�)�)�)�)�)r<c���|j}td��}d|d<t��}t|��}|�|��||���d��dS)Nr,rArBz�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"

)r%rrrr�r�r&s     r:�test_header_splitterz$TestLongHeaders.test_header_splittersx��
�
"���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  r:�	<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)
r%r�SPACEr��rangerSrrr�r�r&s     r:�test_no_semis_header_splitterz-TestLongHeaders.test_no_semis_header_splitter&s���
�
"���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_itselfrDrEs   r:�"test_last_split_chunk_does_not_fitz2TestLongHeaders.test_last_split_chunk_does_not_fit6�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_itselfrDrEs   r:�>test_splittable_leading_char_followed_by_overlong_unsplittablezNTestLongHeaders.test_splittable_leading_char_followed_by_overlong_unsplittable?rcr<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_itselfrDrEs   r:�Gtest_multiple_splittable_leading_char_followed_by_overlong_unsplittablezWTestLongHeaders.test_multiple_splittable_leading_char_followed_by_overlong_unsplittableHrcr<c�n�|j}td��}||���d��dS)NzTthis_part_does_not_fit_within_maxlinelen_and_thus_should_be_on_a_line_all_by_itself;rDrEs   r:�1test_trailing_splittable_on_overlong_unsplittablezATestLongHeaders.test_trailing_splittable_on_overlong_unsplittableQsK��
�
"���*�
+�
+��
��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; rDrEs   r:�Itest_trailing_splittable_on_overlong_unsplittable_with_leading_splittablezYTestLongHeaders.test_trailing_splittable_on_overlong_unsplittable_with_leading_splittableXsS��
�
"���+�
,�
,��	��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 foldedrDrEs   r:�5test_long_header_with_multiple_sequential_split_charszETestLongHeaders.test_long_header_with_multiple_sequential_split_charsasN��
�
"���F�
G�
G��
��1�8�8�:�:�)�	*�	*�	*�	*�	*r<c�n�|j}td��}||���d��dS)N�Kthisverylongheaderhas;semicolons;and,commas,butthey;arenotlegal;fold,pointsrDrEs   r:�:test_splitter_split_on_punctuation_only_if_fws_with_headerzJTestLongHeaders.test_splitter_split_on_punctuation_only_if_fws_with_headerisK��
�
"���+�
,�
,��
��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;rDrEs   r:�Dtest_leading_splittable_in_the_middle_just_before_overlong_last_partzTTestLongHeaders.test_leading_splittable_in_the_middle_just_before_overlong_last_partpsS��
�
"���*�
+�
+��	��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 rDrEs   r:�/test_overlong_last_part_followed_by_split_pointz?TestLongHeaders.test_overlong_last_part_followed_by_split_point{sK��
�
"���*�
+�
+��
��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; rDrEs   r:�@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; rDrEs   r:�>test_multiline_with_overlong_last_part_followed_by_split_pointzNTestLongHeaders.test_multiline_with_overlong_last_part_followed_by_split_point�rwr<c�F�|j}t��}d|d<t�dgdz��|d<|�d��t��}t
|��}|�|��||���d��dS)NrWr�z<foo@dom.ain>  r[r\r]z�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�	r%rr^r�rSrrr�r�r&s     r:�%test_long_header_with_whitespace_runsz5TestLongHeaders.test_long_header_with_whitespace_runs�s���
�
"���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)	NrWr�z
<foo@dom.ain>r[z; abcr\r]z�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

Testr{r&s     r:�'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)NrWr�ror\r]zrFrom: test@dom.ain
References: 
 thisverylongheaderhas;semicolons;and,commas,butthey;arenotlegal;fold,points

Test)r%rrSrrr�r�r&s     r:�.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�PxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxrDr-s    r:�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)
r*r+a_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)rDr-s    r:�"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*)r8r6r,z�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 -0400rDr-s    r:�&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�r5u-grünes Licht für Offshore-Windkraftprojekter	r7zl=?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?=

)r%rrr9r�r�)r7r8r9r/s    r:�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-Tor�r�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?=

r5)r%rr�r)r7r8r9�
header_strings    r:� test_long_8bit_header_no_charsetz0TestLongHeaders.test_long_8bit_header_no_charsets���
�
"���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�r�r�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>

)r%rr�)r7r8r�r9s    r:�test_long_to_headerz#TestLongHeaders.test_long_to_header'sX��
�
"��;��
�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	r7z\This is an example of string which has almost the limit of header length.
 Add another line.�r%rr9r��r7r8r�r/s    r:�test_long_line_after_appendz+TestLongHeaders.test_long_line_after_append8s`��
�
"��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    r:�test_shorter_line_with_appendz-TestLongHeaders.test_shorter_line_with_appendAs]��
�
"��%���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>r5r	r7a=?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_?=rD)r7r8�fn�gsr/s     r:�test_long_field_namez$TestLongHeaders.test_long_field_nameIse��
�
"��
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 -0700r*r+�
Received-1�
Received-2r�r�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

�rrr%r��r7r/r9s   r:�test_long_received_headerz)TestLongHeaders.test_long_received_headerXsl��/���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�r*rHr�r�r�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   r:�test_string_headerinst_eqz)TestLongHeaders.test_string_headerinst_eqjsu��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-2r5r-zFace-3r�r�a�Face-1: 
 iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAGFBMVEUAAAAkHiJeRUIcGBi9
 locQDQ4zJykFBAXJfWDjAAACYUlEQVR4nF2TQY/jIAyFc6lydlG5x8Nyp1Y69wj1PN2I5gzp
Face-2: 
 iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAGFBMVEUAAAAkHiJeRUIcGBi9
 locQDQ4zJykFBAXJfWDjAAACYUlEQVR4nF2TQY/jIAyFc6lydlG5x8Nyp1Y69wj1PN2I5gzp
Face-3: 
 iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAGFBMVEUAAAAkHiJeRUIcGBi9
 locQDQ4zJykFBAXJfWDjAAACYUlEQVR4nF2TQY/jIAyFc6lydlG5x8Nyp1Y69wj1PN2I5gzp

�r%rrr�)r7r8r9�ts    r:�-test_long_unbreakable_lines_with_continuationz=TestLongHeaders.test_long_unbreakable_lines_with_continuation}s~��
�
"���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 -0700r�r�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

)r%r�r	r��r7r8r�r9s    r:�"test_another_long_multiline_headerz2TestLongHeaders.test_another_long_multiline_header�sV��
�
"��/���'��*�*��
��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>�Listr5r�r�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�)r7r8r/r9s    r:�%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 worksrWr])rBr6r+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�r3r�rPs  r:�*test_long_rfc2047_header_with_embedded_fwsz:TestLongHeaders.test_long_rfc2047_header_with_embedded_fws�s����8�?�$,�-�-�#�%�
'�
'�
'��	
��������D��(�/�;7�+8�+8�9=�	+=�	>�	>�	>�	>�	>r<)+r�rr�maxDiffr(r0r?rFrIrKrQrSrUr`rbrergrirkrmrprrrtrvryr|r~r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r|r<r:r#r#�s��������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<r#c�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
)rr9rS�r7s r:�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�r9r3r��r7r�r�s   r:�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   r:�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�rs  r:r�zLTestFromMangling.test_mangle_from_in_preamble_and_epilog.<locals>.<listcomp>�s8��=�=�=�A�%&�\�\�(�%;�%;�=�a�=�=�=r<r+r�)rrr�r	r�r�r�r3r;r�r�)r7r�r�r9s    r:�'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

        rWsFrom Rölli
Tr�s
>From Rölli
)
r�r�r�r�r�rr
r�r3r�)r7r�r9�br�s     r:� 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: È
        rW)r�r�r�r�r�)r7r�r9s   r:�$test_multipart_with_bad_bytes_in_ctez5TestFromMangling.test_multipart_with_bad_bytes_in_cte	s>����"�
�
��V�G�_�_�		�
�&�v�.�.���r<N)	r�rrr�r�r�r�r�r�r|r<r:r�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�r7�extr�s   r:�_make_audiozTestMIMEAudio._make_audios���
�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�r3r�rI�r7r��subtypes   r:�test_guess_minor_typez#TestMIMEAudio.test_guess_minor_types�������	
�
�
�%�'�'�	N�	N�L�C��
���S�!�!�!�$�_�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�r[r3rX�decodebytesrr��r7�payloads  r:�
test_encodingzTestMIMEAudio.test_encoding%sg����������(�&�&�(�(������+�E�'�7�,C�,C�D�D���	*�	*�	*�	*�	*r<c��|�d��t|jd��}|�|���d��dS)Nr��fishz
audio/fish)r�rr�r3rI)r7r�s  r:�test_checkSetMinorz TestMIMEAudio.test_checkSetMinor+sO���������
�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�rZr[�	sndhdr.aur]r_z attachment; filename="sndhdr.au"r�r[r,)r^r�r^r,r���failobjr�rg)r�r3r�rarrJ�assertIs�r7r8�missings   r:�test_add_headerzTestMIMEAudio.test_add_header0s����������
�
������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�rrr�r�r�r�r�r|r<r:r�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   r:�_make_imagezTestMIMEImage._make_imageIs���
�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�r3r�rIr�s   r:r�z#TestMIMEImage.test_guess_minor_typeNs����������������
�
��%�'�'�	N�	N�L�C��
���S�!�!�!�$�_�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�r[r3rXr�rr�r�s  r:r�zTestMIMEImage.test_encodingbsg����������(�&�&�(�(������+�E�'�7�,C�,C�D�D���	(�	(�	(�	(�	(r<c��|�d��t|jd��}|�|���d��dS)Nr�r�z
image/fish)r�rr�r3rI)r7�ims  r:r�z TestMIMEImage.test_checkSetMinorhsO���������
�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�rZr[r�r]r_z%attachment; filename="dingusfish.gif"rr�)r^r�r^r,r�r�rg)r�r3r�rarrJr�r�s   r:r�zTestMIMEImage.test_add_headerms����������
�
������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�rrr�r�r�r�r�r|r<r:r�r�Hsg������,�,�,�
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�������rorCrX)r3rrIr6s   r:�test_headersz TestMIMEApplication.test_headers�sU��
�
���9�:�:��
��3���!�!�#=�>�>�>�
��3�*�+�X�6�6�6�6�6r<c���|j}d}t|��}||������d��||�d���|��dS)Nrz+vv8/f7/TrY)r3rr[�strip)r7r8�	bytesdatar9s    r:�	test_bodyzTestMIMEApplication.test_body�sj��
�
��/�	��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��TrYrFra)rr�encode_7or8bitr3r[r;rr
r�r�r�r��r7rr9r�r��wireform�msg2s       r:�$test_binary_body_with_encode_7or8bitz8TestMIMEApplication.test_binary_body_with_encode_7or8bit�s=��/�	��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)NrrrTrY)rr�encode_noopr3r[r;rr
r�r�r�r�rs       r:�!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������rTrY)rrrr3r[rr
r�r�r�r�rs       r:�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������ rz=FA=FB=FC=FD=FE=FF=20TrYrFrD)rr�
encode_quoprir3r[rr
r�r�r�r�rs       r:�#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)Nrrz	+vv8/f7/
TrY)rr�
encode_base64r3r[rr
r�r�r�r�rs       r:�#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�rrr	r
rrrrr!r|r<r:rr�s�������7�7�7�4�4�4�D�D�D�"C�C�C�"
C�
C�
C�P�P�P� C�C�C�C�Cr<rc�j�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	e
jd��d	���Zd
S)�TestMIMETextc�.�td��|_dS�N�hello there)r�_msgr�s r:r�zTestMIMEText.setUp�s���]�+�+��	�	�	r<c�f�|j}||j���d��||j�d��d��g}|�|j�d|��|��|�|j�d|d���|��dS)Nr@rBrOrgr)r3r'rIrJr�r�s   r:�
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%)r3r'r[�assertFalse�is_multipartr�s r:�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)Nr&rOrrArPrWr�)r3rrGrKr
rbr[rLs    r:�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)Nr&rOrrArP)r3rrGrKr6s   r:�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)Nr&rOrArP)r3rrGr�r�r6s   r:�test_7bit_input_no_charsetz'TestMIMEText.test_7bit_input_no_charsetsm��
�
���}�%�%��
��3�?�?���j�)�)�)�
��3�~�� @�A�A�A��
�
�m�S�]�]�_�_�5�5�5�5�5r<c�
�d}|j}t|d���}||���jd��||dd��||�d���|�d����dS)N�кирилицаrWrrAr�TrY)r3rrG�output_charsetr[r�)r7�teststrr8r9s    r:�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)Nr5)r��UnicodeEncodeErrorr)r7r7s  r:�test_utf8_input_no_charsetz'TestMIMEText.test_utf8_input_no_charsets)��E�����,�h��@�@�@�@�@r<N)
r�rrr�r)r-r/r1r3r8�unittest�skipr;r|r<r:r#r#�s�������,�,�,����3�3�3�-�-�-�B�B�B�6�6�6�B�B�B��X�]����A�A���A�A�Ar<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�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)Nrr�	multipart�mixedr��r"r�)r*r_r[r]z$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�rrrarro�time�	localtime�timezone�altzone�strftimer'r��_txt)r7r�r]�	containerr�intro�now�	timetuple�tzsecs�sign�tzoffsets           r:r�zTestMultipart.setUps���
�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)Nrlr�rr�)
r3r�r'r�r,rIr;r[�
IndexErrorr�rNr�r+)r7r8�raisesr��m0�m1s      r:�test_hierarchyzTestMultipart.test_hierarchy@s:��
�
���"���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�r%r�)r7r�r9s   r:�test_empty_multipart_idempotentz-TestMultipart.test_empty_multipart_idempotentRsF�����h�h����%�%�����d�C�M�M�O�O�4�4�4�4�4r<c��tdd��}d|d<d|d<d|d<|�d	��|�|���d
��dS)NrArB�	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�r%r��r7�outers  r:�/test_no_parts_in_a_multipart_with_none_epiloguez=TestMultipart.test_no_parts_in_a_multipart_with_none_epiloguecst����g�.�.��&��i��'��d��)��f�
�
���:�&�&�&����e�o�o�/�/�
2�
	�
	�
	�
	�
	r<c���tdd��}d|d<d|d<d|d<d	|_d	|_|�d
��|�|���d��dS)NrArBr_r�r`r�rar�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�r%r�rbs  r:�0test_no_parts_in_a_multipart_with_empty_epiloguez>TestMultipart.test_no_parts_in_a_multipart_with_empty_epilogueus�����g�.�.��&��i��'��d��)��f�
�������
���:�&�&�&����e�o�o�/�/�2�	�	�	�	�	r<c��|j}tdd��}d|d<d|d<d|d<|�d	��td
��}|�|��||���d��dS)NrArBr_r�r`r�rar�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--
)r%rr�rror��r7r8rcr9s    r:�test_one_part_in_a_multipartz*TestMultipart.test_one_part_in_a_multipart�s���
�
"����g�.�.��&��i��'��d��)��f�
�
���:�&�&�&��}�%�%��
���S����
��5�?�?����	�	�	�	�	r<c��|j}tdd��}d|d<d|d<d|d<d	|_td
��}|�|��|�d��||���d��dS)
NrArBr_r�r`r�rar�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--
�r%rrfrror�r�rks    r:�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�NrArBr_r�r`r�rar�rr�rjrnrks    r:�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��dSrq�r%rrgrror�r�rks    r:�0test_seq_parts_in_a_multipart_with_none_epiloguez>TestMultipart.test_seq_parts_in_a_multipart_with_none_epilogue�rsr<c��|j}tdd��}d|d<d|d<d|d<d	|_td
��}|�|��|�d��||���d��dS)
NrArBr_r�r`r�rar�r,rr�rjrurks    r:�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)
NrArBr_r�r`r�rar�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--

rurks    r:�.test_seq_parts_in_a_multipart_with_nl_epiloguez<TestMultipart.test_seq_parts_in_a_multipart_with_nl_epilogues���
�
"����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@)r3r4r;r[rI)r7r8r9�msg1r��
subsubparts      r:�test_message_external_bodyz(TestMultipart.test_message_external_body+s3��
�
���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�)r4r3r;r[ris  r:�test_double_boundaryz"TestMultipart.test_double_boundary8sC���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
�r%r4rr!�
_structurer��r7r8r9r's    r:�)test_nested_inner_contains_outer_boundaryz7TestMultipart.test_nested_inner_contains_outer_boundary?sf��
�
"��
�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
r�r�s    r:�test_nested_with_same_boundaryz,TestMultipart.test_nested_with_same_boundaryRsf��
�
"���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--
)r4r3r�ris  r:�test_boundary_in_non_multipartz,TestMultipart.test_boundary_in_non_multipartcsD���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�)r3r�r	r�r,r�r;r[r6s   r:� test_boundary_with_leading_spacez.TestMultipart.test_boundary_with_leading_spacers���
�
���'�)����	
����(�(�*�*�+�+�+�
��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�r3r[r�s  r:�&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)NrArB)rr�r�r��compat32r�s  r:�test_mimebase_default_policyz*TestMultipart.test_mimebase_default_policy�s2���[�'�*�*���
�
�a�h��� 5�6�6�6�6�6r<c��tddtjj���}|�|jtjj��dS)NrArBr�)rr�r��defaultr�r�s  r:�test_mimebase_custom_policyz)TestMultipart.test_mimebase_custom_policy�s<���[�'�%�,�2F�G�G�G���
�
�a�h��� 4�5�5�5�5�5r<N)r�rrr�r[r]rdrhrlrorrrvrxrzrr�r�r�r�r�r�r�r�r|r<r:r?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�)r3r4rIr�r�r6s   r:�test_parse_missing_minor_typez/TestNonConformant.test_parse_missing_minor_type�s{��
�
���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�)
r4r[r��hasattrr3r;r�r�r �StartBoundaryNotFoundDefect)r7r9�inners   r:�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�)
r4r�r[r�r3r;r�r �NoBoundaryInMultipartDefect�!MultipartInvariantViolationDefectris  r:�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�r3r;r�r�r �-InvalidMultipartContentTransferEncodingDefectris  r:�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�r3r;r�ris  r:�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)rra�BINaryz
Content-Transfer-Encoding: {}rr�)r7r�r9s   r:�"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�rEr�r@rAr�zContent-Type: foo

)
r3r%rr�r�rIrrr�r�)r7r8�neqr9r�r�s      r:�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--
)r%r4r[r6s   r:�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
)r%r4r�r6s   r:�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�)
r4r�r�r3r;r�r�r r�r�ris  r:�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)r4r[r3r;r�r�r r�)r7rc�bads   r:�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
)r3r�r	r�r[r;r��assertDefectsEqualr �#FirstHeaderLineIsContinuationDefect�liner�s    r:�&test_first_line_is_continuation_headerz8TestNonConformant.test_first_line_is_continuation_header2	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�r3r�r[r�r�r � MissingHeaderBodySeparatorDefectris  r:�"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�rrr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r|r<r:r�r��s������/�/�/�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	r7ziRe: =?mac-iceland?q?r=8Aksm=9Arg=8Cs?= baz foo bar =?mac-iceland?q?r=8Aksm?=
 =?mac-iceland?q?=9Arg=8Cs?=)r3rrr�r%r��r7r8r��dhr�s     r:�test_rfc2047_multilinez"TestRFC2047.test_rfc2047_multilineL	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>�r3rr�rr�s     r:�test_whitespace_keeper_unicodez*TestRFC2047.test_whitespace_keeper_unicode]	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�)r7r8r�r��hus     r:� test_whitespace_keeper_unicode_2z,TestRFC2047.test_whitespace_keeper_unicode_2f	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�rr3�r7r�r�s   r:�test_rfc2047_missing_whitespacez+TestRFC2047.test_rfc2047_missing_whitespaceo	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   r:�test_rfc2047_with_whitespacez(TestRFC2047.test_rfc2047_with_whitespacev	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�)r7r�r]�q�ar�s      r:�test_rfc2047_B_bad_paddingz&TestRFC2047.test_rfc2047_B_bad_padding}	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>�r3r�r7r�s  r:�test_rfc2047_Q_invalid_digitsz)TestRFC2047.test_rfc2047_Q_invalid_digits�	s9��)������q�)�)�7�8�	:�	:�	:�	:�	:r<c�T�d}|�t|��gd���dS)Nz(=?ISO-8859-1?Q?a?=))��(N��ar>��)Nr�r�s  r:�test_rfc2047_rfc2047_1z"TestRFC2047.test_rfc2047_rfc2047_1�	sA��"������q�)�)�>�>�>�	@�	@�	@�	@�	@r<c�T�d}|�t|��gd���dS)Nz(=?ISO-8859-1?Q?a?= b))r�r�)s b)Nr�r�s  r:�test_rfc2047_rfc2047_2z"TestRFC2047.test_rfc2047_rfc2047_2�	�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  r:�test_rfc2047_rfc2047_3z"TestRFC2047.test_rfc2047_rfc2047_3�	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  r:�test_rfc2047_rfc2047_4z"TestRFC2047.test_rfc2047_rfc2047_4�	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  r:�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  r:�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  r:�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 brsr�z(a b))r3rrr�r�r�r�s  r:�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>)r3rrr�r��
splitlinesr�r�s  r:�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�rrr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rr|r<r:r�r�K	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.txtrWr�)r'r��_text�r7r�s  r:r�zTestMIMEMessage.setUp�	s���
�l�W�
5�
5�
5�	#�������D�J�	#�	#�	#�	#�	#�	#�	#�	#�	#�	#�	#�	#����	#�	#�	#�	#�	#�	#s
�9�=�=c�H�|�ttd��dS)Nza plain string)r�rnrr�s r:�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�rtr�r�subject)	r3rrrIr[r��listr;r�)r7r8rr�r5r�r�s       r:�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 �MultipartConversionErrorro)r7r}rr5s    r:�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.
)rrSrrrr�r3r�)r7r�r5r�r�s     r:�
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)Nrrtr�rrrr)r3r4rIr[r�rr;r)r7r8r9r��submsgs     r:�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.txtrQr�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-recipientrt�
message-idz(<002001c144a6$8752e060$56104586@oxy.edu>)r3r4rIr�r,r;r[r�rrJrr)r7r8r9r��dsn1�dsn2r�r~s        r:�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.txtrWr�r`r�rar�r]r��MIME messagezEnd of MIME message
r�r�rErlr�rC)
r%r'r�rrfrgrrarorrr�r�)	r7r8r�r�r9r}rr'r�s	         r:�
test_epiloguezTestMIMEMessage.test_epilogueC
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)Nr`r�rar�r]r�r%r,r�r�rErlr�rCadFrom: 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--
)r%rrfrgrraror�)r7r8r9r}rs     r:�test_no_nl_preamblez#TestMIMEMessage.test_no_nl_preambleW
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)NrxrWr�rrtr�r@�r3r'r��message_from_filer[�get_default_typerI�r7r8r�r9�
container1�
container2�container1a�container2as        r:�test_default_typez!TestMIMEMessage.test_default_typez
���
�
��
�l�W�
5�
5�
5�	.���)�"�-�-�C�	.�	.�	.�	.�	.�	.�	.�	.�	.�	.�	.����	.�	.�	.�	.��_�_�Q�'�'�
�
��:�&�&�(�(�*:�;�;�;�
��:�&�&�(�(�*:�;�;�;��_�_�Q�'�'�
�
��:�&�&�(�(�*:�;�;�;�
��:�&�&�(�(�*:�;�;�;� �,�,�Q�/�/��
��;�'�'�)�)�<�8�8�8�
��;�'�'�)�)�<�8�8�8� �,�,�Q�/�/��
��;�'�'�)�)�<�8�8�8�
��;�'�'�)�)�<�8�8�8�8�8r'c��|j}tdd���5}tj|��}ddd��n#1swxYwY|�d��}||���d��||���d��|�d��}||���d��||���d��|�d��}||���d��||���d��|�d��}||���d��||���d��dS)Nr}rWr�rrtr�r@r+r.s        r:�.test_default_type_with_explicit_container_typez>TestMIMEMessage.test_default_type_with_explicit_container_type�
r4r'c��|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
rtra�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--
rAr?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--
)
r3r%rrgrrrorIr-r�)r7r8r�rO�	subpart1a�	subpart2a�subpart1�subpart2s        r:�test_default_type_non_parsedz,TestMIMEMessage.test_default_type_non_parsed�
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�)r3rrr;r[)r7r8�text1�text2r9s     r:�$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��}|�|�����dSrg)rr�r,ris  r:�"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�)rr3r5ris  r:�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�rHr�rIz.There may be at most 1 To headers in a message)	rr�r�r�r�rkr3r��	exception)r7r9�cms   r:�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�rrr�r	r
rrrr"r&r)r3r6r?rDrFrJrNr|r<r:rr�	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<rc��eZdZd�Zd�ZdS)�TestNonMultipartc�t�tdd��}|�|�����dS)Nr�r�)rr+r,ris  r:�"test_nonmultipart_is_not_multipartz3TestNonMultipart.test_nonmultipart_is_not_multiparts7���v�w�/�/������)�)�+�+�,�,�,�,�,r<c��t��}d|d<tdd��}|�tj|j|��dS)Nrr�r�r�)rrr�r rro)r7r9r5s   r:�test_attach_raises_exceptionz-TestNonMultipart.test_attach_raises_exceptionsF���i�i��$��I���V�W�-�-�����&�9�1�8�S�I�I�I�I�Ir<N)r�rrrRrTr|r<r:rPrPs7������-�-�-�J�J�J�J�Jr<rPc��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�NrWr��r'r�r�r	�r7r^r�r]r9s     r:r4zTestIdempotent._msgobjs���
�h��
1�
1�
1�	�R��7�7�9�9�D�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	��'��-�-���D�y�r�Fc��|j}t��}t|d���}|�||���|||�����dS)Nrr�r�)r%rrr�r�)r7r9r�r�r8r�r�s       r:�_idempotentzTestIdempotent._idempotents[��
�
"���J�J���a�a�(�(�(��	�	�	�#��	�)�)�)�
��4����������r<c���|j}|�d��\}}||���d��||���d��||���d��||���dd��||�d��d��||jd��||jd��|�	||��dS)	Nr�r@r�r�r�)rBrOrBrO)
r3r4rIr�r�rrJrfrgr\�r7r8r9r�s    r:�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@rB)r3r4rIrrJr\r^s    r:�test_parse_untyped_messagez)TestIdempotent.test_parse_untyped_message1s���
�
���L�L��.�.�	��T�
��3���!�!�<�0�0�0�
��3�>�>���T�"�"�"�
��3�=�=��#�#�T�*�*�*�����d�#�#�#�#�#r<c�b�|�d��\}}|�||��dS)Nrz�r4r\�r7r9r�s   r:�test_simple_multipartz$TestIdempotent.test_simple_multipart9�3���L�L��.�.�	��T�����d�#�#�#�#�#r<c�b�|�d��\}}|�||��dS)N�
msg_02.txtrcrds   r:�test_MIME_digestzTestIdempotent.test_MIME_digest=rfr<c�b�|�d��\}}|�||��dS)Nz
msg_27.txtrcrds   r:�test_long_headerzTestIdempotent.test_long_headerArfr<c�b�|�d��\}}|�||��dS)Nr}rcrds   r:�"test_MIME_digest_with_part_headersz1TestIdempotent.test_MIME_digest_with_part_headersErfr<c�b�|�d��\}}|�||��dS)N�
msg_06.txtrcrds   r:�test_mixed_with_imagez$TestIdempotent.test_mixed_with_imageIrfr<c�b�|�d��\}}|�||��dS)NrOrcrds   r:�test_multipart_reportz$TestIdempotent.test_multipart_reportMrfr<c�b�|�d��\}}|�||��dS)Nrrcrds   r:r"zTestIdempotent.test_dsnQrfr<c�b�|�d��\}}|�||��dS)Nr$rcrds   r:�test_preamble_epiloguez%TestIdempotent.test_preamble_epilogueUrfr<c�b�|�d��\}}|�||��dS)Nz
msg_23.txtrcrds   r:�test_multipart_one_partz&TestIdempotent.test_multipart_one_partYrfr<c�b�|�d��\}}|�||��dS)Nz
msg_24.txtrcrds   r:�test_multipart_no_partsz&TestIdempotent.test_multipart_no_parts]rfr<c�b�|�d��\}}|�||��dS)Nr�rcrds   r:r�z%TestIdempotent.test_no_start_boundaryarfr<c�b�|�d��\}}|�||��dS)N�
msg_32.txtrcrds   r:�test_rfc2231_charsetz#TestIdempotent.test_rfc2231_charseterfr<c�b�|�d��\}}|�||��dS)Nz
msg_33.txtrcrds   r:�test_more_rfc2231_parametersz+TestIdempotent.test_more_rfc2231_parametersirfr<c�b�|�d��\}}|�||��dS)Nz
msg_34.txtrcrds   r:�%test_text_plain_in_a_multipart_digestz4TestIdempotent.test_text_plain_in_a_multipart_digestmrfr<c�b�|�d��\}}|�||��dS)Nzmsg_12a.txtrcrds   r:�test_nested_multipart_mixedsz+TestIdempotent.test_nested_multipart_mixedsqs3���L�L��/�/�	��T�����d�#�#�#�#�#r<c�b�|�d��\}}|�||��dS)Nr|rcrds   r:�%test_message_external_body_idempotentz4TestIdempotent.test_message_external_body_idempotenturfr<c�f�|�d��\}}|�||d���dS)N�
msg_43.txtTr�rcrds   r:�test_message_delivery_statusz+TestIdempotent.test_message_delivery_statusys8���L�L��.�.�	��T�����d�T��2�2�2�2�2r<c�b�|�d��\}}|�||��dS�N�
msg_45.txtrcrds   r:�test_message_signed_idempotentz-TestIdempotent.test_message_signed_idempotent}rfr<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)NrOrQrRrSr"rUz$This is a MIME-encapsulated message.r�rr@zYadda yadda yaddar�r�rt)r3r4rIrrfr�rgr;r[r�rr)r7r8r9r��params�pk�pvr}r�msg3r��msg4s            r:�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)Nrortr�rr@)
r3r4rIr[r�rr;rr�r�)r7r8r9r�r�r}s      r:�test_parserzTestIdempotent.test_parser�s��
�
���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�rrr�r4r\r_rarerirkrmrprrr"rurwryr�r}rr�r�r�r�r�r�r�r|r<r:rVrVs��������G��������
$�
$�
$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�3�3�3�$�$�$�C�C�C�>-�-�-�-�-r<rVc���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-e.j/��e0j1d,��d-�����Z2d.�Z3d/�Z4d0�Z5d1�Z6d2�Z7d3�Z8d4�Z9d5�Z:d6�Z;d7�Z<d8�Z=d9�Z>d:�Z?d;�Z@d<�ZAd=S)>�TestMiscellaneousc�`�tdd���5}|���}ddd��n#1swxYwYtj|��}t	��}t|d���}|�|��|�||�����dS�Nr�rWr�rr��	r'r�r�r	rrr�r3r��r7r�r�r9r�r�s      r:�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�r,rrr�r3r�r�s      r:�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�rWr�c��eZdZdS)�HTestMiscellaneous.test_message_from_string_with_class.<locals>.MyMessageN�r�rrr|r<r:�	MyMessager����������Dr<r�rh)r'r�rr�r	r��walk)r7r�r�r�r9r�s      r:�#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<r:r�r��r�r<r�r�rWr�rh)rr'r�r,r�r�)r7r�r�r9r�s     r:�!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�����dSrg)�super�__init__)r7�	__class__s �r:r�z\TestMiscellaneous.test_custom_message_does_not_require_arguments.<locals>.MyMessage.__init__�s������ � �"�"�"�"�"r<)r�rrr��
__classcell__)r�s@r:r�r��s8�������
#�
#�
#�
#�
#�
#�
#�
#�
#r<r�zSubject: test

test)rr�r�)r7r�r9s   r:�.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�)rrBrr �
feedparserr�r�r!r9�message_from_binary_filer�r,r	r
r�r"r#)�
__import__r3�sorted�__all__)r7�modules  r:�test__all__zTestMiscellaneous.test__all__�sL���G�$�$��������/�/�2�2�2�	�	�	�	�	r<c���tj��}|�tjtj|����dd�tj|��dd���dS)N�)rIr3r#�	parsedate�
formatdate�gmtime�r7rQs  r:�test_formatdatez!TestMiscellaneous.test_formatdate�se���i�k�k��������)9�#�)>�)>�?�?����C���S�)�)�"�1�"�-�	/�	/�	/�	/�	/r<c���tj��}|�tjtj|d�����dd�tj|��dd���dS)NT�rJr�)rIr3r#r�r�rJr�s  r:�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)rJ�usegmtz%a, %d %b %Y %H:%M:%S GMT)rIr3r#r�rMr�r�s  r:�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)r8r�r#r��parsedate_tz)r7�
invalid_datesr�s   r:�/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�rD�pzWed,3 Apr 2002 14:58:26 +0800zWed 3 Apr 2002 14:58:26 +0800�r3r#r�r�s r:�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�rD透��zFebruary 5, 2003 13:47:26 -0800r��r7r8s  r:�test_parsedate_no_dayofweekz-TestMiscellaneous.test_parsedate_no_dayofweek0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 r:�.test_parsedate_no_space_before_positive_offsetz@TestMiscellaneous.test_parsedate_no_space_before_positive_offset7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�rDr�r�r�s r:�.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�rDr�r�r�s  r:�%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�rDi����r�r�s r:�test_parsedate_rfc_850z(TestMiscellaneous.test_parsedate_rfc_850G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�rDr�r�r�s r:�test_parsedate_no_secondsz+TestMiscellaneous.test_parsedate_no_secondsK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 r:�!test_parsedate_dot_time_delimiterz3TestMiscellaneous.test_parsedate_dot_time_delimiterO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��	)	r3r#r��intrI�mktimerJrMr�)r7r8�timetupr�s    r:�+test_parsedate_acceptable_to_time_functionsz=TestMiscellaneous.test_parsedate_acceptable_to_time_functionsU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�rrrrDrDrDrr)
r�r�r�rrrrDrDrDi�i.���)r3r#�	mktime_tzr�s r:�test_mktime_tzz TestMiscellaneous.test_mktime_tz`sm�������*9�:�:�;<�	>�	>�	>������*<�=�=�>C�	E�	E�	E�	E�	Er<c���	|�tjd��tjd����|�tjd��tjd����dS)Nz25 Feb 03 13:47:26 -0800z25 Feb 2003 13:47:26 -0800z25 Feb 71 13:47:26 -0800z25 Feb 1971 13:47:26 -0800r�r�s r:�test_parsedate_y2kz$TestMiscellaneous.test_parsedate_y2kf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<>r3r,�r3r#�	parseaddr�
formataddrr�s r:�test_parseaddr_emptyz&TestMiscellaneous.test_parseaddr_emptyssS��������.�.��9�9�9�����)�%�/�$�*?�*?�@�@�"�E�E�E�E�Er<c��|�tjd��d��|�tjd��d��|�tjd��d��dS)Nza@b@cr3za@b.c@cza@172.17.0.1@c�r3r#rr�s r:�test_parseaddr_multiple_domainsz1TestMiscellaneous.test_parseaddr_multiple_domainsws�������O�G�$�$��	
�	
�	
�	
����O�I�&�&��	
�	
�	
�	
����O�,�-�-��	
�	
�	
�	
�	
r<c�V�|�tjd��d��dS)N)zA Silly Person�person@dom.ainzA Silly Person <person@dom.ain>�r3r#rr�s r:�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
�r3r#rr�r7r�r�s   r:�test_escape_dumpz"TestMiscellaneous.test_escape_dump�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   r:�test_escape_backslashesz)TestMiscellaneous.test_escape_backslashes�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)r7r*�addr�utf8_base64�
latin1_quopris     r:�test_quotes_unicode_namesz+TestMiscellaneous.test_quotes_unicode_names�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����Srgr|)r7�stringrgs  �r:�
header_encodezYTestMiscellaneous.test_accepts_any_charset_like_object.<locals>.CharsetMock.header_encode�s����
r<N)r�rrr!)rgs�r:�CharsetMockr�s.�������
�
�
�
�
�
�
r<r"z <�>rW)r3r#rr
)r7r*rrr"�mock�
mock_expectedrgs       @r:�$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)r7r*r�bad_charsets    r:�-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�r7rs  r:�!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)r7r��yr�r�s     r:�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,r5�!"\"example\" example"@example.com)r,r6�#"\\"example\\" example"@example.com)r,r7rr�s  r:�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.comrr�s r:�-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)r7r�addrstrs   r:�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 Barr?r)r7r�s  r:�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>rr�s r:�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)NrO�US-ASCIIzUs-AsCiI�usascii�USASCII�UsAsCiI)r3�assertNotEqualr
)r7r8�ne�cset1�cset2s     r:�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)N�aperson@dom.ain (Al Person)zBud Person <bperson@dom.ain>�z	Al Personr`)z
Bud Personra�r3r#�getaddressesr�s  r:�test_getaddressesz#TestMiscellaneous.test_getaddresses
sO��
�
��
��5��<�=�?�@�@�,�-�/�	0�	0�	0�	0�	0r<c�`�	|�tjgd���gd���dS)N)z"Bud, Person" <bperson@dom.ain>rQz#"Mariusz Felisiak" <to@example.com>))zBud, PersonrarR)zMariusz Felisiak�to@example.comrSr�s r:�test_getaddresses_comma_in_namez1TestMiscellaneous.test_getaddresses_comma_in_name!
sU��(���������
�
�
�
�
�
	
�
	
�
	
�
	
�
	
r<c�
�	d}d}d}dd|�d�|fgfdd|f|d|fgfdd|f|d|f|gfdd|f|d|fgfd	d|�d
|�d�fgfdd|f|d|fgfd
||d|fgfdd|f|d|fgfdd|fd|fgfdd|dzfd|fgfdd|fdd|�d�fgffD]�\}}|�|�d|�d�}|�|���5|�tj|g��|g��|�tj|gd���|��|�tj|g��|��|�tj|gd���d|f��ddd��n#1swxYwY��|�d|�d�}|�tj|g��d|fd|fg��|�tj|gd���d|fd|fg��|�tj|g��|��|�tj|gd���d|f��d}d}|�tj|g��|g��|�tj|gd���|g��|�tj|g��|��|�tj|gd���d|f��d}d}|�tj|g��|g��|�tj|gd���|g��|�tj|g��|��|�tj|gd���d|f��d}|�tj|g��|g��|�tj|gd���gd���|�tj|g��|��|�tj|gd���d|f��d}|�tj|g��ddg��|�tj|gd���ddg��|�tj|g��|��|�tj|gd���d|f��|�t
jjd��dS) N�alice@example.org�bob@example.comr3�(�<r#�)r,�[z[<z>]�]�@r7�:�.�")�addressF��strictz,<z,"Alice, alice@example.org" <bob@example.com>)zAlice, alice@example.orgr[zalice@example.org (Alice))�AlicerZzalice@example.org )Alice())r,rZr3)r,rh�<"Jane Doe" <jane@example.net>, "John Doe" <john@example.net>)zJane Doezjane@example.net)zJohn Doezjohn@example.netT)r8r3r#rTrr��supports_strict_parsing)r7�alice�bob�empty�invalid_separator�expected_non_strictre�expected_stricts        r:�test_parsing_errorsz%TestMiscellaneous.test_parsing_errors2
si��L�#�������J��J�J�J��&�'�(�
�B��;���C�y�1�2�
�B��;���C�y�%�8�9�
�B��;���C�y�1�2�
�B�5�+�+�C�+�+�+�,�-�.�
�B��;���C�y�1�2�
�5�%�"�c��+�,�
�B��;���C�y�1�2�
�B��;��S�	�*�+�
�B����$�r�3�i�0�1�
�B��;��Z��Z�Z�Z� 0�1�2�7
�	0�	0�2��2��:� 1�:�:�C�:�:�:�G����g��.�.�	
0�	
0�� � ��!3�W�I�!>�!>�"'��*�*�*�� � ��!3�W�I�e�!L�!L�!L�!4�6�6�6�� � ���'��!;�!;�!&�(�(�(�� � ���'��5�!I�!I�!I�"$�g��0�0�0�	
0�	
0�	
0�	
0�	
0�	
0�	
0�	
0�	
0�	
0�	
0����	
0�	
0�	
0�	
0���$�$�c�$�$�$������+�W�I�6�6��u�+��C�y�1�	3�	3�	3�����+�W�I�e�D�D�D��u�+��C�y�1�	3�	3�	3������'��3�3��	 �	 �	 ������'��5�A�A�A��g��	(�	(�	(�A��I������+�W�I�6�6��8I�J�J�J�����+�W�I�e�D�D�D��FW�X�X�X������'��3�3�_�E�E�E������'��5�A�A�A��g��	(�	(�	(�.��8������+�W�I�6�6��8I�J�J�J�����+�W�I�e�D�D�D��FW�X�X�X������'��3�3�_�E�E�E������'��5�A�A�A��g��	(�	(�	(�.������+�W�I�6�6���@�@�@�����+�W�I�e�D�D�D�M�M�M�	O�	O�	O������'��3�3�U�;�;�;������'��5�A�A�A��g��	(�	(�	(�Q������+�W�I�6�6�:�:�<�	=�	=�	=�	
����+�W�I�e�D�D�D�:�:�<�	=�	=�	=�	
�����'��3�3�U�;�;�;������'��5�A�A�A��g��	(�	(�	(�	
�����<�d�C�C�C�C�Cs�"B,E�E	�!E	c�2�dgdgfdgdgfddgddgfdgdgfd	gdgfd
ggd�fdgd
gfdgdgfdgdgfdgddgff
D]�\}}|�|���5|�tj|��|��|�tj|d���|��ddd��n#1swxYwY��dg}|�tj|��dg��|�tj|d���gd���dS)Nu&"Sürname, Firstname" <to@example.com>)uSürname, FirstnamerWzfoo: ;r3z#"Jason R. Mastaler" <jason@dom.ain>)zJason R. Mastalerz
jason@dom.ainz=Pete(A nice \) chap) <pete(his account)@silly.test(his host)>)z)Pete (A nice ) chap his account his host)zpete@silly.testz<(Empty list)(start)Undisclosed recipients  :(nobody(I know))z=Mary <@machine.tld:mary@example.net>, , jdoe@test   . example))�Maryzmary@example.netr3)r,zjdoe@test.examplez*John Doe <jdoe@machine(comment).  example>)zJohn Doe (comment)zjdoe@machine.examplez3"Mary Smith: Personal Account" <smith@home.example>)zMary Smith: Personal Accountzsmith@home.examplezUndisclosed recipients:;z7<boss@nil.test>, "Giant; \"Big\" Box" <bob@example.net>)r,z
boss@nil.test)zGiant; "Big" Boxzbob@example.net)�	addressesFrfz	[]*-- =~$)r3r3)r,z*--)r8r3r#rT)r7rtr�s   r:�test_getaddresses_nastyz)TestMiscellaneous.test_getaddresses_nasty�
s��6�
7�7�
8�
:��Z��Z�
��=�
>��>�
?�
A�O�
O�N�
O�
Q�M�
M��Z�
�N�
N�
P�
P�
P�
R�;�
;�<�
=�
?�D�
D�D�
E�
G�)�
)��Z�
�I�
I�#�%L�
M�
O�9$
�#	+�#	+��I�x�>���	��2�2�
+�
+�� � ��!3�I�!>�!>�!)�+�+�+�� � ��!3�I�e�!L�!L�!L�!)�+�+�+�
+�
+�
+�
+�
+�
+�
+�
+�
+�
+�
+����
+�
+�
+�
+��!�M�	�����+�I�6�6�"��	%�	%�	%�����+�I�e�D�D�D�:�:�:�	<�	<�	<�	<�	<s�AB3�3B7	�:B7	c�p�	|j}tjdg��}||ddd��dS)Nz%User ((nested comment)) <foo@bar.com>rr��foo@bar.comrS)r7r8�addrss   r:�"test_getaddresses_embedded_commentz4TestMiscellaneous.test_getaddresses_embedded_comment�
sA��6�
�
���"�$K�#L�M�M��
��5��8�A�;�
�&�&�&�&�&r<c��	tjtd��g��}|�|ddd��dS)NzAl Person <aperson@dom.ain>rr�r`)r#rTrr3)r7rxs  r:�test_getaddresses_header_objz.TestMiscellaneous.test_getaddresses_header_obj�
sF��3��"�F�+H�$I�$I�#J�K�K������q��!��&7�8�8�8�8�8r<�cpuc�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)�msgidsr9r#�
make_msgidrI�	monotonic)r7r9r��clock�tfins     r:�runzFTestMiscellaneous.test_make_msgid_collisions.<locals>.MsgidsThread.run�
sw�� �����+��"�-�
�����u�w�w��}���e�g�g��n�n��F�:�:�-@�A�A�A�B�B�B��e�g�g��n�n�n�n�n�nr<N)r�rrr�r|r<r:�MsgidsThreadr�
s(������
C�
C�
C�
C�
Cr<r�c�$��g|]}�����
Sr|r|)r�rYr�s  �r:r�z@TestMiscellaneous.test_make_msgid_collisions.<locals>.<listcomp>�
s���4�4�4�a�<�<�>�>�4�4�4r<r�c��g|]	}|j��
Sr|)r�)r�r�s  r:r�z@TestMiscellaneous.test_make_msgid_collisions.<locals>.<listcomp>�
s��1�1�1�A�q�x�1�1�1r<)rr_r%�
start_threads�sumr3r;r<)r7�threads�all_idsr�s   @r:�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)Nr_r[zfoo\wacky"namer])r3rrar~r6s   r:�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 charsetrX�r
r3�get_body_encoding�r7rBs  r:�)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-8rErAr�rrWrXr�rf�aGVsbG8gd29ybGQ=
TrYrCztext/plain; charset="US-ASCII"rOrr)
r3rrvr;r
r�rSr[rr)r7r8r9rwrBs     r:�-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)NrOrGr�)r7�lc�ucs   r:�test_charsets_case_insensitivez0TestMiscellaneous.test_charsets_case_insensitive�
sP��
�Z�
 �
 ��
�Z�
 �
 ������-�-�/�/��1E�1E�1G�1G�H�H�H�H�Hr<c��|j}|�d��}t��}tj||��||���d��dS)Nr�aBmultipart/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
r�r�s    r:�1test_partial_falls_inside_message_delivery_statuszCTestMiscellaneous.test_partial_falls_inside_message_delivery_statussf��
�
"��
�l�l�<�(�(���j�j����S�#�&�&�&�
��3�<�<�>�>��	�	�	�	�	r<c�~�|�tj�d���dd�d��dS)Nr�r�i��z@testdomain-string>�r3r�r#r�r�s r:�test_make_msgid_domainz(TestMiscellaneous.test_make_msgid_domain*sG������K�"�"�*=�"�>�>�s�t�t�D�!�	#�	#�	#�	#�	#r<c��|�tj�dd���dd�d��dS)Nz
test-idstringr�)�idstringr�i���z!.test-idstring@testdomain-string>r�r�s r:�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.comrar#)r	�return_valuer�r�r#r��endswith)r7�mock_getfqdnr�s   r:�test_make_msgid_default_domainz0TestMiscellaneous.test_make_msgid_default_domain5s���
�#�
$�
$�	)��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.txtrWr+�r��newliner�)r'r�r�r�r	rr�rr�r3r��r7�f�msgtxt�	msgtxt_nlr9r�r�s       r:�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�rWr+r�r�r�r�)r'r�r�r�r	rr�r
r�r3r�rZr�s       r:�test_BytesGenerator_linendz,TestMiscellaneous.test_BytesGenerator_linendGs���
�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�rswith attachmentsfo��
rr�r�)r'r�r�r�r�rr�r
r�r3r�r�s       r:�)test_BytesGenerator_linend_with_non_asciiz;TestMiscellaneous.test_BytesGenerator_linend_with_non_asciiRs��
�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�rr)r,)rArBr�)�clsr�r�r�)r'r�rrrrrrrr8r�r�r�r�r�r�)r7r��	audiodatar�classesr��constructorr�s        r:�!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	c���|�ttjd����gd���|�ttjd����ddg��dS)Nza\\b\"c\\"d)�rr�)r��\\)r�r�)r�z\")r��c)�r�)r�rd)r[�dza\r�)r��\)r3rr#�_iter_escaped_charsr�s r:�test_iter_escaped_charsz)TestMiscellaneous.test_iter_escaped_charsss������e�7��G�G�H�H�%�%�%�	&�	&�	&�	
����e�7��>�>�?�?�"�I�.�	0�	0�	0�	0�	0r<c�,���fd�}|dd��|dd��|dd��|dd	��|d
d��|dd
��|dd��|dd��dD]*}��tj|��|���+dS)Nc�X����tj|��|��dSrg�r3r#�_strip_quoted_realnames)rr�r7s  �r:�checkz<TestMiscellaneous.test_strip_quoted_realnames.<locals>.check�s*������U�:�4�@�@�(�K�K�K�K�Kr<riz( <jane@example.net>,  <john@example.net>z""Jane \"Doe\"." <jane@example.net>z <jane@example.net>zbefore"name"after�beforeafterzbefore"name"�beforezb"name"r�z"name"after�afterz"name"ar�z"name"r,)z8Jane Doe <jane@example.net>, John Doe <john@example.net>zlone " quoter�)r7r�rs`  r:�test_strip_quoted_realnamesz-TestMiscellaneous.test_strip_quoted_realnames�s���	L�	L�	L�	L�	L�	��L�8�	:�	:�	:�
��3�#�	%�	%�	%�	��"�M�2�2�2�
��o�x�(�(�(�
��j�#����
��n�g�&�&�&�
��j�#����
��i�����
�	H�	H�D�
���U�:�4�@�@�$�G�G�G�G�		H�	Hr<c��d}|�tj|�d�����|�tj|�d�����|�tj|�d�����|�tj|�d�����|�tjd|������dS)Nzalice@example.netz (Alice)z )Alice(z	 (Alice))z	 ((Alice)z")Alice((" )r�r#�_check_parenthesisr+r/s  r:�test_check_parenthesisz(TestMiscellaneous.test_check_parenthesis�s���"������0�D�1B�1B�1B�C�C�D�D�D�����1�T�2C�2C�2C�D�D�E�E�E�����1�T�2D�2D�2D�E�E�F�F�F�����1�T�2D�2D�2D�E�E�F�F�F�	
����0�1E�t�1E�1E�F�F�G�G�G�G�Gr<N)Br�rrr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrrrr&r+r0r3r8r=rArCrErOrUrXrqruryr{r%�requires_working_threadingr$�requires_resourcer�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r|r<r:r�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�
�
�
�"VD�VD�VD�p*<�*<�*<�X'�'�'�9�9�9�
1��0�2�2��W��u�%�%�:�:�&�%�3�2�:�&2�2�2�@�@�@�5�5�5�4I�I�I�
(�(�(�T#�#�#�
1�1�1�)�)�)�	2�	2�	2�	?�	?�	?�
/�
/�
/�>�>�>�*0�0�0�H�H�H�2H�H�H�H�Hr<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�rh�+z
msg_19.txtrWr�)r3r%r4r!�body_line_iteratorrr;�EMPTYSTRINGr�r[r'r�)r7r8r�r9�itr�r�s       r:�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)Nrzr�rr�r�z`a simple kind of mirror
to reflect upon our own
a simple kind of mirror
to reflect upon our own
�r3r4r!�typed_subpart_iteratorr9r[r�r��r7r8r9r�r��subpartsr�s       r:�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       r:�(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)N))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   r:r�z0TestIterators.test_pushCR_LF.<locals>.<listcomp>�s��!6�!6�!6���Q�"�!6�!6�!6r<)
�email.feedparserr�r��push�iter�readliner9r3r;r�)r7�imtr�r��bsf�om�ntr�r��n1�ols           r:�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��dSrgr)r�rY�charss  �r:rZz1TestIterators.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�r_rr;r��extendr�r�r3)r7r�r�r��	chunksizer��targetr�r�rY�chunkr�s           @r:�test_push_randomzTestIterators.test_push_random�s����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�rrr�r�r�r�rr|r<r:r�r��sb������4�4�4�"���"���&F�F�F�<(�(�(�(�(r<r�c�&�eZdZd�Zd�Zd�Zd�ZdS)�TestFeedParsersc�z�t��}|D]}|�|���|���Srg)r)�feed�close)r7�chunksr�rs    r:�parsezTestFeedParsers.parsesA���\�\�
��	#�	#�E��O�O�E�"�"�"�"����!�!�!r<c��|�d��}|�|dd��|�|dd��dS)NzFirst: val
: bad
Second: valr��valr�)r	r3ris  r:�test_empty_header_name_handledz.TestFeedParsers.test_empty_header_name_handledsN���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�r�r�za:
b:
c:
d:za:
b�c:
r��bc�a:
zb:
r�z
b:
ua:…b:
c:
)r�u	…b:
c:)rub:…r�r�r,)r�u…c:)r	r3r�r�r�s  r:�
test_newlineszTestFeedParsers.test_newliness����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

�…rzb: rr�)r	r3r�r[)r7�Mr6r�s    r:�test_long_lineszTestFeedParsers.test_long_lines,s������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�rrr	rrrr|r<r:rrsX������"�"�"�/�/�/�B�B�B�$
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S)�TestParsersc���|j}tdd���5}t���|��}ddd��n#1swxYwY||dd��||dd��||���d��|�|�����|�|���t��dS)	NrhrWr�r��ppp-request@zzz.orgr��ppp@zzz.orgrl)
r3r'rr	rIr+r,r�r[r��r7r8r�r9s    r:�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)
Nrhrr�rr�rrlTrY)
r3r'r�r�r�r	rIr+r,r�r[r�rrs    r:�test_bytes_header_parserz$TestParsers.test_bytes_header_parserIsC��
�
��
�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�B�tdd���5}|���}ddd��n#1swxYwYtj�tjj���}|�|d���}|�|j	g��dS)Nz
msg_47.txtrWr�r�T)�headersonly)
r'r�r�r�rr�r�r�r3r�)r7r�r�r��
parsed_msgs     r:�%test_header_parser_multipart_is_validz1TestParsers.test_header_parser_multipart_is_validUs���
�l�W�
5�
5�
5�	 ���g�g�i�i�G�	 �	 �	 �	 �	 �	 �	 �	 �	 �	 �	 ����	 �	 �	 �	 ���$�$�E�L�,@�$�A�A���_�_�W�$�_�?�?�
�����+�R�0�0�0�0�0r�c���tdd��5}tj����|��|�|j��ddd��dS#1swxYwYdS)Nrhr)r'r�r��BytesParserr	r+�closedrs  r:�%test_bytes_parser_does_not_close_filez1TestParsers.test_bytes_parser_does_not_close_file_s���
�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�rr�)r'r�r�r%r�r r�r�rgr	r+r&)r7r��bytesParsers   r:�2test_bytes_parser_on_exception_does_not_close_filez>TestParsers.test_bytes_parser_on_exception_does_not_close_fileds���
�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)NrhrWr�)r'r�r�rr	r+r&rs  r:�test_parser_does_not_close_filez+TestParsers.test_parser_does_not_close_filels���
�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�rWr�r�)r'r�r�rr�r r�r�rgr	r+r&)r7r�r�s   r:�,test_parser_on_exception_does_not_close_filez8TestParsers.test_parser_on_exception_does_not_close_fileqs���
�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
�r3r�r	r[r6s   r:�test_whitespace_continuationz(TestParsers.test_whitespace_continuationx�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
rr0rr1r2r3r6s   r:�(test_whitespace_continuation_last_headerz4TestParsers.test_whitespace_continuation_last_header�r5r<c��|j}tddd���5}t���|��}ddd��n#1swxYwY|t	|�����d��|�d��}||���d��||���d��|�d	��}||���d
��dS)Nr�rWr+r�r�rr@z!Simple email with attachment.

r�zapplication/riscos)r3r'rr	r;r[rI)r7r8r�r9�part1�part2s      r:�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�rWr+r�r�r�r�r�s      r:�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)Nr}rWr�r�r�rrtr@r9r:)	r3r%r'r�r,r,r;r[rI)	r7r8r�r�r9r9�part1ar:�part2as	         r:�-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�r	r�r�r3)r7r�r9s   r:�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)r3r�r	�get)r7r8�value1�value2r�r9s      r:�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��dSrgr|)r��fields  r:rZz9TestParsers.test_rfc2822_header_syntax.<locals>.<genexpr>�s"����)�)�E�%�)�)�)�)�)�)r<)z!"#QUX;~z>Fromr�r�)r3r�r	r;r�r[r�s    r:�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)r3r�r	r;r�r�s    r:�(test_rfc2822_space_not_allowed_in_headerz4TestParsers.test_rfc2822_space_not_allowed_in_header�sE��
�
��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�)r3r�r	r��sortr[)r7r8r�r9�headerss     r:�!test_rfc2822_one_character_headerz-TestParsers.test_rfc2822_one_character_header�st��
�
��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�r	r�r[r��r7r�r9s   r:�test_CRLFLF_at_end_of_partz&TestParsers.test_CRLFLF_at_end_of_part�s\��

�	
��'��*�*���������*�*�6�6�8�8�A�A�&�I�I�J�J�J�J�Jr<)r�rrrrr#r'r*r,r.r4r7r;r=r�rArDrIrMrOrVrYr|r<r:rr<s4������	6�	6�	6�
C�
C�
C�1�1�1�(�(�(�
(�(�(�(�(�(�
(�(�(�;�;�;�$;�;�;�$	;�	;�	;�-�-�-��G�1�1�1�>I�I�I�	+�	+�	+�&�&�&����&�&�&�K�K�K�K�Kr<rc��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)NrWra�pöstal�rBr��bodyline�pöstal
TrY��bodytest_msgr�r�r�r�r3r[rXs   r:�test_known_8bit_CTEz)Test8BitBytesHandling.test_known_8bit_CTE#s�����$�$�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�notavalidcharsetrar]r^rWup��stal
TrYr`rarXs   r:�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)	NrWrD�p=C3=B6stálr^u
p=C3=B6stál
TrY�	pöstál
rarXs   r:�test_8bit_in_quopri_bodyz.Test8BitBytesHandling.test_8bit_in_quopri_body5s���
��$�$�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�rDrhr^rWup=C3=B6st��l
TrYrirarXs   r:�.test_invalid_8bit_in_non_8bit_cte_uses_replacezDTest8BitBytesHandling.test_invalid_8bit_in_non_8bit_cte_uses_replaceGs���
��$�$�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)	NrWrXu
cMO2c3RhbAá=r^TrYr]r)rbr�r�r�r�r3r[r�r�r r�rXs   r:�test_8bit_in_base64_bodyz.Test8BitBytesHandling.test_8bit_in_base64_bodyWs���
��$�$�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)NrWr�u
<,.V<W1A; á r^TrYu<,.V<W1A; á 
rarXs   r:�test_8bit_in_uuencode_bodyz0Test8BitBytesHandling.test_8bit_in_uuencode_bodyds���
��$�$�W�)3�.=�
%�
?�
?�?E�v�g���	
��&�q�)�)����������5�5�*�1�1�'�:�:�	<�	<�	<�	<�	<r<))zFrom: foo@bar.com�r�rw)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�r=�_s   r:r�z Test8BitBytesHandling.<listcomp>ys�� H� H� H��#�q�� H� H� Hr<z
Yes, they are flying.
rWc��tj|j��}|�t	|�d����d��|�t	|d��d��dS)Nr��b��z)r�r��headertest_msgr3r�rFris  r:�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|)r�rsr�s   r:r�zATest8BitBytesHandling.test_print_8bit_headers.<locals>.<listcomp>�s2��*A�*A�*A�-�1�h�(�1�+�*A�*A�*Ar<)	r�r�rvr3r�r�r�r��headertest_headersris  r:�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�rs  r:r�zGTest8BitBytesHandling.test_values_with_8bit_headers.<locals>.<listcomp>�s��;�;�;��c�!�f�f�;�;�;r<)rwru�]Maintenant je vous pr��sente mon coll��gue, le pouf c��l��bre
	Jean de Baddie�	g��st)r�r�rv�assertListEqualr�ris  r:�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~)r�r�r2s   r:r�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<)rq)r�ru)r�r)r�r�)r�r�rvr�r�ris  r:�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~rs  r:r�zHTest8BitBytesHandling.test_get_all_with_8bit_headers.<locals>.<listcomp>�s��B�B�B��c�!�f�f�B�B�Br<r�rwr�)r�r�rvr�r5ris  r:�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�r3rIr�r�ris  r:�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�Foor�ub§r)r�r�r�r3rrJris  r:�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)rO�enuThis is not f�n)r�r�r�r�r�r3rJris  r:�!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)Nr�r�r��test)r�r�r�r�r�rLr3rJris  r:�!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)Nr�r�r�r�)	r�r�r�r�r�rVr3rJr�ris  r:�!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
TrYspayload
)r�r�r�r�r�r3r[ris  r:�%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��dSrg)	r�r��non_latin_bin_msgrr�r
r�r3r��r7r9r�s   r:�test_bytes_generatorz*Test8BitBytesHandling.test_bytes_generator�si���&�t�'=�>�>���i�i��
��&�&�s�+�+�3�3�C�8�8�8����������)?�@�@�@�@�@r<c��tj���}t��}tj�|���|��|�|���d��dS)Nr)	r�r9rrr�r
r�r3r�r�s   r:�&test_bytes_generator_handles_None_bodyz<Test8BitBytesHandling.test_bytes_generator_handles_None_body�sf���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	��dSrg)
r�r�r�rr�rr�r3r�� non_latin_bin_msg_as7bit_wrappedr�s   r:�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	|���|��|�	|���|��dSrg)
r�r�r�rr
r�r�rrr3)r7r9r��
orig_values    r:�;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�rrsFromr�)r�r�r�rr�r
r�r�r�r3r�)r7r9r�r�s    r:�#test_bytes_generator_with_unix_fromz9Test8BitBytesHandling.test_bytes_generator_with_unix_froms����&�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�writer�r�r�r%r	r3r��non_latin_bin_msg_as7bit)r7r��testfiler�s    r:�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��dSrg)r�r��
latin_bin_msgr3r��latin_bin_msg_as7bitr�s  r:�:test_string_generator_reencodes_to_quopri_when_appropriatezPTest8BitBytesHandling.test_string_generator_reencodes_to_quopri_when_appropriateGs:���$�T�%7�8�8������Q����!:�;�;�;�;�;r<c�>�tj|j��}t��}tj�|���|��|�|���|j�	d��dz��dS)Nr�r+)
r�r�r�rr�rr�r3r�rZ)r7r�r�s   r:�)test_decoded_generator_emits_unicode_bodyz?Test8BitBytesHandling.test_decoded_generator_emits_unicode_bodyKs����$�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)Nrr[)r�r�r*r_r;r�rrr3r�r�)r7�bfprYr�s    r:�test_bytes_feedparserz+Test8BitBytesHandling.test_bytes_feedparserUs�����.�.�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�rr�r�)
r'r�r�r�rr�r
r�r3r�r�s      r:r=z'Test8BitBytesHandling.test_crlf_flatten\s���
�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--

            rW)r�r�r�r�r�rr�r
r�r3r�)r7r�r9r�r�s     r:�test_8bit_multipartz)Test8BitBytesHandling.test_8bit_multipartes�����%"�%�%�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�r3r��r7r�r�r�s    r:�'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�r3r�r�s    r:�!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�rrr�r�rbrcrfrjrlrnrprzr�r�rvrwr{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:r[r[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<r[c� �eZdZdZd�Zdd�ZdS)� BaseTestBytesGeneratorIdempotentNc���t|d��5}|���}ddd��n#1swxYwY|j�|j|��}tj|��}||fS)Nr)r'r��normalize_linesep_regex�sub�blinesepr�r�rZs     r:r4z(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�r3r�)r7r9r]r�r�r�s      r:r\z,BaseTestBytesGeneratorIdempotent._idempotent�sc���I�I���O�*�*�1�1�*�=�=��	�	�	�#��$�,�	�?�?�?�����q�z�z�|�|�,�,�,�,�,r<r�)r�rrr�r4r\r|r<r:r�r��s<�������G����-�-�-�-�-�-r<r�c�6�eZdZdZdZejd��ZdS)�TestBytesGeneratorIdempotentNLr+rs\r\nN�r�rrr�r��re�compiler�r|r<r:r�r��s,�������G��H�(�b�j��2�2���r<r�c�6�eZdZdZdZejd��ZdS)� TestBytesGeneratorIdempotentCRLFr�r�s	(?<!\r)\nNr�r|r<r:r�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��r�)r3r�
header_lengthr;�body_encoder_)r7r8�size�bsizes    r:�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�)r3rrZr�s  r:�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 �(r7z�eHh4eCB4eHh4IHh4eHggeHh4eCB4eHh4IHh4eHgg
eHh4eCB4eHh4IHh4eHggeHh4eCB4eHh4IHh4eHgg
eHh4eCB4eHh4IHh4eHggeHh4eCB4eHh4IHh4eHgg
eHh4eCB4eHh4IA==
r��r8r�z�eHh4eCB4eHh4IHh4eHggeHh4eCB4eHh4IHh4eHgg
eHh4eCB4eHh4IHh4eHggeHh4eCB4eHh4IHh4eHgg
eHh4eCB4eHh4IHh4eHggeHh4eCB4eHh4IHh4eHgg
eHh4eCB4eHh4IA==
)r3rr�r�s  r:�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=?=rsrfz=?iso-8859-2?b?aGVsbG8=?=)r3rr!)r7r8�hes   r:�test_header_encodezTestBase64.test_header_encode�s���
�
��
�
%��
��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�rrr�r�r�r�r|r<r:r�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���_tttd��td
��dz�����_�j�td�����j�td�����fd�td��D���_	dS)Nr��zr�rQ�Zr��9c3�K�|]}|V��dSrgr|)r�r�s  r:rZz#TestQuopri.setUp.<locals>.<genexpr>
s"����!�!�1�Q�!�!�!�!�!�!r<s!*+-/c�&��g|]
}|�jv�|��Sr|)�hlit�r�r�r7s  �r:r�z$TestQuopri.setUp.<locals>.<listcomp>
�%���A�A�A�1�a�t�y�.@�.@�Q�.@�.@�.@r<�r-�~r*�=c�&��g|]
}|�jv�|��Sr|)�blitr�s  �r:r�z$TestQuopri.setUp.<locals>.<listcomp>r�r<)
rrr_�ordr��hnonr�r9�remove�bnonr�s`r:r�zTestQuopri.setUps9������#�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��	���s�3�x�x��S���A��6�6�7�7��	��	����T���#�#�#��	����S���"�"�"�B�A�A�A��c�
�
�A�A�A��	�	�	r<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�r+r"�header_check�chrr�r��r7r�s  r:�test_quopri_header_checkz#TestQuopri.test_quopri_header_checks�����	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�r+r"�
body_checkrr�r�rs  r:�test_quopri_body_checkz!TestQuopri.test_quopri_body_check!s�����	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��xxxrfr[s
h@e@l@l@o@r�r�zexpected length 1 for %rr-r�zexpected length 3 for %r� )
r3r"r�r;r!r�rrr�r��r7r8r�s   r:�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�)r3r�r"�body_lengthrr�r
s   r:�test_body_quopri_lenzTestQuopri.test_body_quopri_lenBs���
�
����	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�)r_rr3r"r.�quote)r7r�r�s   r:�test_quote_unquote_idempotentz(TestQuopri.test_quote_unquote_idempotentIs_���s���	I�	I�A��A���A����Z�/�
�0@��0C�0C�D�D�a�H�H�H�H�	I�	Ir<Nc��|�tj|��}ntj||��}|�||��dSrg)r"r!r3)r7r��expected_encoded_headerrB�encoded_headers     r:�_test_header_encodezTestQuopri._test_header_encodeNsH���?�'�5�f�=�=�N�N�'�5�f�g�F�F�N�����)@�A�A�A�A�Ar<c�2�|�dd��dS)Nr<r,�rr�s r:�test_header_encode_nullz"TestQuopri.test_header_encode_nullUs��� � ��b�)�)�)�)�)r<c�2�|�dd��dS)Nr�z=?iso-8859-1?q?hello?=rr�s r:�test_header_encode_one_wordz&TestQuopri.test_header_encode_one_wordXs��� � ��+C�D�D�D�D�Dr<c�2�|�dd��dS)Nshello
worldz=?iso-8859-1?q?hello=0Aworld?=rr�s r:�test_header_encode_two_linesz'TestQuopri.test_header_encode_two_lines[s.��� � �� @�	B�	B�	B�	B�	Br<c�2�|�dd��dS)Nshello�therez=?iso-8859-1?q?hello=C7there?=rr�s r:�test_header_encode_non_asciiz'TestQuopri.test_header_encode_non_ascii_s/��� � �!2� @�	B�	B�	B�	B�	Br<c�6�|�ddd���dS)Nr�z=?iso-8859-2?q?hello?=rsrfrr�s r:�test_header_encode_alt_charsetz)TestQuopri.test_header_encode_alt_charsetcs1��� � ��+C�$�	!�	&�	&�	&�	&�	&r<c�Z�tj|��}|�||��dSrg)r"�
header_decoder3)r7r�expected_decoded_header�decoded_headers    r:�_test_header_decodezTestQuopri._test_header_decodegs/��#�1�.�A�A������)@�A�A�A�A�Ar<c�2�|�dd��dS�Nr,�r%r�s r:�test_header_decode_nullz"TestQuopri.test_header_decode_nullks��� � ��R�(�(�(�(�(r<c�2�|�dd��dS�Nr�r(r�s r:�test_header_decode_one_wordz&TestQuopri.test_header_decode_one_wordns��� � ��'�2�2�2�2�2r<c�2�|�dd��dS)Nz
hello=0Aworldr�r(r�s r:�test_header_decode_two_linesz'TestQuopri.test_header_decode_two_linesqs��� � ��.�A�A�A�A�Ar<c�2�|�dd��dS)Nz
hello=C7thereuhelloÇtherer(r�s r:�test_header_decode_non_asciiz'TestQuopri.test_header_decode_non_asciits��� � ��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)r3r"r"r�s r:�test_header_decode_re_bug_18380z*TestQuopri.test_header_decode_re_bug_18380ws)������1�+�>�>�	�J�J�J�J�Jr<c��|�tj|��}ntj||���}|�||��dS)Nr�)r"rZr3)r7�encoded�expected_decodedr��decodeds     r:�_test_decodezTestQuopri._test_decode{sK���;� �'��0�0�G�G� �'��S�9�9�9�G�����"2�3�3�3�3�3r<c�2�|�dd��dSr'�r8r�s r:�test_decode_null_wordz TestQuopri.test_decode_null_word�������"�b�!�!�!�!�!r<c�2�|�dd��dS)Nr�r+r:r�s r:�test_decode_null_line_null_wordz*TestQuopri.test_decode_null_line_null_word�s�����&�$�'�'�'�'�'r<c�2�|�dd��dSr+r:r�s r:�test_decode_one_wordzTestQuopri.test_decode_one_word�s�����'�7�+�+�+�+�+r<c�6�|�ddd���dS)Nr��Xr�r:r�s r:�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 r:�test_decode_one_linezTestQuopri.test_decode_one_line�������+�y�1�1�1�1�1r<c�2�|�dd��dS�NrGr:r�s r:�test_decode_one_line_lfz"TestQuopri.test_decode_one_line_lf�������)�Y�/�/�/�/�/r<c�2�|�dd��dS)Nzhello
rGr:r�s r:�test_decode_one_line_crz"TestQuopri.test_decode_one_line_cr�rMr<c�6�|�ddd���dS)NrG�helloXrBr�r:r�s r:�test_decode_one_line_nlz"TestQuopri.test_decode_one_line_nl�s#�����)�X�3��7�7�7�7�7r<c�6�|�ddd���dS)NrFrQrBr�r:r�s r:�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 r:�test_decode_one_line_one_wordz(TestQuopri.test_decode_one_line_one_word�s�����*�N�;�;�;�;�;r<c�6�|�ddd���dS)Nr��helloXworldrBr�r:r�s r:�!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 r:�test_decode_two_linesz TestQuopri.test_decode_two_lines�s �����.�0@�A�A�A�A�Ar<c�6�|�ddd���dS)Nr[�helloXworldXrBr�r:r�s r:�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 r:�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 r:�test_decode_one_spacez TestQuopri.test_decode_one_space�s�����#�r�"�"�"�"�"r<c�2�|�dd��dS)Nz     r,r:r�s r:�test_decode_multiple_spacesz&TestQuopri.test_decode_multiple_spaces�s�����'�2�&�&�&�&�&r<c�2�|�dd��dS)Nzhello    
rGr:r�s r:�$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   
r\r:r�s r:�%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 r:�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 r:�test_decode_uppercase_quotingz(TestQuopri.test_decode_uppercase_quoting�������*�l�3�3�3�3�3r<c�2�|�dd��dS)Nzab=cd=efror:r�s r:�test_decode_lowercase_quotingz(TestQuopri.test_decode_lowercase_quoting�rqr<c�2�|�dd��dS)Nzsoft line=
breakzsoft linebreakr:r�s r:�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 r:�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	r8r+r�r�)r"r�r3rrr;)r7r��expected_encoded_bodyr8r��kwargs�encoded_bodyr�s        r:�_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 r:�test_encode_nullzTestQuopri.test_encode_null�r<r<c�2�|�dd��dS)Nz

r~r�s r:�test_encode_null_linesz!TestQuopri.test_encode_null_lines�s�����&�&�)�)�)�)�)r<c�2�|�dd��dSrKr~r�s r:�test_encode_one_linezTestQuopri.test_encode_one_line�rMr<c�2�|�dd��dSrEr~r�s r:�test_encode_one_line_crlfz$TestQuopri.test_encode_one_line_crlf�rIr<c�6�|�ddd���dS)NrGrFr�r�r~r�s r:�test_encode_one_line_eolz#TestQuopri.test_encode_one_line_eol�s#�����)�[�f��=�=�=�=�=r<c��|�d�d���d��dd���dS)Nuhelloυ
rW�latin1z
hello=CF=85
r�r�)r|r�rZr�s r:�(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 r:�test_encode_one_spacez TestQuopri.test_encode_one_space�s�����#�u�%�%�%�%�%r<c�2�|�dd��dS)Nz 
z=20
r~r�s r:�test_encode_one_line_one_spacez)TestQuopri.test_encode_one_line_one_space�s�����%��)�)�)�)�)r<c�2�|�dd��dS)Nz 
 
z=20
=20
r~r�s r:�test_encode_two_lines_one_spacez*TestQuopri.test_encode_two_lines_one_space�s�����(�L�1�1�1�1�1r<c�2�|�dd��dS)Nzhello   z
hello  =20r~r�s r:�$test_encode_one_word_trailing_spacesz/TestQuopri.test_encode_one_word_trailing_spaces�rqr<c�2�|�dd��dS)Nz	hello   
zhello  =20
r~r�s r:�$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 r:�!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 r:�!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�r7r~r�s r:�,test_encode_trailing_space_before_maxlinelenz7TestQuopri.test_encode_trailing_space_before_maxlinelen	s$�����-�)9�a��H�H�H�H�Hr<c�6�|�ddd���dS)Nr�zabcd=
=20
1234r�r7r~r�s r:�(test_encode_trailing_space_at_maxlinelenz3TestQuopri.test_encode_trailing_space_at_maxlinelen�$�����-�);���J�J�J�J�Jr<c�6�|�ddd���dS)Nr�zabc=
d=20
1234r�r7r~r�s r:�,test_encode_trailing_space_beyond_maxlinelenz7TestQuopri.test_encode_trailing_space_beyond_maxlinelenr�r<c�2�|�dd��dS)Nz
 
 
 
 
 
z=20
=20
=20
=20
=20
r~r�s r:�test_encode_whitespace_linesz'TestQuopri.test_encode_whitespace_liness�����)�[�1�1�1�1�1r<c�2�|�dd��dS)Nza = bza =3D br~r�s r:�test_encode_quoted_equalsz$TestQuopri.test_encode_quoted_equalss�����'�9�-�-�-�-�-r<c�2�|�dd��dS)N�dxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxzfxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx=
xxxxxxxxxxxxxxxxxxxxxxxxxr~r�s r:�test_encode_one_long_stringz&TestQuopri.test_encode_one_long_strings�����)�%@�A�A�A�A�Ar<c�2�|�dd��dS)Nzexxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
zgxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx=
xxxxxxxxxxxxxxxxxxxxxxxxx
r~r�s r:�test_encode_one_long_linez$TestQuopri.test_encode_one_long_lines �����*�,N�O�O�O�O�Or<c�2�|�dd��dS)Nz�xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
z�xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx=
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx=
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
r~r�s r:�test_encode_one_very_long_linez)TestQuopri.test_encode_one_very_long_lines*�����*�8�	:�	:�	:�	:�	:r<c�6�|�ddd���dS)Nz=====z=3D=
=3D=
=3D=
=3D=
=3Dr�r7r~r�s r:�test_encode_shortest_maxlinelenz*TestQuopri.test_encode_shortest_maxlinelen"s$�����'�#7�A��F�F�F�F�Fr<c�N�|�t|jddd���dS)Nr,r�r7)r�rkr|r�s r:� test_encode_maxlinelen_too_smallz+TestQuopri.test_encode_maxlinelen_too_small%s*�����*�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�r7zjxxxx 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)r3r"r�r�s  r:r�zTestQuopri.test_encode(s���
�
��
��:�!�"�%�%�r�*�*�*�
��:�!�'�*�*�G�4�4�4�
��:�!�"2�3�3�^�D�D�D�
��:�!�,�2�>�>�>�A�	�	�	�
	��:�!�,�2�6�J�J�J��	�	�	�
	��:�!�#�
�
��	
�	
�	
�	
�	
r<rg)NN)Fr�rrr�rrrrrrrrrrr r%r)r,r.r0r3r8r;r>r@rCrHrLrOrRrTrVrYr]r`rcrergrirkrmrprsrurwr|rr�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�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)Nrrf�fake)r�rB�CHARSETSr�)r7�
CharsetModules  r:�tearDownzTestCharset.tearDownEsL��2�2�2�2�2�2�	��&�v�.�.�.���	�	�	��D�D�	���s��
 � c��|j}td��}||�d��d��d}|�t|j|��td��}||�|��d��dS)NrO�Hello World!u¤¢¤¤¤¦¤¨¤ªrWz(=?utf-8?b?wqTCosKkwqTCpMKmwqTCqMKkwqo=?=)r3r
r!r�r.)r7r8r�r�s    r:�test_codec_encodeablez!TestCharset.test_codec_encodeableLs���
�
���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örldrWr�r�rOrrrrfr�)r3r
r�r�rB�add_charset�QP)r7r8r�r�s    r:�test_body_encodezTestCharset.test_body_encodeWs���
�
���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)NrOuascÿii)r
r3r�r�r �CharsetErrorr�s  r:�test_unicode_charset_namez%TestCharset.test_unicode_charset_namevsL���*�%�%������W���z�2�2�2����&�-�w��D�D�D�D�Dr<N)r�rrr�r�r�r�r|r<r:r�r�DsX���������	K�	K�	K�8�8�8�>E�E�E�E�Er<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�ZdS)�
TestHeaderc���|j}td��}||���d��|�d��||���d��dS)Nr�z Goodbye World!zHello World!  Goodbye World!�r%rr�r9rEs   r:�test_simplezTestHeader.test_simplese��
�
"���>�"�"��
��1�8�8�:�:�~�&�&�&�	���"�#�#�#�
��1�8�8�:�:�5�6�6�6�6�6r<c���|j}td��}||���d��|�d��||���d��dS)Nr�zGoodbye World!zHello World! Goodbye World!r�rEs   r:�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�rPs  r:�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	r7r-)�
splitcharsz
 )rr�r�rr;)r7r/�ls   r:�	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>rsrWr2r3r4r	r7a=?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.」と言っています。)
r%r
rr9r�rr;r�rZr)
r7r8r�r:r;r<r=r>r/�encr7�ustr�newhs
             r:�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'rOrPs  r:�test_empty_header_encodez#TestHeader.test_empty_header_encode�s/���H�H����������R�(�(�(�(�(r<c��|j}t��}||d��|�dtd����||d��dS)Nr,r�r>)r%rr9r
rEs   r:�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�r5z}A very long line that must get split to something other than at the
 76th character boundary to test the non-default behaviori)r8r6)r%rr�r�r-s    r:�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��rBr8r�a=?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_?=�r%rr9r�r�rr�r7r8r/r�r�s     r:�test_quopri_splittablez!TestHeader.test_quopri_splittable�s��
�
"���<�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)Nrtr�r�r�a�=?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     r:�test_base64_splittablez!TestHeader.test_base64_splittable9s��
�
"���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�r3rrr�)r7r8r�r�r/s     r:�test_us_ascii_headerzTestHeader.test_us_ascii_headeros\��
�
�����!����
��1��� � � ���N�N��
��1�a�h�h�j�j�����r<c�t�|j}t��}|�dd��||d��dS)Nr�r>)r3rr9rEs   r:�test_string_charsetzTestHeader.test_string_charsetws:��
�
���H�H��	����,�'�'�'�
��1�g�����r<c���|j}tdd��}||���d��tdd��}||���d��dS)Nr]rWz=?utf-8?q?p=C3=B6stal?=u菊地時夫z=?utf-8?b?6I+K5Zyw5pmC5aSr?=�r3rr�rEs   r:�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 BigrWr�r)r�r3r.rr9rZr�)r7rXr8r�r/�es      r:�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��surrogateescaperf�2Ynwp4dUEbay Auction Semiar- No Charge � Earn Big�unknown-8bit)	rZrr�rB�UNKNOWN8BITr3r�r�r)r7r�r�r/s    r:�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�rfr�r�)rr�rBr�r3r�r�r)r7r�r/s   r:�&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�rBr�r�rrr3r�)r7r�r/�h2s    r:�+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)Nr�)r��test2)rr�r�rr9r3r�)r7r/rs   r:�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)r3rr9r�rr)r7r8r/r�s    r:� 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������� � ��������rt)s zz.Nz6Subject: =?koi8-r?b?8NLP18XSy8EgzsEgxsnOwczYztnK?= zz.r�)r7r8r��parts�hdrs     r:�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)r7rXr�s   r:�test_broken_base64_headerz$TestHeader.test_broken_base64_header�s,���"��f����v�&�
�q�9�9�9�9�9r<c�x�tdd���}|�|���d��dS)NrM�	shift_jisrfrNrOrPs  r:�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�r	r3r�ris  r:�!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

)rr3r�ris  r:�)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 r:�test_whitespace_headerz!TestHeader.test_whitespace_header�s0���������+�+�-�-�s�3�3�3�3�3r<N)r�rrr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrr
r
rr|r<r:r�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.txtr��rOr��%This is even more ***fun*** isn't it!Fr-)rOr�z'"This is even more ***fun*** isn't it!")r3r4rJr6s   r:r(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)
Nr�rrOrf)rOr,rr��rB�languagerr�r�r�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
)r%rrLrJr4r�r6s   r:rMzTestRFC2231.test_set_param�s��
�
"���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)Nr�r�rAztext/plain; title="foo"rF)�requoteztext/plain; title=barz	(bar)bellztext/plain; title="(bar)bell")rrLr3ris  r:�test_set_param_requotez"TestRFC2231.test_set_param_requotes����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�rrOr�rr�rrErr�r�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
)r%r4rLrVr�r6s   r:rXzTestRFC2231.test_del_params���
�
"���l�l�<�(�(���
�
�e�U�J��
�F�F�F��
�
�g�G���	�	/�	/�	/��
�
�e�N�
�3�3�3�
��3�=�=�b�=�)�)�,�	�	�	�	�	r<c�z�|j}|�d��}||���d��dS)Nr|rO)r3r4�get_content_charsetr6s   r:� test_rfc2231_get_content_charsetz,TestRFC2231.test_rfc2231_get_content_charset@s?��
�
���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�r	r3r~r�rXs   r:�test_rfc2231_parse_rfc_quotingz*TestRFC2231.test_rfc2231_parse_rfc_quotingF�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!rXs   r:� test_rfc2231_parse_extra_quotingz,TestRFC2231.test_rfc2231_parse_extra_quotingTr#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�r	rJ�assertNotIsInstance�tupler3�r7r�r9�params    r:�#test_rfc2231_no_language_or_charsetz/TestRFC2231.test_rfc2231_no_language_or_charsetdso��
���'��*�*���
�
�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
rXs   r:�/test_rfc2231_no_language_or_charset_in_filenamez;TestRFC2231.test_rfc2231_no_language_or_charset_in_filenames�S��
���'��*�*������)�)�+�+�D�	F�	F�	F�	F�	Fr<c��d}tj|��}|�|���d��dSr/r
rXs   r:�7test_rfc2231_no_language_or_charset_in_filename_encodedzCTestRFC2231.test_rfc2231_no_language_or_charset_in_filename_encoded�r1r<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
rXs   r:�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
rXs   r:�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 rrXs   r:�/test_rfc2231_no_language_or_charset_in_boundaryz;TestRFC2231.test_rfc2231_no_language_or_charset_in_boundary�r1r<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�r	r3rrXs   r:�.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
rXs   r:�%test_rfc2231_bad_encoding_in_filenamez1TestRFC2231.test_rfc2231_bad_encoding_in_filename�r1r<c��d}tj|��}|�|���d��dS)Nz:Content-Type: text/plain; charset*=bogus''utf-8%E2%80%9D

r;rXs   r:�$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;rXs   r:�%test_rfc2231_bad_character_in_charsetz1TestRFC2231.test_rfc2231_bad_character_in_charset�rAr<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
rXs   r:�&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
rXs   r:�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

rGr
rXs   r:�&test_rfc2231_bad_character_in_encodingz2TestRFC2231.test_rfc2231_bad_character_in_encoding�rIr<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'�r7r8r�r9rBrr�s       r:�-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*rMr(r+s    r:�$test_rfc2231_single_tick_in_filenamez0TestRFC2231.test_rfc2231_single_tick_in_filenames_��
���'��*�*���
�
�f�%�%��� � ���.�.�.����� 2�3�3�3�3�3r<c��d}tj|��}|�|���d��dS)NzAContent-Disposition: inline;
	filename*0*="'This%20is%20broken";
z'This is brokenr
rXs   r:�test_rfc2231_missing_tickz%TestRFC2231.test_rfc2231_missing_ticksO��
���'��*�*�����������	�	�	�	�	r<c��d}tj|��}|�|���d��dS)NzAContent-Disposition: inline;
	filename*0*="'This%20is%E2broken";
u'This is�brokenr
rXs   r:�0test_rfc2231_missing_tick_with_encoded_non_asciiz<TestRFC2231.test_rfc2231_missing_tick_with_encoded_non_ascii"sO��
���'��*�*����������"�	$�	$�	$�	$�	$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*rO�en-usrMr'rNs       r:�!test_rfc2231_tick_attack_extendedz-TestRFC2231.test_rfc2231_tick_attack_extended-sx��
�
��
��
�'��*�*��"�}�}�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    r:�test_rfc2231_tick_attackz$TestRFC2231.test_rfc2231_tick_attack;s_��
��
�'��*�*���
�
�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*rMr'r�s    r:�test_rfc2231_no_extended_valuesz+TestRFC2231.test_rfc2231_no_extended_valuesGsH��
�
��
���'��*�*��
��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*rOrW�My Document For Your'rNs       r:�,test_rfc2231_encoded_then_unencoded_segmentsz8TestRFC2231.test_rfc2231_encoded_then_unencoded_segmentsQ�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*rOrWr^r'rNs       r:�,test_rfc2231_unencoded_then_encoded_segmentsz8TestRFC2231.test_rfc2231_unencoded_then_encoded_segmentsbr`r<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�)r8r�r	)r7�messagesr�r9s    r:�+test_should_not_hang_on_invalid_ew_messagesz7TestRFC2231.test_should_not_hang_on_invalid_ew_messagesqs�������"�	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�rrr(rMrrXrr"r%r-r0r3r5r7r9r<r>r@rCrErHrKrOrQrSrUrXrZr\r_rbrer|r<r:rr�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<rc�,�eZdZd�Zd�Zd�Zd�Zd�ZdS)�
TestSignedc��t|d���5}|���}tj|��}ddd��n#1swxYwY||fSrXrY)r7r^r��originalr9s     r:�_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�groupr3)r7ri�resultr��repart�inpart�outparts       r:�_signed_parts_eqzTestSigned._signed_parts_eq�s����	�	�	����8�"�$���+�F�F�����x�(�(�.�.�q�1�1���-�-��'�'�-�-�a�0�0������&�)�)�)�)�)r<c��|�d��\}}|���}|�||��dSr��rjr�rs�r7rir9ros    r:�test_long_headers_as_stringz&TestSigned.test_long_headers_as_string�sB���)�)�,�7�7�
��#����������h��/�/�/�/�/r<c��|�d��\}}|�d���}|�||��dS)Nr��<r�rurvs    r:�(test_long_headers_as_string_maxheaderlenz3TestSigned.test_long_headers_as_string_maxheaderlen�sH���)�)�,�7�7�
��#����B��/�/�����h��/�/�/�/�/r<c���|�d��\}}t��}t|���|��|���}|�||��dSr�)rjrrr�r�rs)r7rir9r�ros     r:�test_long_headers_flattenz$TestSigned.test_long_headers_flatten�se���)�)�,�7�7�
��#�
�Z�Z���"�
�
���c�"�"�"����������h��/�/�/�/�/r<N)r�rrrjrsrwrzr|r|r<r:rgrg�s_���������*�*�*�0�0�0�
0�0�0�
0�0�0�0�0r<rgc��eZdZd�ZdS)�TestHeaderRegistryc��t��}|dd��}|�|jdtj��dS)NrZzattachment; 0*00="foo"r)rr�r�r �InvalidHeaderDefect)r7�regr�s   r:�test_HeaderRegistryz&TestHeaderRegistry.test_HeaderRegistry�sE�������C�%�'?�@�@�����a�i��l�F�,F�G�G�G�G�Gr<N)r�rrr�r|r<r:r~r~�s(������H�H�H�H�Hr<r~�__main__)ir�rIrXr<r��warnings�iorr�	itertoolsr�randomr�	threadingr�
unittest.mockr	r��email.policy�email.utils�
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#r�r$�test.supportr%�test.support.os_helperr&�test.test_emailr'r(r)r*r�r�r^r/�TestCaserr#r�r�r�rr#r?r�r�rrPrVr�r�rrr[r�r�r�r�r�r�r�rrgr~r��mainr|r<r:�<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�	������G�G�G�G�G�]�G�G�G�V?�?�?�?�?�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-�~nH�nH�nH�nH�nH�
�nH�nH�nH�dd(�d(�d(�d(�d(�M�d(�d(�d(�N-A�-A�-A�-A�-A�m�-A�-A�-A�`QK�QK�QK�QK�QK�-�QK�QK�QK�h[�[�[�[�[�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<