
    7bhw                       d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlZd dl	Z	d dl
mZ d dlmZ d dlmZ d dlmZ d dlZd dlZd dlZd dlZej(                  s ej*                  d       G d d      Z G d	 d
e      Z G d deej0                        Z G d deej0                        Z G d de      Z G d de      Z G d deej0                        Z G d deej0                        Z G d deej0                        Z G d deej0                        Z  G d d      Z! G d dejD                        Z# G d d ej0                        Z$ G d! d"eej0                        Z% G d# d$e%ej0                        Z& G d% d&      Z' G d' d(e'e%      Z( G d) d*e%ej0                        Z) G d+ d,e%ej0                        Z* G d- d.e'e%      Z+ G d/ d0eej0                        Z, G d1 d2e      Z- G d3 d4e-ej0                        Z. G d5 d6e-ej0                        Z/d7Z0d8Z1 G d9 d:ej0                        Z2d;Z3e3ji                  d<      Z5g d=Z6d>Z7 G d? d@ej0                        Z8dA Z9e:dBk(  r ejv                          yy)C    N)support)import_helper)	os_helper)socket_helperztest requires gethostname()c                       e Zd Zej                  ej
                  ej                  ej                  ej                  ej                  fZ
d Zd Zy)TestBasec                    | j                  |t        j                  j                         | j                  |t        j                         t
        D ]&  \  }}| j                  ||j                  |             ( | j                  |j                                | j                  t        |j                               t        t                     t        t              D ]  \  }}|j                  |      }| j                  |t        j                  j                         | j                  |t        j                         | j                  |j                         |        y N)assertIsInstanceemailmessageMessagemailbox_sample_headersassertInget_all
assertTrueis_multipartassertEquallenget_payload_sample_payloads	enumerateassertNotIsInstance)selfmsgkeyvalueipayloadparts          ;/opt/python-3.12.12/usr/lib/python3.12/test/test_mailbox.py_check_samplezTestBase._check_sample   s    c5==#8#89c7??3)JCMM%S!12 *((*+S__./5E1FG#$45JAw??1%D!!$(=(=>$$T7??;T--/9	 6    c                     t         j                  j                  |      rt        j                  |       y t         j                  j                  |      rt        j                  |       y y r
   )ospathisdirr   rmtreeexistsunlink)r   targets     r"   _delete_recursivelyzTestBase._delete_recursively-   sC    77== V$WW^^F#V$ $r$   N)__name__
__module____qualname__r   r   MaildirMessagemboxMessage	MHMessageBabylMessageMMDFMessageall_mailbox_typesr#   r-    r$   r"   r   r      sF     '*@*@ ,,g.?.? --w/B/BD:%r$   r   c                      e Zd ZdZdZdZd Zd Zd Z e	j                  d      Zd Zd Zd	 Zd
 Z e	j                  d      j!                  d      Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd4dZd Zd Zd Zd Zd Z d Z!d Z"d Z#d Z$d  Z%d! Z&d" Z'd# Z(d$ Z)d4d%Z*d& Z+d4d'Z,d( Z-d4d)Z.d* Z/d4d+Z0d, Z1d- Z2d. Z3d/ Z4d0 Z5d1 Z6d2 Z7d3 Z8y)5TestMailboxNzFrom: foo

%s
c                     t         j                  | _        | j                  | j                         | j	                  | j                        | _        y r
   )r   TESTFN_pathr-   _factory_boxr   s    r"   setUpzTestMailbox.setUp<   s5    %%
  ,MM$**-	r$   c                 n    | j                   j                          | j                  | j                         y r
   )r>   closer-   r<   r?   s    r"   tearDownzTestMailbox.tearDownA   s"    		  ,r$   c           
         g }|j                  | j                  j                  | j                  dz               | j	                  t        | j                        d       |j                  | j                  j                  t        j                  t                           | j	                  t        | j                        d       |j                  | j                  j                  t        j                  t                           | j	                  t        | j                        d       |j                  | j                  j                  t        j                  t                           | j	                  t        | j                        d       |j                  | j                  j                  t                     | j	                  t        | j                        d       |j                  | j                  j                  t                     | j	                  t        | j                        d       | j                  t              5  |j                  | j                  j                  t        j                   t        j                  t              d	                   d d d        | j	                  t        | j                        d
       | j	                  | j                  j#                  |d         | j                  dz         dD ]#  }| j%                  | j                  ||             % y # 1 sw Y   xY w)Nr                     utf-8encoding   )rE   rF   rG   rH   rI   rJ   )appendr>   add	_templater   r   r   r   _sample_messager   message_from_stringioBytesIO_bytes_sample_messageassertWarnsDeprecationWarningTextIOWrapper
get_stringr#   )r   keysr   s      r"   test_addzTestMailbox.test_addE   s   DIIMM$..1"456TYY+DIIMM'///"BCDTYY+DIIMM%";";O"LMNTYY+DIIMM"**-B"CDETYY+DIIMM/23TYY+DIIMM"789TYY+01KK		  ,A!BWUW X 2 	TYY+--d1g68JK#Atyya12 $ 21s   AL44L=u{               From: foo
            Subject: Falinaptár házhozszállítással. Már rendeltél?

            0
            c                 >   | j                   j                  | j                  j                  d            }| j	                  t        | j                         d       | j	                  | j                   j                  |      | j                  j                  d             y )Nlatin-1rE   )r>   rP   _nonascii_msgencoder   r   	get_bytesr   r   s     r"   "test_add_invalid_8bit_bytes_headerz.TestMailbox.test_add_invalid_8bit_bytes_headerc   sp    iimmD..55i@ATYY+,,S1%%i0	2r$   c                     | j                   j                         d   }| j                  j                  |j	                  d            }| j                  | j                  j                  |      d       y )NrE   r^   zZSubject: =?unknown-8bit?b?RmFsaW5hcHThciBo4Xpob3pzeuFsbO104XNzYWwuIE3hciByZW5kZWx06Ww/?=

)r_   
splitlinesr>   rP   r`   r   rZ   )r   subjr   s      r"   &test_invalid_nonascii_header_as_stringz2TestMailbox.test_invalid_nonascii_header_as_stringi   sZ    !!,,.q1iimmDKK	23--c2-	.r$   c                 B   | j                  t        d      5  | j                  j                  | j                         d d d        | j                  j                          | j                  t        | j                        d       | j                          y # 1 sw Y   YxY wNz
ASCII-onlyr   )	assertRaisesRegex
ValueErrorr>   rP   r_   flushr   r   assertMailboxEmptyr?   s    r"   &test_add_nonascii_string_header_raisesz2TestMailbox.test_add_nonascii_string_header_raisesp   sh    ##J=IIMM$,,- >		TYY+!	 >=s   &BBc                     G d dt               dfd}t        j                  | t        j                  j
                  d|       | j                        5  | j                  j                  t        j                  d             d d d        | j                  t        | j                        d       | j                  j                          | j                          y # 1 sw Y   YxY w)Nc                       e Zd Zy)JTestMailbox.test_add_that_raises_leaves_mailbox_empty.<locals>.CustomErrorNr.   r/   r0   r7   r$   r"   CustomErrorrq   x   s    r$   rs   za fake errorc                             r
   r7   )argskwrs   exc_msgs     r"   raiserzETestMailbox.test_add_that_raises_leaves_mailbox_empty.<locals>.raiser{   s    g&&r$   flattenu   From: Alphösor   )	Exceptionr   patchr   	generatorBytesGeneratorrj   r>   rP   rS   r   r   rB   rm   )r   rx   rs   rw   s     @@r"   )test_add_that_raises_leaves_mailbox_emptyz5TestMailbox.test_add_that_raises_leaves_mailbox_emptyw   s    ))) 	'dEOO::IvN##K9IIMM%334DEF :TYY+		!	 :9s   /C##C,u0          From: foo@bar.com
        To: báz
        Subject: Maintenant je vous présente mon collègue, le pouf célèbre
        	Jean de Baddie
        Mime-Version: 1.0
        Content-Type: text/plain; charset="utf-8"
        Content-Transfer-Encoding: 8bit

        Да, они летят.
        rK   c           	         | j                   j                  | j                        }| j                  | j                   j	                  |      | j                         | j                   j                  |      5 }| j                  |j                         | j                  j                  dt        j                  j                                      d d d        | j                  | j                   |   j                         d       y # 1 sw Y   7xY w)N   
u   Да, они летят.
)r>   rP   _non_latin_bin_msgr   ra   get_filereadreplacer&   linesepr`   r   r   r   fs      r"   test_add_8bit_bodyzTestMailbox.test_add_8bit_body   s    iimmD334,,S100	2YY$QVVX!44<<U "

 1 1 356 % 	33354	6	 %$s   6ADDc                 t   t        j                  d      5 }|j                  t               |j	                  d       | j
                  j                  |      }d d d        | j                  | j
                  j                        j                  d      t        j                  d             y # 1 sw Y   WxY wNwb+r   r   )
tempfileTemporaryFilewriterV   seekr>   rP   r   ra   splitr   r   r   s      r"   test_add_binary_filez TestMailbox.test_add_binary_file   s    ##E*aGG)*FF1I))--"C + 	,,S177>!''.	0	 +*s   AB..B7c                    t        j                  d      5 }|j                  | j                         |j	                  d       | j
                  j                  |      }d d d        | j                  | j
                  j                        j                  d      | j                  j                  d             y # 1 sw Y   ]xY wr   )
r   r   r   r   r   r>   rP   r   ra   r   r   s      r"   test_add_binary_nonascii_filez)TestMailbox.test_add_binary_nonascii_file   s    ##E*aGGD++,FF1I))--"C + 	,,S177>##))%0	2	 +*s   AB::Cc                    t        j                  dd      5 }|j                  t               |j	                  d       | j                  t              5  | j                  j                  |      }d d d        d d d        | j                  | j                  j                        j                  d      t        j                  d             y # 1 sw Y   _xY w# 1 sw Y   cxY w)Nw+rK   rL   r   r   )r   r   r   rR   r   rW   rX   r>   rP   r   ra   r   rV   r   s      r"   test_add_text_file_warnsz$TestMailbox.test_add_text_file_warns   s    ##D7;qGGO$FF1I!!"45iimmA& 6 <
 	,,S177>!''.	0 65 <;s#   <CC0CC	CC#c                 >   | j                  t              5  | j                  j                  t	        j
                  | j                  dz              }d d d        | j                  | j                  j                        | j                  dz         y # 1 sw Y   BxY w)N0)	rW   rX   r>   rP   rT   StringIOrQ   r   rZ   rb   s     r"   test_add_StringIO_warnsz#TestMailbox.test_add_StringIO_warns   sk    01))--DNNS,@ ABC 2--c2DNNS4HI 21s   <BBc                    | j                  t              5  | j                  t        d      5  | j                  j                  t        j                  | j                               d d d        d d d        | j                  t        | j                        d       | j                  j                          | j                          y # 1 sw Y   axY w# 1 sw Y   exY wri   )rW   rX   rj   rk   r>   rP   rT   r   r_   r   r   rB   rm   r?   s    r"   !test_add_nonascii_StringIO_raisesz-TestMailbox.test_add_nonascii_StringIO_raises   s    01''
LA		bkk$*<*<=> B 2 	TYY+		!	 BA 21s"   C9C&CC	CCc                 N    | j                  | j                  j                         y r
   )_test_remove_or_delitemr>   remover?   s    r"   test_removezTestMailbox.test_remove   s    $$TYY%5%56r$   c                 N    | j                  | j                  j                         y r
   )r   r>   __delitem__r?   s    r"   test_delitemzTestMailbox.test_delitem   s    $$TYY%:%:;r$   c                      j                   j                   j                  dz         j                   j                   j                  dz         j                  t	         j                         d                j                  t	         j                         d        j                  t         fd        j                  t        fd        j                   j                   j                         j                  dz          j                   j                   j                  dz         j                  t	         j                         d                j                  t	         j                         d        j                  t         fd        j                  t        fd        j                   j                   j                         j                  dz                  j                  t	         j                         d        j                  t         fd        j                  t        fd	       y )
Nr   rE   rF   c                  "    j                       S r
   r>   key0r   s   r"   <lambda>z5TestMailbox._test_remove_or_delitem.<locals>.<lambda>       DIIdOr$   c                              S r
   r7   )r   methods   r"   r   z5TestMailbox._test_remove_or_delitem.<locals>.<lambda>   	    F4Lr$   c                  "    j                       S r
   r   )key2r   s   r"   r   z5TestMailbox._test_remove_or_delitem.<locals>.<lambda>   r   r$   c                              S r
   r7   )r   r   s   r"   r   z5TestMailbox._test_remove_or_delitem.<locals>.<lambda>   r   r$   c                  "    j                       S r
   r   )key1r   s   r"   r   z5TestMailbox._test_remove_or_delitem.<locals>.<lambda>   r   r$   c                              S r
   r7   )r   r   s   r"   r   z5TestMailbox._test_remove_or_delitem.<locals>.<lambda>   r   r$   )r>   rP   rQ   r   r   assertRaisesKeyErrorrZ   )r   r   r   r   r   s   ``@@@r"   r   z#TestMailbox._test_remove_or_delitem   s   yy}}T^^a/0yy}}T^^a/0TYY+tTYY+($;<($89--d3T^^a5GHyy}}T^^a/0TYY+tTYY+($;<($89--d3T^^a5GHtTYY+($;<($89r$   c                 Z     j                   j                   j                  dz         j                   j                   j                  dz        } j                  t	         j                         d        j                   j                          j                  t	         j                         d        j                  t         fd        j                   j                          j                  t	         j                         d        j                  t         fd       y )Nr   rE   rF   c                  "    j                       S r
   r   r   s   r"   r   z*TestMailbox.test_discard.<locals>.<lambda>   r   r$   c                  "    j                       S r
   r   r   s   r"   r   z*TestMailbox.test_discard.<locals>.<lambda>   r   r$   )r>   rP   rQ   r   r   discardr   r   )r   repetitionsr   r   s   `  @r"   test_discardzTestMailbox.test_discard   s    yy}}T^^a/0yy}}T^^a/0TYY+		$TYY+($;<		$TYY+($;<r$   c                    | j                   j                  | j                  dz        }| j                   j                  |      }| j	                  |d   d       | j	                  |j                         d       | j                  | j                   j                  d             | j                  | j                   j                  dd      d       | j                   j                          | j                  | j                        | _         | j                   j                  | j                  dz        }| j                   j                  |      }| j	                  |d   d       | j	                  |j                         d       y )Nr   fromfoo0
