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_generator.cpython-312.pyc
�

}h�e�/����ddlZddlZddlZddlmZmZddlmZddlm	Z	m
Z
ddlmZddlm
Z
ddlmZmZeGd�d	��ZGd
�dee�ZGd�d
ee�Zedk(rej*�yy)�N)�message_from_string�message_from_bytes)�EmailMessage)�	Generator�BytesGenerator)�Address��policy)�
TestEmailBase�parameterizec�N�eZdZejZdd�Zejd�ejd�ejd�d�Zeded<ej�Z
d	e
d<d
e
d<eD��cgc]}|��c}}Zd�Zd�Z
d
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zycc}}w)�TestGeneratorBaseNc�H�|�|jn|}|j||��S)Nr	)r
�msgfunc)�self�msgr
s   �E/opt/alt/python312/lib64/python3.12/test/test_email/test_generator.py�msgmakerzTestGeneratorBase.msgmakers$�� &�����F���|�|�C��|�/�/�af            To: whom_it_may_concern@example.com
            From: nobody_you_want_to_know@example.com
            Subject: We the willing led by the unknowing are doing the
             impossible for the ungrateful. We have done so much for so long with so little
             we are now qualified to do anything with nothing.

            None
            a�            To: whom_it_may_concern@example.com
            From:
             nobody_you_want_to_know@example.com
            Subject: We the willing led by the
             unknowing are doing the impossible for
             the ungrateful. We have done so much
             for so long with so little we are now
             qualified to do anything with nothing.

            None
            a�            To:
             whom_it_may_concern@example.com
            From:
             nobody_you_want_to_know@example.com
            Subject: We the
             willing led by the
             unknowing are doing
             the impossible for
             the ungrateful. We
             have done so much
             for so long with so
             little we are now
             qualified to do
             anything with
             nothing.

            None
            )r�(�r�daTo: whom_it_may_concern@example.com
From: nobody_you_want_to_know@example.com
Subject: We the willing led by the unknowing are doing the impossible for the ungrateful. We have done so much for so long with so little we are now qualified to do anything with nothing.

None
aTo: whom_it_may_concern@example.com
From: nobody_you_want_to_know@example.com
Subject: We the willing led by the unknowing are doing the impossible for the ungrateful. We have
 done so much for so long with so little we are now qualified to do anything with nothing.

None
c�T�|j|j|jd��}|j�}|j	|||j
��}|j
|�|j|j�|j|j|��y)Nr��maxheaderlenr
)	r�typ�refold_long_expected�ioclass�genclassr
�flatten�assertEqual�getvalue�r�nr�s�gs     r� length_as_maxheaderlen_parameterz2TestGeneratorBase.length_as_maxheaderlen_parameterWs|���m�m�D�H�H�T�%>�%>�q�%A�B�C���L�L�N���M�M�!�!�D�K�K�M�@��	�	�	�#���������t�x�x��0I�0I�!�0L�'M�Nrc�r�|j|j|jd��}|j�}|j	||j
j
|����}|j|�|j|j�|j|j|��y�Nr��max_line_lengthr	�
rrrrrr
�cloner r!r"r#s     r� length_as_max_line_length_policyz2TestGeneratorBase.length_as_max_line_length_policy^s����m�m�D�H�H�T�%>�%>�q�%A�B�C���L�L�N���M�M�!�D�K�K�$5�$5�a�$5�$H�M�I��	�	�	�#���������t�x�x��0I�0I�!�0L�'M�Nrc�t�|j|j|jd��}|j�}|j	|||j
j
d����}|j|�|j|j�|j|j|��y)Nr�
r*rr,r#s     r�,length_as_maxheaderlen_parm_overrides_policyz>TestGeneratorBase.length_as_maxheaderlen_parm_overrides_policyes����m�m�D�H�H�T�%>�%>�q�%A�B�C���L�L�N���M�M�!�!�!%���!2�!2�2�!2�!F�
�
H��	�	�	�#���������t�x�x��0I�0I�!�0L�'M�Nrc�t�|j|j|jd��}|j�}|j	||j
j
d|����}|j|�|j|j�|j|jd��y)Nr�none��
refold_sourcer+r	r,r#s     r�8length_as_max_line_length_with_refold_none_does_not_foldzJTestGeneratorBase.length_as_max_line_length_with_refold_none_does_not_foldms����m�m�D�H�H�T�%>�%>�q�%A�B�C���L�L�N���M�M�!�D�K�K�$5�$5�F�FG�%6�%I�M�
J��	�	�	�#���������t�x�x��0I�0I�!�0L�'M�Nrc�t�|j|j|jd��}|j�}|j	||j
j
d|����}|j|�|j|j�|j|j|��y)Nr�allr4r	)rrrrrr
r-r r!r"�refold_all_expectedr#s     r�/length_as_max_line_length_with_refold_all_foldszATestGeneratorBase.length_as_max_line_length_with_refold_all_foldsus����m�m�D�H�H�T�%>�%>�q�%A�B�C���L�L�N���M�M�!�D�K�K�$5�$5�E�FG�%6�%I�M�
J��	�	�	�#���������t�x�x��0H�0H��0K�'L�Mrc�.�d}|}|j|j|��}|j�}|j|tj
��}|j
|�|j|j�|j|��y)NzSubject: test

