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.7/test/test_email/__pycache__/test_generator.cpython-37.pyc
B

��g�/�@s�ddlZddlZddlZddlmZmZddlmZddlm	Z	m
Z
ddlmZddlm
Z
ddlmZmZeGdd	�d	��ZGd
d�dee�ZGdd
�d
ee�Zedkr�e��dS)�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 |dkr|jn|}|j||d�S)N)r)r�msgfunc)�self�msgr�r�:/usr/local/lib/python3.7/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)�maxheaderlenr)	r�typ�refold_long_expected�ioclass�genclassr�flatten�assertEqual�getvalue)r
rr�s�grrr� length_as_maxheaderlen_parameterWs

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

z2TestGeneratorBase.length_as_max_line_length_policycCsb|�|�|jd��}|��}|j|||jjdd�d�}|�|�|�|�	�|�|j|��dS)Nr�
)r#)rr)
rrrrrrr$rrr)r
rrr r!rrr�,length_as_maxheaderlen_parm_overrides_policyes
z>TestGeneratorBase.length_as_maxheaderlen_parm_overrides_policycCsb|�|�|jd��}|��}|j||jjd|d�d�}|�|�|�|�	�|�|jd��dS)NrZnone)�
refold_sourcer#)r)
rrrrrrr$rrr)r
rrr r!rrr�8length_as_max_line_length_with_refold_none_does_not_foldms
zJTestGeneratorBase.length_as_max_line_length_with_refold_none_does_not_foldcCsb|�|�|jd��}|��}|j||jjd|d�d�}|�|�|�|�	�|�|j
|��dS)Nr�all)r(r#)r)rrrrrrr$rrr�refold_all_expected)r
rrr r!rrr�/length_as_max_line_length_with_refold_all_foldsus
zATestGeneratorBase.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�
)�linesep)	rrrrrr-rrr)r
r.r/rr r!rrr�%test_flatten_linesep_overrides_policy�sz7TestGeneratorBase.test_flatten_linesep_overrides_policyc	
Cs�t�d�}dtjdftjdftjjdd�dff}x�|D]|\}}|rN|�dd�n|}|j||d��L|�|�	|��}|�
�}|j||d	�}|�|�|�
|��|�	|��WdQRXq6WdS)
Nz�            Subject: test that
             from is mangled in the body!

            From time to time I write a rhyme.
            )NTTF)�mangle_from_zFrom z>From )rr4)r)�textwrap�dedentr�compat32�defaultr$�replaceZsubTestrrrrrrr)	r
r.Zvariants�pZmangler/rr r!rrr�test_set_mangle_from_via_policy�s
z1TestGeneratorBase.test_set_mangle_from_via_policycCs`|�|�|jd��}|��}|j|tjjdd�d�}|�|�|�	|�
�|�|jd��dS)Nr)r#)r)rrrrrrr7r$rrr)r
rr r!rrr�5test_compat32_max_line_length_does_not_fold_when_none�s

zGTestGeneratorBase.test_compat32_max_line_length_does_not_fold_when_nonecCsd|�|�t�d���}t�d�}|��}|j||jjdd�d�}|�|�|�	|�
�|�|��dS)Nz�            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)rrr5r6rrrr$rrr)r
rr/r r!rrr�test_rfc2231_wrapping�s

z'TestGeneratorBase.test_rfc2231_wrappingcCsd|�|�t�d���}t�d�}|��}|j||jjdd�d�}|�|�|�	|�
�|�|��dS)Nz�            To: nobody
            Content-Disposition: attachment;
             filename="afilenamelongenoghtowraphere"

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

            None
            r)r#)r)rrr5r6rrrr$rrr)r
rr/r r!rrr�;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__rr8rr5r6r�copyr+Z
length_paramsr"r%r'r)r,r0r3r;r<r>r?rrrrrs0

				rc@s"eZdZee�ZeZej	Z
eZdS)�
TestGeneratorN)
r@rArB�staticmethodrrrr�io�StringIOr�strrrrrrrD�srDc@sFeZdZee�ZeZej	Z
dd�Zdd�Zdd�Z
dd�Zd	d
�ZdS)�TestBytesGeneratorcCs
|�d�S)N�ascii)�encode)r
�xrrr�<lambda>��zTestBytesGenerator.<lambda>cCsXd�d�}d�d�}t|�}t��}t||jjdd�d�}|�|�|�|�	�|�dS)Nu5Subject: Maintenant je vous présente mon collègue

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

rJ�7bit)�cte_type)r)
rKrrF�BytesIOrrr$rrr)r
r.r/rr r!rrr�'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?
            rJrOr1)rPr2)r)r5r6rKrrFrQrrr$rrr)r
r.rr/r 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?
            zutf-8�
s
)r)r�set_contentr5r6rKr9rFrQrrZSMTPUTF8rrr)r
rr/r r!rrr�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_namerUzbar@foo.comrVrWzNudge nudge, wink, winkrXz+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?
            rYs
)r)rrrZr5r6rKr9rFrQrrr-rrr)r
rr/r r!rrr�test_smtp_policy's
	
z#TestBytesGenerator.test_smtp_policyN)r@rArBrErrrrrFrQrrrRrTr[r\rrrrrI�srI�__main__)rFr5ZunittestZemailrrZ
email.messagerZemail.generatorrrZemail.headerregistryrrZtest.test_emailr	r
rrDrIr@�mainrrrr�<module>sQY