FrE   1
)r>   rP   rQ   getr   r   assertIsNoneassertIsrB   r=   r<   )r   r   r   r   s       r"   test_getzTestMailbox.test_get   s   yy}}T^^a/0iimmD!Ve,*E2$))--./diimmE5159		MM$**-	yy}}T^^a/0iimmD!Ve,*E2r$   c                 |     j                   j                   j                  dz         j                      } j                  |d   d        j                  |j	                         d        j                  t         fd        j                   j                          j                  t         fd       y )Nr   r   r   r   c                  "     j                   d   S Nr   r   r?   s   r"   r   z*TestMailbox.test_getitem.<locals>.<lambda>       DIIe,<r$   c                  "    j                       S r
   r   r   s   r"   r   z*TestMailbox.test_getitem.<locals>.<lambda>  r   r$   )r>   rP   rQ   r   r   r   r   r   )r   r   r   s   ` @r"   test_getitemzTestMailbox.test_getitem   s    yy}}T^^a/0iioVe,*E2($<=		$($;<r$   c                    | j                   j                  | j                  dz        }| j                   j                  t              }| j                   j	                  |      }| j                  |t        j                         | j                  |d   d       | j                  |j                         d       | j                  | j                   j	                  |             y )Nr   r   r   r   )r>   rP   rQ   rR   get_messager   r   r   r   r   r#   )r   r   r   msg0s       r"   test_get_messagezTestMailbox.test_get_message  s    yy}}T^^a/0yy}}_-yy$$T*dGOO4fu-))+U34990067r$   c                 ~   | j                   j                  | j                  dz        }| j                   j                  t              }| j	                  | j                   j                  |      | j                  dz  j                  d             | j	                  | j                   j                  |      t               y )Nr   asciir>   rP   rQ   rR   r   ra   r`   rV   r   r   r   s      r"   test_get_byteszTestMailbox.test_get_bytes  s    yy}}T^^a/0yy}}_-,,T2^^a''0	2,,T24IJr$   c                    | j                   j                  | j                  dz        }| j                   j                  t              }| j	                  | j                   j                  |      | j                  dz         | j	                  | j                   j                  |      j                  d      t        j                  d             y )Nr   
r>   rP   rQ   rR   r   rZ   r   r   s      r"   test_get_stringzTestMailbox.test_get_string  s    yy}}T^^a/0yy}}_---d3T^^a5GH--d399$?(..t4	6r$   c                    | j                   j                  | j                  dz        }| j                   j                  t              }| j                   j	                  |      5 }|j                         }d d d        | j                   j	                  |      5 }|j                         }d d d        | j                  j                  d      j                  t        j                  d      | j                  dz         | j                  j                  d      j                  t        j                  d      t               y # 1 sw Y   xY w# 1 sw Y   xY w)Nr   r   r   )r>   rP   rQ   rR   r   r   r   decoder   r&   r   )r   r   r   filedata0data1s         r"   test_get_filezTestMailbox.test_get_file  s    yy}}T^^a/0yy}}_-YY%IIKE &YY%IIKE &g.66rzz4H!+	-g.66rzz4H(	* &%%%s   #E E E	Ec                     | j                   j                  t              }| j                   j                  |      }|j	                          |j	                          y r
   )r>   rP   rR   r   rB   r   s      r"   !test_get_file_can_be_closed_twicez-TestMailbox.test_get_file_can_be_closed_twice+  s:    iimmO,IIs#				r$   c                 T    | j                  | j                  j                  dd       y NTFdo_keys	do_values)_check_iterationr>   iterkeysr?   s    r"   test_iterkeyszTestMailbox.test_iterkeys2  s!    dii00$%Pr$   c                 T    | j                  | j                  j                  dd       y r   )r   r>   r[   r?   s    r"   	test_keyszTestMailbox.test_keys6  s    diinndeLr$   c                 T    | j                  | j                  j                  dd       y NFTr   )r   r>   
itervaluesr?   s    r"   test_itervalueszTestMailbox.test_itervalues:  s&    dii22E(, 	 	.r$   c                 T    | j                  | j                  j                  dd       y r   )r   r>   __iter__r?   s    r"   	test_iterzTestMailbox.test_iter?  s&    dii00%(, 	 	.r$   c                 T    | j                  | j                  j                  dd       y r   )r   r>   valuesr?   s    r"   test_valueszTestMailbox.test_valuesD  s!    dii..Nr$   c                 T    | j                  | j                  j                  dd       y NTr   )r   r>   	iteritemsr?   s    r"   test_iteritemszTestMailbox.test_iteritemsH  s&    dii114(, 	 	.r$   c                 T    | j                  | j                  j                  dd       y r   )r   r>   itemsr?   s    r"   
test_itemszTestMailbox.test_itemsM  s    diioottLr$   c                 6    |       D ]  }| j                  d        g g }}t        |      D ]W  }|j                  | j                  j	                  | j
                  |z               |j                  | j
                  |z         Y |r|st         |             }	nJ|r|st         |             }
n5g g }
}	 |       D ]'  \  }}|	j                  |       |
j                  |       ) |rH| j                  t        |      t        	             | j                  t        |      t        |	             |rhd}
D ]E  }| j                  |d   d       | j                  t        |j                               |       |dz  }G | j                  t        |      |       y y )Nz	Not emptyr   r   r   rE   )failrangerO   r>   rP   rQ   listr   r   set
assertLessintr   )r   r   r   r   r   r   r[   r   r   returned_keysreturned_valuesr   counts                r"   r   zTestMailbox._check_iterationQ  s]   XEIIk" 2f{#AKK		dnnq&89:MM$..1,- $ 9 NMw"68nO-/?M$h
U$$S)&&u- ' SYM(:;SYM(:;E(  v6E$5$5$7 8+F
 ) S[%0 r$   c                    | j                  d| j                         | j                  j                  | j                  dz        }| j	                  || j                         | j                  d| j                         | j                  j                  | j                  dz        }| j	                  || j                         | j	                  || j                         | j                  d| j                         | j                  j                  |       | j                  || j                         | j	                  || j                         | j                  d| j                         | j                  j                  |       | j                  || j                         | j                  || j                         | j                  d| j                         y )Nr   r   rE   )assertNotInr>   rP   rQ   r   r   r   s      r"   test_containszTestMailbox.test_containsl  sD   		*yy}}T^^a/0dDII&		*yy}}T^^a/0dDII&dDII&		*		tyy)dDII&		*		tyy)tyy)		*r$   c                 2   g }t        |      D ]  }| j                  t        | j                        |       |j	                  | j                  j                  | j                  |z               | j                  t        | j                        |dz           t        |      D ]s  }| j                  t        | j                        ||z
         | j                  j                  ||          | j                  t        | j                        ||z
  dz
         u y )NrE   )r   r   r   r>   rO   rP   rQ   r   )r   r   r[   r   s       r"   test_lenzTestMailbox.test_len  s    {#AS^Q/KK		dnnq&89:S^QU3 $ {#AS^[1_=IIT!W%S^[1_q-@A $r$   c                 >     j                   j                   j                  dz        } j                   j                   j	                  |       j                  dz          j                   j                   j                  dz        } j                   j                   j	                  |       j                  dz          j                  dz   j                   |<    j                   j                   j	                  |       j                  dz          j                  dz   j                   |<    j                   j                   j	                  |       j                  dz         t
         j                   |<    j                   j                   |           j                   |    j                   |<    j                   j                   |           j                  dz   j                   |<    j                   j                   j	                  |       j                  dz          j                   j                   |           j                  t         fd        j                  t         fd        j                  t         j                         d       y )N
original 0
original 1	changed 0	changed 1c                  <     j                   j                  dd      S )Nr   bar)r>   __setitem__r?   s   r"   r   z+TestMailbox.test_set_item.<locals>.<lambda>  s    $))"7"7u"Er$   c                  "     j                   d   S r   r   r?   s   r"   r   z+TestMailbox.test_set_item.<locals>.<lambda>  r   r$   rF   )
r>   rP   rQ   r   rZ   rR   r#   r   r   r   r   s   `  r"   test_set_itemzTestMailbox.test_set_item  s   yy}}T^^l:;--d3,6	8yy}}T^^l:;--d3,6	8..;6		$--d3+5	7..;6		$--d3+5	7)		$499T?+))D/		$499T?+..<7		$--d3^^l2	4499T?+(E	G($<=TYY+r$   c                     g }t        |      D ]*  } j                  j                   j                  |z         , t	        |      D ]=  \  } j                   j                  j                         j                  |z         ?  j                  j                           j                  t         j                        d       t	        |      D ]  \  } j                  t         fd       ! y )Nr   c                  :    j                   j                         S r
   )r>   rZ   r   r   s   r"   r   z(TestMailbox.test_clear.<locals>.<lambda>  s    		0D0DS0Ir$   )r   r>   rP   rQ   r   r   rZ   clearr   r   r   )r   
iterationsr[   r   r   s   `   @r"   
test_clearzTestMailbox.test_clear  s    z"AIIMM$..1,- #oFAsTYY11#68JK &		TYY+oFAsh(IJ &r$   c                 T   | j                   j                  | j                  dz        }| j                  || j                          | j                   j                  | j                  dz        }| j                  || j                          | j	                  | j                   j                  |      j                         d       | j                  || j                          | j                  || j                          | j                   j                  | j                  dz        }| j                  || j                          | j	                  | j                   j                  |      j                         d       | j                  || j                          | j                  || j                          | j	                  | j                   j                  |      j                         d       | j                  || j                          | j	                  t        | j                         d       y )Nr   rE   r   rF   z2
r   )	r>   rP   rQ   r   r   popr   r  r   r   r   r   r   s       r"   test_popzTestMailbox.test_pop  ss   yy}}T^^a/0dDII&yy}}T^^a/0dDII&t,88:EBtyy)dDII&yy}}T^^a/0dDII&t,88:EBtyy)dDII&t,88:EBtyy)TYY+r$   c                 ^    g }t        d      D ]9  }|j                   j                  j                   j                  |z               ; g }t        d      D ]  } j                  j                         \  } j                  |        j                  |       |j                          j                  t        |j                               |j                                 j                  t         j                        d       |D ]   j                  t         fd        y )N
   r   c                  "    j                       S r
   r   r  s   r"   r   z*TestMailbox.test_popitem.<locals>.<lambda>  s    		#r$   )r   rO   r>   rP   rQ   popitemr   r  r   r  r   indexr   r   r   )r   r  r[   r   seenr   r   s   `     @r"   test_popitemzTestMailbox.test_popitem  s    rAKK		dnnq&89: rAyy((*HCMM#t$S$'KKS!23TZZ_E  	TYY+Ch(>? r$   c                      j                   j                   j                  dz         j                   j                   j                  dz        } j                   j                   j                  dz        } j                   j                   j                  dz  |t        i        j                  t         j                         d        j                   j                   j                         j                  dz          j                   j                   j                  |       j                  dz          j                   j                   |           j                   j                  | j                  dz  f| j                  dz  f j                  dz  fg        j                  t         j                         d        j                   j                   j                         j                  dz          j                   j                   j                  |       j                  dz          j                   j                   j                  |       j                  dz          j                  t         fd        j                  t         j                         d        j                   j                   j                         j                  dz          j                   j                   j                  |       j                  dz          j                   j                   j                  |       j                  dz         y )	Nr  r  z
original 2r  rG   z	changed 2r  c                  \    j                   j                  dd j                  dz  i      S )Nr   r  r  )r>   updaterQ   r   s   r"   r   z)TestMailbox.test_update.<locals>.<lambda>  s-    $))"2"2E5*.0L4N #Or$   )r>   rP   rQ   r(  rR   r   r   rZ   r#   r   r   )r   r   r   r   s   `  @r"   test_updatezTestMailbox.test_update  s   yy}}T^^l:;yy}}T^^l:;yy}}T^^l:;		$ <1 	2TYY+--d3^^k1	3--d3^^l2	4499T?+		4+!=>4>>K784>>L89; 	< 	TYY+--d3^^l2	4--d3^^k1	3--d3^^k1	3(O	P 	TYY+--d3^^k1	3--d3^^k1	3--d3^^k1	3r$   c                 P    | j                  | j                  j                  d       y NT)_test_flush_or_closer>   rl   r?   s    r"   
test_flushzTestMailbox.test_flush  s    !!$))//48r$   c                    | j                   j                  | j                  dz         | j                   j                  | j                  dz         | j                   j                          | j                   j	                          | j                   j                          | j                   j	                          | j                   j                          y Nr   rE   )r>   rP   rQ   rl   r"  r?   s    r"   test_popitem_and_flush_twicez(TestMailbox.test_popitem_and_flush_twice  s~    		dnnq()		dnnq()										r$   c                    | j                  t        j                  j                  | j	                                      | j
                  j                          | j                  t        j                  j                  | j	                                      | j
                  j                          | j                  t        j                  j                  | j	                                      y r
   )	assertFalser&   r'   r*   _get_lock_pathr>   lockr   unlockr?   s    r"   test_lock_unlockzTestMailbox.test_lock_unlock  s    (;(;(=>?		t':':'<=>		(;(;(=>?r$   c                 P    | j                  | j                  j                  d       y NF)r,  r>   rB   r?   s    r"   
test_closezTestMailbox.test_close  s    !!$))//59r$   c                    t        d      D cg c]  }| j                  |z   }}| j                  j                  |d          | j                  j                  |d          | j                  j                  |d          | j                  } |        |r| j                  j	                          | j                  | j                        | _        | j                  j                         }| j                  t        |      d       |D ]-  }| j                  | j                  j                  |      |       / |j	                          y c c}w )NrG   r   rE   rF   )r   rQ   r>   rP   rB   r=   r<   r[   r   r   r   rZ   )r   r   should_call_closer   contentsoldboxr[   r   s           r"   r,  z TestMailbox._test_flush_or_close  s    05a91DNNQ&9		hqk"		hqk"		hqk"IIOOMM$**-	yy~~TA&CMM$))..s3X>  :s   Ec           	          t        j                  t              t        t        j                  t
              fD ]  }t        j                          j                  j                  |        j                  j                         t
        j                  dt        j                  j                                       t        j                          j                  t         fd       y )Nr   c                  <    j                   j                  d        S r
   )r>   _dump_message)outputr   s   r"   r   z/TestMailbox.test_dump_message.<locals>.<lambda>+  s    $))"9"9$"Gr$   )r   rS   rR   rT   rU   rV   r>   r@  r   getvaluer   r&   r   r`   r   	TypeError)r   inputrA  s   ` @r"   test_dump_messagezTestMailbox.test_dump_message!  s    //@%rzz2G'HJEZZ\FII##E62V__.%--eRZZ5F5F5HIK	J )G	Ir$   c                      | j                   dz   S )Nz.lock)r<   r?   s    r"   r3  zTestMailbox._get_lock_path-  s    zzG##r$   r   )9r.   r/   r0   maxDiffr=   rQ   r@   rC   r\   textwrapdedentr_   rc   rg   rn   r~   r`   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r
  r  r  r  r%  r)  r-  r0  r6  r9  r,  rE  r3  r7   r$   r"   r9   r9   5   s?   GH#I.