test body
r	�	rrrrr
�SMTPr r!r"�r�source�expectedrr%r&s      r�test_crlf_control_via_policyz.TestGeneratorBase.test_crlf_control_via_policy}sn��5�����m�m�D�H�H�V�,�-���L�L�N���M�M�!�F�K�K�M�0��	�	�	�#���������t�x�x��'9�:rc�2�d}|}|j|j|��}|j�}|j|tj
��}|j
|d��|j|j�|j|��y)NzSubject: test

test body
r	�
)�linesepr<r>s      r�%test_flatten_linesep_overrides_policyz7TestGeneratorBase.test_flatten_linesep_overrides_policy�ss��/�����m�m�D�H�H�V�,�-���L�L�N���M�M�!�F�K�K�M�0��	�	�	�#�t�	�$��������t�x�x��'9�:rc�P�tjd�}dtjdftjdftjjd��dff}|D]�\}}|r|j
dd�n|}|j||��5|j|j|��}|j�}|j||�	�}|j|�|j|j�|j|��ddd���y#1swY��xYw)
Nz�            Subject: test that
             from is mangled in the body!

            From time to time I write a rhyme.
            )NTTF)�mangle_from_zFrom z>From )r
rGr	)�textwrap�dedentr
�compat32�defaultr-�replace�subTestrrrrr r!r")	rr?�variants�p�mangler@rr%r&s	         r�test_set_mangle_from_via_policyz1TestGeneratorBase.test_set_mangle_from_via_policy�s�����"���
�
�_�_�d�#�
�^�^�U�#�
�^�^�
!�
!�t�
!�
4�d�;�	��"�	C�I�A�v�<B�v�~�~�g�x�8��H����Q�V��<�
C��m�m�D�H�H�V�$4�5���L�L�N���M�M�!�A�M�.���	�	�#��� � �����t�x�x��/A�B�
C�
C�	C�
C�
C�s
�
BD�D%	c�z�|j|j|jd��}|j�}|j	|t
jjd����}|j|�|j|j�|j|jd��yr))rrrrrr
rJr-r r!r")rrr%r&s    r�5test_compat32_max_line_length_does_not_fold_when_nonezGTestGeneratorBase.test_compat32_max_line_length_does_not_fold_when_none�s����m�m�D�H�H�T�%>�%>�q�%A�B�C���L�L�N���M�M�!�F�O�O�$9�$9�$�$9�$O�M�P��	�	�	�#���������t�x�x��0I�0I�!�0L�'M�Nrc��|j|jtjd���}tjd�}|j	�}|j||jjd����}|j|�|j|j�|j|��y)N��            To: nobody
            Content-Disposition: attachment;
             filename="afilenamelongenoghtowraphere"

            None
            z�            To: nobody
            Content-Disposition: attachment;
             filename*0*=us-ascii''afilename;
             filename*1*=longenoghtowraphere

            None
            �!r*r	�rrrHrIrrr
r-r r!r"�rrr@r%r&s     r�test_rfc2231_wrappingz'TestGeneratorBase.test_rfc2231_wrapping�s����m�m�D�H�H�X�_�_�6�&�����?�?�$���
�L�L�N���M�M�!�D�K�K�$5�$5�b�$5�$I�M�J��	�	�	�#���������t�x�x��'9�:rc��|j|jtjd���}tjd�}|j	�}|j||jjd����}|j|�|j|j�|j|��y)NrUz�            To: nobody
            Content-Disposition:
             attachment;
             filename*0*=us-ascii''afilenamelongenoghtowraphere

            None
            rr*r	rWrXs     r�;test_rfc2231_wrapping_switches_to_default_len_if_too_narrowzMTestGeneratorBase.test_rfc2231_wrapping_switches_to_default_len_if_too_narrow�s����m�m�D�H�H�X�_�_�6�&�����?�?�$���
