Your IP : 216.73.216.213


Current Path : /opt/alt/python36/lib64/python3.6/test/test_email/__pycache__/
Upload File :
Current File : //opt/alt/python36/lib64/python3.6/test/test_email/__pycache__/test_generator.cpython-36.opt-1.pyc

3

� f�+�@s�ddlZddlZddlZddlmZmZddlmZddlm	Z	m
Z
ddlmZddlm
Z
mZeGdd�d��ZGd	d
�d
ee
�ZGdd�dee
�Zed
kr�ej�dS)�N)�message_from_string�message_from_bytes)�EmailMessage)�	Generator�BytesGenerator)�policy)�
TestEmailBase�parameterizec@s�eZdZejZd$dd�Zejd�ejd�ejd�d�Zeded	<ej	�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�C/opt/alt/python36/lib64/python3.6/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>TszTestGeneratorBase.<listcomp>cCsZ|j|j|jd��}|j�}|j|||jd�}|j|�|j|j�|j|j|��dS)Nr)�maxheaderlenr)	r�typ�refold_long_expected�ioclass�genclassr�flatten�assertEqual�getvalue)rrr
�s�grrr� length_as_maxheaderlen_parameterVs

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

z2TestGeneratorBase.length_as_max_line_length_policycCsb|j|j|jd��}|j�}|j|||jjdd�d�}|j|�|j|j	�|j|j|��dS)Nr�
)r")rr)
rrrrrrr#rrr)rrr
rr rrr�,length_as_maxheaderlen_parm_overrides_policyds
z>TestGeneratorBase.length_as_maxheaderlen_parm_overrides_policycCsb|j|j|jd��}|j�}|j||jjd|d�d�}|j|�|j|j	�|j|jd��dS)NrZnone)�
refold_sourcer")r)
rrrrrrr#rrr)rrr
rr rrr�8length_as_max_line_length_with_refold_none_does_not_foldls
zJTestGeneratorBase.length_as_max_line_length_with_refold_none_does_not_foldcCsb|j|j|jd��}|j�}|j||jjd|d�d�}|j|�|j|j	�|j|j
|��dS)Nr�all)r'r")r)rrrrrrr#rrr�refold_all_expected)rrr
rr rrr�/length_as_max_line_length_with_refold_all_foldsts
zATestGeneratorBase.length_as_max_line_length_with_refold_all_foldscCsTd}|}|j|j|��}|j�}|j|tjd�}|j|�|j|j�|j|��dS)NzSubject: test

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

test body
)r�
)�linesep)	rrrrrr,rrr)rr-r.r
rr rrr�%test_flatten_linesep_overrides_policy�sz7TestGeneratorBase.test_flatten_linesep_overrides_policyc	Cs�tjd�}d	tjdftjdftjjdd�dff}x�|D]|\}}|rN|jdd�n|}|j||d��L|j|j	|��}|j
�}|j||d�}|j|�|j
|j�|j	|��WdQRXq6WdS)
Nz�            Subject: test that
             from is mangled in the body!

            From time to time I write a rhyme.
            TF)�mangle_from_zFrom z>From )rr3)r)NT)�textwrap�dedentr�compat32�defaultr#�replaceZsubTestrrrrrrr)	rr-Zvariants�pZmangler.r
rr rrr�test_set_mangle_from_via_policy�s
z1TestGeneratorBase.test_set_mangle_from_via_policycCs`|j|j|jd��}|j�}|j|tjjdd�d�}|j|�|j	|j
�|j|jd��dS)Nr)r")r)rrrrrrr6r#rrr)rr
rr rrr�5test_compat32_max_line_length_does_not_fold_when_none�s

zGTestGeneratorBase.test_compat32_max_line_length_does_not_fold_when_nonecCsd|j|jtjd���}tjd�}|j�}|j||jjdd�d�}|j|�|j	|j
�|j|��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)rrr4r5rrrr#rrr)rr
r.rr rrr�test_rfc2231_wrapping�s

z'TestGeneratorBase.test_rfc2231_wrappingcCsd|j|jtjd���}tjd�}|j�}|j||jjdd�d�}|j|�|j	|j
�|j|��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)rrr4r5rrrr#rrr)rr
r.rr 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__rr7rr4r5r�copyr*Z
length_paramsr!r$r&r(r+r/r2r:r;r=r>rrrrr
s0

				r
c@s"eZdZee�ZeZej	Z
eZdS)�
TestGeneratorN)
r?r@rA�staticmethodrrrr�io�StringIOr�strrrrrrrC�srCc@s>eZdZee�ZeZej	Z
dd�Zdd�Zdd�Z
dd�Zd	S)
�TestBytesGeneratorcCs
|jd�S)N�ascii)�encode)r�xrrr�<lambda>�szTestBytesGenerator.<lambda>cCsXdjd�}djd�}t|�}tj�}t||jjdd�d�}|j|�|j|j	�|�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?=

rI�7bit)�cte_type)r)
rJrrE�BytesIOrrr#rrr)rr-r.r
rr rrr�'test_cte_type_7bit_handles_unknown_8bit�s
z:TestBytesGenerator.test_cte_type_7bit_handles_unknown_8bitcCsftjd�jd�}t|�}tjd�jd�}tj�}t||jjddd�d�}|j	|�|j
|j�|�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?
            rIrMr0)rNr1)r)r4r5rJrrErOrrr#rrr)rr-r
r.rr rrr�&test_cte_type_7bit_transforms_8bit_cte�s		
z9TestBytesGenerator.test_cte_type_7bit_transforms_8bit_ctecCstt�}d|d<d|d<d|d<|jd�tjd�jd	�jd
d�}tj�}t|t	j
d�}|j|�|j|j
�|�dS)
NuPáolo <főo@bar.com>ZFromZDinsdaleZTouNudge nudge, wink, wink ὠ9ZSubjectu/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)rZset_contentr4r5rJr8rErOrrZSMTPUTF8rrr)rr
r.rr rrr�test_smtputf8_policys
	
z'TestBytesGenerator.test_smtputf8_policyN)r?r@rArDrrrrrErOrrrPrRrTrrrrrH�srH�__main__)rEr4ZunittestZemailrrZ
email.messagerZemail.generatorrrrZtest.test_emailrr	r
rCrHr?�mainrrrr�<module>sQD