-3. $HOO % M2."" ) 
* 
 VG_ 	6020J
"7<:,
=3=8K6*QM.
.
O.
M16+&
B,6
K,$@  3D9	@: 
I$r$   r9   c                       e Zd Zd Zy)TestMailboxSuperclassc                    t        j                  d      | j                  t        fd       | j                  t        fd       | j                  t        fd       | j                  t        fd       | j                  t        fd       | j                  t        fd       | j                  t        fd       | j                  t        fd	       | j                  t        fd
       | j                  t        fd       | j                  t        fd       | j                  t        fd       | j                  t        fd       | j                  t        fd       | j                  t        fd       | j                  t        fd       | j                  t        fd       | j                  t        fd       | j                  t        fd       | j                  t        fd       | j                  t        fd       | j                  t        fd       | j                  t        fd       | j                  t        fd       | j                  t        fd       | j                  t        fd       | j                  t        fd       | j                  t        fd       | j                  t        fd       y )Nr'   c                  &     j                  d      S N )rP   boxs   r"   r   z;TestMailboxSuperclass.test_notimplemented.<locals>.<lambda>7      swwr{r$   c                  &     j                  d      S rO  )r   rQ  s   r"   r   z;TestMailboxSuperclass.test_notimplemented.<locals>.<lambda>8  s    szz"~r$   c                  &     j                  d      S rO  )r   rQ  s   r"   r   z;TestMailboxSuperclass.test_notimplemented.<locals>.<lambda>9      sr7Jr$   c                  &     j                  d      S rO  )r   rQ  s   r"   r   z;TestMailboxSuperclass.test_notimplemented.<locals>.<lambda>:  s    s{{2r$   c                  (     j                  dd      S rO  )r  rQ  s   r"   r   z;TestMailboxSuperclass.test_notimplemented.<locals>.<lambda>;  s    sr27Nr$   c                  $     j                         S r
   )r   rQ  s   r"   r   z;TestMailboxSuperclass.test_notimplemented.<locals>.<lambda><  s    s||~r$   c                  $     j                         S r
   )r[   rQ  s   r"   r   z;TestMailboxSuperclass.test_notimplemented.<locals>.<lambda>=      sxxzr$   c                  @     j                         j                         S r
   )r   __next__rQ  s   r"   r   z;TestMailboxSuperclass.test_notimplemented.<locals>.<lambda>>  s    s~~7G7P7P7Rr$   c                  @     j                         j                         S r
   )r   r]  rQ  s   r"   r   z;TestMailboxSuperclass.test_notimplemented.<locals>.<lambda>?  s    s||~7N7N7Pr$   c                  $     j                         S r
   )r   rQ  s   r"   r   z;TestMailboxSuperclass.test_notimplemented.<locals>.<lambda>@      szz|r$   c                  @     j                         j                         S r
   )r   r]  rQ  s   r"   r   z;TestMailboxSuperclass.test_notimplemented.<locals>.<lambda>A  s    s}}7O7O7Qr$   c                  $     j                         S r
   )r   rQ  s   r"   r   z;TestMailboxSuperclass.test_notimplemented.<locals>.<lambda>B      syy{r$   c                  &     j                  d      S rO  )r   rQ  s   r"   r   z;TestMailboxSuperclass.test_notimplemented.<locals>.<lambda>C  rS  r$   c                  &     j                  d      S rO  )__getitem__rQ  s   r"   r   z;TestMailboxSuperclass.test_notimplemented.<locals>.<lambda>D  rV  r$   c                  &     j                  d      S rO  )r   rQ  s   r"   r   z;TestMailboxSuperclass.test_notimplemented.<locals>.<lambda>E  rV  r$   c                  &     j                  d      S rO  )rZ   rQ  s   r"   r   z;TestMailboxSuperclass.test_notimplemented.<locals>.<lambda>F  s    s~~b7Ir$   c                  &     j                  d      S rO  )ra   rQ  s   r"   r   z;TestMailboxSuperclass.test_notimplemented.<locals>.<lambda>G  s    s}}R7Hr$   c                  &     j                  d      S rO  )r   rQ  s   r"   r   z;TestMailboxSuperclass.test_notimplemented.<locals>.<lambda>H  s    s||B7Gr$   c                      d v S rO  r7   rQ  s   r"   r   z;TestMailboxSuperclass.test_notimplemented.<locals>.<lambda>I  s	    rSyr$   c                  &     j                  d      S rO  )__contains__rQ  s   r"   r   z;TestMailboxSuperclass.test_notimplemented.<locals>.<lambda>J  s    s7G7G7Kr$   c                  $     j                         S r
   )__len__rQ  s   r"   r   z;TestMailboxSuperclass.test_notimplemented.<locals>.<lambda>K      s{{}r$   c                  $     j                         S r
   )r  rQ  s   r"   r   z;TestMailboxSuperclass.test_notimplemented.<locals>.<lambda>L  rc  r$   c                  &     j                  d      S rO  )r  rQ  s   r"   r   z;TestMailboxSuperclass.test_notimplemented.<locals>.<lambda>M  rS  r$   c                  $     j                         S r
   )r"  rQ  s   r"   r   z;TestMailboxSuperclass.test_notimplemented.<locals>.<lambda>N  rp  r$   c                  &     j                  d      S )N))rP  rP  )r(  rQ  s   r"   r   z;TestMailboxSuperclass.test_notimplemented.<locals>.<lambda>O  s    szz+7Nr$   c                  $     j                         S r
   )rl   rQ  s   r"   r   z;TestMailboxSuperclass.test_notimplemented.<locals>.<lambda>P  rc  r$   c                  $     j                         S r
   )r4  rQ  s   r"   r   z;TestMailboxSuperclass.test_notimplemented.<locals>.<lambda>Q  r[  r$   c                  $     j                         S r
   )r5  rQ  s   r"   r   z;TestMailboxSuperclass.test_notimplemented.<locals>.<lambda>R  r`  r$   c                  $     j                         S r
   )rB   rQ  s   r"   r   z;TestMailboxSuperclass.test_notimplemented.<locals>.<lambda>S  rc  r$   )r   Mailboxr   NotImplementedError)r   rR  s    @r"   test_notimplementedz)TestMailboxSuperclass.test_notimplemented4  s   oof%-/BC-/EF-/JK-/FG-/NO-/EF-/AB-/RS-/PQ-/CD-/QR-/BC-/BC-/JK-/JK-/IJ-/HI-/GH-/@A-/KL-/DE-/BC-/BC-/DE-/NO-/BC-/AB-/CD-/BCr$   N)r.   r/   r0   r{  r7   r$   r"   rL  rL  2  s    Dr$   rL  c                      e Zd ZddZd Zd Zd Zd Zd Zd Z	d	 Z
d
 ZddZd Zd Zd Zd ZddZd Zd Zd Zd Zd Zd Z ej2                   eed      d      d        Z ej2                   eed      d      d        Zd Zy)TestMaildirNc                 .    t        j                  ||      S r
   )r   Maildirr   r'   factorys      r"   r   zTestMaildir.<lambda>X  s    g0Nr$   c                     t         j                  |        t        j                  dk(  st        j
                  dk(  rd| j                  _        y y )Nntcygwin!)r9   r@   r&   namesysplatformr>   colonr?   s    r"   r@   zTestMaildir.setUpZ  s6    $GGtO!9!DIIO ":r$   c                     | j                  t        j                  t        j                  j	                  | j
                  d            g        y Ntmp)r   r&   listdirr'   joinr<   r?   s    r"   rm   zTestMaildir.assertMailboxEmpty_  s.    BGGLLU$CDbIr$   c                    t        j                  | j                  dz        }|j                  d       |j	                  d       | j
                  j                  |      }| j                  t        j                  j                  t        j                  j                  | j                  d|| j
                  j                  d                   y )Nr   curr   )r   r1   rQ   
set_subdirset_infor>   rP   r   r&   r'   r*   r  r<   r  )r   r   r   s      r"   test_add_MMzTestMaildir.test_add_MMb  s    $$T^^a%78uUiimmC rww||DJJ25tyyHH (I J 	Kr$   c                    t        j                  | j                  dz        }|j                  d       |j	                  d       | j
                  j                  |      }| j
                  j                  |      }| j                  |t         j                         | j                  |j                         d       | j                  |j                         d       y )Nr   r  RFFR)r   r1   rQ   r  	set_flagsr>   rP   r   r   r   
get_subdir	get_flags)r   r   r   msg_returneds       r"   test_get_MMzTestMaildir.test_get_MMk  s    $$T^^a%78udiimmC yy,,S1lG,B,BC002E://148r$   c                 `   t        j                  | j                  dz        }|j                  d       | j                  j                  |      }| j                  j                  |      }| j                  |j                         d       | j                  |j                         d       t        j                  | j                  dz        }|| j                  |<   | j                  j                  |      }| j                  |j                         d       | j                  |j                         d       | j                  |j                         d       t        j                  | j                  dz        }|j                  d	       || j                  |<   | j                  d
z  | j                  |<   | j                  j                  |      }| j                  |j                         d       | j                  |j                         d       | j                  |j                         d       y )Nr   TPnewPTrE   rP  r   rF   z2,SrG   Sz3
)r   r1   rQ   r  r>   rP   r   r   r  r  r   r  )r   r   r   r  msg1msg2s         r"   test_set_MMzTestMaildir.test_set_MMv  s   %%dnnq&89tiimmD!yy,,S1002E://148%%dnnq&89		#yy,,S1002E://126113U;%%dnnq&89e		#!+		#yy,,S1002E://137113U;r$   c                    t        j                  | j                  dz        }|j                  d       |j	                  d       | j
                  j                  |      } G d dt         j                        }t        j                  | j                  |      }| j
                  j                  |_	        |j                  |      }| j                  ||       y )Nr   r  r  c                       e Zd Zy)8TestMaildir.test_consistent_factory.<locals>.FakeMessageNrr   r7   r$   r"   FakeMessager    s    r$   r  r  )r   r1   rQ   r  r  r>   rP   r  r<   r  r   r   )r   r   r   r  rR  r  s         r"   test_consistent_factoryz#TestMaildir.test_consistent_factory  s    $$T^^a%78udiimmC 	'00 	oodjj+>IIOO	s#dK0r$   c                 &   | j                          t        j                  | j                        | _        | j                          | j                  | j                         | j                  | j                  d       | _        | j                          y )Nr  )rC   r   r  r<   r>   _check_basicsr-   r=   r?   s    r"   test_initialize_newzTestMaildir.test_initialize_new  sa    OODJJ/	  ,MM$**dM;	r$   c           	      N   | j                          dD ]\  }t        j                  t        j                  j	                  t        j                  j                  | j                  |                   ^ t        j                  | j                        | _	        | j                          y )NrP  r  r  r  )rC   r&   mkdirr'   normpathr  r<   r   r  r>   r  )r   subdirs     r"   test_initialize_existingz$TestMaildir.test_initialize_existing  sc    -FHHRWW%%bggll4::v&FGH .OODJJ/	r$   c                    | j                  | j                  j                  t        j                  j                  | j                               | j                  | j                  j                  |       dD ]z  }t        j                  j                  | j                  |      }t        j                  |      t        j                     }| j                  t        j                  |      d|z         | y )Nr  zNot a directory: '%s')r   r>   r<   r&   r'   abspathr=   r  statST_MODEr   S_ISDIR)r   r  r  r'   modes        r"   r  zTestMaildir._check_basics  s    "''//$***EF++W5-F77<<

F3D774=.DOODLL.0G$0NO .r$   c                    | j                   j                  d       | j                   j                  d       | j                   j                  d       | j                  t        | j                   j	                               d       | j                  t        | j                   j	                               t        d             y NonetwothreerG   )r  r  r  r>   
add_folderr   r   list_foldersr   r?   s    r"   test_list_folderszTestMaildir.test_list_folders      		U#		U#		W%TYY3356:TYY335601	3r$   c                    | j                   j                  d       | j                   j                  d      }|j                  | j                  dz         | j                  t        j                  j                  t        j                  j                  | j                  d                   | j                   j                  d      }| j                  |j                  |j                         d         | j                  dz         y )Nfoo.barr  z.foo.barr   )r>   r  
get_folderrP   rQ   r   r&   r'   r(   r  r<   r   rZ   r[   )r   folder0folder1s      r"   test_get_folderzTestMaildir.test_get_folder  s    		Y'))&&y1DNNU*+bggll4::z&JKL))&&y1++GLLN1,=>%/	1r$   c                 z   | j                   j                  d       | j                   j                  d       | j                  t        | j                   j	                               d       | j                  t        | j                   j	                               t        d             | j                   j                  d       | j                  t        | j                   j	                               d       | j                  t        | j                   j	                               t        d             | j                   j                  d       | j                  t        | j                   j	                               d       | j                  t        | j                   j	                               t        d             | j                   j                  d       | j                  t        | j                   j	                               d       | j                  t        | j                   j	                               t        d             | j                   j                  d       | j                  t        | j                   j	                               d	       | j                  | j                   j	                         g        y 
Nr  r  rF   )r  r  rE   )r  r  )r  r  r   r>   r  r   r   r  r   remove_folderr?   s    r"   test_add_and_remove_foldersz'TestMaildir.test_add_and_remove_folders     		U#		U#TYY3356:TYY3356N8KL		&TYY3356:TYY3356HF		W%TYY3356:TYY3356<L8MN		(TYY3356:TYY3356HF		&TYY3356://126r$   c                    t         j                  j                  | j                  dd      }t         j                  j                  | j                  dd      }t	        |dd      5 }|j                  d       d d d        t	        |dd      5 }|j                  d       d d d        | j                  j                          | j                  t         j                  j                  |             | j                  t         j                  j                  |             t        j                  |      }t        j                  |t        j                         dz
  d	z
  |j                  f       | j                  j                          | j                  t         j                  j                  |             | j                  t         j                  j                  |             y # 1 sw Y   nxY w# 1 sw Y   SxY w)
