o
    JXh                     @   s   d Z ddlZddlZddlmZmZ ddlmZ ddlm	Z	 ddl
mZmZ dd ZeG d	d
 d
eZedkr>e  dS dS )zTest 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parameterizec                    sP   |   }|d  stdt|d t|d    d fdd|D S )Nr   zFirst line must contain texts   
c                    s(   g | ]}t | kr| d  ndqS )N    )len).0xZstripamt H/opt/python-3.10.19/usr/lib/python3.10/test/test_email/test_inversion.py
<listcomp>   s     zdedent.<locals>.<listcomp>)
splitlinesstrip
ValueErrorr	   lstripjoin)Zbstrlinesr   r   r   dedent   s   
r   c                   @   s^   e Zd ZejZeZdd ZedfedfdZ	e
dde
dd	d
e
ddd
dZdd ZdS )TestInversionc                 C   s<   t |tjd}t }t|}|| | | | d S )Nr   )	r   r   ZSMTPioBytesIOr   ZflattenassertEqualgetvalue)selfmsgmbgr   r   r   msg_as_input    s
   
zTestInversion.msg_as_inputsl               From: abc@xyz.com
            X-Status: 
            Subject: test

            foo
            s               Date: Tue, 06 Jun 2017 27:39:33 +0600
            From: abc@xyz.com
            Subject: timezones

            How do they work even?
            )Zheader_with_one_space_bodyZheader_with_invalid_datea,  This is a test
This is a test
This is a test
This is a test
This is a test
This is a test
This is a test
This is a test
This is a test
This is a test
This is a test
This is a test
This is a test
This is a test
This is a test
This is a test
This is a test
This is a test
This is a test
This is a test
)payloada%  xy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy a
xy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy a
xy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy a
xy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy a
xy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy a
base64)r#   Zctezquoted-printable)Z
plain_textZbase64_textZqp_textc                 K   sl   |   }d|d< d|d< d|d< |j|fi | t|}t|| jd}| t|| | | | d S )NZfooZFromZbarZTozpayload round trip testZSubjectr   )Z_make_messageZset_contentbytesr   r   r   Zget_content)r   r#   kwr   r    Zmsg2r   r   r   payload_as_bodyA   s   zTestInversion.payload_as_bodyN)__name__
__module____qualname__r   defaultr   messager"   r   Z
msg_paramsdictZpayload_paramsr'   r   r   r   r   r      s    	

r   __main__)__doc__r   ZunittestZemailr   r   Zemail.messager   Zemail.generatorr   Ztest.test_emailr   r   r   r   r(   mainr   r   r   r   <module>   s    
2