�L�L�N���M�M�!�D�K�K�$5�$5�b�$5�$I�M�J��	�	�	�#���������t�x�x��'9�:r)N)�__name__�
__module__�__qualname__r
rKrrHrIr�copyr9�
length_paramsr'r.r1r6r:rArErQrSrYr[)�.0r$s00rrrs����^�^�F�0�
�8�?�?���
�H�O�O��
�
�H�O�O��
�-)
��T!5�Q� 7����.�3�3�5��
����
����!5�5�1�Q�5�M�O�O�O�O�N�;�;�C�,O�;�.;��]6s�2	B!rc�<�eZdZee�ZeZejZ
eZy)�
TestGeneratorN)
r\r]r^�staticmethodrrrr�io�StringIOr�strr�rrrcrc�s ���.�/�G��H��k�k�G�

�Crrcc�V�eZdZee�ZeZejZ
d�Zd�Zd�Z
d�Zd�Zy)�TestBytesGeneratorc�$�|jd�S)N�ascii)�encode)r�xs  r�<lambda>zTestBytesGenerator.<lambda>�s��!�(�(�7�+�rc�6�djd�}djd�}t|�}tj�}t	||j
j
d����}|j|�|j|j�|�y)Nu5Subject: Maintenant je vous présente mon collègue

�utf-8zPSubject: Maintenant je vous =?unknown-8bit?q?pr=C3=A9sente_mon_coll=C3=A8gue?=

rl�7bit)�cte_typer	)
rmrre�BytesIOrr
r-r r!r"r>s      r�'test_cte_type_7bit_handles_unknown_8bitz:TestBytesGenerator.test_cte_type_7bit_handles_unknown_8bit�s|��!�"(�&��/�	�<�=C�V�G�_�	� ��(���J�J�L���1�T�[�[�%6�%6��%6�%G�H��	�	�	�#���������x�0rc��tjd�jd�}t|�}tjd�jd�}t	j
�}t
||jjdd����}|j|�|j|j�|�y)	Nu/            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?
            �latin1a@            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?
            rlrrrC)rsrDr	)rHrIrmrrertrr
r-r r!r")rr?rr@r%r&s      r�&test_cte_type_7bit_transforms_8bit_ctez9TestBytesGenerator.test_cte_type_7bit_transforms_8bit_cte�s������	"�	����!�	�!��(���O�O�	%�	�����	�
�J�J�L���1�T�[�[�%6�%6��?C�&7�&E�
F��	�	�	�#���������x�0rc��t�}d|d<d|d<d|d<|jd�tjd�j	d	�jd
d�}t
j�}t|tj��}|j|�|j|j�|�y)
NuPáolo <főo@bar.com>�From�Dinsdale�TouNudge nudge, wink, wink ὠ9�Subjectu/oh là là, know what I mean, know what I mean?u<            From: Páolo <főo@bar.com>
            To: Dinsdale
            Subject: Nudge nudge, wink, wink ὠ9
            Content-Type: text/plain; charset="utf-8"
            Content-Transfer-Encoding: 8bit
            MIME-Version: 1.0

            oh là là, know what I mean, know what I mean?
            rq�
�
r	)r�set_contentrHrIrmrLrertrr
�SMTPUTF8r r!r"rXs     r�test_smtputf8_policyz'TestBytesGenerator.test_smtputf8_policys����n��-��F����D�	�:��I�����I�J��?�?�	$�	���������!8�	�
�J�J�L���1�V�_�_�5��	�	�	�#���������x�0rc��t�}tdd��|d<tdd��|d<d|d	<|jd
�tjd�j�j
dd
�}tj�}t|tj��}|j|�|j|j�|�y)Nzfoo@bar.comuPáolo)�	addr_spec�display_namerzzbar@foo.comr{r|zNudge nudge, wink, winkr}z+oh boy, know what I mean, know what I mean?aP            From: =?utf-8?q?P=C3=A1olo?= <foo@bar.com>
            To: Dinsdale <bar@foo.com>
            Subject: Nudge nudge, wink, wink
            Content-Type: text/plain; charset="utf-8"
            Content-Transfer-Encoding: 7bit
            MIME-Version: 1.0

            oh boy, know what I mean, know what I mean?
            r~rr	)rrr�rHrIrmrLrertrr
r=r r!r"rXs     r�test_smtp_policyz#TestBytesGenerator.test_smtp_policy's����n���
�H�M��F���m�*�M��D�	�2��I�����E�F��?�?�	$�	����'�'�%��1�	�
�J�J�L���1�V�[�[�1��	�	�	�#���������x�0rN)r\r]r^rdrrrrrertrrrurxr�r�rhrrrjrj�s4���-�.�G��H��j�j�G�
+�C�	1�1�81�*1rrj�__main__)rerH�unittest�emailrr�
email.messager�email.generatorrr�email.headerregistryrr
�test.test_emailrrrrcrjr\�mainrhrr�<module>r�sx��	���9�&�5�(��7��L;�L;��L;�^�%�}��V1�*�M�V1�r�z���H�M�M�O�r