Nr  r   r  wrK   rL   @i@ rF   )r&   r'   r  r<   openr   r>   cleanr   r*   r  utimetimest_mtimer2  )r   foo_pathbar_pathr   foo_stats        r"   
test_cleanzTestMaildir.test_clean  s@   77<<

E5977<<

E59(C'2aGGCL 3(C'2aGGCL 3		x01x01778$
DIIK&014$--/ 	0		12x01 3222s   %G#G0#G-0G:c           
      L   t        j                         }d|v r|j                  dd      }d|v r|j                  dd      }t        j                         }t        j                  d      }d }t        |      D ]J  }| j                  j                         }t        j                  j                  |j                        \  }}	| j                  |t        j                  j                  t        j                  j                  | j                   d            d|z         |j#                  |	      }
| j%                  |
d|	z         |
j'                         }|| j)                  t+        |d	         t+        |d	         d
|d	   d|d	   d       t+        |d	         t+        |d	         k(  r8| j)                  t+        |d         t+        |d         d|d   d|d   d       | j                  t+        |d         |d|d   d|d       | j                  t+        |d         t+        |d         dz   d|d   d|d   d       | j                  |d   |d|d   d|d       |}|j-                  t.               |j1                  d	       | j                  |j3                         t.               |j5                          M t7        t        j8                  t        j                  j                  | j                   d                  }| j                  ||d|d|d       y )N/z\057:z\072zF(?P<time>\d+)\.M(?P<M>\d{1,6})P(?P<P>\d+)Q(?P<Q>\d+)\.(?P<host>[^:/]*)r  zFile in wrong location: '%s'zInvalid file name: '%s'r   zNon-monotonic seconds: 'z
' before ''rE   zNon-monotonic milliseconds: 'rF   zProcess ID mismatch: 'z' should be 'rG   zNon-sequential counter: 'rH   zHost name mismatch: 'zWrong file count: ')socketgethostnamer   r&   getpidrecompiler   r>   _create_tmpr'   r   r  r   r  r  r<   matchassertIsNotNonegroupsassertGreaterEqualr  r   rV   r   r   rB   r   r  )r   r   hostnamepidpatternprevious_groupsxtmp_fileheadtailr  r  
file_counts                r"   test_create_tmpzTestMaildir.test_create_tmp  s   %%'(?''W5H(?''W5Hiik** > ?{#Ayy,,.Hx}}5JD$T277??277<<

@E4G $H;dBD MM$'E  (AD(HI\\^F*''F1IOA<N8O-a0&)=> vay>S);%<<++Cq	NCPQ@R<S!0!3VAY!@A   VAY$Qi./   VAY_Q5G1H11L-a0&)=>   H$Qi34 %ONN01MM!X]]_.CDNN= $> BGGLLU$CDE
[ +/	0r$   c                    | j                  | j                  j                  i        | j                  j                  | j                  dz        }| j                  j                  | j                  dz        }| j                  | j                  j                  i        | j                  j                          | j                  | j                  j                  |t        j                  j                  d|      |t        j                  j                  d|      i       | j                  j                  | j                  dz        }| j                  | j                  j                  |t        j                  j                  d|      |t        j                  j                  d|      i       | j                  j                          | j                  | j                  j                  |t        j                  j                  d|      |t        j                  j                  d|      |t        j                  j                  d|      i       y )Nr   rE   r  rF   )	r   r>   _tocrP   rQ   _refreshr&   r'   r  r  s       r"   test_refreshzTestMaildir.test_refresh  s   ,yy}}T^^a/0yy}}T^^a/0,		$UD0I*.UD0I*K 	Lyy}}T^^a/0$UD0I*.UD0I*K 	L		$UD0I*.UD0I*.UD0I*K 	Lr$   c                    | j                   j                  | j                  dz        }| j                   j                  | j                  dz        }| j                  | j                        | _         | j                  | j                   j                  i        d| j                   _        | j                   j                          | j                  t        | j                   j                  j                               t        ||g             y )Nr   rE   )r>   rP   rQ   r=   r<   r   r  _skewfactorr  sortedr[   r   s      r"    test_refresh_after_safety_periodz,TestMaildir.test_refresh_after_safety_period.  s     yy}}T^^a/0yy}}T^^a/0MM$**-	, !#						 3 3 56d|8LMr$   c                      j                  t         fd        j                  j                   j                  dz         j                   j                  j                        t        j                  j                  d             t        j                  t        j                  j                   j                  d              j                   j                  j                  t        j                  j                  d      i        j                  j                           j                  t         fd        j                   j                  j                  i        y )Nc                  :     j                   j                  d      S r   r>   _lookupr?   s   r"   r   z)TestMaildir.test_lookup.<locals>.<lambda>C  s    DII,=,=e,Dr$   r   r  c                  :    j                   j                         S r
   r  r   s   r"   r   z)TestMaildir.test_lookup.<locals>.<lambda>K  s    DII,=,=d,Cr$   )r   r   r>   rP   rQ   r   r  r&   r'   r  r   r<   r  rl   )r   r   s   `@r"   test_lookupzTestMaildir.test_lookupA  s    ($DEyy}}T^^a/0**40"'',,ud2KL
		"'',,tzz5$78$UD0I)JK 			($CD,r$   c                 l    | j                   j                          | j                   j                          y r
   )r>   r4  r5  r?   s    r"   r6  zTestMaildir.test_lock_unlockN  s     				r$   c                     d }| j                  | j                  |      }|j                  d      }| j                  |j                   |       |j	                  d      }| j                  |j                   |       y )Nc                      y r
   r7   ss    r"   dummy_factoryz.TestMaildir.test_folder.<locals>.dummy_factoryV      r$   r  r  )r=   r<   r  r   r  )r   r  rR  folderfolder1_aliass        r"   test_folderzTestMaildir.test_folderS  s_    	mmDJJm>	*foo}5y1m,,m<r$   c                 &   t        d      D ]4  }| j                  j                  t        j                  t
                     6 t        j                  t        j                  j                  | j                  dd             | j                  D ]  } y )Nr   r  z	stray-dir)r   r>   rP   r   r   rR   r&   r  r'   r  r<   )r   r   r   s      r"   test_directory_in_folderz$TestMaildir.test_directory_in_folder_  sa     rAIIMM'///:;  	djj%=> 99C r$   umasktest needs os.umask()c                    t        j                  | j                  dz        }t        j                  d      }	 | j
                  j                  |      }t        j                  |       t        j                  j                  | j                  | j
                  j                  |            }t        j                  |      j                  }| j                  |dz         y # t        j                  |       w xY w)Nr   I   )r   r1   rQ   r&   r  r>   rP   r'   r  r<   r  r  st_moder2  )r   r   
orig_umaskr   r'   r  s         r"   test_file_permissionsz!TestMaildir.test_file_permissionsl  s     $$T^^a%78XXa[
	!))--$CHHZ ww||DJJ		(9(9#(>?wwt}$$& HHZ s   C   C7c                    t        j                  d      }	 | j                  j                  d      }t        j                  |       t         j                  j                  |j                  d      }t        j                  |      }|j                  }| j                  |dz         y # t        j                  |       w xY w)Nr   	subfoldermaildirfolderr  )
r&   r  r>   r  r'   r  r<   r  r  r2  )r   r  r  r'   stpermss         r"   test_folder_file_permsz"TestMaildir.test_folder_file_permsy  s     XXa[
	!		,,[9IHHZ ww||IOO_=WWT]

%%-) HHZ s   B' 'B>c                      j                   j                          dD ]c  }t        j                  t        j                  j                   j                   j                  |      t        j                         dz
  fdz         e d j                   _         j                   j                   fd} j                   j                           j                   |              t        j                  j                   j                  dd      }t        j                  |       t        j                  |        j                   j                           j                   |              y )N)r  r  rI   rF   r  c                  4    j                   j                   uS r
   )r>   r  )orig_tocr   s   r"   	refreshedz*TestMaildir.test_reread.<locals>.refreshed  s    99>>11r$   r  z
stray-file)r>   r  r&   r  r'   r  r<   r  r  r  r2  r   create_empty_filer+   r   )r   r  r  filenamer  s   `   @r"   test_rereadzTestMaildir.test_reread  s    		 %FHHRWW\\$))//6:iik!m%a') % !#		
 99>>	2 			%
 77<<

E<@##H-
		(			$r$   r
   rG  )r.   r/   r0   r=   r@   rm   r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r6  r  r  unittest
skipUnlesshasattrr&   r  r  r!  r7   r$   r"   r}  r}  V  s    NH"
JK	9<.1P317&2$-0^L"N&-

= XW-/FG
' H
' XW-/FG* H*&%r$   r}  c                   Z    e Zd Z	 d Zd Z ej                   eed      d      d        Z	y)_TestSingleFilec                    t        j                  | j                        j                  }| j                  j                  | j                  dz         | j                  j                          t        j                  | j                        j                  }| j                  ||       | j                  j                          | j                  | j                        | _        | j                  t        | j                        d       y r/  )r&   r  r<   st_inor>   rP   rQ   rl   r   rB   r=   r   )r   inode_beforeinode_afters      r"   test_add_doesnt_rewritez'_TestSingleFile.test_add_doesnt_rewrite  s     wwtzz*11		dnnq()		ggdjj)00{3 			MM$**-	TYY+r$   c                    t        j                  | j                        j                  dz  }t        j                  | j                  |       | j
                  j                  | j                  dz         | j
                  j                  | j                  dz        }| j
                  j                  |       | j
                  j                          | j                  t        j                  | j                        j                  |       y )N  r   rE   )r&   r  r<   r  chmodr>   rP   rQ   r   rl   r   )r   r  r   s      r"   test_permissions_after_flushz,_TestSingleFile.test_permissions_after_flush  s     wwtzz"**U2
T"		dnnq()IIMM$..1,-				,44d;r$   chownzrequires os.chownc                    t        j                  d      }t        j                  d      }t        j                  | j                        }|j                         D ])  }|j                  |j                  k7  s|j                  } n | j                  d       |j                         D ])  }|j                  |j                  k7  s|j                  } n | j                  d       	 t        j                  | j                         |j                  dz  }t        j                  | j                  |       | j                   j#                  | j$                  dz         | j                   j#                  | j$                  dz        }| j                   j'                  |       | j                   j)                          t        j                  | j                        }| j+                  |j                         | j+                  |j                         | j+                  |j                  |       y # t        $ r | j                  d       Y Ew xY w)	Npwdgrpztest needs more than one userztest needs more than one groupztest needs root privileger-  r   rE   )r   import_moduler&   r  r<   getpwallpw_uidst_uidskipTestgetgrallgr_gidst_gidr0  OSErrorr  r.  r>   rP   rQ   r   rl   r   )	r   r2  r3  r  e	other_uid	other_gidr  r   s	            r"   test_ownership_after_flushz*_TestSingleFile.test_ownership_after_flush  s    ))%0))%0WWTZZ Axx299$HH	  
 MM9:Axx299$HH	  
 MM:;	7HHTZZI6 zzE!
T"		dnnq()IIMM$..1,-				WWTZZ I.I.T*  	7MM56	7s   %!H. .IIN)
r.   r/   r0   r+  r/  r"  r#  r$  r&   r@  r7   r$   r"   r&  r&    s;    0,(<" XW-/BC&+ D&+r$   r&  c                        e Zd Z fdZd Zd Zd Zd Zd Zd Z	d Z
d	 Z ej                          ej                   eed
      d      d               Zd Z xZS )_TestMboxMMDFc                 *   t         |           | j                  j                          | j	                  | j
                         t        j                  t        j                  | j
                        dz         D ]  }t        j                  |        y Nz.*
superrC   r>   rB   r-   r<   globescaper   r+   r   lock_remnant	__class__s     r"   rC   z_TestMboxMMDF.tearDown  b    		  , IIdkk$**&=&DEL\* Fr$   c                     t        | j                  d      5 }| j                  |j                         g        d d d        y # 1 sw Y   y xY wNrbr  r<   r   	readlinesr   r   s     r"   rm   z _TestMboxMMDF.assertMailboxEmpty  4    $**d#qQ[[]B/ $##   !AA
c                    d}| j                   j                  || j                  dz  z         }| j                   j                  |t        z         }| j	                  | j                   j                  |d      | j                  dz  j                  d             | j	                  | j                   j                  |d      t               | j	                  | j                   j                  |d      || j                  dz  z   j                  d             | j	                  | j                   j                  |d      |j                  d      t        z          y )NFrom foo@bar blah
r   Ffrom_r   Tr   r   unixfromr   r   s       r"   test_get_bytes_fromz!_TestMboxMMDF.test_get_bytes_from  s   (yy}}X(::;yy}}X78,,T,?^^a''0	2,,T,?!	#,,T,>**227;	=,,T,>OOG$'<<	>r$   c                    d}| j                   j                  || j                  dz  z         }| j                   j                  |t        z         }| j	                  | j                   j                  |d      | j                  dz         | j	                  | j                   j                  |d      j                  d      t        j                  d             | j	                  | j                   j                  |d      || j                  dz  z          | j	                  | j                   j                  |d      j                  d      |t        z   j                  d             y )NrV  r   FrW  r   Tr   rY  s       r"   test_get_string_fromz"_TestMboxMMDF.test_get_string_from  s#   (yy}}X(::;yy}}X78--d%-@!+	---d%-@FFtL(..t4	6--d$-?!DNNQ$66	8--d$-?EEdK"_4;;DA	Cr$   c                 H   | j                   j                  d      }| j                  | j                   |   j                         d       | j                  | j                   |   j	                         d       | j                  | j                   |   j                         d       y )NFrom foo@bar blah
From: foo

0
foo@bar blahFrom foo@bar blahr   r>   rP   r   get_fromget_unixfromr   rb   s     r"   test_add_from_stringz"_TestMboxMMDF.test_add_from_string,  sy    iimmAB3002NC34468KL3335u=r$   c                 H   | j                   j                  d      }| j                  | j                   |   j                         d       | j                  | j                   |   j	                         d       | j                  | j                   |   j                         d       y )Ns   From foo@bar blah
From: foo

