
    daf                         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$                          yy)    N)MessageEmailMessage)default)TestEmailBasec                   f    e Zd Z G d de      Zej                  j                  d      Zd Z	d Z
y)TestCustomMessagec                        e Zd Z fdZ xZS )TestCustomMessage.MyMessagec                 0    || _         t        | 	          y N)check_policysuper__init__)selfpolicy	__class__s     6/root/Python-3.12.4/Lib/test/test_email/test_parser.pyr   z$TestCustomMessage.MyMessage.__init__   s     &DG    )__name__
__module____qualname__r   __classcell__)r   s   @r   	MyMessager
      s    	 	r   r   boo)linesepc                     t        j                  d| j                  | j                        }| j	                  || j                         | j                  |j                  | j                         y 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   sQ    ''(A(,/3}}> 	c4>>2c&&6r   c                 
   t        j                  d      }t        j                  || j                  | j
                        }| j                  || j                         | j                  |j                  | j
                         y 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   s_    kk";<%%k&*nn-1]]< 	c4>>2c&&6r   N)r   r   r   r   r   r   r   cloner!   r%   r+    r   r   r   r   	   s3    G 
 ##))%)8H77r   r   c                   4    e Zd Zd Z G d de      Zd Zd Zy)TestParserBasec                 (   | j                   D ]w  }| j                  |j                        5   |dt              }| j	                  |j                         g d       | j	                  |j                         d       d d d        y y # 1 sw Y   xY w)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     ll 	8FV__5 8	 #    
/ 
   !2B738 8	88 8s   ABB	c                       e Zd Zy)TestParserBase.MyMessageN)r   r   r   r-   r   r   r   r<   F   s    r   r   c                    | j                   D ]m  }| j                  |j                        5  t        j                  | j
                        } |d|      }| j                  || j
                         d d d        o y # 1 sw Y   zxY w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   st    ll 	;FV__5 ;"==H.x@%%c4>>:; ;	;; ;s   AA>>B	c                 J   | j                   D ]  }| j                  |j                        5  t        j                  | j
                        } |dt        |      }| j                  || j
                         | j                  |t               d d d         y # 1 sw Y   xY wr>   )	r5   r6   r   r   r,   r   r   assertNotIsInstancer"   r@   s       r   !test_factory_arg_overrides_policyz0TestParserBase.test_factory_arg_overrides_policyP   s    ll 	4FV__5 4"==H.I((dnn=%%c73	4 4	44 4s   A"BB"	N)r   r   r   r:   r   r   rA   rD   r-   r   r   r/   r/   $   s    8@L ;4r   r/   c                 ^    t        j                  |       }t        j                  |g|i |S r   )r'   r(   r   r)   sargskwfs       r   r)   r)   [   s*    
AA""12t2r22r   c                   (    e Zd Zej                  efZy)
TestParserN)r   r   r   r   r    r)   r5   r-   r   r   rL   rL   _   s    ((*;<Gr   rL   c                 P    t        j                  | j                         g|i |S r   )r   message_from_bytesencode)rG   rH   rI   s      r   rN   rN   b   s#    ##AHHJ<<<<r   c                 z    t        j                  | j                               }t        j                  |g|i |S r   )r'   BytesIOrO   r   message_from_binary_filerF   s       r   rR   rR   e   s1    


188:A))!9d9b99r   c                       e Zd ZeefZy)TestBytesParserN)r   r   r   rN   rR   r5   r-   r   r   rT   rT   i   s    !#;<Gr   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[      ss    	   /   )7 7624 24n3= ==:=nm = zHMMO r   