
    <e                         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 Ze G d d	e                      Zed
k    r ej                     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                 :   |                                  }|d                                         st          d          t          |d                   t          |d                                                   z
  d                    fd|D                       S )Nr   zFirst line must contain texts   
c                 N    g | ]!}t          |          k    r
|d          nd"S )N    )len).0xstripamts     5/usr/lib/python3.11/test/test_email/test_inversion.py
<listcomp>zdedent.<locals>.<listcomp>   sE     	 	 	 Q))899s 	 	 	r   )
splitlinesstrip
ValueErrorr   lstripjoin)bstrlinesr   s     @r   dedentr      s    OOE8>> 9788858}}s58??#4#4555H<<	 	 	 		 	 	  r   c                       e Zd Zej        ZeZd Z ed          f ed          fdZ	 e
d           e
dd	           e
dd
	          dZd ZdS )TestInversionc                     t          |t          j                  }t          j                    }t          |          }|                    |           |                     |                                |           d S )Nr   )	r   r   SMTPioBytesIOr   flattenassertEqualgetvalue)selfmsgmbgs        r   msg_as_inputzTestInversion.msg_as_input    sa    s6;777JLL1			!s+++++r   sl               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?
            )header_with_one_space_body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,   ctezquoted-printable)
plain_textbase64_textqp_textc                 H   |                                  }d|d<   d|d<   d|d<    |j        |fi | t          |          }t          || j                  }|                     t          |          |           |                     |                                |           d S )NfooFrombarTozpayload round trip testSubjectr   )_make_messageset_contentbytesr   r   r"   get_content)r$   r,   kwr%   r'   msg2s         r   payload_as_bodyzTestInversion.payload_as_bodyA   s      ""FD	2I&&2&&&#JJ!!DK888ta((())++W55555r   N)__name__
__module____qualname__r   defaultr   messager)   r   
msg_paramsdictpayload_paramsr>    r   r   r   r      s         ^FG, , , (.v / ( ( ' &,V - & & % J( d#8999t%7hGGG4!3:LMMM
 
N	6 	6 	6 	6 	6r   r   __main__)__doc__r   unittestemailr   r   email.messager   email.generatorr   test.test_emailr   r   r   r   r?   mainrG   r   r   <module>rP      s     
			  , , , , , , , , & & & & & & * * * * * * 7 7 7 7 7 7 7 7   /6 /6 /6 /6 /6M /6 /6 /6d zHMOOOOO r   