0
r`  ra  r   rb  rb   s     r"   test_add_from_bytesz!_TestMboxMMDF.test_add_from_bytes3  sy    iimmBC3002NC34468KL3335u=r$   c                     t         j                  t         j                  fD ]%  } |d      }| j                  j	                  |      }' y )Nr_  )r   r2   r5   r>   rP   )r   class_r   r   s       r"   test_add_mbox_or_mmdf_messagez+_TestMboxMMDF.test_add_mbox_or_mmdf_message:  s;    **G,?,?@F>?C))--$C Ar$   c                    t        d      D cg c]  }| j                  |z   }}|D ]  }| j                  j                  |        | j                  j	                          t
        j                  j                  | j                        }| j                  | j                        | _        | j                  t        | j                        d       | j                  j                         D ]-  }| j                  | j                  j                  |      |       / | j                  j	                          | j                  |t
        j                  j                  | j                               y c c}w )NrG   )r   rQ   r>   rP   rB   r&   r'   getmtimer<   r=   r   r   r   r   rZ   )r   r   r   r   mtimer   s         r"   test_open_close_openz"_TestMboxMMDF.test_open_close_open@  s    .3Ah7h$..1$h7EIIMM%  		  ,MM$**-	TYY+99%%'CMM$))..s3V< (		 0 0 <= 8s   E.c                    | j                   j                  t               t        d      D ]*  }| j                   j                  | j                  |z         , | j                   j                  t               | j                   j
                  j                          | j                   j
                  j                  d       | j                   j
                  j                         }| j                   j                          t        | j                  d      5 }| j                  ||j                                d d d        | j                  | j                        | _         y # 1 sw Y   *xY w)NrG   r   rO  )r>   rP   rR   r   rQ   _filerl   r   r   rB   r  r<   r   r=   )r   r   r<  r   s       r"   test_add_and_closez _TestMboxMMDF.test_add_and_closeN  s    		o&qAIIMM$..1,- 		o&				Q99??'')		$**d#qXqvvx0 $MM$**-	 $#s   !EE'
socketpairzTest needs socketpair().c                 z   t        j                         \  }}| j                  |j                         | j                  |j                         t	        j
                         }|dk(  rl	 | j                  j                          |j                  d       |j                  d       | j                  j                          t	        j                  d       |j                  d       	 | j                  t        j                  | j                  j                         |j                  d       t        j                   |d       | j                  j                          | j                  j                          y # t	        j                  d       w xY w# |j                  d       t        j                   |d       w xY w)Nr      crE      p)exitcode)r  rr  
addCleanuprB   r&   forkr>   r4  sendrecvr5  _exitr   r   ExternalClashErrorr   wait_process)r   cpr  s       r"   test_lock_conflictz _TestMboxMMDF.test_lock_conflict\  s)   
   "1  ggi!8			 t q			  " 	
q		2g88"iinn. FF4L  q1				  FF4L  q1s   (AE6 %4F 6F*F:c                    d}| j                   j                  |      }| j                   j                          | j                   j                          | j	                  | j
                        | _         | j                   j                          | j                   j                  |      }| j                   j                          | j                  | j                   j                         | j                   j                          y )NzSubject: sub

body
)	r>   rP   rl   rB   r=   r<   r4  r   _locked)r   r   r   r   s       r"   test_relockz_TestMboxMMDF.test_relock  s     'yy}}S!				MM$**-			yy}}S!				))*		r$   )r.   r/   r0   rC   rm   r[  r]  re  rg  rj  rn  rq  r   requires_forkr"  r#  r$  r  r  r  __classcell__rK  s   @r"   rB  rB    sv    +0>C>>%>. WX68RS! T !Fr$   rB  c                   `    e Zd ZddZ ej
                   eed      d      d        Zd Z	d Z
y)	TestMboxNc                 .    t        j                  ||      S r
   )r   mboxr  s      r"   r   zTestMbox.<lambda>      T70Kr$   r  r  c                 4   	 t        j                  d      }| j                  j                          t        j                  | j
                         t        j                  | j
                  d      | _        | j                  j                  d       | j                  j                          t        j                  |       t        j                  | j
                        }|j                  }| j                  |dz         y # t        j                         w xY w)N?   T)createrP  r  )r&   r  r>   rB   r+   r<   r   r  rP   r  r  r2  )r   	old_umaskr  r  s       r"   test_file_permszTestMbox.test_file_perms  s    
	 IIIOOIIdjj!TZZ=DIIIMM"IIOOHHYWWTZZ 

%%-)	 HHYs   B)D   Dc                    t         j                  j                         }d|d<   |j                  d       | j                  j                  |      }| j                  j                  |      }| j                  |j                         d       y )Nzjohn@example.comFromzNo newline at the endzNo newline at the end
)	r   r   r   set_payloadr>   rP   r   r   r   )r   r   r   s      r"   test_terminating_newlinez!TestMbox.test_terminating_newline  sl    --''),34IIMM'" ))--",,.0IJr$   c                    | j                   j                  d       t        | j                  d      5 }|j	                         }| j                  |dd  d       d d d        | j                   j                  d       t        | j                  d      5 }|j	                         }| j                  |dd  d       d d d        y # 1 sw Y   jxY w# 1 sw Y   y xY w)NzFrom: foo

0rK   rL   r  z0

zFrom: foo

0
)r>   rP   r  r<   r   r   )r   r   datas      r"   test_message_separatorzTestMbox.test_message_separator  s    		&'$**w/1668DT"#Y0 0 			()$**w/1668DT"#Y0 0/ 0/
 0/s   &C&CCCr
   )r.   r/   r0   r=   r"  r#  r$  r&   r  r  r  r7   r$   r"   r  r    s<    KHXW-/FG* H*$K
1r$   r  c                       e Zd ZddZy)TestMMDFNc                 .    t        j                  ||      S r
   )r   MMDFr  s      r"   r   zTestMMDF.<lambda>  r  r$   r
   )r.   r/   r0   r=   r7   r$   r"   r  r    s    KHr$   r  c                   J    e Zd ZddZd Zd Zd Zd Zd Zd Z	d	 Z
d
 Zd Zy)TestMHNc                 .    t        j                  ||      S r
   )r   MHr  s      r"   r   zTestMH.<lambda>  s    

40Ir$   c                 d    | j                  t        j                  | j                        dg       y )Nz.mh_sequences)r   r&   r  r<   r?   s    r"   rm   zTestMH.assertMailboxEmpty  s"    DJJ//1BCr$   c                    | j                   j                  d       | j                   j                  d       | j                   j                  d       | j                  t        | j                   j	                               d       | j                  t        | j                   j	                               t        d             y r  r  r?   s    r"   r  zTestMH.test_list_folders  r  r$   c                    d }| j                  | j                  |      | _        | j                  j                  d      }| j                  j	                  d      }|j                  | j                  dz         | j                  t        j                  j                  t        j                  j                  | j                  d                   | j                  j	                  d      }| j                  |j                  |j                         d         | j                  dz         | j                  |j                   | j                  j                          | j                  |j                   | j                  j                          y )Nc                      y r
   r7   r  s    r"   r  z-TestMH.test_get_folder.<locals>.dummy_factory  r  r$   r  r  r   )r=   r<   r>   r  r  rP   rQ   r   r&   r'   r(   r  r   rZ   r[   r   )r   r  
new_folderr  r  s        r"   r  zTestMH.test_get_folder  s
   	MM$**m<	YY)))4
))&&y1DNNU*+bggll4::y&IJK))&&y1++GLLN1,=>%/	1
 	j))499+=+=>g&&		(:(:;r$   c                 z   | j                   j                  d       | j                   j                  d       | j                  t        | j                   j	                               d       | j                  t        | j                   j	                               t        d             | j                   j                  d       | j                  t        | j                   j	                               d       | j                  t        | j                   j	                               t        d             | j                   j                  d       | j                  t        | j                   j	                               d       | j                  t        | j                   j	                               t        d             | j                   j                  d       | j                  t        | j                   j	                               d       | j                  t        | j                   j	                               t        d             | j                   j                  d       | j                  t        | j                   j	                               d	       | j                  | j                   j	                         g        y r  r  r?   s    r"   r  z"TestMH.test_add_and_remove_folders  r  r$   c                    | j                  | j                  j                         i        t        j                  | j
                  dz        }|j                  d       | j                  j                  |      }| j                  | j                  j                         d|gi       t        j                  | j
                  dz        }|j                  g d       | j                  j                  |      }| j                  | j                  j                         ||g|g|gd       |j                  dg       || j                  |<   | j                  | j                  j                         |g|g|g|gd       | j                  j                  |       | j                  | j                  j                         d|gi       y )Nr   r   rE   )r  repliedr   r   r  r  flagged)r   r  r  r  )
r   r>   get_sequencesr   r3   rQ   add_sequencerP   set_sequencesr   r   r   r   r  r   s        r"   test_sequenceszTestMH.test_sequences  sn   002B7  !!34% yy}}T"002UD6NC  !!3445yy}}T"002!4L4&I	KI;'		$002!F4&TF!%(	) 			002Yv4FGr$   c                     t        j                  | j                  dz        }|j                  d       | j                  j                  |      }| j                  j                  |      }y )Nr   r   )r   r3   rQ   r  r>   rP   r   )r   r   r   refmsg0s       r"   test_issue2625zTestMH.test_issue2625  sO      !!34% yy}}T"))''-r$   c                    t        j                  | j                  dz        }| j                  j	                  |      }| j                  j                          | j                  j                  |       | j                  j                          y )Nr   )r   r3   rQ   r>   rP   r4  r   r5  )r   r   r   s      r"   test_issue7627zTestMH.test_issue7627  s]      !!34yy}}T"						r$   c           	         t        j                  | j                  dz        }t        j                  | j                  dz        }t        j                  | j                  dz        }t        j                  | j                  dz        }|j                  ddg       |j                  dg       |j                  ddg       |j                  g d       | j                  j                  |      }| j                  j                  |      }| j                  j                  |      }| j                  j                  |      }| j                  | j                  j                         ||||g|g|g|g|gd	       | j                  j                  |       | j                  | j                  j                         |||g|g|g|gd
       | j                  j                          | j                  | j                  j                         g d       |}|dz   }|dz   }| j                  | j                  j                         g ddgdgdgd
       | j                  j                  |      }| j                  j                  |      }| j                  j                  |      }| j                  j                  |      }| j                  j                  |       | j                  j                  |       | j                  j                          | j                  j                          | j                  j                          | j                  | j                  j                         g ddgdgdgd
       y )Nr   rE   rF   rG   r   unseenr  r  )r   r  r  r  r  )r   r  r  r  )rE   rF   rG   )rE   rF   rG   rH   rI   )r   r3   rQ   r  r>   rP   r   r  r   packr[   r4  r5  )	r   r   r  r  msg3r   r   r   key3s	            r"   	test_packzTestMH.test_pack  s     !!34  !!34  !!34  !!34E8,-E7#E9-.45yy}}T"yy}}T"yy}}T"yy}}T"002!$tD1TF!%tfH	I 			002!$t,vdV!%(	) 			)95axax002%A31#N	P yy}}T"yy}}T"yy}}T"yy}}T"										002+ !s1#!>	?r$   c                 V    t         j                  j                  | j                  d      S )Nz.mh_sequences.lock)r&   r'   r  r<   r?   s    r"   r3  zTestMH._get_lock_pathG  s    ww||DJJ(<==r$   r
   )r.   r/   r0   r=   rm   r  r  r  r  r  r  r  r3  r7   r$   r"   r  r    s7    IHD3<&7&H(.*?X>r$   r  c                   2     e Zd ZddZd Z fdZd Z xZS )	TestBabylc                 .    t        j                  ||      S r
   )r   Babylr  s      r"   r   zTestBabyl.<lambda>M  s    dG0Lr$   c                     t        | j                  d      5 }| j                  |j                         g        d d d        y # 1 sw Y   y xY wrN  rP  rR  s     r"   rm   zTestBabyl.assertMailboxEmptyO  rS  rT  c                 *   t         |           | j                  j                          | j	                  | j
                         t        j                  t        j                  | j
                        dz         D ]  }t        j                  |        y rD  rE  rI  s     r"   rC   zTestBabyl.tearDownS  rL  r$   c                    | j                  | j                  j                         g        t        j                  | j
                  dz        }|j                  d       | j                  j                  |      }| j                  | j                  j                         dg       t        j                  | j
                  dz        }|j                  g d       | j                  j                  |      }| j                  t        | j                  j                               t        ddg             |j                  ddg       || j                  |<   | j                  t        | j                  j                               t        g d             | j                  j                  |       | j                  t        | j                  j                               t        dg             y )	Nr   r   rE   )r  answeredr   r  blahfiled)r   r  r  )r   r>   
get_labelsr   r4   rQ   	add_labelrP   
set_labelsr   r   r  s        r"   test_labelszTestBabyl.test_labelsZ  s[   --/4##DNNQ$67uyy}}T"--/%9##DNNQ$6723yy}}T"TYY1134c5%.6IJ)*		$TYY1134/0	2		TYY1134c6(mDr$   r
   )r.   r/   r0   r=   rm   rC   r  r  r  s   @r"   r  r  K  s    LH0+Er$   r  c                       e Zd Zd Zd Zy)FakeFileLikeObjectc                     d| _         y r8  closedr?   s    r"   __init__zFakeFileLikeObject.__init__o  s	    r$   c                     d| _         y r+  r  r?   s    r"   rB   zFakeFileLikeObject.closer  s	    r$   N)r.   r/   r0   r  rB   r7   r$   r"   r  r  m  s    r$   r  c                       e Zd Zd Zd Zy)FakeMailBoxc                     t         j                  j                  | dd        t        d      D cg c]  }t	                c}| _        y c c}w )NrP  c                      y r
   r7   )r   s    r"   r   z&FakeMailBox.__init__.<locals>.<lambda>y  s    r$   r   )r   ry  r  r   r  files)r   r   s     r"   r  zFakeMailBox.__init__x  s:      r+<=49"I>Iq(*I>
>s   A
c                      | j                   |   S r
   )r  rb   s     r"   r   zFakeMailBox.get_file|  s    zz#r$   N)r.   r/   r0   r  r   r7   r$   r"   r  r  v  s    ?r$   r  c                       e Zd Zd Zy)TestFakeMailBoxc                 "   t               }t        d      D ]*  }| j                  |j                  |   j                         , t        d      D ]  }||    	 t        d      D ]*  }| j                  |j                  |   j                         , y )Nr   )r  r   r2  r  r  r   )r   rR  r   s      r"   test_closing_fdzTestFakeMailBox.test_closing_fd  sp    mrASYYq\001 rAF rAOOCIIaL//0 r$   N)r.   r/   r0   r  r7   r$   r"   r  r    s    1r$   r  c                   l    e Zd Zej                  Zd Zd Zd Zd Z	d Z
d Zd Zd Zd	 Zd
 Zd Zd Zy)TestMessagec                 .    t         j                  | _        y r
   )r   r;   r<   r?   s    r"   r@   zTestMessage.setUp  s    %%
