HEX
Server: Apache
System: Linux bd12.noc223.com 4.18.0-553.121.1.lve.el8.x86_64 #1 SMP Thu Apr 30 16:40:41 UTC 2026 x86_64
User: handcraf (1693)
PHP: 8.1.28
Disabled: NONE
Upload Files
File: //opt/alt/python312/lib64/python3.12/test/test_email/__pycache__/test_message.cpython-312.opt-1.pyc
�

}h�e������ddlZddlZddlmZmZddlmZmZddlm	Z	m
Z
d�ZGd�de	�Ze
Gd�d	��Z
Gd
�de
e	�ZGd�d
e
e	�Zedk(rej"�yy)�N)�policy�message_from_string)�EmailMessage�MIMEPart)�
TestEmailBase�parameterizec�0�ttd�|�d�S)Nc�
�|duS�N�)�xs �C/opt/alt/python312/lib64/python3.12/test/test_email/test_message.py�<lambda>zfirst.<locals>.<lambda>
s
���$���)�next�filter)�iterables r�firstr	s����.��9�4�@�@rc�0�eZdZejZd�Zd�Zy)�Testc��|jd�}d|d<|jt�5d|d<ddd�y#1swYyxYw)N�zabc@xyz�Tozxyz@abc)�_str_msg�assertRaises�
ValueError��self�ms  r�+test_error_on_setitem_if_max_count_exceededz0Test.test_error_on_setitem_if_max_count_exceededsE���M�M�"�����$��
�
�
�z�
*�	 ��A�d�G�	 �	 �	 �s	�;�Ac���ttjd�tj��}|j|dd�|j|dd�|j
|t�y)Na>            Subject: Ayons asperges pour le =?utf-8?q?d=C3=A9jeuner?=
            From: =?utf-8?q?Pep=C3=A9?= Le Pew <pepe@example.com>
            To: "Penelope Pussycat" <"penelope@example.com">
            MIME-Version: 1.0
            Content-Type: text/plain; charset="utf-8"

            sample text
            �r�subjectu Ayons asperges pour le déjeuner�fromuPepé Le Pew <pepe@example.com>)r�textwrap�dedentr�default�assertEqual�assertIsInstancerrs  r�/test_rfc2043_auto_decoded_and_emailmessage_usedz4Test.test_rfc2043_auto_decoded_and_emailmessage_usedsa������1�!� ���
)��	
����9��'I�J�����6��$E�F����a��.rN)�__name__�
__module__�__qualname__rr'r r*rrrrr
s��
�^�^�F� �/rrc�>�eZdZejZddddejd�fdddejd�fdddejd	�fdddejd
�fdddejd
�fdddejd�fdddejd�fdddejd�fdddejd�fdddejd�fdddejd�fdddejd�fdddejd�fdddejd�fd �Zd!�Zd"�Z	d#�Z
Gd$�d%�Zd&�Zd'�Z
d(�Zd)�Zd*Zd+�Zd,�Zd-�Zd.�Zd/�Zd0�ZGd1�d2�Zd3�ZGd4�d5�Zd6�Zd7�Zd8�Zd9�Zd:�Zd;d<d=d>d?�Zd@�Z yA)B�TestEmailMessageBase)�NNrrrrr0rzV                To: foo@example.com

                simple text body
                )NNNz�                To: foo@example.com
                MIME-Version: 1.0
                Content-Type: image/jpg

                bogus body.
                )N��)r2r1a�                To: foo@example.com
                MIME-Version: 1.0
                Content-Type: multipart/alternative; boundary="==="

                preamble

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

                simple body

                --===
                Content-Type: text/html

                <p>simple body</p>
                --===--
                a�                To: foo@example.com
                MIME-Version: 1.0
                Content-Type: multipart/mixed; boundary="==="

                preamble

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

                simple body

                --===
                Content-Type: text/html

                <p>simple body</p>

                --===--
                )NNr2)r1a�                To: foo@example.com
                MIME-Version: 1.0
                Content-Type: multipart/mixed; boundary="==="

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

                simple body

                --===
                Content-Type: text/html
                Content-Disposition: attachment

                <p>simple body</p>

                --===--
                )Nr1N)r2a�                To: foo@example.com
                MIME-Version: 1.0
                Content-Type: multipart/mixed; boundary="==="

                --===
                Content-Type: text/plain
                Content-Disposition: AtTaChment

                simple body

                --===
                Content-Type: text/html

                <p>simple body</p>

                --===--
                a�                To: foo@example.com
                MIME-Version: 1.0
                Content-Type: multipart/mixed; boundary="==="

                --===
                Content-Type: text/plain
                Content-Disposition: InLine

                simple body

                --===
                Content-Type: text/html
                Content-Disposition: inline

                <p>simple body</p>

                --===--
                )rr2Na�                To: foo@example.com
                MIME-Version: 1.0
                Content-Type: multipart/related; boundary="==="; type=text/html

                --===
                Content-Type: text/html

                <p>simple body</p>

                --===
                Content-Type: image/jpg
                Content-ID: <image1>

                bogus data

                --===--
                )rr1Na                To: foo@example.com
                MIME-Version: 1.0
                Content-Type: multipart/related; boundary="==="; type=text/html;
                 start="<body>"

                --===
                Content-Type: text/html
                Content-ID: <include>

                useless text

                --===
                Content-Type: text/html
                Content-ID: <body>

                <p>simple body</p>
                <!--#include file="<include>"-->

                --===--
                )��r1)��)r2r5r6a�                To: foo@example.com
                MIME-Version: 1.0
                Content-Type: multipart/mixed; boundary="==="

                --===
                Content-Type: multipart/alternative; boundary="+++"

                --+++
                Content-Type: text/plain

                simple body

                --+++
                Content-Type: multipart/related; boundary="___"

                --___
                Content-Type: text/html

                <p>simple body</p>

                --___
                Content-Type: image/jpg
                Content-ID: <image1@cid>

                bogus jpg body

                --___--

                --+++--

                --===
                Content-Type: image/jpg
                Content-Disposition: attachment

                bogus jpg body

                --===
                Content-Type: image/jpg
                Content-Disposition: AttacHmenT

                another bogus jpg body

                --===--
                )r2r4r3a�                To: foo@example.com
                MIME-Version: 1.0
                Content-Type: multipart/mixed; boundary="==="

                --===
                Content-Type: multipart/related; boundary="+++"

                --+++
                Content-Type: multipart/alternative; boundary="___"

                --___
                Content-Type: text/plain

                simple body

                --___
                Content-Type: text/html

                <p>simple body</p>

                --___--

                --+++
                Content-Type: image/jpg
                Content-ID: <image1@cid>

                bogus jpg body

                --+++--

                --===
                Content-Type: image/jpg
                Content-Disposition: attachment

                bogus jpg body

                --===
                Content-Type: image/jpg
                Content-Disposition: attachment

                another bogus jpg body

                --===--
                )r2NNa�                To: foo@example.com
                MIME-Version: 1.0
                Content-Type: multipart/mixed; boundary="==="

                --===
                Content-Type: multipart/related; boundary="+++"

                --+++
                Content-Type: image/jpg
                Content-ID: <image1@cid>

                bogus jpg body

                --+++
                Content-Type: multipart/alternative; boundary="___"

                --___
                Content-Type: text/plain

                simple body

                --___
                Content-Type: text/html

                <p>simple body</p>

                --___--

                --+++--

                --===
                Content-Type: image/jpg
                Content-Disposition: attachment

                bogus jpg body

                --===
                Content-Type: image/jpg
                Content-Disposition: attachment

                another bogus jpg body

                --===--
                z�                To: foo@example.com
                MIME-Version: 1.0
                Content-Type: message/rfc822

                To: bar@example.com
                From: robot@examp.com

                this is a message body.
                a�                To: foo@example.com
                MIME-Version: 1.0
                Content-Type: multipart/mixed; boundary="==="

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

                Your message has bounced, sir.

                --===
                Content-Type: message/rfc822

                To: bar@example.com
                From: robot@examp.com

                this is a message body.

                --===--
                )�
