
    <e                         d dl 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	  G d de	          Z
 G d d          Zd	 Z G d
 dee	          Zd Zd Z G d dee	          Zedk    r ej                     dS dS )    N)MessageEmailMessage)default)TestEmailBasec                   l    e Zd Z G d de          Zej                            d          Zd Z	d Z
dS )TestCustomMessagec                        e Zd Z fdZ xZS )TestCustomMessage.MyMessagec                 V    || _         t                                                       d S N)check_policysuper__init__)selfpolicy	__class__s     2/usr/lib/python3.11/test/test_email/test_parser.pyr   z$TestCustomMessage.MyMessage.__init__   s'     &DGG    )__name__
__module____qualname__r   __classcell__)r   s   @r   	MyMessager
      s8        	 	 	 	 	 	 	 	 	r   r   boo)linesepc                     t          j        d| j        | j                  }|                     || j                   |                     |j        | j                   d S NzSubject: bogus

msg
r   )emailmessage_from_stringr   MyPolicyassertIsInstanceassertIsr   )r   msgs     r   7test_custom_message_gets_policy_if_possible_from_stringzITestCustomMessage.test_custom_message_gets_policy_if_possible_from_string   s_    '(A(,/3}> > > 	c4>222c&66666r   c                     t          j        d          }t          j        || j        | j                  }|                     || j                   |                     |j        | j                   d S r   )	ioStringIOr   message_from_filer   r!   r"   r#   r   )r   source_filer$   s      r   5test_custom_message_gets_policy_if_possible_from_filezGTestCustomMessage.test_custom_message_gets_policy_if_possible_from_file   sn    k";<<%k&*n-1]< < < 	c4>222c&66666r   N)r   r   r   r   r   r   r   cloner!   r%   r+    r   r   r   r   	   sw            G   
 #))%)88H7 7 77 7 7 7 7r   r   c                   <    e Zd Zd Z G d de          Zd Zd ZdS )TestParserBasec                 H   | j         D ]}|                     |j                  5   |dt                    }|                     |                                g d           |                     |                                d           d d d            n# 1 swxY w Y   d S )Nparseru   Next-Line: notbroken
Null: not broken
Vertical-Tab: notbroken
Form-Feed: notbroken
File-Separator: notbroken
Group-Separator: notbroken
Record-Separator: notbroken
Line-Separator: not broken
Paragraph-Separator: not broken

r   )	)z	Next-Lineu   notbroken)Nullz
not broken)zVertical-Tabz
notbroken)z	Form-Feedz
notbroken)zFile-Separatorz
notbroken)zGroup-Separatorz
notbroken)zRecord-Separatorz
notbroken)zLine-Separatoru   not broken)zParagraph-Separatoru   not broken )parserssubTestr   r   assertEqualitemsget_payload)r   r2   r$   s      r   test_only_split_on_cr_lfz'TestParserBase.test_only_split_on_cr_lf&   s     l 	8 	8FV_55 8 8f	 #      
/ 
/ 
/ 
 
 
   !2!2B77738 8 8 8 8 8 8 8 8 8 8 8 8 8 8	8 	8s   A%BB	B	c                       e Zd ZdS )TestParserBase.MyMessageN)r   r   r   r-   r   r   r   r<   F   s        r   r   c                    | j         D ]w}|                     |j                  5  t          j        | j                  } |d|          }|                     || j                   d d d            n# 1 swxY w Y   xd S Nr1   )message_factoryzTo: foo

testr   )r5   r6   r   r   r,   r   r"   r   r2   r!   r$   s       r   %test_custom_message_factory_on_policyz4TestParserBase.test_custom_message_factory_on_policyI   s    l 	; 	;FV_55 ; ;"=HHHf.x@@@%%c4>:::; ; ; ; ; ; ; ; ; ; ; ; ; ; ;	; 	;s   AA44A8	;A8	c                 F   | j         D ]}|                     |j                  5  t          j        | j                  } |dt          |          }|                     || j                   |                     |t                     d d d            n# 1 swxY w Y   d S r>   )	r5   r6   r   r   r,   r   r   assertNotIsInstancer"   r@   s       r   !test_factory_arg_overrides_policyz0TestParserBase.test_factory_arg_overrides_policyP   s    l 	4 	4FV_55 4 4"=HHHf.III((dn===%%c7333	4 4 4 4 4 4 4 4 4 4 4 4 4 4 4	4 	4s   A$BB	B	N)r   r   r   r:   r   r   rA   rD   r-   r   r   r/   r/   $   sl        8 8 8@    L   ; ; ;4 4 4 4 4r   r/   c                 T    t          j        |           }t          j        |g|R i |S r   )r'   r(   r   r)   sargskwfs       r   r)   r)   [   s0    
AA"12t222r222r   c                        e Zd Zej        efZdS )
TestParserN)r   r   r   r   r    r)   r5   r-   r   r   rL   rL   _   s        (*;<GGGr   rL   c                 P    t          j        |                                 g|R i |S r   )r   message_from_bytesencode)rG   rH   rI   s      r   rN   rN   b   s+    #AHHJJ<<<<<<<r   c                 x    t          j        |                                           }t          j        |g|R i |S r   )r'   BytesIOrO   r   message_from_binary_filerF   s       r   rR   rR   e   s:    

188::A)!9d999b999r   c                       e Zd ZeefZdS )TestBytesParserN)r   r   r   rN   rR   r5   r-   r   r   rT   rT   i   s        !#;<GGGr   rT   __main__)r'   r   unittestemail.messager   r   email.policyr   test.test_emailr   r   r/   r)   rL   rN   rR   rT   r   mainr-   r   r   <module>r[      sZ   				   / / / / / / / /             ) ) ) ) ) )7 7 7 7 7 7 7 7624 24 24 24 24 24 24 24n3 3 3= = = = = = = == = =: : := = = = =nm = = = zHMOOOOO r   