r$   c                 :    | j                  | j                         y r
   )r-   r<   r?   s    r"   rC   zTestMessage.tearDown  s      ,r$   c                     t        j                  t              }| j                  |      }| j	                  |       | j                  |       y r
   )r   rS   rR   r=   _post_initialize_hookr#   r   eMMr   s      r"   test_initialize_with_eMMz$TestMessage.test_initialize_with_eMM  s<    ''8mmC ""3'3r$   c                 r    | j                  t              }| j                  |       | j                  |       y r
   )r=   rR   r  r#   r   r   s     r"   test_initialize_with_stringz'TestMessage.test_initialize_with_string  s,    mmO,""3'3r$   c                    t        | j                  dd      5 }|j                  t               |j	                  d       | j                  |      }| j                  |       | j                  |       d d d        y # 1 sw Y   y xY w)Nr   rK   rL   r   )r  r<   r   rR   r   r=   r  r#   r   r   r   s      r"   test_initialize_with_filez%TestMessage.test_initialize_with_file  sa    $**dW5GGO$FF1I--"C&&s+s# 655s   AA<<Bc                    t        | j                  d      5 }|j                  t               |j	                  d       | j                  |      }| j                  |       | j                  |       d d d        y # 1 sw Y   y xY w)Nr   r   )r  r<   r   rV   r   r=   r  r#   r  s      r"    test_initialize_with_binary_filez,TestMessage.test_initialize_with_binary_file  s`    $**e$GG)*FF1I--"C&&s+s# %$$s   AA::Bc                    | j                         }| j                  |       | j                  |t        j                  j
                         | j                  |t        j
                         | j                  || j                          | j                  |j                         g        | j                  |j                                | j                  |j                                y r
   )r=   r  r   r   r   r   r   r   r[   r2  r   r   r   r  s     r"   test_initialize_with_nothingz(TestMessage.test_initialize_with_nothing  s    mmo""3'c5==#8#89c7??3c4==1R())+,#//+,r$   c                 8      j                  t         fd       y )Nc                  6     j                  t                     S r
   )r=   objectr?   s   r"   r   z9TestMessage.test_initialize_incorrectly.<locals>.<lambda>  s    T]]68-Dr$   )r   rC  r?   s   `r"   test_initialize_incorrectlyz'TestMessage.test_initialize_incorrectly  s    )%DEr$   c                     t        j                  t              }| j                  t              }|j                  D ].  }| j                  ||j                  dj                  |             0 y )Nz{} attribute does not exist)r   rS   rR   r=   __dict__r   format)r   r  r   attrs       r"   test_all_eMM_attributes_existz)TestMessage.test_all_eMM_attributes_exist  sP    ''8mmO,LLDMM$-44T:< !r$   c                     t        j                  t              }| j                         }|j	                  |       | j                  |       y r
   )r   rS   rR   r=   _become_messager#   r  s      r"   test_become_messagezTestMessage.test_become_message  s9    ''8mmoC 3r$   c                     | j                         | j                  D ]  } |       j                          t        j                  j                         | j                  t        fd       y )Nc                  &     j                        S r
   )_explain_to)r   	other_msgs   r"   r   z-TestMessage.test_explain_to.<locals>.<lambda>  s    S__Y-Gr$   )r=   r6   r  r   r   r   r   rC  )r   ri  r   r  s     @@r"   test_explain_tozTestMessage.test_explain_to  sX     mmo,,FIOOI& - MM))+	)%GHr$   c                      y r
   r7   r  s     r"   r  z!TestMessage._post_initialize_hook  s    r$   N)r.   r/   r0   r   r   r=   r@   rC   r  r  r  r  r  r  r  r  r  r  r7   r$   r"   r  r    sI    H&-  $$	-F< Ir$   r  c                   H    e Zd Zej                  Zd Zd Zd Zd Z	d Z
d Zy)TestMaildirMessagec                 t    | j                  |j                  d       | j                  |j                  d       y )Nr  rP  )r   _subdir_infor  s     r"   r  z(TestMaildirMessage._post_initialize_hook  s*    e,B'r$   c                 2   t        j                  t              | j                  j	                         d       j                  d       | j                  j	                         d       j                  d       | j                  j	                         d       | j                  t        fd       | j                  j	                         d       j                  d       | j                  j	                         d       | j                         y )Nr  r  c                  &     j                  d      S r  )r  r   s   r"   r   z0TestMaildirMessage.test_subdir.<locals>.<lambda>  s    cnnU.Cr$   )	r   r1   rR   r   r  r  r   rk   r#   r  s    @r"   test_subdirzTestMaildirMessage.test_subdir  s    $$_5)51u)51u)51*&CD)51u)513r$   c                    t        j                  t              }| j                  |j	                         d       | j                  |j                         d       |j                  d       | j                  |j                         d       | j                  |j	                         d       |j                  d       | j                  |j	                         d       |j                  d       | j                  |j	                         d       |j                  d       | j                  |j	                         d	       | j                  |j                         d       | j                  |       y )
NrP  r  FSDTPDPSTFTDFPSTTDRPFS)
r   r1   rR   r   r  r  r  add_flagremove_flagr#   r  s     r"   
test_flagszTestMaildirMessage.test_flags  s   $$_5"-)51c)51#.f&1T'2$/)513r$   c                    t        j                  t              }| j                  t	        |j                         t        j                         z
        d       |j                  d       | j                  |j                         d       y )N<           )	r   r1   rR   r  absget_dater  set_dater   r  s     r"   	test_datezTestMaildirMessage.test_date	  sX    $$_5CLLNTYY[892>S-r$   c                 .   t        j                  t              | j                  j	                         d       j                  d       | j                  j	                         d       | j                  t        fd       | j                         y )NrP  z	1,foo=barc                  &     j                  d       S r
   )r  r  s   r"   r   z.TestMaildirMessage.test_info.<locals>.<lambda>  s    S\\$-?r$   )	r   r1   rR   r   get_infor  r   rC  r#   r  s    @r"   	test_infozTestMaildirMessage.test_info  sj    $$_5,[!5)%?@3r$   c                     t        j                  t              }| j                  |j	                         d       |j                  d       | j                  |j                         d       | j                  |j	                         d       |j                  d       | j                  |j                         d       | j                  |j	                         d       |j                  d       | j                  |j                         d       | j                  |j	                         d       |j                  d       | j                  |j                         d       | j                  |j	                         d       | j                  |       y )	NrP  SFr  z2,FSz1,RPTDz2,D)r   r1   rR   r   r  r  r  r  r  r  r#   r  s     r"   test_info_and_flagsz&TestMaildirMessage.test_info_and_flags  s   $$_5,d$/0T"-."-.S#./3r$   N)r.   r/   r0   r   r1   r=   r  r  r  r  r  r"  r7   r$   r"   r   r     s+    %%H(  ".  r$   r   c                   D    e Zd Zej                  Zd Zd Zd Zd Z	ddZ
y)_TestMboxMMDFMessagec                 &    | j                  |       y r
   )_check_fromr  s     r"   r  z*_TestMboxMMDFMessage._post_initialize_hook0  s    r$   c                    t        j                  t              }|j                  d       t        j                  |      }| j                  |j                         d       | j                  |j                         d       y )Nra  r`  )r   r   rR   set_unixfromr2   r   rc  rd  r  s     r"   test_initialize_with_unixfromz2_TestMboxMMDFMessage.test_initialize_with_unixfrom3  s_    ooo.,-!!#&8))+-@Ar$   c                 f   t        j                  t              }| j                  |       | j	                  |j                                |j                  d       | j                  |j                         d       | j	                  |j                                |j                  dd       | j                  |d       | j	                  |j                                |j                  dt        j                                | j                  |d       | j	                  |j                                y )Nzfoo barfoo@barTz	blah@temp)r   r2   rR   r&  r   rd  set_fromr   rc  r  	localtimer  s     r"   	test_fromz_TestMboxMMDFMessage.test_from;  s    !!/2#**,-Y3#**,-Y%i(#**,-[$.."23k*#**,-r$   c                     t        j                  t              }| j                  |j	                         d       |j                  d       | j                  |j	                         d       |j                  d       | j                  |j	                         d       |j                  d       | j                  |j	                         d       |j                  d       | j                  |j	                         d       | j                  |       y )	NrP  r	  XODRRODXFARODFAXFDXARO)	r   r2   rR   r   r  r  r  r  r#   r  s     r"   r  z_TestMboxMMDFMessage.test_flagsJ  s    !!/2"-c#.f&1T(3$/3r$   Nc                 x    |d}| j                  t        j                  |dz   |j                                      y )NzMAILER-DAEMONz. \w{3} \w{3} [\d ]\d [\d ]\d:\d{2}:\d{2} \d{4})r  r  r  rc  )r   r   senders      r"   r&  z _TestMboxMMDFMessage._check_fromX  s7    >$FRXXJJ  	!r$   r
   )r.   r/   r0   r   _mboxMMDFMessager=   r  r)  r.  r  r&  r7   r$   r"   r$  r$  ,  s'    ''HB. !r$   r$  c                   $    e Zd Zej                  Zy)TestMboxMessageN)r.   r/   r0   r   r2   r=   r7   r$   r"   r:  r:  a      ""Hr$   r:  c                   0    e Zd Zej                  Zd Zd Zy)TestMHMessagec                 <    | j                  |j                  g        y r
   )r   
_sequencesr  s     r"   r  z#TestMHMessage._post_initialize_hookj  s    ,r$   c                    t        j                  t              }| j                  |j	                         g        |j                  dg       | j                  |j	                         dg       |j                  g        | j                  |j	                         g        |j                  d       | j                  |j	                         dg       |j                  d       | j                  |j	                         ddg       |j                  d       | j                  |j	                         ddg       |j                  d       | j                  |j	                         dg       |j                  d       | j                  |j	                         ddg       |j                  d       | j                  |j	                         ddg       |j                  ddg       | j                  |j	                         ddg       y )Nfoobarr  r  r  )r   r3   rR   r   r  r  r  remove_sequencer  s     r"   r  zTestMHMessage.test_sequencesm  s   0**,b18*%**,xj9"**,b1"**,xj9#**,x.CD#**,x.CDH%**,yk:"**,y(.CDI&**,y(.CD8Y/0**,x.CDr$   N)r.   r/   r0   r   r3   r=   r  r  r7   r$   r"   r=  r=  f  s      H-Er$   r=  c                   6    e Zd Zej                  Zd Zd Zd Zy)TestBabylMessagec                 <    | j                  |j                  g        y r
   )r   _labelsr  s     r"   r  z&TestBabylMessage._post_initialize_hook  s    b)r$   c                    t        j                  t              }| j                  |j	                         g        |j                  dg       | j                  |j	                         dg       |j                  g        | j                  |j	                         g        |j                  d       | j                  |j	                         dg       |j                  d       | j                  |j	                         ddg       |j                  d       | j                  |j	                         ddg       |j                  d       | j                  |j	                         dg       |j                  d       | j                  |j	                         ddg       |j                  d       | j                  |j	                         ddg       |j                  ddg       | j                  |j	                         ddg       y )NrA  r  resentr  r  )r   r4   rR   r   r  r  r  remove_labelr  s     r"   r  zTestBabylMessage.test_labels  s   ""?3)2.z")H:6r)2.g)G95h)GX+>?h)GX+>?!)H:6h)Hh+?@")Hh+?@*-.)Hj+ABr$   c                    t        j                  t              }|j                         }| j	                  |j                         g        | j                  |j                                d|d<   d|d<   | j	                  |j                         j                         g        |j                  |       |j                         }| j	                  |j                         ddg       | j	                  |d   d       | j	                  |d   d       | j                  |j                                |j                          | j	                  |j                         ddg       | j                  |j                                |j                         }| j	                  |j                         g d       dD ]  }| j	                  ||   ||           y )Nz
FooBar 1.0
User-AgentBlahz
X-Whatever)rK  Dater  ToSubject)
r   r4   rR   get_visibler   r[   r   r   set_visibleupdate_visible)r   r   visibleheaders       r"   test_visiblezTestBabylMessage.test_visible  s{   ""?3//#,'--/0 , &*//126 //#,)EF.=.7'--/0,)EF'--/0//# *5 	6EFWV_c&k: Fr$   N)	r.   r/   r0   r   r4   r=   r  r  rU  r7   r$   r"   rD  rD    s    ##H*C.;r$   rD  c                   $    e Zd Zej                  Zy)TestMMDFMessageN)r.   r/   r0   r   r5   r=   r7   r$   r"   rW  rW    r;  r$   rW  c                       e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zy)TestMessageConversionc                     | j                   D ]4  }t        j                  t              } ||      }| j	                  |       6 y r
   )r6   r   r   rR   r#   )r   ri  	msg_plainr   s       r"   test_plain_to_xz%TestMessageConversion.test_plain_to_x  s8    ,,F8I#Cs# -r$   c                     | j                   D ]4  } |t              }t        j                  |      }| j	                  |       6 y r
   )r6   rR   r   r   r#   )r   ri  r   r[  s       r"   test_x_to_plainz%TestMessageConversion.test_x_to_plain  s8    ,,F)C,Iy) -r$   c                 `    | j                   D ]  } |t              }| j                  |       ! y r
   )r6   rV   r#   )r   ri  r   s      r"   test_x_from_bytesz'TestMessageConversion.test_x_from_bytes  s+    ,,F./Cs# -r$   c                 Z    | j                   D ]  | j                  t        fd        y )Nc                        d      S r8  r7   )ri  s   r"   r   z9TestMessageConversion.test_x_to_invalid.<locals>.<lambda>  s	    r$   )r6   r   rC  )r   ri  s    @r"   test_x_to_invalidz'TestMessageConversion.test_x_to_invalid  s$    ,,Fi)>? -r$   c                    | j                   D ci c]  }| |t              j                   }}| j                   D ]y  }| j                   D ]h  }||u r |t              } ||      }||   D cg c]  }|||   vr| }}|D ]/  }	| j                  |	|j                  dj	                  ||             1 j { y c c}w c c}w )Nzwhile converting {} to {})r6   rR   r  r  r  )
r   ri  	referenceclass1class2sourcer,   atype_specificr  s
             r"   3test_type_specific_attributes_removed_on_conversionzITestMessageConversion.test_type_specific_attributes_removed_on_conversion  s    &*&<&<>&<F VO4===&< 	 >,,F00V#0,5f,= !B,=q&'y/@&@ "#,= !B)D$$T6??3::66JL * 1 ->!Bs   B8-B=c                    t        j                  t              }|j                  d       |j	                  d       |j                         }t        j                  |      }| j                  |       | j                  |j                         d       | j                  |j                         d       | j                  |j                         |       y )NDFPRSTr  )