empty_message�non_mime_plain�
mime_non_text�plain_html_alternative�plain_html_mixed�plain_html_attachment_mixed�html_text_attachment_mixed�!html_text_attachment_inline_mixed�related�related_with_start�mixed_alternative_plain_related�$mixed_related_alternative_plain_html�0mixed_related_alternative_plain_html_wrong_order�message_rfc822�mixed_text_message_rfc822c	�P�|j|�}t|j��}|D�cgc]}|�dn||��
}}d}	d}
d}|j|j	�t|��|j|j	d��t|��|j|j	d��t||	|
dz��|j|j	d��t||	||g��|j|j	d��t||
|dz��|j|j	d	g��||	�|j|j	d
g��||
�|j|j	dg��||�|j|j	d��t|||
dz
d
���|j|j	d��t||||	g��|j|j	d��t||
dd
���|j|j	d��t|ddd
���|j|j	d��t||
||||	g��ycc}w)Nrr2r1)r?�html�plain)�preferencelist)r?rG)r?rH)rGrHr?rGrH)rHrG���)rHr?)rGr?)rHrGr?)rGrHr?)r�list�walkr(�get_bodyr)r�
body_parts�attachments�parts�msgr�allparts�n�expectedr?rGrHs            r�message_as_get_bodyz(TestEmailMessageBase.message_as_get_body�s����M�M�#��������>��@J�K�1�A�I�D�8�A�;�6�K��K���A�T�q�u��������u�X��7�������4D��E��x��	*�	
������3F��G��x���Q��7�8�	:�������3G��H���� 1�8�E�?�C�D�	F�������3D��E��x��U�1�W�5�6�	8�������I�;��?�!�'�*�	,�������F�8��<�h�t�n�M�������G�9��=�x���O�������3D��E��x��d�1�f�R��8�9�	;�������3G��H������'�1B�C�D�	F�������3F��G��x���b��1�2�	4�������3O��P��x��"��~�.�	0�������3O��P����� (��� (�� 1� 3�4�	5��1Ls�J#c���|j|�}t|j��}|D�cgc]}||��	}}|jt|j	��|�ycc}wr)rrKrLr(�iter_attachments)rrNrOrPrQrrRrSs        r�message_as_iter_attachmentz/TestEmailMessageBase.message_as_iter_attachment�sY���M�M�#��������>��,7�8�q�x��{�8��8�����a�0�0�2�3�[�A��9s�A'c��d�}|j|�}t|j��}|D�cgc]}||��	}}||�rt|j��ng}	|j	|	|�ycc}w)Nc�
�d|vS)NzContent-Type: multipartr)rQs r�_is_multipart_msgzETestEmailMessageBase.message_as_iter_parts.<locals>._is_multipart_msg�s
��,��3�3r)rrKrL�
iter_partsr()
rrNrOrPrQr[rrRrSr\s
          r�message_as_iter_partsz*TestEmailMessageBase.message_as_iter_parts�sk��	4�
�M�M�#��������>��&+�,���!��,��,�->�s�-C�T�!�,�,�.�)��
�����U�+��-s�A6c��eZdZd�Zd�Zy)�(TestEmailMessageBase._TestContentManagerc��|||fSrr�rrQ�args�kws    r�get_contentz4TestEmailMessageBase._TestContentManager.get_content�s����b�=� rc�.�||_||_||_yr)rQrbrcras    r�set_contentz4TestEmailMessageBase._TestContentManager.set_content�s���D�H��D�I��D�GrN)r+r,r-rdrfrrr�_TestContentManagerr_�s��	!�	rrgc�D�|jd�}|j�}|j|j|��|dif�|jd|dd��\}}}|j||�|j|d�|j|t	dd�	��y�
Nr��content_managerr�foor2r1)rk�bar�k�rl�rmrn)rrgr(rd�dict)rr�cmrQrbrcs      r�test_get_content_with_cmz-TestEmailMessageBase.test_get_content_with_cm�s����M�M�"���
�
%�
%�
'��������r��:�Q��B�K�H��
�
�e�R�Q�!�
�L�
��T�2�����a� �����x�(�����T�a�1�-�.rc�~�tjj|j���}|j	d|��}|j|j
�|dif�|j
ddd��\}}}|j||�|j|d	�|j|tdd���y�
Nrjrr"rrlr2r1rpro)rr'�clonergrr(rdrq)r�prrQrbrcs      r�-test_get_content_default_cm_comes_from_policyzBTestEmailMessageBase.test_get_content_default_cm_comes_from_policys����N�N� � ��1I�1I�1K� �L���M�M�"�Q�M�'���������1�b�"�+�6��
�
�e��a�
�8�
��T�2�����a� �����x�(�����T�a�1�-�.rc��|jd�}|j�}|j|��|j|j|�|j|j
d�|j|ji�|jd|dd��|j|j|�|j|j
d�|j|jtdd�	��yri)rrgrfr(rQrbrcrq�rrrrs   r�test_set_content_with_cmz-TestEmailMessageBase.test_set_content_with_cm
s����M�M�"���
�
%�
%�
'��	�
�
�b�
�)��������#�������"�%��������#�	�
�
�e�R�Q�!�
�<��������#�������(�+���������a� 0�1rc�8�|j�}tjj|��}|j	d|��}|j�|j
|j|�|j
|jd�|j
|ji�|jddd��|j
|j|�|j
|jd	�|j
|jtdd���yru)rgrr'rvrrfr(rQrbrcrq)rrrrwrs    r�-test_set_content_default_cm_comes_from_policyzBTestEmailMessageBase.test_set_content_default_cm_comes_from_policys���
�
%�
%�
'���N�N� � �� �4���M�M�"�Q�M�'��	�
�
���������#�������"�%��������#�	�
�
�e��a�
�(��������#�������(�+���������a� 0�1r))r?�
no_content�succeeds)r?�noner)r?rHr)r?r?r)r?�alternative�raises)r?�mixedr�)r�r~r)r�r�r)r�rHr)r�r?r)r�r�r)r�r�r�)r�r~r)r�r�r)r�rHr)r�r?r)r�r�r)r�r�rc�V�|j�}d}ddg}|dk7r	|jd�|dk(r%d}|jd�|jd�n|dk7rg}|jdd	|zf�|jd
�|j|�|D]
\}}|||<�|||fS)N)rzfoo@bar.com)�Fromzbar@foo.comr~)zX-Random-Header�Corwin�textr)�Content-Type�
text/plainr��
multipart/)zX-Trump�Random)�message�append�set_payload)r�subtyper�payload�msg_headers�name�values       r�_make_subtype_test_messagez/TestEmailMessageBase._make_subtype_test_messageAs����L�L�N����!�#����l�"�)����8�9��f���G����=�>�
�M�M�"��
��
$��G������w�0F�G�H����0�1�	�
�
�g��&�	�K�D�%��A�d�G�	��+�w�&�&rc���|jt�5}t||��ddd�tj�}|j||�|j||�y#1swY�CxYwr)rr�getattr�str�	exception�assertIn)rr�method_namer��method�ar�exc_texts       r� _check_disallowed_subtype_raisesz5TestEmailMessageBase._check_disallowed_subtype_raisesXs`��
�
�
�z�
*�	!�b��G�A�v�� �	!��r�|�|�$���
�
�g�x�(��
�
�k�8�,�		!�	!�s�A*�*A3c��d}|D]?\}}|j�jd�r�&|j|||�|dz
}�A|jt|�|dz�t	|j��}d}|D]?\}}|j�jd�s�&|j|||�|dz
}�A|jt|�|�|j|j
�|�y)Nr�content-r2)�lower�
startswithr(�lenrr\�get_payload)rrr�r��countr�r��parts        r�_check_make_multipartz*TestEmailMessageBase._check_make_multipart_s�����&�	�K�D�%��:�:�<�*�*�:�6�� � ��4��%�0���
��	�	
����Q���q��)��A�L�L�N�#����&�	�K�D�%��z�z�|�&�&�z�2�� � ��d��U�3���
��	�	
����T��E�*�����)�)�+�W�5rc�4�|j|�\}}}d|z}|dvr|j||||�yt||��|j|j	�d�|j|j�|�|dk(rS|jt
|j��d�|j|j�|dd|zfgz�y|jt
|j��d�|j|||�y)	N�make_�rr��	multipartr~rr�r�r2)
r�r�r�r(�get_content_maintype�get_content_subtyper�r��itemsr�)rr�r��outcomerr�r��make_methods        r�subtype_as_makez$TestEmailMessageBase.subtype_as_makeos��"&�"A�"A�'�"J���;����&���n�$��1�1�!�V�W�k�R�����;��!�����/�/�1�;�?�����.�.�0�&�9��l�"����S�����1�1�5����Q�W�W�Y�(�^�-9�&�-@�-B�,C�C�
D�
���S�����1�1�5��&�&�q�+�w�?rc��|j�}|dvr;d|z|d<|jt�5}t|d|z��ddd�y|dk(rd|d<n
|dk7rd|z|d<t|d|z�d�	�|j	|j��|j
|j�d�y#1swYyxYw)
Nr�r�r�r�rHr�r~�abc)�boundary)r�rrr��
assertTrue�is_multipartr(�get_boundary)rr�r�r�rrrs      r�subtype_as_make_with_boundaryz2TestEmailMessageBase.subtype_as_make_with_boundary�s����L�L�N���n�$� ,�w� 6�A�n���"�"�:�.�
/�"�,���7�V�+�,�.�
/���g�� ,�A�n��
��
$� ,�w� 6�A�n��$���7�V�#�$�e�4�������(�)�������)�5�1�
/��s�B>�>Cc��dD]y}|j|jjd����}d|d<t||��|j	|jd�jjd��{y)N)�make_related�make_alternative�
make_mixedrlrjr"r�r�r)r�rrvr�r(r�rk)rr�rs   r�3test_policy_on_part_made_by_make_comes_from_messagezHTestEmailMessageBase.test_policy_on_part_made_by_make_comes_from_message�ss��H�	M�F����D�K�K�$5�$5�e�$5�$L��M�A� ,�A�n���G�A�v�� ����Q�]�]�1�-�4�4�D�D�e�L�		Mrc��eZdZd�Zy)�+TestEmailMessageBase._TestSetContentManagerc�0�d|d<|j|�y)Nr�r�)r��rrQ�contentrbrcs     rrfz7TestEmailMessageBase._TestSetContentManager.set_content�s��".�C����O�O�G�$rN�r+r,r-rfrrr�_TestSetContentManagerr��s��	%rr�c��|j|�\}}}|j�}|dk(rdnd|z}|dk(r|j||||�yt||�d|��|j	|j�d�|j	|j
�|�||k(s|dk(r\|j	t|j��d	�|D]\}	}
|j	||	|
��|j�d
}nO|j	t|j��d�|j|||�|j�d	}|j	|j�d�|j	|j�d�|dk(r|j	|d
d�y|dk(r|j	|d
d�y|j|d
�y)Nr��add_attachment�add_r��testrjr�r~r2rr1r��Content-Disposition�
attachmentr?�inline)r�r�r�r�r(r�r�r�r�r��get_content_type�assertIsNone)rr�r�r�rr�r�rr�
add_methodr�r�r�s            r�subtype_as_addz#TestEmailMessageBase.subtype_as_add�s���"&�"A�"A�'�"J���;��
�
(�
(�
*��)/���%�f�v�o�
��h���1�1�!�V�W�j�Q�����:��v�r�:�����/�/�1�;�?�����.�.�0�&�9��W���<� 7����S�����1�1�5�*�
1���e�� � ��4��%�0�
1��=�=�?�1�%�D����S�����1�1�5��&�&�q�+�w�?��=�=�?�1�%�D�����.�.�0�,�?�����)�)�+�V�4��7�?����T�"7�8�,�G�
�Y�
����T�"7�8�(�C�
���d�#8�9�:rc�(�eZdZGd�de�Zd�Zy)�2TestEmailMessageBase._TestSetRaisingContentManagerc��eZdZy)�>TestEmailMessageBase._TestSetRaisingContentManager.CustomErrorN)r+r,r-rrr�CustomErrorr��s��rr�c�$�|jd��)Nr�)r�r�s     rrfz>TestEmailMessageBase._TestSetRaisingContentManager.set_content�s���"�"�6�*�*rN)r+r,r-�	Exceptionr�rfrrr�_TestSetRaisingContentManagerr��s��	�)�	�	+rr�c�l�|j�}|j|jj|����}dD]g}|j	|jj
�5}t
||�d�ddd�|jtj�d��iy#1swY�1xYw)Nrjr")�add_related�add_alternativer�rr�)
r�r�rrvrr�r�r(r�r�)rrrrr�r�s     r�6test_default_content_manager_for_add_comes_from_policyzKTestEmailMessageBase.test_default_content_manager_for_add_comes_from_policy�s���
�
/�
/�
1���L�L���� 1� 1�"� 1� E�L�F��J�	8�F��"�"�4�#E�#E�#Q�#Q�R�
'�VX�"���6�"�2�&�
'����S����.��7�	8�
'�
'�s�'B*�*B3	c�^�|j|�}|j�|jt|�d�|jt	|j��g�|j
|j��|jt	|j��g�y)Nr)	r�clearr(r�rKr�r�r�r\)rrNrOrPrQrs      r�message_as_clearz%TestEmailMessageBase.message_as_clear�sv���M�M�#���	���	�����Q���#�����a�g�g�i��"�-����!�-�-�/�*�����a�l�l�n�-�r�2rc��|j|�}|j�D�cgc]#}|j�jd�s|��%}}|j	�|jt
|j��|�|j|j��|jt
|j��g�ycc}w)Nr�)
r�keysr�r��
clear_contentr(rKr�r�r\)rrNrOrPrQr�h�expected_headerss        r�message_as_clear_contentz-TestEmailMessageBase.message_as_clear_content�s����M�M�#���'(�v�v�x�E�!�#$�7�7�9�#7�#7�
�#C��E��E�	��������a�f�f�h��)9�:����!�-�-�/�*�����a�l�l�n�-�r�2��Es�(Cc���|j�}|j|j��d|d<|j|j��|jdd�|j	|j��|jdd�|j	|j��|jddd�|j	|j��y)Nr�r�r��
AtTachMent�filenamezabc.png)�
_make_message�assertFalse�
is_attachment�replace_headerr��	set_paramrs  r�test_is_attachmentz'TestEmailMessageBase.test_is_attachment�s������ ��������*�+�#+��
� �������*�+�	���.��=�������)�*�	���.��=�������)�*�	���J�	�+@�A�������)�*rc�j�|j�}|jd�|jd�|jd�|j�j	�}|jt
t|j���d�|j|j�|�y)Nzarbitrary text as main partzmore text as a related partz&yet more text as a second "attachment"r1)	r�rfr�r��copyr(r�rKrW)rr�origs   r�test_iter_attachments_mutationz3TestEmailMessageBase.test_iter_attachments_mutation�s������ ��	�
�
�3�4�	�
�
�3�4�	�
�
�>�?��}�}��#�#�%������T�!�"4�"4�"6�7�8�!�<��������$�/r)u4String that can be encod��d with surrogateescapes0String that can be encodëd with surrogateescape)uString with utf-8 charactërsString with utf-8 charact�r)u8String that cannot be ëncod��d with surrogateescapes=String that cannot be �ncod\udcc3\udcabd with surrogateescape)u6String with � cannot be encoded with surrogateescapes9String with \udfff cannot be encoded with surrogateescape)�good_surrogateescape�string_with_utf8�surrogate_and_utf8�out_of_range_surrogatec�n�|j|�}|jd��}|j||�y)ztest for GH issue 94606T)�decodeN)rr�r()rrQrTrr�s     r�!get_payload_surrogate_as_gh_94606z6TestEmailMessageBase.get_payload_surrogate_as_gh_94606s0���M�M�#����-�-�t�-�,������7�+rN)!r+r,r-rr'r%r&�message_paramsrUrXr]rgrsrxr{r}�subtype_paramsr�r�r�r�r�r�r�r�r�r�r�r�r�r��get_payload_surrogate_paramsr�rrrr/r/&s����^�^�F��
����H�O�O��
�	�
����H�O�O��
�	
�
����H�O�O��
�	#�0
����H�O�O��
�	�2
����H�O�O��
�	(�0
����H�O�O��
�	'�0
����H�O�O��
�	.�4
����H�O�O��
�	�6
����H�O�O��
�	�8
����H�O�O�,�,
�	0,�j
����H�O�O�,�,
�	01�l
����H�O�O�,�,
�	0=�f
����H�O�O�	�	
�	
� 
����H�O�O��
�	&�gL�N�\5�@B�,���/�/�
2�2�&
�N�*'�.-�6� @�$2� M�%�%�
;�:+�+�8�3�3�
+�0�!�
�
�
#�#$� �.,rr/c��eZdZeZd�ZGd�d�Zd�Zd�Zd�Z	d�Z
d�Zd	�Zd
�Z
d�Zd�Zd
�Zd�Zd�Zd�Zd�Zd�Zy)�TestEmailMessagec��|jd�}|j�}|jd|�|j|��|j	|dd�y�Nr�MIME-Versionrj�1.0)rrg�assertNotInrfr(rzs   r�"test_set_content_adds_MIME_Versionz3TestEmailMessage.test_set_content_adds_MIME_VersionsQ���M�M�"���
�
%�
%�
'�������+�	�
�
�b�
�)�����>�*�E�2rc��eZdZd�Zy)�(TestEmailMessage._MIME_Version_adding_CMc��d|d<y)Nrrrras    rrfz4TestEmailMessage._MIME_Version_adding_CM.set_contents��"'�C��rNr�rrr�_MIME_Version_adding_CMrs��	(rrc��|jd�}|j�}|jd|�|j|��|j	|dd�yr�)rrrrfr(rzs   r�0test_set_content_does_not_duplicate_MIME_VersionzATestEmailMessage.test_set_content_does_not_duplicate_MIME_VersionsQ���M�M�"���
�
)�
)�
+�������+�	�
�
�b�
�)�����>�*�E�2rc��|jd�}|jt|j�j	�j��d�y�N��Subject: long line ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab

r3�rr(r��	as_string�strip�
splitlinesrs  r�0test_as_string_uses_max_header_length_by_defaultzATestEmailMessage.test_as_string_uses_max_header_length_by_default"s>���M�M�B�C������Q�[�[�]�0�0�2�=�=�?�@�!�Drc�B�|jd�}|jt|jd��j	�j��d�|jt|jd��j	�j��d�y)Nrr)�maxheaderlenr2�"r5r
rs  r�"test_as_string_allows_maxheaderlenz3TestEmailMessage.test_as_string_allows_maxheaderlen&s{���M�M�B�C������Q�[�[�a�[�8�>�>�@�K�K�M�N��	�����Q�[�[�b�[�9�?�?�A�L�L�N�O��	rc���|jd�}|jd�|j|jd��d�|j|jd��d�y)Nr�z%From foo@bar Thu Jan  1 00:00:00 1970T)�unixfromz+From foo@bar Thu Jan  1 00:00:00 1970

testFz
test)r�set_unixfromr(rrs  r�test_as_string_unixformz(TestEmailMessage.test_as_string_unixform-sW���M�M�&�!��	���>�?�������d��3�G�	I�������e��4�h�?rc��|jd�}|jtt|�j	�j��d�yr)rr(r�r�rrrs  r�+test_str_defaults_to_policy_max_line_lengthz<TestEmailMessage.test_str_defaults_to_policy_max_line_length4s9���M�M�B�C������S��V�\�\�^�6�6�8�9�1�=rc�X�t�}d|d<|jt|�d�y)Nuunicöde�SubjectuSubject: unicöde

)rr(r�rs  r�test_str_defaults_to_utf8z*TestEmailMessage.test_str_defaults_to_utf88s'���N��!��)������Q��!8�9rc�X�t�}d|d<|jt|�d�y)NuDHello Wörld! Hello Wörld! Hello Wörld! Hello Wörld!Hello Wörld!rs|Subject: Hello =?utf-8?q?W=C3=B6rld!_Hello_W=C3=B6rld!_Hello_W=C3=B6rld!?=
 Hello =?utf-8?q?W=C3=B6rld!Hello_W=C3=B6rld!?=

�rr(�bytesrs  r�!test_folding_with_utf8_encoding_1z2TestEmailMessage.test_folding_with_utf8_encoding_1=s2��
�N��B��)������q��P�	Qrc�X�t�}d|d<|jt|�d�y)NuHHello Wörld! Hello Wörld! Hello Wörlds123! Hello Wörld!Hello Wörld!rs�Subject: Hello =?utf-8?q?W=C3=B6rld!_Hello_W=C3=B6rld!_Hello_W=C3=B6rlds123!?=
 Hello =?utf-8?q?W=C3=B6rld!Hello_W=C3=B6rld!?=

