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

�i�/�@s�ddlZddlZddlZddlmZmZddlmZddlm	Z	m
Z
ddlmZddlm
Z
ddlmZmZeGdd	�d	��ZGd
d�dee�ZGdd
�d
ee�Zedkr[e��dSdS)�N)�message_from_string�message_from_bytes)�EmailMessage)�	Generator�BytesGenerator)�Address��policy)�
TestEmailBase�parameterizec@s�eZdZejZd$dd�Ze�d�e�d�e�d�d�Zeded	<e�	�Z
d
e
d<de
d	<dd
�eD�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�ZdS)%�TestGeneratorBaseNcCs |dur|jn|}|j||d�S)Nr)r	�msgfunc)�self�msgr	�r�;/usr/local/lib/python3.10/test/test_email/test_generator.py�msgmakerszTestGeneratorBase.msgmakeraf            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
cCsg|]}|�qSrr)�.0�nrrr�
<listcomp>UszTestGeneratorBase.<listcomp>cCsZ|�|�|jd��}|��}|j|||jd�}|�|�|�|��|�|j|��dS)Nr�Zmaxheaderlenr	)	r�typ�refold_long_expected�ioclass�genclassr	�flatten�assertEqual�getvalue�rrr�s�grrr� length_as_maxheaderlen_parameterWs

 z2TestGeneratorBase.length_as_maxheaderlen_parametercCs`|�|�|jd��}|��}|j||jj|d�d�}|�|�|�|�	�|�|j|��dS�Nr��max_line_lengthr�
rrrrrr	�clonerrr r!rrr� length_as_max_line_length_policy^�

 z2TestGeneratorBase.length_as_max_line_length_policycCsb|�|�|jd��}|��}|j|||jjdd�d�}|�|�|�|�	�|�|j|��dS)Nr�
r&rr(r!rrr�,length_as_maxheaderlen_parm_overrides_policyes�
 z>TestGeneratorBase.length_as_maxheaderlen_parm_overrides_policycCsb|�|�|jd��}|��}|j||jjd|d�d�}|�|�|�|�	�|�|jd��dS)NrZnone�Z
refold_sourcer'rr(r!rrr�8length_as_max_line_length_with_refold_none_does_not_foldm�
�
 zJTestGeneratorBase.length_as_max_line_length_with_refold_none_does_not_foldcCsb|�|�|jd��}|��}|j||jjd|d�d�}|�|�|�|�	�|�|j
|��dS)Nr�allr.r)rrrrrr	r)rrr �refold_all_expectedr!rrr�/length_as_max_line_length_with_refold_all_foldsur0zATestGeneratorBase.length_as_max_line_length_with_refold_all_foldscCsTd}|}|�|�|��}|��}|j|tjd�}|�|�|�|��|�|��dS)NzSubject: test

test body
r�	rrrrr	�SMTPrrr �r�source�expectedrr"r#rrr�test_crlf_control_via_policy}s
z.TestGeneratorBase.test_crlf_control_via_policycCsXd}|}|�|�|��}|��}|j|tjd�}|j|dd�|�|��|�|��dS)NzSubject: test

test body
r�
)�linesepr4r6rrr�%test_flatten_linesep_overrides_policy�sz7TestGeneratorBase.test_flatten_linesep_overrides_policyc		Cs�t�d�}dtjdftjdftjjdd�dff}|D]H\}}|r&|�dd�n|}|j||d��+|�|�	|��}|�
�}|j||d	�}|�|�|�
|��|�	|��Wd�n1s]wYqdS)
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	r=r)�textwrap�dedentr	�compat32�defaultr)�replaceZsubTestrrrrrrr )	rr7Zvariants�pZmangler8rr"r#rrr�test_set_mangle_from_via_policy�s"
�
���z1TestGeneratorBase.test_set_mangle_from_via_policycCs`|�|�|jd��}|��}|j|tjjdd�d�}|�|�|�	|�
�|�|jd��dSr%)rrrrrr	r@r)rrr )rrr"r#rrr�5test_compat32_max_line_length_does_not_fold_when_none�r+zGTestGeneratorBase.test_compat32_max_line_length_does_not_fold_when_nonecC�d|�|�t�d���}t�d�}|��}|j||jjdd�d�}|�|�|�	|�
�|�|��dS)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�rrr>r?rrr	r)rrr �rrr8r"r#rrr�test_rfc2231_wrapping�s

z'TestGeneratorBase.test_rfc2231_wrappingcCrF)NrGz�            To: nobody
            Content-Disposition:
             attachment;
             filename*0*=us-ascii''afilenamelongenoghtowraphere

            None
            rr&rrIrJrrr�;test_rfc2231_wrapping_switches_to_default_len_if_too_narrow�s

zMTestGeneratorBase.test_rfc2231_wrapping_switches_to_default_len_if_too_narrow)N)�__name__�
__module__�__qualname__r	rArr>r?r�copyr2Z
length_paramsr$r*r-r/r3r9r<rDrErKrLrrrrrs2
	�*�
�
		rc@s"eZdZee�ZeZej	Z
eZdS)�
TestGeneratorN)
rMrNrO�staticmethodrr
rr�io�StringIOr�strrrrrrrQ�s
rQc@sFeZdZee�ZeZej	Z
dd�Zdd�Zdd�Z
dd�Zd	d
�ZdS)�TestBytesGeneratorcCs
|�d�S)N�ascii)�encode)r�xrrr�<lambda>�s
zTestBytesGenerator.<lambda>cCsXd�d�}d�d�}t|�}t��}t||jjdd�d�}|�|�|�|�	�|�dS)Nu5Subject: Maintenant je vous présente mon collègue

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

rW�7bit)�cte_typer)
rXrrS�BytesIOrr	r)rrr r6rrr�'test_cte_type_7bit_handles_unknown_8bit�s��
z:TestBytesGenerator.test_cte_type_7bit_handles_unknown_8bitcCsft�d��d�}t|�}t�d��d�}t��}t||jjddd�d�}|�	|�|�
|��|�dS)	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?
            rWr\r:)r]r;r)r>r?rXrrSr^rr	r)rrr )rr7rr8r"r#rrr�&test_cte_type_7bit_transforms_8bit_cte�s	�
	�

�
z9TestBytesGenerator.test_cte_type_7bit_transforms_8bit_ctecCstt�}d|d<d|d<d|d<|�d�t�d��d	��d
d�}t��}t|t	j
d�}|�|�|�|�
�|�dS)
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?
            r[�
�
r)r�set_contentr>r?rXrBrSr^rr	ZSMTPUTF8rrr rJrrr�test_smtputf8_policys
	�

z'TestBytesGenerator.test_smtputf8_policycCs�t�}tddd�|d<tddd�|d<d|d	<|�d
�t�d����dd
�}t��}t	|t
jd�}|�|�|�
|��|�dS)Nzfoo@bar.comuPáolo)Z	addr_specZdisplay_namerbzbar@foo.comrcrdzNudge nudge, wink, winkrez+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?
            rfrgr)rrrhr>r?rXrBrSr^rr	r5rrr rJrrr�test_smtp_policy's
	�

z#TestBytesGenerator.test_smtp_policyN)rMrNrOrRrr
rrrSr^rrr_rarirjrrrrrV�srV�__main__)rSr>ZunittestZemailrrZ
email.messagerZemail.generatorrrZemail.headerregistryrr	Ztest.test_emailr
rrrQrVrM�mainrrrr�<module>s"PY