r   r1   rR   r  r  r  r#   r   r  r  )r   msg_maildirdater   s       r"   test_maildir_to_maildirz-TestMessageConversion.test_maildir_to_maildir  s    ,,_=h'u%##%$$[13(3)51.r$   c                 n   d}t         j                  t         j                  fD ]  }t        j                  t              }|j                  d       |D ]  \  }}|j                  |        ||      }| j                  |j                         |       | j                  |j                         dt        j                  t        j                  d            z         | j                  |j                                 |j                  d       | j                   ||      j                         d        y )N))r!  rP  r	  r	  )PrP  )RA)r  rt  )Tr!  )rm  RDFAr  zMAILER-DAEMON %sr  RODFA)r   r2   r5   r1   rR   r  r  r   r  rc  r  asctimegmtimer   rd  r  )r   pairsri  rn  settingresultr   s          r"   test_maildir_to_mboxmmdfz.TestMessageConversion.test_maildir_to_mboxmmdf  s    1**G,?,?@F!00AK  %#(%%g.[)  &9  1C!\\$++c*:;2< =!!#"2"2"45 $) ""5)VK0::<gF Ar$   c           	         t        j                  t              }ddgfdddgfddgfdddgfdg fd	dgfd
ddgff}|D ]I  \  }}|j                  |       | j	                  t        j
                  |      j                         |       K y )Nr!  r  r	  r  rs  rt  r  r  rv  rm  )r   r1   rR   r  r   r3   r  r   rn  r{  r|  r}  s        r"   test_maildir_to_mhz(TestMessageConversion.test_maildir_to_mh  s    ,,_=z"S8Y*?$@z"S8Y*?$@3)z"X	9/E$FH  %OGV!!'*W..{;IIK#%  %r$   c           	         t        j                  t              }ddgfddgfdddgfdddgfdg fd	dd
gfdg dff}|D ]I  \  }}|j                  |       | j	                  t        j
                  |      j                         |       K y )Nr!  r  r	  rs  	forwardedrt  r  r  rv  deletedrm  )r  r  r  )r   r1   rR   r  r   r4   r  r  s        r"   test_maildir_to_babylz+TestMessageConversion.test_maildir_to_babyl  s    ,,_=z"S8*$5+./#*7M1NrS8Y"78@AC  %OGV!!'*W11+>IIK#%  %r$   c                    t         j                  t         j                  fD ]  } |t              }|j	                  dt        j                  d             d}|D ]k  \  }}|j                  |       t        j                  |      }| j                  |j                         |       | j                  |j                         d       m |j                  d       | j                  t        j                  |      j                         d        y )Nr+  r  ))rt  r  )OrP  )r!  rv  rr  )ru  rt  )rx  FRSTr  r  )r   r2   r5   rR   r,  r  rz  r  r1   r   r  r  r  )r   ri  msg_mboxMMDFr{  r|  r}  r   s          r"   test_mboxmmdf_to_maildirz.TestMessageConversion.test_mboxmmdf_to_maildir  s    **G,?,?@F!/2L!!)T[[-=>(E#(&&w/,,\:  &9  5	 $)
 ""3'W33LALLN"$ Ar$   c                     t         j                  t         j                  fD ]  } |t              }|j	                  d       |j                  d       | j                  |j                                t         j                  t         j                  fD ]i  } ||      }| j                  |j                         d       | j                  |j                         d       | j                  |j                                k  y )Nrx  r+  )r   r2   r5   rR   r  r,  r   rd  r   r  rc  )r   ri  r  class2_r  s        r"   test_mboxmmdf_to_mboxmmdfz/TestMessageConversion.test_mboxmmdf_to_mboxmmdf/  s    **G,?,?@F!/2L""7+!!),l779:#//1D1DE|,  !17;  )<!!$"3"3"56	 F Ar$   c           	      :   t         j                  t         j                  fD ]x  } |t              }dg fddgfddgfdddgfdddgfd	ddgff}|D ]I  \  }}|j	                  |       | j                  t        j                  |      j                         |       K z y )
Nrt  r  r  r!  r	  r  ru  r  rx  )r   r2   r5   rR   r  r   r3   r  )r   ri  r  r{  r|  r}  s         r"   test_mboxmmdf_to_mhz)TestMessageConversion.test_mboxmmdf_to_mh<  s    **G,?,?@F!/2L2Yxj 1C(3DHi01Hi01	9568E $)&&w/  !2!2<!@!N!N!P!') $) Ar$   c           	      :   t         j                  t         j                  fD ]x  } |t              }dg fddgfdddgfddgfdddgfd	ddgff}|D ]I  \  }}|j	                  |       | j                  t        j                  |      j                         |       K z y )
Nrt  r  r  r!  r  r	  ru  r  rx  )r   r2   r5   rR   r  r   r4   r  )r   ri  r   r{  r|  r}  s         r"   test_mboxmmdf_to_babylz,TestMessageConversion.test_mboxmmdf_to_babylI  s    **G,?,?@F)C2Yxj 1Hi01C(3DHj12	:679E $)g&  !5!5c!:!E!E!GP $) Ar$   c                    d}|D ]  \  }}t        j                  t              }|j                  |       | j	                  t        j
                  |      j                         |       | j	                  t        j
                  |      j                         d        t        j                  t              }|j                  d       |j                  d       |j                  d       | j	                  t        j
                  |      j                         d       | j	                  t        j
                  |      j                         d       y )N)r  rP  )r  RS)r  r  r  r  r  r  r  )r   r3   rR   r  r   r1   r  r  r   r{  r|  r}  r   s        r"   test_mh_to_maildirz(TestMessageConversion.test_mh_to_maildirU  s    F$OGV##O4CW%W33C8BBDfMW33C8CCEuM	  %
 0"##//4>>@$G//4??A5Ir$   c                 4   d}|D ]z  \  }}t        j                  t              }|j                  |       t         j                  t         j
                  fD ](  }| j                   ||      j                         |       * | t        j                  t              }|j                  d       |j                  d       |j                  d       t         j                  t         j
                  fD ](  }| j                   ||      j                         d       * y )N)r  r  )r  ROA)r  ROFr  r  r  OFA)r   r3   rR   r  r2   r5   r   r  )r   r{  r|  r}  r   ri  s         r"   test_mh_to_mboxmmdfz)TestMessageConversion.test_mh_to_mboxmmdfd  s    I$OGV##O4CW%"..0C0CD  !6!6!8&A E  %
 0"##**G,?,?@FVC[224e< Ar$   c                    t        j                  t              }|j                  d       |j                  d       |j                  d       | j	                  t        j                  |      j                         g d       y )Nr  r  r  )r  r  r  )r   r3   rR   r  r   r  r  s     r"   test_mh_to_mhz#TestMessageConversion.test_mh_to_mhs  sc    0"##**3/==?9	;r$   c                    ddgfddgfdg ff}|D ]b  \  }}t        j                  t              }|j                  |       | j	                  t        j
                  |      j                         |       d t        j                  t              }|j                  d       |j                  d       |j                  d       | j	                  t        j
                  |      j                         ddg       y )Nr  r  r  r  )r   r3   rR   r  r   r4   r  r  s        r"   test_mh_to_babylz&TestMessageConversion.test_mh_to_babyl|  s    XJ')j\)BR"$OGV##O4CW%W11#6AACVL  % 0"##--c2==?"J/	1r$   c                 j   d}|D ]  \  }}t        j                  t              }|j                  |       | j	                  t        j
                  |      j                         |       | j	                  t        j
                  |      j                         d        t        j                  t              }dD ]  }|j                  |        | j	                  t        j
                  |      j                         d       | j	                  t        j
                  |      j                         d       y )N)r  )r  ST)r  r  )r  r  )r  PS)editedr  )rH  r  r  r  r  r  r  r  r  rH  PRT)r   r4   rR   r  r   r1   r  r  r   r{  r|  r}  r   labels         r"   test_babyl_to_maildirz+TestMessageConversion.test_babyl_to_maildir  s    #  %OGV&&7CMM'"W33C8BBDfMW33C8CCEuM	  %
 ""?3*EMM% * 	//4>>@%H//4??A5Ir$   c                    d}|D ]z  \  }}t         j                  t         j                  fD ]R  }t        j                  t              }|j                  |       | j                   ||      j                         |       T | t        j                  t              }dD ]  }|j                  |        t         j                  t         j                  fD ](  }| j                   ||      j                         d       * y )N)r  )r  ROD)r  r5  )r  r  )r  r5  )r  r5  )rH  r5  r  ODA)r   r2   r5   r4   rR   r  r   r  )r   r{  r|  r}  ri  r   r  s          r"   test_babyl_to_mboxmmdfz,TestMessageConversion.test_babyl_to_mboxmmdf  s    #  %OGV"..0C0CD**?;g&  !6!6!8&A E  %
 ""?3*EMM% * **G,?,?@FVC[224e< Ar$   c                    ddgfdg fdg fddgfdg fdg fdg ff}|D ]b  \  }}t        j                  t              }|j                  |       | j	                  t        j
                  |      j                         |       d t        j                  t              }d	D ]  }|j                  |        | j	                  t        j
                  |      j                         ddg       y )
Nr  r  r  r  r  r  r  rH  r  )r   r4   rR   r  r   r3   r  r  s         r"   test_babyl_to_mhz&TestMessageConversion.test_babyl_to_mh  s    XJ')R7B-yk*[",="~B!  %OGV&&7CMM'"W..s3AACVL  % ""?3*EMM% * 	**3/==?"I.	0r$   c                 6   t        j                  t              }|j                          dD ]  }|j	                  |        t        j                  |      }| j                  |j                         g d       | j                  |j                         j                         |j                         j                                |j                         j                         D ]6  }| j                  |j                         |   |j                         |          8 y )Nr  )	r   r4   rR   rR  r  r   r  rP  r[   )r   r   r  r  r   s        r"   test_babyl_to_babylz)TestMessageConversion.test_babyl_to_babyl  s    ""?3*EMM% * ##C(* -7 	8 	*//143C3C3E3J3J3LM??$))+CS__.s3T5E5E5G5LM ,r$   N)r.   r/   r0   r\  r^  r`  rc  rk  rp  r~  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r7   r$   r"   rY  rY    sr    $*$@
L
/G"	%
%$ 7)
QJ=;1J"="0 Nr$   rY  c                   0    e Zd Zd Zd Zd Zd Zd Zd Zy)TestProxyFileBasec                    |j                  d       | j                  |j                         d       |j                  d       | j                  |j                         d       |j                  d       | j                  |j                  d      d       |j                  d       | j                  |j                  d      d       |j                  d       | j                  |j                  d      d	       y )
Nr      barrE   s   arrF   s   ba     r)r   r   r   r   proxys     r"   
_test_readzTestProxyFileBase._test_read  s    

1v.

1u-

1A.

1B/

1D)40r$   c                 d   t         j                  j                         }|j                  d       | j	                  |j                         d|z          | j	                  |j                         d|z          | j	                  |j                         d|z          | j	                  |j                         d       |j                  d       | j	                  |j                         d|z          |j                  ddt        t         j                        z  z          | j	                  |j                         d|z          |j                  ddt        t         j                        z  z          | j	                  |j                  d      d	       | j	                  |j                  d
      d|z          y )Nr      foor     fred   bobrF      orJ   s   fris   ed)r&   r   r`   r   r   readliner   r   r  r   s      r"   _test_readlinez TestProxyFileBase._test_readline  s>   **##%

1)6G+;<)6G+;<)7W+<=)62

1)4'>:

1q3rzz?**+)7W+<=

1q3rzz?**+*E2,ego>r$   c                 D   t         j                  j                         }|j                  d       | j	                  |j                         d|z   d|z   d|z   dg       |j                  d       | j	                  |j                  d      d|z   g       |j                  dt        |      z          | j	                  |j                  dt        |      z         d|z   d|z   g       |j                  d       | j	                  |j                  d	      |d|z   d|z   dg       y )
Nr   r  r  r  r  rF   rG   rH   r  )r&   r   r`   r   r   rQ  r   r  s      r"   _test_readlinesz!TestProxyFileBase._test_readlines  s   **##%

1*Vg-=+1G+;+2W+<f-F 	G 	

1+fw.>-?@

1s7|#$S\)9:w&'(9:	<

1.&7:J/6/@&1J 	Kr$   c                    t         j                  j                         }|j                  d       t	        |      }| j                  t        |      d|z          | j                  t        |      d|z          | j                  t        |      d|z          | j                  t        |      d       | j                  t        t        |       y )Nr   r  r  r  r  )	r&   r   r`   r   iterr   nextr   StopIteration)r   r  r   iterators       r"   _test_iterationz!TestProxyFileBase._test_iteration  s    **##%

1;h')9:h')9:h7):;h0-x8r$   c                    t         j                  j                         }|j                  d       | j	                  |j                         d       | j	                  |j                  t        |            |       |j                  dd       | j	                  |j                  dt        |      z         d|z          |j                  dt        |      z
  d       | j	                  |j                  d      d       |j                  dd       | j	                  |j                         d|z   dz   |z          |j                  d	       | j                  |j                                y )
NrG   rF   rE   r  r  r  r   r  d   )	r&   r   r`   r   r   tellr   r   r2  r  s      r"   _test_seek_and_tellz%TestProxyFileBase._test_seek_and_tell  s   **##%

1q)CL17;

1aAG$45tg~F

2G$a(A/

1atg~'>'HI

3&r$   c                     | j                  |j                         |j                          | j                  |j                         |j                          | j                  |j                         y r
   )r2  r  rB   r   r  s     r"   _test_closezTestProxyFileBase._test_close  sF    &%%r$   N)	r.   r/   r0   r  r  r  r  r  r  r7   r$   r"   r  r    s!    1? K 	9'&r$   r  c                   B    e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zy
)TestProxyFilec                 d    t         j                  | _        t        | j                  d      | _        y Nr   r   r;   r<   r  rp  r?   s    r"   r@   zTestProxyFile.setUp"  !    %%
$**e,
r$   c                 n    | j                   j                          | j                  | j                         y r
   rp  rB   r-   r<   r?   s    r"   rC   zTestProxyFile.tearDown&  $    

  ,r$   c                    | j                   j                  d       | j                   j                         }t        j                  | j                         }| j                  |j                         |       | j                  | j                   j                         |       t        j                  | j                   d      }| j                  |j                         d       | j                  | j                   j                         |       y )Nr  r   )rp  r   r  r   