r rs  r�!test_folding_with_utf8_encoding_2z2TestEmailMessage.test_folding_with_utf8_encoding_2Ns2��
�N��F��)������q��P�	Qrc�X�t�}d|d<|jt|�d�y)NuHHello-Wörld!-Hello-Wörld!-Hello-Wörlds123! Hello Wörld!Hello Wörld!rs�Subject: =?utf-8?q?Hello-W=C3=B6rld!-Hello-W=C3=B6rld!-Hello-W=C3=B6rlds123!?=
 Hello =?utf-8?q?W=C3=B6rld!Hello_W=C3=B6rld!?=

r rs  r�!test_folding_with_utf8_encoding_3z2TestEmailMessage.test_folding_with_utf8_encoding_3^s1��
�N��4��)������q��P�	Qrc�X�t�}d|d<|jt|�d�y)NuHHello-Wörld!-Hello-Wörld!-Hello-Wörlds123!-Hello Wörld!Hello Wörld!rs�Subject: =?utf-8?q?Hello-W=C3=B6rld!-Hello-W=C3=B6rld!-Hello-W=C3=B6rlds123!?=
 =?utf-8?q?-Hello_W=C3=B6rld!Hello_W=C3=B6rld!?=

r rs  r�!test_folding_with_utf8_encoding_4z2TestEmailMessage.test_folding_with_utf8_encoding_4ns1��
�N��/��)������q��Q�	Rrc�X�t�}d|d<|jt|�d�y)NuS123456789 123456789 123456789 123456789 123456789 123456789 123456789 Hello Wörld!rsoSubject: 123456789 123456789 123456789 123456789 123456789 123456789 123456789
 Hello =?utf-8?q?W=C3=B6rld!?=

