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_inversion.cpython-36.pyc

3

� f�@s|dZddlZddlZddlmZmZddlmZddlm	Z	ddl
mZmZdd�Z
eGd	d
�d
e��Zedkrxej�dS)z�Test the parser and generator are inverses.

Note that this is only strictly true if we are parsing RFC valid messages and
producing RFC valid messages.
�N)�policy�message_from_bytes)�EmailMessage)�BytesGenerator)�
TestEmailBase�parameterizecsP|j�}|dj�std��t|d�t|dj���dj�fdd�|D��S)NrzFirst line must contain texts
cs(g|] }t|��kr |�d�nd�qS)N�)�len)�.0�x)�stripamt��C/opt/alt/python36/lib64/python3.6/test/test_email/test_inversion.py�
<listcomp>szdedent.<locals>.<listcomp>)�
splitlines�strip�
ValueErrorr	�lstrip�join)Zbstr�linesr
)rr�dedents
rc@sreZdZejZeZdd�Zded�fiZ	e
ddd�e
dd	d
ddd
�e
dd	d
ddd
�d�Zdd�ZdS)�
TestInversioncCs<t|tjd�}tj�}t|�}|j|�|j|j�|�dS)N)r)	rrZSMTP�io�BytesIOrZflatten�assertEqual�getvalue)�self�msg�m�b�gr
r
r�msg_as_input s

zTestInversion.msg_as_inputZheader_with_one_space_bodysl            From: abc@xyz.com
            X-Status: 
            Subject: test

            foo
            zThis is a test
�)�payloadzxy a�(�
��base64)r#Zctezquoted-printable)Z
plain_textZbase64_textZqp_textcKsh|j�}d|d<d|d<d|d<|j|f|�t|�}t||jd�}|jt|�|�|j|j�|�dS)NZfooZFromZbarZTozpayload round trip testZSubject)r)Z
_make_messageZset_content�bytesrrrZget_content)rr#�kwrrZmsg2r
r
r�payload_as_body9szTestInversion.payload_as_bodyN)
�__name__�
__module__�__qualname__r�defaultr�messager!rZ
msg_params�dictZpayload_paramsr*r
r
r
rrs	
r�__main__)�__doc__rZunittestZemailrrZ
email.messagerZemail.generatorrZtest.test_emailrrrrr+�mainr
r
r
r�<module>s
*