_ProxyFiler   )r   posproxy0proxy1s       r"   test_initializezTestProxyFile.test_initialize*  s    

 jjoo##DJJ/,*C0##DJJ2**C0r$   c                     | j                   j                  d       | j                  t        j                  | j                                y )Nr  )rp  r   r  r   r  r?   s    r"   	test_readzTestProxyFile.test_read5  s/    

 **4::67r$   c                    | j                   j                  t        dt        j                  dt        j                  dt        j                  dd             | j                  t        j                  | j                                y Nr   r  fredbobr   )rp  r   bytesr&   r   r  r   r  r?   s    r"   test_readlinezTestProxyFile.test_readline9  sU    



BJJ24** >?FH 	IG..tzz:;r$   c                    | j                   j                  t        dt        j                  dt        j                  dt        j                  dd             | j                  t        j                  | j                                y r  )rp  r   r  r&   r   r  r   r  r?   s    r"   test_readlineszTestProxyFile.test_readlines>  U    



BJJ24** >?FH 	IW//

;<r$   c                    | j                   j                  t        dt        j                  dt        j                  dt        j                  dd             | j                  t        j                  | j                                y r  )rp  r   r  r&   r   r  r   r  r?   s    r"   test_iterationzTestProxyFile.test_iterationC  r  r$   c                     | j                   j                  t        dt        j                  dt        j                  d             | j                  t        j                  | j                                y Nr   r  r   )rp  r   r  r&   r   r  r   r  r?   s    r"   test_seek_and_tellz TestProxyFile.test_seek_and_tellH  sE    

rzz2::FPQ  !3!3DJJ!?@r$   c                     | j                   j                  t        dt        j                  dt        j                  d             | j                  t        j                  | j                                y r  )rp  r   r  r&   r   r  r   r  r?   s    r"   r9  zTestProxyFile.test_closeL  sE    

rzz2::FPQ++DJJ78r$   Nr.   r/   r0   r@   rC   r  r  r  r  r  r  r9  r7   r$   r"   r  r     s0    --	18<
=
=
A9r$   r  c                   B    e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zy
)TestPartialFilec                 d    t         j                  | _        t        | j                  d      | _        y r  r  r?   s    r"   r@   zTestPartialFile.setUpS  r  r$   c                 n    | j                   j                          | j                  | j                         y r
   r  r?   s    r"   rC   zTestPartialFile.tearDownW  r  r$   c                    | j                   j                  t        dt        j                  z   dz   d             | j                   j                         }t        j                  | j                   dd      }| j                  |j                         d       | j                  | j                   j                         |       y )Nr   r  r   rF   rI   r   )	rp  r   r  r&   r   r  r   _PartialFiler   )r   r  r  s      r"   r  zTestPartialFile.test_initialize[  s    

urzz1E97CDjjoo$$TZZA6q)*C0r$   c                     | j                   j                  t        dd             | j                  t	        j
                  | j                   dd             y )Nz	***bar***r   rG   rJ   )rp  r   r  r  r   r  r?   s    r"   r  zTestPartialFile.test_readc  s:    

{G45,,TZZA>?r$   c                 P   | j                   j                  t        dt        j                  dt        j                  dt        j                  dd             | j                  t        j                  | j                   dddt        t        j                        z  z                y )	Nz!!!!!foor  r  zbob!!!!!r   rI      rG   )	rp  r   r  r&   r   r  r   r  r   r?   s    r"   r  zTestPartialFile.test_readlineg  sr    

**bjj"** >?FH 	IG00Q13a#bjj/6I1IK 	Lr$   c                 P   | j                   j                  t        dt        j                  dt        j                  dt        j                  dd             | j                  t        j                  | j                   dddt        t        j                        z  z                y )	Nr   r  r  zbob?????r   r      rG   )	rp  r   r  r&   r   r  r   r  r   r?   s    r"   r  zTestPartialFile.test_readlinesm  r    

**bjj"** >?FH 	IW11$**a24q3rzz?7J2JL 	Mr$   c                 P   | j                   j                  t        dt        j                  dt        j                  dt        j                  dd             | j                  t        j                  | j                   dddt        t        j                        z  z                y )	N____foor  r  zbob####r   rH      rG   )	rp  r   r  r&   r   r  r   r  r   r?   s    r"   r  zTestPartialFile.test_iterations  r  r$   c                 .   | j                   j                  t        dt        j                  dt        j                  dd             | j                  t        j                  | j                   dddt        t        j                        z  z                y )Nz(((foor  z$$$r   rG   	   rF   )	rp  r   r  r&   r   r  r   r  r   r?   s    r"   r  z"TestPartialFile.test_seek_and_telly  sb    

RZZLgVW  !5!5djj!67!c"**o:M6M"O 	Pr$   c                 .   | j                   j                  t        dt        j                  dt        j                  dd             | j                  t        j                  | j                   dddt        t        j                        z  z                y )Nz&foor  ^r   rE   rJ   rG   )	rp  r   r  r&   r   r  r   r  r   r?   s    r"   r9  zTestPartialFile.test_close~  sb    

RZZH'RS--djj!./!c"**o2E.EG 	Hr$   Nr  r7   r$   r"   r  r  Q  s5    --1@LMMP
Hr$   r  z6From some.body@dummy.domain  Sat Jul 24 13:43:35 2004
z]From: some.body@dummy.domain
To: me@my.domain
Subject: Simple Test

This is a dummy message.
c                   8    e Zd Zd Zd Zd	dZd Zd Zd Zd Z	y)
MaildirTestCasec                    t         j                  | _        t        j                  j                  | j                        r t        j                  | j                         nHt        j                  j                  | j                        rt        j                  | j                         t        j                  | j                         t        j                  t        j                  j                  | j                  d             t        j                  t        j                  j                  | j                  d             t        j                  t        j                  j                  | j                  d             d| _        g | _        y )Nr  r  r  rE   )r   r;   _dirr&   r'   r(   r)   isfiler+   r  r  _counter	_msgfilesr?   s    r"   r@   zMaildirTestCase.setUp  s    $$	77==#TYY'WW^^DII&TYY'

dii/0
dii/0
dii/0r$   c                 
   t        t        t        j                  | j                               t        j                  t        j                  j                  | j                  d             t        j                  t        j                  j                  | j                  d             t        j                  t        j                  j                  | j                  d             t        j                  | j                         y )Nr  r  r  )
r   mapr&   r+   r  r   rmdirr'   r  r	  r?   s    r"   rC   zMaildirTestCase.tearDown  s    SDNN+,TYY67TYY67TYY67		"r$   c                 R   t        t        j                         dz        }| j                  }| xj                  dz  c_        dj                  t	        |      t	        |      ddf      }t
        j                  j                  | j                  d|      }t
        j                  j                  | j                  ||      }t        |dd	      5 }| j                  j                  |       |r|j                  t               |j                  t               d d d        	 t        j                  ||       | j                  j                  |       |S # 1 sw Y   =xY w# t        t         f$ r: t        |d      5 }|j                  t               d d d        n# 1 sw Y   nxY wY qw xY w)
Ni@B rE   .
myhostnamemydomainr  r  rK   rL   )r  r  r  r  strr&   r'   r	  r  r  rO   r   FROM_DUMMY_MESSAGElinkAttributeErrorPermissionError)	r   dirr  tr  r   tmpnamenewnamefps	            r"   createMessagezMaildirTestCase.createMessage  s.   		g%&mm88SVSX|ZHI'',,tyy%:'',,tyy#x8'31RNN!!'*HH]#	 2
	(GGGW% 	g& 21 0 	(gs#r' $##	(s7   AEE EF&8F	F&F 	F&%F&c                     	 t        j                  t        j                        | _        | j                  | j                  j                                | j                  | j                  j                                y r
   )r   r  r   r;   r  r   r  r?   s    r"   test_empty_maildirz"MaildirTestCase.test_empty_maildir  sQ    + OOI$4$45	 	$))..*+$))..*+r$   c                 l   | j                  d       t        j                  t        j                        | _        | j                  | j
                  j                                | j                  | j
                  j                                | j                  | j
                  j                                y )Nr  	r  r   r  r   r;   r  r  r  r   r?   s    r"   test_nonempty_maildir_curz)MaildirTestCase.test_nonempty_maildir_cur  q    5!OOI$4$45	TYY^^-.$))..*+$))..*+r$   c                 l   | j                  d       t        j                  t        j                        | _        | j                  | j
                  j                                | j                  | j
                  j                                | j                  | j
                  j                                y )Nr  r#  r?   s    r"   test_nonempty_maildir_newz)MaildirTestCase.test_nonempty_maildir_new  r%  r$   c                    | j                  d       | j                  d       t        j                  t        j                        | _        | j                  | j
                  j                                | j                  | j
                  j                                | j                  | j
                  j                                | j                  | j
                  j                                y )Nr  r  r#  r?   s    r"   test_nonempty_maildir_bothz*MaildirTestCase.test_nonempty_maildir_both  s    5!5!OOI$4$45	TYY^^-.TYY^^-.$))..*+$))..*+r$   N)F)
r.   r/   r0   r@   rC   r  r!  r$  r'  r)  r7   r$   r"   r  r    s%    #(,,,,r$   r  aK  Return-Path: <gkj@gregorykjohnson.com>
X-Original-To: gkj+person@localhost
Delivered-To: gkj+person@localhost
Received: from localhost (localhost [127.0.0.1])
        by andy.gregorykjohnson.com (Postfix) with ESMTP id 356ED9DD17
        for <gkj+person@localhost>; Wed, 13 Jul 2005 17:23:16 -0400 (EDT)
Delivered-To: gkj@sundance.gregorykjohnson.com
Received: from localhost [127.0.0.1]
        by localhost with POP3 (fetchmail-6.2.5)
        for gkj+person@localhost (single-drop); Wed, 13 Jul 2005 17:23:16 -0400 (EDT)
Received: from andy.gregorykjohnson.com (andy.gregorykjohnson.com [64.32.235.228])
        by sundance.gregorykjohnson.com (Postfix) with ESMTP id 5B056316746
        for <gkj@gregorykjohnson.com>; Wed, 13 Jul 2005 17:23:11 -0400 (EDT)
Received: by andy.gregorykjohnson.com (Postfix, from userid 1000)
        id 490CD9DD17; Wed, 13 Jul 2005 17:23:11 -0400 (EDT)
Date: Wed, 13 Jul 2005 17:23:11 -0400
From: "Gregory K. Johnson" <gkj@gregorykjohnson.com>
To: gkj@gregorykjohnson.com
Subject: Sample message
Message-ID: <20050713212311.GC4701@andy.gregorykjohnson.com>
Mime-Version: 1.0
Content-Type: multipart/mixed; boundary="NMuMz9nt05w80d4+"
Content-Disposition: inline
User-Agent: Mutt/1.5.9i


--NMuMz9nt05w80d4+
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

This is a sample message.

--
Gregory K. Johnson

--NMuMz9nt05w80d4+
Content-Type: application/octet-stream
Content-Disposition: attachment; filename="text.gz"
Content-Transfer-Encoding: base64

H4sICM2D1UIAA3RleHQAC8nILFYAokSFktSKEoW0zJxUPa7wzJIMhZLyfIWczLzUYj0uAHTs
3FYlAAAA

--NMuMz9nt05w80d4+--
r   ))zReturn-Pathz<gkj@gregorykjohnson.com>)zX-Original-Togkj+person@localhost)Delivered-Tor*  )Receivedzfrom localhost (localhost [127.0.0.1])
        by andy.gregorykjohnson.com (Postfix) with ESMTP id 356ED9DD17
        for <gkj+person@localhost>; Wed, 13 Jul 2005 17:23:16 -0400 (EDT))r+  z gkj@sundance.gregorykjohnson.com)r,  zfrom localhost [127.0.0.1]
        by localhost with POP3 (fetchmail-6.2.5)
        for gkj+person@localhost (single-drop); Wed, 13 Jul 2005 17:23:16 -0400 (EDT))r,  zfrom andy.gregorykjohnson.com (andy.gregorykjohnson.com [64.32.235.228])
        by sundance.gregorykjohnson.com (Postfix) with ESMTP id 5B056316746
        for <gkj@gregorykjohnson.com>; Wed, 13 Jul 2005 17:23:11 -0400 (EDT))r,  ztby andy.gregorykjohnson.com (Postfix, from userid 1000)
        id 490CD9DD17; Wed, 13 Jul 2005 17:23:11 -0400 (EDT))rM  zWed, 13 Jul 2005 17:23:11 -0400)r  z."Gregory K. Johnson" <gkj@gregorykjohnson.com>)rN  zgkj@gregorykjohnson.com)rO  zSample message)zMime-Versionz1.0)zContent-Typez,multipart/mixed; boundary="NMuMz9nt05w80d4+")zContent-Dispositioninline)rK  zMutt/1.5.9i)z1This is a sample message.

--
Gregory K. Johnson
zRH4sICM2D1UIAA3RleHQAC8nILFYAokSFktSKEoW0zJxUPa7wzJIMhZLyfIWczLzUYj0uAHTs
3FYlAAAA
c                       e Zd Zd Zy)MiscTestCasec                 @    t        j                  | t        ddh       y )Nr   fcntl)not_exported)r   check__all__r   r?   s    r"   test__all__zMiscTestCase.test__all__7	  s    T7+4g*>	@r$   N)r.   r/   r0   r4  r7   r$   r"   r/  r/  6	  s    @r$   r/  c                  ,    t        j                          y r
   )r   reap_childrenr7   r$   r"   tearDownModuler7  <	  s    r$   __main__)<r&   r  r  r  r  r   email.messager  rT   r   testr   test.supportr   r   r   r"  rI  r   rG  has_gethostnameSkipTestr   r9   TestCaserL  r}  r&  rB  r  r  r  r  r  ry  r  r  r  r   r$  r:  r=  rD  rW  rY  r  r  r  r  r  r  rR   r`   rV   r   r   r/  r7  r.   mainr7   r$   r"   <module>r@     s   	 
      	 	   & " &     $$
(

9
::% %8z$( z$z!DHh&7&7 !DHX%+x00 X%v
O+k O+dKO K\+1}h// +1\L}h// L
D>[(++ D>NE!2!2 ED '// 	1h'' 	1S(H-- SlG h&7&7 G T2! 2!j#*K #
EK!2!2 E>4;{H$5$5 4;n#*K #
INHh&7&7 INXP& P&f.9%x'8'8 .9b0H'):): 0Hj 	BM,h'' M,d-^ (..w7 4 @8$$ @ zHMMO r$   