r rs  r�!test_folding_with_utf8_encoding_5z2TestEmailMessage.test_folding_with_utf8_encoding_5~s0��
�N��<��)������q��?�	@rc�X�t�}d|d<|jt|�d�y)Nuq123456789 123456789 123456789 123456789 Hello Wörld! 123456789 123456789 123456789 123456789 123456789 123456789rs�Subject: 123456789 123456789 123456789 123456789 Hello =?utf-8?q?W=C3=B6rld!?=
 123456789 123456789 123456789 123456789 123456789 123456789

r rs  r�!test_folding_with_utf8_encoding_6z2TestEmailMessage.test_folding_with_utf8_encoding_6�s1��
�N��$��)��	
����q��*�	+rc�X�t�}d|d<|jt|�d�y)Nuo123456789 123456789 Hello Wörld! Hello Wörld! 123456789-123456789 123456789 Hello Wörld! 123456789 123456789rs�Subject: 123456789 123456789 Hello =?utf-8?q?W=C3=B6rld!_Hello_W=C3=B6rld!?=
 123456789-123456789 123456789 Hello =?utf-8?q?W=C3=B6rld!?= 123456789
 123456789

r rs  r�!test_folding_with_utf8_encoding_7z2TestEmailMessage.test_folding_with_utf8_encoding_7�s3��
�N��$��)��	
����q��N�	Orc�X�t�}d|d<|jt|�d�y)Nu�123456789 123456789 Hello Wörld! Hello Wörld! 123456789 123456789 123456789 123456789 123456789 123456789-123456789 123456789 Hello Wörld! 123456789 123456789rs�Subject: 123456789 123456789 Hello =?utf-8?q?W=C3=B6rld!_Hello_W=C3=B6rld!?=
 123456789 123456789 123456789 123456789 123456789 123456789-123456789
 123456789 Hello =?utf-8?q?W=C3=B6rld!?= 123456789 123456789

r rs  r�!test_folding_with_utf8_encoding_8z2TestEmailMessage.test_folding_with_utf8_encoding_8�s3��
�N��$��)��	
����q��L�	Mrc�p�tjd�}|j|�}|j�y)ztest for bpo-42892a'            Message-ID: <674392CA.4347091@email.au>
            Date: Wed, 08 Nov 2017 08:50:22 +0700
            From: Foo Bar <email@email.au>
            MIME-Version: 1.0
            To: email@email.com <email@email.com>
            Subject: Python Email
            Content-Type: multipart/mixed;
            boundary="------------879045806563892972123996"
            X-Global-filter:Messagescannedforspamandviruses:passedalltests

            This is a multi-part message in MIME format.
            --------------879045806563892972123996
            Content-Type: text/plain; charset=ISO-8859-1; format=flowed
            Content-Transfer-Encoding: 7bit

            Your message is ready to be sent with the following file or link
            attachments:
            XU89 - 08.11.2017
            N)r%r&rrM)rrQrs   r�test_get_body_malformedz(TestEmailMessage.test_get_body_malformed�s0���o�o����(
�M�M�#���	
�
�
�rN)r+r,r-rr�rrr	rrrrrr"r$r&r(r*r,r.r0r2rrrr�r�
sj���G�3�(�(�3�E��@�>�:�
Q�"Q� Q� R� @�+� O�"M�(rr�c��eZdZeZd�Zd�Zy)�TestMIMEPartc��|jd�}|j�}|jd|�|j|��|jd|�y)Nrrrj)rrgrrfrzs   r�*test_set_content_does_not_add_MIME_Versionz7TestMIMEPart.test_set_content_does_not_add_MIME_Version�sL���M�M�"���
�
%�
%�
'�������+�	�
�
�b�
�)������+rc��ttjd�tj��}|j�}|j
t|�g�y)NzT        Content-Type: multipart/mixed; charset="utf-8"

        sample text
        r")rr%r&rr'rWr(rK)rrQrOs   r�/test_string_payload_with_multipart_content_typez<TestMIMEPart.test_string_payload_with_multipart_content_type�sJ��!�(�/�/�3�#
��^�^�	%��
�*�*�,������k�*�B�/rN)r+r,r-rr�r6r8rrrr4r4�s���G�,�0rr4�__main__)�unittestr%�emailrr�
email.messagerr�test.test_emailrrrrr/r�r4r+�mainrrr�<module>r?s~����-�0�7�A�/�=�/�2�c,�c,��c,�LM�+�]�M�`0�'��0�.�z���H�M�M�O�r