B
    u9aj                @   s  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Zd dlZd dlZd dlZG dd dZG dd deZG dd deejZG d	d
 d
eejZG dd deZG dd deZG dd deejZG dd deejZG dd deejZG dd deejZG dd dZG dd dejZG dd dejZG dd deejZG dd  d eejZ G d!d" d"Z!G d#d$ d$e!eZ"G d%d& d&eejZ#G d'd( d(eejZ$G d)d* d*e!eZ%G d+d, d,eejZ&G d-d. d.eZ'G d/d0 d0e'ejZ(G d1d2 d2e'ejZ)d3Z*d4Z+G d5d6 d6ejZ,d7Z-e-.d8Z/d9d:d:d;d<d=d>d?d@dAdBdCdDdEdFdGdHZ0dIZ1G dJdK dKejZ2dLdM Z3e4dNkre3  dS )O    N)supportc               @   s8   e Zd Zejejejejejej	fZ
dd Zdd ZdS )TestBasec             C   s   |  |tjj |  |tj x&t D ]\}}| ||| q(W | 	|
  | t| tt xLttD ]@\}}||}|  |tjj | |tj | | | qvW d S )N)assertIsInstanceemailmessageMessagemailbox_sample_headersitemsassertInZget_all
assertTrueis_multipartassertEquallenget_payload_sample_payloads	enumerateZassertNotIsInstance)selfmsgkeyvalueiZpayloadpart r   "/usr/lib/python3.7/test_mailbox.py_check_sample   s    
zTestBase._check_samplec             C   s2   t j|rt| nt j|r.t| d S )N)ospathisdirr   rmtreeexistsunlink)r   targetr   r   r   _delete_recursively&   s    zTestBase._delete_recursivelyN)__name__
__module____qualname__r   r   MaildirMessagemboxMessage	MHMessageBabylMessageMMDFMessageall_mailbox_typesr   r#   r   r   r   r   r      s
   r   c               @   s  e Zd ZdZdZdZdd Zdd Zdd Ze	
d	Zd
d Zdd Zdd Zdd Ze	
ddZdd Zdd Zdd Zdd Zdd Zdd Zd d! Zd"d# Zd$d% Zdcd'd(Zd)d* Zd+d, Zd-d. Zd/d0 Zd1d2 Z d3d4 Z!d5d6 Z"d7d8 Z#d9d: Z$d;d< Z%d=d> Z&d?d@ Z'dAdB Z(dCdD Z)dddEdFZ*dGdH Z+dedIdJZ,dKdL Z-dfdMdNZ.dOdP Z/dgdQdRZ0dSdT Z1dUdV Z2dWdX Z3dYdZ Z4d[d\ Z5d]d^ Z6d_d` Z7dadb Z8dS )hTestMailboxNzFrom: foo

%s
c             C   s&   t j| _| | j | | j| _d S )N)r   TESTFN_pathr#   _factory_box)r   r   r   r   setUp5   s    zTestMailbox.setUpc             C   s   | j   | | j d S )N)r1   closer#   r/   )r   r   r   r   tearDown:   s    
zTestMailbox.tearDownc          
   C   s  g }| | j| jd  | t| jd | | jtt | t| jd | | jt	
t | t| jd | | jtt | t| jd | | jt | t| jd | | jt | t| jd | t$ | | jttt W d Q R X | t| jd | | j|d | jd  x"d	D ]}| | j||   q^W d S )
Nr                        )r5   r6   r7   r8   r9   r:   )appendr1   add	_templater   r   r   r   _sample_messager   message_from_stringioBytesIO_bytes_sample_messageassertWarnsDeprecationWarningTextIOWrapper
get_stringr   )r   keysr   r   r   r   test_add>   s(    

zTestMailbox.test_addu{               From: foo
            Subject: Falinaptár házhozszállítással. Már rendeltél?

            0
            c             C   sF   | j | jd}| t| j d | | j || jd d S )Nzlatin-1r5   )r1   r=   _nonascii_msgencoder   r   	get_bytes)r   r   r   r   r   "test_add_invalid_8bit_bytes_header\   s    z.TestMailbox.test_add_invalid_8bit_bytes_headerc             C   s8   | j  d }| j|d}| | j|d d S )Nr5   zlatin-1zZSubject: =?unknown-8bit?b?RmFsaW5hcHThciBo4Xpob3pzeuFsbO104XNzYWwuIE3hciByZW5kZWx06Ww/?=

)rJ   
splitlinesr1   r=   rK   r   rG   )r   Zsubjr   r   r   r   &test_invalid_nonascii_header_as_stringb   s    z2TestMailbox.test_invalid_nonascii_header_as_stringc          	   C   sN   |  td | j| j W d Q R X | j  | t| jd |   d S )Nz
ASCII-onlyr   )	assertRaisesRegex
ValueErrorr1   r=   rJ   flushr   r   assertMailboxEmpty)r   r   r   r   &test_add_nonascii_string_header_raisesi   s
    
z2TestMailbox.test_add_nonascii_string_header_raisesc          	   C   sl   dd }t | tjjd| | t | jt	d W d Q R X | 
t| jd | j  |   d S )Nc              _   s   t dd S )Nza fake error)	Exception)argskwr   r   r   raiserq   s    zETestMailbox.test_add_that_raises_leaves_mailbox_empty.<locals>.raiserZflattenu   From: Alphösor   )r   Zpatchr   	generatorZBytesGeneratorassertRaisesrU   r1   r=   r@   r   r   r3   rS   )r   rX   r   r   r   )test_add_that_raises_leaves_mailbox_emptyp   s    
z5TestMailbox.test_add_that_raises_leaves_mailbox_emptyu0          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

        Да, они летят.
        zutf-8c          	   C   sv   | j | j}| | j || j | j |&}| | | jdtj	
  W d Q R X | | j |  d d S )N   
u   Да, они летят.
)r1   r=   _non_latin_bin_msgr   rL   get_filereadreplacer   lineseprK   r   )r   r   fr   r   r   test_add_8bit_body   s    
zTestMailbox.test_add_8bit_bodyc          	   C   sZ   t d&}|t |d | j|}W d Q R X | | j|	dt	d d S )Nzwb+r   r\   )
tempfileTemporaryFilewriterC   seekr1   r=   r   rL   split)r   rb   r   r   r   r   test_add_binary_file   s    

z TestMailbox.test_add_binary_filec          	   C   s^   t d(}|| j |d | j|}W d Q R X | | j|	d| j	d d S )Nzwb+r   r\   )
rd   re   rf   r]   rg   r1   r=   r   rL   rh   )r   rb   r   r   r   r   test_add_binary_nonascii_file   s    
z)TestMailbox.test_add_binary_nonascii_filec          
   C   sp   t d<}|t |d | t | j|}W d Q R X W d Q R X | 	| j
|dtd d S )Nzw+r   r\   )rd   re   rf   r?   rg   rD   rE   r1   r=   r   rL   rh   rC   )r   rb   r   r   r   r   test_add_text_file_warns   s    

 z$TestMailbox.test_add_text_file_warnsc          	   C   sL   |  t | jt| jd }W d Q R X | | j|| jd  d S )N0)	rD   rE   r1   r=   rA   StringIOr>   r   rG   )r   r   r   r   r   test_add_StringIO_warns   s    "z#TestMailbox.test_add_StringIO_warnsc          
   C   sj   |  t2 | td | jt| j W d Q R X W d Q R X | 	t
| jd | j  |   d S )Nz
ASCII-onlyr   )rD   rE   rP   rQ   r1   r=   rA   rm   rJ   r   r   r3   rS   )r   r   r   r   !test_add_nonascii_StringIO_raises   s    (
z-TestMailbox.test_add_nonascii_StringIO_raisesc             C   s   |  | jj d S )N)_test_remove_or_delitemr1   remove)r   r   r   r   test_remove   s    zTestMailbox.test_removec             C   s   |  | jj d S )N)rp   r1   __delitem__)r   r   r   r   test_delitem   s    zTestMailbox.test_delitemc                sd  j jd  j jd tj d   tj d t fdd t fdd j jd  j jd tj d  tj d tfdd tfdd j jd   tj d tfd	d tfd
d d S )Nr   r5   r6   c                  s
   j   S )N)r1   r   )key0r   r   r   <lambda>       z5TestMailbox._test_remove_or_delitem.<locals>.<lambda>c                  s    S )Nr   r   )ru   methodr   r   rv      rw   c                  s
   j   S )N)r1   r   )key2r   r   r   rv      rw   c                  s    S )Nr   r   )ry   rx   r   r   rv      rw   c                  s
   j   S )N)r1   r   )key1r   r   r   rv      rw   c                  s    S )Nr   r   )rz   rx   r   r   rv      rw   )r1   r=   r>   r   r   rZ   KeyErrorrG   )r   rx   r   )ru   rz   ry   rx   r   r   rp      s&    z#TestMailbox._test_remove_or_delitem
   c                s   j jd  j jd }tj d j   tj d t fdd j   tj d t fdd d S )Nr   r5   r6   c                  s
   j   S )N)r1   r   )ru   r   r   r   rv      rw   z*TestMailbox.test_discard.<locals>.<lambda>c                  s
   j   S )N)r1   r   )ru   r   r   r   rv      rw   )r1   r=   r>   r   r   discardrZ   r{   )r   repetitionsrz   r   )ru   r   r   test_discard   s    zTestMailbox.test_discardc             C   s   | j | jd }| j |}| |d d | | d | | j d | | j ddd | j   | 	| j
| _ | j | jd }| j |}| |d d | | d d S )Nr   fromfooz0
Fr5   z1
)r1   r=   r>   getr   r   assertIsNoneassertIsr3   r0   r/   )r   ru   r   rz   r   r   r   test_get   s    
zTestMailbox.test_getc                sv   j jd  j   }|d d | d tfdd j   t fdd d S )Nr   r   r   z0
c                  s
    j d S )Nr   )r1   r   )r   r   r   rv      rw   z*TestMailbox.test_getitem.<locals>.<lambda>c                  s
   j   S )N)r1   r   )ru   r   r   r   rv      rw   )r1   r=   r>   r   r   rZ   r{   r}   )r   r   r   )ru   r   r   test_getitem   s    
zTestMailbox.test_getitemc             C   sn   | j | jd }| j t}| j |}| |tj | |d d | |	 d | 
| j | d S )Nr   r   r   z0
)r1   r=   r>   r?   get_messager   r   r   r   r   r   )r   ru   rz   msg0r   r   r   test_get_message   s    zTestMailbox.test_get_messagec             C   sV   | j | jd }| j t}| | j || jd d | | j |t d S )Nr   ascii)r1   r=   r>   r?   r   rL   rK   rC   )r   ru   rz   r   r   r   test_get_bytes  s
    zTestMailbox.test_get_bytesc             C   s\   | j | jd }| j t}| | j || jd  | | j |dtd d S )Nr   
)r1   r=   r>   r?   r   rG   rh   )r   ru   rz   r   r   r   test_get_string  s
    zTestMailbox.test_get_stringc          	   C   s   | j | jd }| j t}| j |}| }W d Q R X | j |}| }W d Q R X | |dt	j
d| jd  | |dt	j
dt d S )Nr   r   r   )r1   r=   r>   r?   r^   r_   r   decoder`   r   ra   )r   ru   rz   fileZdata0Zdata1r   r   r   test_get_file  s    zTestMailbox.test_get_filec             C   s,   | j t}| j |}|  |  d S )N)r1   r=   r?   r^   r3   )r   r   rb   r   r   r   !test_get_file_can_be_closed_twice!  s    z-TestMailbox.test_get_file_can_be_closed_twicec             C   s   | j | jjddd d S )NTF)do_keys	do_values)_check_iterationr1   iterkeys)r   r   r   r   test_iterkeys(  s    zTestMailbox.test_iterkeysc             C   s   | j | jjddd d S )NTF)r   r   )r   r1   rH   )r   r   r   r   	test_keys,  s    zTestMailbox.test_keysc             C   s   | j | jjddd d S )NFT)r   r   )r   r1   
itervalues)r   r   r   r   test_itervalues0  s    zTestMailbox.test_itervaluesc             C   s   | j | jjddd d S )NFT)r   r   )r   r1   __iter__)r   r   r   r   	test_iter5  s    zTestMailbox.test_iterc             C   s   | j | jjddd d S )NFT)r   r   )r   r1   values)r   r   r   r   test_values:  s    zTestMailbox.test_valuesc             C   s   | j | jjddd d S )NT)r   r   )r   r1   	iteritems)r   r   r   r   test_iteritems>  s    zTestMailbox.test_iteritemsc             C   s   | j | jjddd d S )NT)r   r   )r   r1   r
   )r   r   r   r   
test_itemsC  s    zTestMailbox.test_itemsc             C   s<  x| D ]}|  d qW g g  }}x8t|D ],}|| j| j|  || j|  q.W |rr|srt| }	nF|r|st| }
n2g g  }	}
x&| D ]\}}|	| |
| qW |r| t|t|	 | t	|t	|	 |r8d}x8|
D ]0}| |d d | 
t| | |d7 }qW | t|| d S )Nz	Not emptyr   r   r   r5   )Zfailranger<   r1   r=   r>   listr   r   set
assertLessintr   )r   rx   r   r   r~   r   rH   r   r   Zreturned_keysZreturned_valuesr   countr   r   r   r   G  s0    



zTestMailbox._check_iterationc             C   s   |  d| j | j| jd }| || j |  d| j | j| jd }| || j | || j |  d| j | j| |  || j | || j |  d| j | j| |  || j |  || j |  d| j d S )Nr   r   r5   )assertNotInr1   r=   r>   r   rq   )r   ru   rz   r   r   r   test_containsb  s     zTestMailbox.test_containsc             C   s   g }xPt |D ]D}| t| j| || j| j|  | t| j|d  qW xPt |D ]D}| t| j||  | j||  | t| j|| d  q`W d S )Nr5   )r   r   r   r1   r<   r=   r>   rq   )r   r~   rH   r   r   r   r   test_lenu  s    zTestMailbox.test_lenc                s^   j  jd }  j | jd   j  jd }  j | jd   jd  j |<   j | jd   jd  j |<   j | jd  t j |<   j |   j |  j |<   j |   jd  j |<   j | jd    j |   t fdd  t fdd  t	 j d d S )	Nz
original 0z
original 1z	changed 0z	changed 1c                  s    j ddS )Nr   bar)r1   __setitem__r   )r   r   r   rv     rw   z+TestMailbox.test_set_item.<locals>.<lambda>c                  s
    j d S )Nr   )r1   r   )r   r   r   rv     rw   r6   )
r1   r=   r>   r   rG   r?   r   rZ   r{   r   )r   ru   rz   r   )r   r   test_set_item  s0    
zTestMailbox.test_set_itemc                s   g }x"t |D ]}jj|  qW x.t|D ]"\} j j|  q2W j  tjd x*t|D ]\} 	t
 fdd q~W d S )Nr   c                  s   j  S )N)r1   rG   r   )r   r   r   r   rv     rw   z(TestMailbox.test_clear.<locals>.<lambda>)r   r1   r=   r>   r   r   rG   clearr   rZ   r{   )r   
iterationsrH   r   r   )r   r   r   
test_clear  s    
zTestMailbox.test_clearc             C   s  | j | jd }| || j  | j | jd }| || j  | | j | d | || j  | || j  | j | jd }| || j  | | j | d | || j  | || j  | | j | d | || j  | t| j d d S )Nr   r5   z0
r6   z2
z1
)	r1   r=   r>   r   r   popr   r   r   )r   ru   rz   ry   r   r   r   test_pop  s    zTestMailbox.test_popc                s   g }x(t dD ]}|jj|  qW g }xZt dD ]N}j \ } |  | |  t	|
 |  q<W tjd x"|D ] t fdd qW d S )Nr|   r   c                  s
   j   S )N)r1   r   )r   r   r   r   rv     rw   z*TestMailbox.test_popitem.<locals>.<lambda>)r   r<   r1   r=   r>   popitemr   r   r   r   r   indexr   rZ   r{   )r   r   rH   r   seenr   r   )r   r   r   test_popitem  s    

zTestMailbox.test_popitemc                s  j jd  j jd }j jd }j  jd |ti tj d j  jd  j |jd  j |  j |jd f|jd f jd fg tj d j  jd  j |jd  j |jd  	t
 fdd	 tj d j  jd  j |jd  j |jd  d S )
Nz
original 0z
original 1z
original 2z	changed 0r7   z	changed 2z	changed 1c                  s   j dd jd iS )Nr   r   z	changed 0)r1   updater>   r   )ru   r   r   r   rv     s   
z)TestMailbox.test_update.<locals>.<lambda>)r1   r=   r>   r   r?   r   r   rG   r   rZ   r{   )r   rz   ry   r   )ru   r   r   test_update  s<    
zTestMailbox.test_updatec             C   s   |  | jjd d S )NT)_test_flush_or_closer1   rR   )r   r   r   r   
test_flush  s    zTestMailbox.test_flushc             C   sZ   | j | jd  | j | jd  | j   | j   | j   | j   | j   d S )Nr   r5   )r1   r=   r>   rR   r   )r   r   r   r   test_popitem_and_flush_twice  s    



z(TestMailbox.test_popitem_and_flush_twicec             C   sZ   |  tj|   | j  | tj|   | j  |  tj|   d S )N)	assertFalser   r   r    _get_lock_pathr1   lockr   unlock)r   r   r   r   test_lock_unlock  s
    

zTestMailbox.test_lock_unlockc             C   s   |  | jjd d S )NF)r   r1   r3   )r   r   r   r   
test_close  s    zTestMailbox.test_closec                s    fddt dD } j|d   j|d   j|d   j}|  |r` j    j _ j } t|d x |D ]} 	 j
|| qW |  d S )Nc                s   g | ]} j | qS r   )r>   ).0r   )r   r   r   
<listcomp>  s    z4TestMailbox._test_flush_or_close.<locals>.<listcomp>r7   r   r5   r6   )r   r1   r=   r3   r0   r/   rH   r   r   r   rG   )r   rx   Zshould_call_closecontentsZoldboxrH   r   r   )r   r   r     s    


z TestMailbox._test_flush_or_closec          	      sv   xRt ttttfD ]8}t  j|   	 t
dtj  qW t  t fdd d S )Nr\   c                  s   j d  S )N)r1   _dump_messager   )outputr   r   r   rv   !  rw   z/TestMailbox.test_dump_message.<locals>.<lambda>)r   r@   r?   rA   rB   rC   r1   r   r   getvaluer`   r   ra   rK   rZ   	TypeError)r   inputr   )r   r   r   test_dump_message  s    

zTestMailbox.test_dump_messagec             C   s
   | j d S )Nz.lock)r/   )r   r   r   r   r   #  s    zTestMailbox._get_lock_path)r|   )r|   )r|   )r|   )r|   )9r$   r%   r&   ZmaxDiffr0   r>   r2   r4   rI   textwrapdedentrJ   rM   rO   rT   r[   rK   r]   rc   ri   rj   rk   rn   ro   rr   rt   rp   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-   .   sj   

	






"r-   c               @   s   e Zd Zdd ZdS )TestMailboxSuperclassc                sR  t d | t fdd | t fdd | t fdd | t fdd | t fdd | t fdd | t fd	d | t fd
d | t fdd | t fdd | t fdd | t fdd | t fdd | t fdd | t fdd | t fdd | t fdd | t fdd | t fdd | t fdd | t fdd | t fdd | t fdd | t fdd | t fdd | t fdd | t fdd | t fdd | t fdd d S ) Nr   c                  s
     dS )N )r=   r   )boxr   r   rv   -  rw   z;TestMailboxSuperclass.test_notimplemented.<locals>.<lambda>c                  s
     dS )Nr   )rq   r   )r   r   r   rv   .  rw   c                  s
     dS )Nr   )rs   r   )r   r   r   rv   /  rw   c                  s
     dS )Nr   )r}   r   )r   r   r   rv   0  rw   c                  s     ddS )Nr   )r   r   )r   r   r   rv   1  rw   c                  s      S )N)r   r   )r   r   r   rv   2  rw   c                  s      S )N)rH   r   )r   r   r   rv   3  rw   c                  s       S )N)r   __next__r   )r   r   r   rv   4  rw   c                  s       S )N)r   r   r   )r   r   r   rv   5  rw   c                  s      S )N)r   r   )r   r   r   rv   6  rw   c                  s       S )N)r   r   r   )r   r   r   rv   7  rw   c                  s      S )N)r
   r   )r   r   r   rv   8  rw   c                  s
     dS )Nr   )r   r   )r   r   r   rv   9  rw   c                  s
     dS )Nr   )__getitem__r   )r   r   r   rv   :  rw   c                  s
     dS )Nr   )r   r   )r   r   r   rv   ;  rw   c                  s
     dS )Nr   )rG   r   )r   r   r   rv   <  rw   c                  s
     dS )Nr   )rL   r   )r   r   r   rv   =  rw   c                  s
     dS )Nr   )r^   r   )r   r   r   rv   >  rw   c                  s   d kS )Nr   r   r   )r   r   r   rv   ?  rw   c                  s
     dS )Nr   )__contains__r   )r   r   r   rv   @  rw   c                  s      S )N)__len__r   )r   r   r   rv   A  rw   c                  s      S )N)r   r   )r   r   r   rv   B  rw   c                  s
     dS )Nr   )r   r   )r   r   r   rv   C  rw   c                  s      S )N)r   r   )r   r   r   rv   D  rw   c                  s
     dS )N))r   r   )r   r   )r   r   r   rv   E  rw   c                  s      S )N)rR   r   )r   r   r   rv   F  rw   c                  s      S )N)r   r   )r   r   r   rv   G  rw   c                  s      S )N)r   r   )r   r   r   rv   H  rw   c                  s      S )N)r3   r   )r   r   r   rv   I  rw   )r   MailboxrZ   NotImplementedError)r   r   )r   r   test_notimplemented*  s<    
z)TestMailboxSuperclass.test_notimplementedN)r$   r%   r&   r   r   r   r   r   r   (  s   r   c               @   s  e Zd Zd7ddZdd Zdd Zdd	 Zd
d Zdd Zdd Z	dd Z
dd Zd8ddZdd Zdd Zdd Zdd Zd9dd Zd!d" Zd#d$ Zd%d& Zd'd( Zd)d* Zd+d, Zeeed-d.eeed/d0d1d2 Zeeed-d.eeed/d0d3d4 Zd5d6 ZdS ):TestMaildirNc             C   s   t ||S )N)r   Maildir)r   r   factoryr   r   r   rv   N  rw   zTestMaildir.<lambda>c             C   s*   t |  tjdkstjdkr&d| j_d S )Nntcygwin!)r-   r2   r   namesysplatformr1   colon)r   r   r   r   r2   P  s    
zTestMaildir.setUpc             C   s"   |  ttj| jdg  d S )Ntmp)r   r   listdirr   joinr/   )r   r   r   r   rS   U  s    zTestMaildir.assertMailboxEmptyc             C   s`   t | jd }|d |d | j|}| tj	
tj	| jdd|| jjf  d S )Nr   curr   z%s%sfoo)r   r'   r>   
set_subdirset_infor1   r=   r   r   r   r    r   r/   r   )r   r   r   r   r   r   test_add_MMX  s    

zTestMaildir.test_add_MMc             C   sn   t | jd }|d |d | j|}| j|}| |t j | 	|
 d | 	| d d S )Nr   r   RFFR)r   r'   r>   r   	set_flagsr1   r=   r   r   r   
get_subdir	get_flags)r   r   r   msg_returnedr   r   r   test_get_MMa  s    

zTestMaildir.test_get_MMc             C   s  t | jd }|d | j|}| j|}| | d | |	 d t | jd }|| j|< | j|}| | d | |	 d | |
 d t | jd }|d	 || j|< | jd
 | j|< | j|}| | d | |	 d | |
 d d S )Nr   ZTPnewZPTr5   r   z1
r6   z2,Sr7   Sz3
)r   r'   r>   r   r1   r=   r   r   r   r   r   r   )r   r   r   r   msg1msg2r   r   r   test_set_MMl  s(    



zTestMaildir.test_set_MMc             C   sv   t | jd }|d |d | j|}G dd dt j}t j| j|d}| jj	|_	|
|}| || d S )Nr   r   r   c               @   s   e Zd ZdS )z8TestMaildir.test_consistent_factory.<locals>.FakeMessageN)r$   r%   r&   r   r   r   r   FakeMessage  s   r   )r   )r   r'   r>   r   r   r1   r=   r   r/   r   r   r   )r   r   r   r   r   r   r   r   r   test_consistent_factory  s    



z#TestMaildir.test_consistent_factoryc             C   sH   |    t| j| _|   | | j | j| jd d| _|   d S )N)r   )r4   r   r   r/   r1   _check_basicsr#   r0   )r   r   r   r   test_initialize_new  s    zTestMaildir.test_initialize_newc          	   C   sN   |    x*dD ]"}ttjtj| j| qW t| j| _	| 
  d S )N)r   r   r   r   )r4   r   mkdirr   normpathr   r/   r   r   r1   r   )r   subdirr   r   r   test_initialize_existing  s
    
"z$TestMaildir.test_initialize_existingc             C   sr   |  | jjtj| j |  | jj| xBdD ]:}tj| j|}t|tj	 }| 
t|d|  q0W d S )N)r   r   r   r   zNot a directory: '%s')r   r1   r/   r   r   abspathr0   r   statST_MODEr   S_ISDIR)r   r   r   r   moder   r   r   r     s    
zTestMaildir._check_basicsc             C   sX   | j d | j d | j d | t| j  d | t| j  td d S )Nonetwothreer7   )r   r  r  )r1   
add_folderr   r   list_foldersr   )r   r   r   r   test_list_folders  s    zTestMaildir.test_list_foldersc             C   sv   | j d | j d}|| jd  | tjtj	| j
d | j d}| || d | jd  d S )Nzfoo.barr   z.foo.barr   )r1   r  
get_folderr=   r>   r   r   r   r   r   r/   r   rG   rH   )r   folder0folder1r   r   r   test_get_folder  s    zTestMaildir.test_get_folderc             C   s4  | j d | j d | t| j  d | t| j  td | j d | t| j  d | t| j  td | j d | t| j  d | t| j  td | j d | t| j  d | t| j  td | j d | t| j  d	 | | j  g  d S )
Nr   r  r6   )r   r  r5   )r  r  )r  r  r   )r1   r  r   r   r  r   remove_folder)r   r   r   r   test_add_and_remove_folders  s     z'TestMaildir.test_add_and_remove_foldersc          	   C   s   t j| jdd}t j| jdd}t|d}|d W d Q R X t|d}|d W d Q R X | j  | t j	| | t j	| t 
|}t |t d d |jf | j  | t j	| | t j	| d S )Nr   r   r   w@i@ r6   )r   r   r   r/   openrf   r1   Zcleanr   r    r   utimetimest_mtimer   )r   Zfoo_pathZbar_pathrb   Zfoo_statr   r   r   
test_clean  s    



zTestMaildir.test_cleanr|   c          
   C   s  t  }d|kr|dd}d|kr0|dd}t }td}d }xt|D ]}| j	 }tj
|j\}}	| |tj
tj
| jdd|  ||	}
| |
d|	  |
 }|d k	r| t|d	 t|d	 d
|d	 |d	 f  t|d	 t|d	 kr<| t|d t|d d|d |d f  | t|d |d|d |f  | t|d t|d d d|d |d f  | |d |d|d |f  |}|t |d	 | | t |  qRW tttj
| jd}| ||d||f  d S )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: '%s' before '%s'r5   z,Non-monotonic milliseconds: '%s' before '%s'r6   z(Process ID mismatch: '%s' should be '%s'r7   z(Non-sequential counter: '%s' before '%s'r8   z'Host name mismatch: '%s' should be '%s'z%Wrong file count: '%s' should be '%s')socketZgethostnamer`   r   getpidrecompiler   r1   Z_create_tmpr   rh   r   r   r   r   r/   matchassertIsNotNonegroupsZassertGreaterEqualr   rf   rC   rg   r_   r3   r   r   )r   r~   ZhostnamepidpatternZprevious_groupsxZtmp_fileheadtailr  r  Z
file_countr   r   r   test_create_tmp  sV    






zTestMaildir.test_create_tmpc             C   s   |  | jji  | j| jd }| j| jd }|  | jji  | j  |  | jj|tjd||tjd|i | j| jd }|  | jj|tjd||tjd|i | j  |  | jj|tjd||tjd||tjd|i d S )Nr   r5   r   r6   )	r   r1   _tocr=   r>   _refreshr   r   r   )r   ru   rz   ry   r   r   r   test_refresh  s    

zTestMaildir.test_refreshc             C   sx   | j | jd }| j | jd }| | j| _ | | j ji  d| j _| j   | t	| j j
 t	||g d S )Nr   r5   )r1   r=   r>   r0   r/   r   r"  _skewfactorr#  sortedrH   )r   ru   rz   r   r   r    test_refresh_after_safety_period$  s    
z,TestMaildir.test_refresh_after_safety_periodc                s    tfdd jjd  j tj	d  t
tj	jd  jj tj	d i j   t fdd jji  d S )Nc                  s    j dS )Nr   )r1   _lookupr   )r   r   r   rv   9  rw   z)TestMaildir.test_lookup.<locals>.<lambda>r   r   c                  s   j  S )N)r1   r)  r   )ru   r   r   r   rv   A  rw   )rZ   r{   r1   r=   r>   r   r)  r   r   r   rq   r/   r"  rR   )r   r   )ru   r   r   test_lookup7  s    
zTestMaildir.test_lookupc             C   s   | j   | j   d S )N)r1   r   r   )r   r   r   r   r   D  s    
zTestMaildir.test_lock_unlockc             C   sL   dd }| j | j|d}|d}| |j | |d}| |j | d S )Nc             S   s   d S )Nr   )sr   r   r   dummy_factoryL  s    z.TestMaildir.test_folder.<locals>.dummy_factory)r   r  )r0   r/   r  r   r  )r   r,  r   ZfolderZfolder1_aliasr   r   r   test_folderI  s    

zTestMaildir.test_folderc             C   sP   x"t dD ]}| jtt q
W ttj	| j
dd x| jD ]}qDW d S )Nr|   r   z	stray-dir)r   r1   r=   r   r   r?   r   r   r   r   r/   )r   r   r   r   r   r   test_directory_in_folderU  s
    z$TestMaildir.test_directory_in_folderumaskztest needs os.umask()r   ztest needs os.stat()c          	   C   sn   t | jd }td}z| j|}W d t| X tj| j	| j
|}t|j}| |d@  d S )Nr   I   )r   r'   r>   r   r/  r1   r=   r   r   r/   r)  r   st_moder   )r   r   
orig_umaskr   r   r   r   r   r   test_file_permissionsb  s    
z!TestMaildir.test_file_permissionsc          	   C   sZ   t d}z| jd}W d t | X t j|jd}t |}|j}| 	|d@  d S )Nr   	subfolderZmaildirfolderr0  )
r   r/  r1   r  r   r   r/   r   r1  r   )r   r2  r4  r   stpermsr   r   r   test_folder_file_permsp  s    

z"TestMaildir.test_folder_file_permsc                s   j   x4dD ],}ttjj j|t d fd  qW dj _j j	  fdd}j   
|  tjjdd}t| t| j   |  d S )	N)r   r   r9   r6   r%  c                  s   j j k	S )N)r1   r"  r   )orig_tocr   r   r   	refreshed  s    z*TestMaildir.test_reread.<locals>.refreshedr   z
stray-file)r1   r#  r   r  r   r   r/   r  r&  r"  r   r   Zcreate_empty_filer!   r   )r   r   r9  filenamer   )r8  r   r   test_reread  s    





zTestMaildir.test_reread)N)N)r|   )r$   r%   r&   r0   r2   rS   r   r   r   r   r   r   r   r  r	  r  r  r!  r$  r(  r*  r   r-  r.  unittest
skipUnlesshasattrr   r3  r7  r;  r   r   r   r   r   L  s4   
		
		

/r   c               @   s   e Zd Zdd Zdd ZdS )_TestSingleFilec             C   sr   t | jj}| j| jd  | j  t | jj}| || | j	  | 
| j| _| t| jd d S )Nr   r5   )r   r   r/   st_inor1   r=   r>   rR   r   r3   r0   r   )r   Zinode_beforeZinode_afterr   r   r   test_add_doesnt_rewrite  s    

z'_TestSingleFile.test_add_doesnt_rewritec             C   st   t | jjdB }t | j| | j| jd  | j| jd }| j| | j	  | 
t | jj| d S )Ni  r   r5   )r   r   r/   r1  chmodr1   r=   r>   rq   rR   r   )r   r   r   r   r   r   test_permissions_after_flush  s    
z,_TestSingleFile.test_permissions_after_flushN)r$   r%   r&   rA  rC  r   r   r   r   r?    s   r?  c                   s   e Zd Z fddZdd Zdd Zdd Zd	d
 Zdd Zdd Z	e
eedde
eedddd Zdd Z  ZS )_TestMboxMMDFc                sH   t    | j  | | j x"t| jd D ]}t| q2W d S )Nz.*)	superr4   r1   r3   r#   r/   globr   r!   )r   lock_remnant)	__class__r   r   r4     s
    

z_TestMboxMMDF.tearDownc          	   C   s*   t | j}| | g  W d Q R X d S )N)r  r/   r   	readlines)r   rb   r   r   r   rS     s    z _TestMboxMMDF.assertMailboxEmptyc             C   s<   | j d}| | j |  d | | j |  d d S )NzFrom foo@bar blah
From: foo

0
zfoo@bar blahz0
)r1   r=   r   get_fromr   )r   r   r   r   r   test_add_from_string  s    z"_TestMboxMMDF.test_add_from_stringc             C   s<   | j d}| | j |  d | | j |  d d S )Ns   From foo@bar blah
From: foo

0
zfoo@bar blahz0
)r1   r=   r   rJ  r   )r   r   r   r   r   test_add_from_bytes  s    z!_TestMboxMMDF.test_add_from_bytesc             C   s.   x(t jt jfD ]}|d}| j|}qW d S )NzFrom foo@bar blah
From: foo

0
)r   r(   r+   r1   r=   )r   class_r   r   r   r   r   test_add_mbox_or_mmdf_message  s    z+_TestMboxMMDF.test_add_mbox_or_mmdf_messagec                s    fddt dD }x|D ]} j| qW  j  tj j}  j _ 	t
 jd x& j D ]}  j|| qtW  j   	|tj j d S )Nc                s   g | ]} j | qS r   )r>   )r   r   )r   r   r   r     s    z6_TestMboxMMDF.test_open_close_open.<locals>.<listcomp>r7   )r   r1   r=   r3   r   r   getmtimer/   r0   r   r   r   r   rG   )r   r   r   mtimer   r   )r   r   test_open_close_open  s    


z"_TestMboxMMDF.test_open_close_openc          	   C   s   | j t x"tdD ]}| j | j|  qW | j t | j j  | j jd | j j }| j 	  t
| jd}| ||  W d Q R X | | j| _ d S )Nr7   r   rb)r1   r=   r?   r   r>   _filerR   rg   r_   r3   r  r/   r   r0   )r   r   r   rb   r   r   r   test_add_and_close  s    
z _TestMboxMMDF.test_add_and_closeforkzTest needs fork().
socketpairzTest needs socketpair().c          
   C   s   t  \}}| |j | |j t }|dkrnz,| j  |d |	d | j
  W d td X |	d z| tj| jj W d |d t|d\}}X | j  | j
  d S )Nr      cr5      p)r  rV  Z
addCleanupr3   r   rU  r1   r   sendZrecvr   _exitrZ   r   ZExternalClashErrorwaitpid)r   cpr  Z
exited_pidstatusr   r   r   test_lock_conflict  s&    





z _TestMboxMMDF.test_lock_conflictc             C   sn   d}| j |}| j   | j   | | j| _ | j   | j |}| j   | | j j | j   d S )NzSubject: sub

body
)	r1   r=   rR   r3   r0   r/   r   r   Z_locked)r   r   rz   ry   r   r   r   test_relock2  s    



z_TestMboxMMDF.test_relock)r$   r%   r&   r4   rS   rK  rL  rN  rQ  rT  r<  r=  r>  r   r  r_  r`  __classcell__r   r   )rH  r   rD    s   $rD  c               @   sR   e Zd ZdddZeeeddeeedddd	 Zd
d Z	dd Z
dS )TestMboxNc             C   s   t ||S )N)r   mbox)r   r   r   r   r   r   rv   D  rw   zTestMbox.<lambda>r/  ztest needs os.umask()r   ztest needs os.stat()c          	   C   s~   zLt d}| j  t | j tj| jdd| _| jd | j  W d t | X t 	| j}|j
}| |d@  d S )N?   T)Zcreater   r0  )r   r/  r1   r3   r!   r/   r   rc  r=   r   r1  r   )r   Z	old_umaskr5  r6  r   r   r   test_file_permsF  s    

zTestMbox.test_file_permsc             C   sH   t j }d|d< |d | j|}| j|}| | d d S )Nzjohn@example.comFromzNo newline at the endzNo newline at the end
)	r   r   r   Zset_payloadr1   r=   r   r   r   )r   r   r   r   r   r   test_terminating_newlineZ  s    

z!TestMbox.test_terminating_newlinec          	   C   s   | j d t| j"}| }| |dd  d W d Q R X | j d t| j"}| }| |dd  d W d Q R X d S )NzFrom: foo

0r%  z0

zFrom: foo

0
)r1   r=   r  r/   r_   r   )r   rb   datar   r   r   test_message_separatord  s    zTestMbox.test_message_separator)N)r$   r%   r&   r0   r<  r=  r>  r   re  rg  ri  r   r   r   r   rb  B  s
   

rb  c               @   s   e Zd ZdddZdS )TestMMDFNc             C   s   t ||S )N)r   ZMMDF)r   r   r   r   r   r   rv   s  rw   zTestMMDF.<lambda>)N)r$   r%   r&   r0   r   r   r   r   rj  q  s   rj  c               @   s^   e Zd ZdddZdd Zdd Zdd	 Zd
d Zdd Zdd Z	dd Z
dd Zdd ZdS )TestMHNc             C   s   t ||S )N)r   ZMH)r   r   r   r   r   r   rv   x  rw   zTestMH.<lambda>c             C   s   |  t| jdg d S )Nz.mh_sequences)r   r   r   r/   )r   r   r   r   rS   z  s    zTestMH.assertMailboxEmptyc             C   sX   | j d | j d | j d | t| j  d | t| j  td d S )Nr   r  r  r7   )r   r  r  )r1   r  r   r   r  r   )r   r   r   r   r  }  s    zTestMH.test_list_foldersc             C   s   dd }|  | j|| _| jd}| jd}|| jd  | tj	
tj	| jd | jd}| || d | jd  | |j | jj  | |j | jj  d S )Nc             S   s   d S )Nr   )r+  r   r   r   r,    s    z-TestMH.test_get_folder.<locals>.dummy_factoryzfoo.barr   r   )r0   r/   r1   r  r  r=   r>   r   r   r   r   r   r   rG   rH   r   )r   r,  Z
new_folderr  r  r   r   r   r	    s    zTestMH.test_get_folderc             C   s4  | j d | j d | t| j  d | t| j  td | j d | t| j  d | t| j  td | j d | t| j  d | t| j  td | j d | t| j  d | t| j  td | j d | t| j  d	 | | j  g  d S )
Nr   r  r6   )r   r  r5   )r  r  )r  r  r   )r1   r  r   r   r  r   r
  )r   r   r   r   r    s     z"TestMH.test_add_and_remove_foldersc             C   s   |  | j i  t| jd }|d | j|}|  | j d|gi t| jd }|dddg | j|}|  | j ||g|g|gd |dg || j|< |  | j |g|g|g|gd | j	| |  | j d|gi d S )	Nr   r   r5   r   replied)r   r   rl  flagged)r   r   rl  rm  )
r   r1   get_sequencesr   r)   r>   add_sequencer=   set_sequencesrq   )r   r   ru   r   rz   r   r   r   test_sequences  s"    

zTestMH.test_sequencesc             C   s6   t | jd }|d | j|}| j|}d S )Nr   r   )r   r)   r>   ro  r1   r=   r   )r   r   ru   Zrefmsg0r   r   r   test_issue2625  s    
zTestMH.test_issue2625c             C   s@   t | jd }| j|}| j  | j| | j  d S )Nr   )r   r)   r>   r1   r=   r   rq   r   )r   r   ru   r   r   r   test_issue7627  s
    
zTestMH.test_issue7627c       	   	   C   s  t | jd }t | jd }t | jd }t | jd }|ddg |dg |ddg |ddd	g | j|}| j|}| j|}| j|}| | j ||||g|g|g|g|gd
 | j| | | j |||g|g|g|gd | j	  | | j
 dddg |}|d }|d }| | j dddgdgdgdgd | j|}| j|}| j|}| j|}| j| | j| | j  | j	  | j  | | j dddddgdgdgdgd d S )Nr   r5   r6   r7   r   unseenrm  r   rl  )r   rt  rm  r   rl  )r   rt  r   rl  r8   r9   )r   r)   r>   rp  r1   r=   r   rn  rq   packrH   r   r   )	r   r   r   r   Zmsg3ru   rz   ry   Zkey3r   r   r   	test_pack  sL    



zTestMH.test_packc             C   s   t j| jdS )Nz.mh_sequences.lock)r   r   r   r/   )r   r   r   r   r     s    zTestMH._get_lock_path)N)r$   r%   r&   r0   rS   r  r	  r  rq  rr  rs  rv  r   r   r   r   r   rk  v  s   
	,rk  c                   s6   e Zd Zd
ddZdd Z fddZdd	 Z  ZS )	TestBabylNc             C   s   t ||S )N)r   ZBabyl)r   r   r   r   r   r   rv     rw   zTestBabyl.<lambda>c          	   C   s*   t | j}| | g  W d Q R X d S )N)r  r/   r   rI  )r   rb   r   r   r   rS     s    zTestBabyl.assertMailboxEmptyc                sH   t    | j  | | j x"t| jd D ]}t| q2W d S )Nz.*)	rE  r4   r1   r3   r#   r/   rF  r   r!   )r   rG  )rH  r   r   r4     s
    

zTestBabyl.tearDownc             C   s   |  | j g  t| jd }|d | j|}|  | j dg t| jd }|dddg | j|}|  t	| j t	ddg |ddg || j|< |  t	| j t	dddg | j
| |  t	| j t	dg d S )Nr   r   r5   r   answeredZblahfiled)r   r1   
get_labelsr   r*   r>   	add_labelr=   
set_labelsr   rq   )r   r   ru   r   rz   r   r   r   test_labels  s    

zTestBabyl.test_labels)N)r$   r%   r&   r0   rS   r4   r}  ra  r   r   )rH  r   rw    s   
rw  c               @   s   e Zd Zdd Zdd ZdS )FakeFileLikeObjectc             C   s
   d| _ d S )NF)closed)r   r   r   r   __init__!  s    zFakeFileLikeObject.__init__c             C   s
   d| _ d S )NT)r  )r   r   r   r   r3   $  s    zFakeFileLikeObject.closeN)r$   r%   r&   r  r3   r   r   r   r   r~    s   r~  c               @   s   e Zd Zdd Zdd ZdS )FakeMailBoxc             C   s,   t j| ddd  dd tdD | _d S )Nr   c             S   s   d S )Nr   )r   r   r   r   rv   +  rw   z&FakeMailBox.__init__.<locals>.<lambda>c             S   s   g | ]
}t  qS r   )r~  )r   r   r   r   r   r   ,  s    z(FakeMailBox.__init__.<locals>.<listcomp>r|   )r   r   r  r   files)r   r   r   r   r  *  s    zFakeMailBox.__init__c             C   s
   | j | S )N)r  )r   r   r   r   r   r^   .  s    zFakeMailBox.get_fileN)r$   r%   r&   r  r^   r   r   r   r   r  (  s   r  c               @   s   e Zd Zdd ZdS )TestFakeMailBoxc             C   sl   t  }x"tdD ]}| |j| j qW xtdD ]}||  q4W x"tdD ]}| |j| j qNW d S )Nr|   )r  r   r   r  r  r   )r   r   r   r   r   r   test_closing_fd4  s    zTestFakeMailBox.test_closing_fdN)r$   r%   r&   r  r   r   r   r   r  2  s   r  c               @   sr   e Zd ZejZdd Zdd Zdd Zdd Z	d	d
 Z
dd Zdd Zdd Zdd Zdd Zdd Zdd ZdS )TestMessagec             C   s   t j| _d S )N)r   r.   r/   )r   r   r   r   r2   B  s    zTestMessage.setUpc             C   s   |  | j d S )N)r#   r/   )r   r   r   r   r4   E  s    zTestMessage.tearDownc             C   s,   t t}| |}| | | | d S )N)r   r@   r?   r0   _post_initialize_hookr   )r   eMMr   r   r   r   test_initialize_with_eMMH  s    


z$TestMessage.test_initialize_with_eMMc             C   s"   |  t}| | | | d S )N)r0   r?   r  r   )r   r   r   r   r   test_initialize_with_stringO  s    

z'TestMessage.test_initialize_with_stringc          	   C   sN   t | jd8}|t |d | |}| | | | W d Q R X d S )Nzw+r   )r  r/   rf   r?   rg   r0   r  r   )r   rb   r   r   r   r   test_initialize_with_fileU  s    



z%TestMessage.test_initialize_with_filec          	   C   sN   t | jd8}|t |d | |}| | | | W d Q R X d S )Nzwb+r   )r  r/   rf   rC   rg   r0   r  r   )r   rb   r   r   r   r    test_initialize_with_binary_file^  s    



z,TestMessage.test_initialize_with_binary_filec             C   sn   |   }| | | |tjj | |tj | || j  | | g  | 	|
  | |  d S )N)r0   r  r   r   r   r   r   r   rH   r   r   r   r   )r   r   r   r   r   test_initialize_with_nothingg  s    
z(TestMessage.test_initialize_with_nothingc                s     t fdd d S )Nc                  s     t S )N)r0   objectr   )r   r   r   rv   t  rw   z9TestMessage.test_initialize_incorrectly.<locals>.<lambda>)rZ   r   )r   r   )r   r   test_initialize_incorrectlyr  s    z'TestMessage.test_initialize_incorrectlyc             C   s>   t t}| t}x$|jD ]}| ||jd| qW d S )Nz{} attribute does not exist)r   r@   r?   r0   __dict__r   format)r   r  r   attrr   r   r   test_all_eMM_attribues_existv  s
    


z(TestMessage.test_all_eMM_attribues_existc             C   s*   t t}|  }|| | | d S )N)r   r@   r?   r0   Z_become_messager   )r   r  r   r   r   r   test_become_message~  s    

zTestMessage.test_become_messagec                sL   |    x| jD ]}|   qW tj | t fdd d S )Nc                  s
     S )N)_explain_tor   )r   	other_msgr   r   rv     rw   z-TestMessage.test_explain_to.<locals>.<lambda>)r0   r,   r  r   r   r   rZ   r   )r   rM  r   )r   r  r   test_explain_to  s    
zTestMessage.test_explain_toc             C   s   d S )Nr   )r   r   r   r   r   r    s    z!TestMessage._post_initialize_hookN)r$   r%   r&   r   r   r0   r2   r4   r  r  r  r  r  r  r  r  r  r  r   r   r   r   r  >  s   		
r  c               @   sB   e Zd ZejZdd Zdd Zdd Zdd Z	d	d
 Z
dd ZdS )TestMaildirMessagec             C   s    |  |jd |  |jd d S )Nr   r   )r   Z_subdir_info)r   r   r   r   r   r    s    z(TestMaildirMessage._post_initialize_hookc                s   t t |   d  d |   d  d |   d | t fdd |   d  d |   d |   d S )Nr   r   c                  s
     dS )Nr   )r   r   )r   r   r   rv     rw   z0TestMaildirMessage.test_subdir.<locals>.<lambda>)	r   r'   r?   r   r   r   rZ   rQ   r   )r   r   )r   r   test_subdir  s    



zTestMaildirMessage.test_subdirc             C   s   t t}| | d | | d |d | | d | | d |d | | d |d | | d |d | | d	 | | d | 	| d S )
Nr   r   FZSDTPZDPSTZFTZDFPSTZTDRPFS)
r   r'   r?   r   r   r   r   add_flagremove_flagr   )r   r   r   r   r   
test_flags  s    




zTestMaildirMessage.test_flagsc             C   sD   t t}| t| t  d |d | | d d S )N<   g        )	r   r'   r?   r   absget_dater  set_dater   )r   r   r   r   r   	test_date  s    

zTestMaildirMessage.test_datec                sV   t t |   d  d |   d | t fdd |   d S )Nr   z	1,foo=barc                  s
     d S )N)r   r   )r   r   r   rv     rw   z.TestMaildirMessage.test_info.<locals>.<lambda>)	r   r'   r?   r   get_infor   rZ   r   r   )r   r   )r   r   	test_info  s    

zTestMaildirMessage.test_infoc             C   s   t t}| | d |d | | d | | d |d | | d | | d |d | | d | | d |	d | | d | | d | 
| d S )	Nr   ZSFr  z2,FSz1,ZRPTDz2,D)r   r'   r?   r   r  r   r   r   r  r  r   )r   r   r   r   r   test_info_and_flags  s    




z&TestMaildirMessage.test_info_and_flagsN)r$   r%   r&   r   r'   r0   r  r  r  r  r  r  r   r   r   r   r    s   	r  c               @   s<   e Zd ZejZdd Zdd Zdd Zdd Z	dd
dZ
d	S )_TestMboxMMDFMessagec             C   s   |  | d S )N)_check_from)r   r   r   r   r   r    s    z*_TestMboxMMDFMessage._post_initialize_hookc             C   s8   t t}|d t |}| | d|  d S )NzFrom foo@bar blahzfoo@bar blah)r   r   r?   Zset_unixfromr(   r   rJ  )r   r   r   r   r   test_initialize_with_unixfrom  s    


z2_TestMboxMMDFMessage.test_initialize_with_unixfromc             C   sf   t t}| | |d | | d |dd | |d |dt  | |d d S )Nzfoo barzfoo@barTz	blah@temp)	r   r(   r?   r  set_fromr   rJ  r  Z	localtime)r   r   r   r   r   	test_from  s    


z_TestMboxMMDFMessage.test_fromc             C   s   t t}| | d |d | | d |d | | d |d | | d |d | | d | | d S )	Nr   r  ZXODRZRODXZFAZRODFAXZFDXARO)	r   r(   r?   r   r   r   r  r  r   )r   r   r   r   r   r    s    




z_TestMboxMMDFMessage.test_flagsNc             C   s*   |d krd}|  t|d |  d S )NzMAILER-DAEMONz. \w{3} \w{3} [\d ]\d [\d ]\d:\d{2}:\d{2} \d{4})r  r  r  rJ  )r   r   Zsenderr   r   r   r    s
    z _TestMboxMMDFMessage._check_from)N)r$   r%   r&   r   Z_mboxMMDFMessager0   r  r  r  r  r  r   r   r   r   r    s   r  c               @   s   e Zd ZejZdS )TestMboxMessageN)r$   r%   r&   r   r(   r0   r   r   r   r   r    s   r  c               @   s"   e Zd ZejZdd Zdd ZdS )TestMHMessagec             C   s   |  |jg  d S )N)r   Z
_sequences)r   r   r   r   r   r    s    z#TestMHMessage._post_initialize_hookc             C   s(  t t}| | g  |dg | | dg |g  | | g  |d | | dg |d | | ddg |d | | ddg |d | | dg |d | | ddg |d | | ddg |ddg | | ddg d S )Nfoobarrt  rm  rl  )r   r)   r?   r   rn  rp  ro  Zremove_sequence)r   r   r   r   r   rq    s(    







zTestMHMessage.test_sequencesN)r$   r%   r&   r   r)   r0   r  rq  r   r   r   r   r    s   r  c               @   s*   e Zd ZejZdd Zdd Zdd ZdS )TestBabylMessagec             C   s   |  |jg  d S )N)r   Z_labels)r   r   r   r   r   r  6  s    z&TestBabylMessage._post_initialize_hookc             C   s(  t t}| | g  |dg | | dg |g  | | g  |d | | dg |d | | ddg |d | | ddg |d | | dg |d | | ddg |d | | ddg |ddg | | ddg d S )Nr  ry  resentrt  rx  )r   r*   r?   r   rz  r|  r{  Zremove_label)r   r   r   r   r   r}  9  s(    







zTestBabylMessage.test_labelsc             C   s  t t}| }| | g  | |  d|d< d|d< | |  g  || | }| | ddg | |d d | |d d | |  |	  | | ddg | |  | }| | dddddg x d	D ]}| || ||  qW d S )
Nz
FooBar 1.0z
User-AgentZBlahz
X-WhateverDaterf  ToSubject)z
User-Agentr  rf  r  r  )
r   r*   r?   get_visibler   rH   r   r   Zset_visibleupdate_visible)r   r   Zvisibleheaderr   r   r   test_visibleP  s*    


zTestBabylMessage.test_visibleN)	r$   r%   r&   r   r*   r0   r  r}  r  r   r   r   r   r  2  s   r  c               @   s   e Zd ZejZdS )TestMMDFMessageN)r$   r%   r&   r   r+   r0   r   r   r   r   r  i  s   r  c               @   s   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd Zdd Z	dd Z
dd Zdd Zdd Zdd Zdd Zdd Zdd Zdd  Zd!d" Zd#d$ Zd%d& Zd'd( Zd)d* Zd+S ),TestMessageConversionc             C   s0   x*| j D ] }tt}||}| | qW d S )N)r,   r   r   r?   r   )r   rM  	msg_plainr   r   r   r   test_plain_to_xp  s    
z%TestMessageConversion.test_plain_to_xc             C   s0   x*| j D ] }|t}t|}| | qW d S )N)r,   r?   r   r   r   )r   rM  r   r  r   r   r   test_x_to_plainw  s    
z%TestMessageConversion.test_x_to_plainc             C   s&   x | j D ]}|t}| | qW d S )N)r,   rC   r   )r   rM  r   r   r   r   test_x_from_bytes~  s    z'TestMessageConversion.test_x_from_bytesc                s(   x"| j D ] | t fdd qW d S )Nc                  s    dS )NFr   r   )rM  r   r   rv     rw   z9TestMessageConversion.test_x_to_invalid.<locals>.<lambda>)r,   rZ   r   )r   r   )rM  r   test_x_to_invalid  s    z'TestMessageConversion.test_x_to_invalidc                s   dd | j D xv| j D ]l}xf| j D ]\ | kr2q$|t} |} fdd| D }x$|D ]}| ||jd|  q`W q$W qW d S )Nc             S   s   i | ]}|t j|qS r   )r?   r  )r   rM  r   r   r   
<dictcomp>  s   z]TestMessageConversion.test_type_specific_attributes_removed_on_conversion.<locals>.<dictcomp>c                s   g | ]}|  kr|qS r   r   )r   a)class2	referencer   r   r     s    z]TestMessageConversion.test_type_specific_attributes_removed_on_conversion.<locals>.<listcomp>zwhile converting {} to {})r,   r?   r   r  r  )r   Zclass1sourcer"   Ztype_specificr  r   )r  r  r   3test_type_specific_attributes_removed_on_conversion  s    


zITestMessageConversion.test_type_specific_attributes_removed_on_conversionc             C   sn   t t}|d |d | }t |}| | | | d | |	 d | | | d S )NDFPRSTr   )
r   r'   r?   r   r   r  r   r   r   r   )r   msg_maildirZdater   r   r   r   test_maildir_to_maildir  s    




z-TestMessageConversion.test_maildir_to_maildirc             C   s   d}xt jt jfD ]}t t}|d xR|D ]J\}}|| ||}| | | | |	 dt
t
d  q0W |d | || d qW d S )N))r  r   )r  r  )Pr   )RA)r   r  )Tr  )r  ZRDFAg        zMAILER-DAEMON %sr   RODFA)r   r(   r+   r'   r?   r  r   r   r   rJ  r  Zasctimegmtimer   )r   pairsrM  r  settingresultr   r   r   r   test_maildir_to_mboxmmdf  s    



z.TestMessageConversion.test_maildir_to_mboxmmdfc          	   C   s   t 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}x0|D ](\}}|| | t | | qPW d S )Nr  rt  r  rm  r  r  rl  r   r  r  )r   r'   r?   r   r   r)   rn  )r   r  r  r  r  r   r   r   test_maildir_to_mh  s    

z(TestMessageConversion.test_maildir_to_mhc          
   C   s   t 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d
ddgff}x0|D ](\}}|| | t | | qTW d S )Nr  rt  r  r  	forwardedr  rx  r   r  deletedr  )r   r'   r?   r   r   r*   rz  )r   r  r  r  r  r   r   r   test_maildir_to_babyl  s    

z+TestMessageConversion.test_maildir_to_babylc             C   s   xt jt jfD ]}|t}|dtd d}xD|D ]<\}}|| t |}| 	|
 | | 	| d q6W |d | 	t | d qW d S )Nzfoo@barg        ))r  r   )Or   )r  r  )r  r  )r  r  )r  ZFRSTr  r   )r   r(   r+   r?   r  r  r  r   r'   r   r   r  r   )r   rM  msg_mboxMMDFr  r  r  r   r   r   r   test_mboxmmdf_to_maildir  s    


z.TestMessageConversion.test_mboxmmdf_to_maildirc             C   st   xnt jt jfD ]^}|t}|d |d x<t jt jfD ],}||}| | d | | d q<W qW d S )Nr  zfoo@bar)	r   r(   r+   r?   r   r  r   r   rJ  )r   rM  r  Zclass2_r   r   r   r   test_mboxmmdf_to_mboxmmdf  s    

z/TestMessageConversion.test_mboxmmdf_to_mboxmmdfc          	   C   s   xt jt jfD ]v}|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}x0|D ](\}}|| | t | | qXW qW d S )
Nr  r  rt  r  r  rm  r  rl  r  )r   r(   r+   r?   r   r   r)   rn  )r   rM  r  r  r  r  r   r   r   test_mboxmmdf_to_mh  s    


z)TestMessageConversion.test_mboxmmdf_to_mhc          	   C   s   xt jt jfD ]v}|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}x0|D ](\}}|| | t | | qXW qW d S )
Nr  r  rt  r  r  r  r  rx  r  )r   r(   r+   r?   r   r   r*   rz  )r   rM  r   r  r  r  r   r   r   test_mboxmmdf_to_babyl  s    

z,TestMessageConversion.test_mboxmmdf_to_babylc             C   s   d}xP|D ]H\}}t t}|| | t | | | t | d q
W t t}|d |d |d | t | d | t | d d S )N))rt  r   )rl  RS)rm  r  r   rt  rl  rm  r   )r   r)   r?   ro  r   r'   r   r   )r   r  r  r  r   r   r   r   test_mh_to_maildir  s    





z(TestMessageConversion.test_mh_to_maildirc             C   s   d}xN|D ]F\}}t t}|| x(t jt jfD ]}| || | q4W q
W t t}|d |d |d x(t jt jfD ]}| || d qW d S )N))rt  r  )rl  ROA)rm  ZROFrt  rl  rm  ZOFA)r   r)   r?   ro  r(   r+   r   r   )r   r  r  r  r   rM  r   r   r   test_mh_to_mboxmmdf  s    





z)TestMessageConversion.test_mh_to_mboxmmdfc             C   sH   t t}|d |d |d | t | dddg d S )Nrt  rl  rm  )r   r)   r?   ro  r   rn  )r   r   r   r   r   test_mh_to_mh  s    



z#TestMessageConversion.test_mh_to_mhc             C   s   ddgfddgfdg ff}x:|D ]2\}}t t}|| | t | | q W t t}|d |d |d | t | ddg d S )Nrt  rl  rx  rm  )r   r)   r?   ro  r   r*   rz  )r   r  r  r  r   r   r   r   test_mh_to_babyl&  s    






z&TestMessageConversion.test_mh_to_babylc             C   s   d}xP|D ]H\}}t t}|| | t | | | t | d q
W t t}xdD ]}|| qfW | t | d | t | d d S )N))rt  r   )r  ZST)ry  r   )rx  r  )r  PS)editedr   )r  r  r   )rt  r  ry  rx  r  r  r  ZPRT)r   r*   r?   r{  r   r'   r   r   )r   r  r  r  r   labelr   r   r   test_babyl_to_maildir5  s    



z+TestMessageConversion.test_babyl_to_maildirc             C   s   d}xN|D ]F\}}x<t jt jfD ],}t t}|| | || | q W q
W t t}xdD ]}|| qdW x(t jt jfD ]}| || d qW d S )N))rt  r  )r  ZROD)ry  r  )rx  r  )r  r  )r  r  )r  r  )rt  r  ry  rx  r  r  r  ZODA)r   r(   r+   r*   r?   r{  r   r   )r   r  r  r  rM  r   r  r   r   r   test_babyl_to_mboxmmdfF  s    



z,TestMessageConversion.test_babyl_to_mboxmmdfc             C   s   ddgfdg fdg fddgfdg fdg fdg ff}x:|D ]2\}}t t}|| | t | | q8W t t}xd	D ]}|| q~W | t | ddg d S )
Nrt  r  ry  rx  rl  r  r  r  )rt  r  ry  rx  r  r  r  )r   r*   r?   r{  r   r)   rn  )r   r  r  r  r   r  r   r   r   test_babyl_to_mhW  s    




z&TestMessageConversion.test_babyl_to_mhc          
   C   s   t t}|  xdD ]}|| qW t |}| | dddddddg | |  |   x0|  D ] }| | | | |  q|W d S )	N)rt  r  ry  rx  r  r  r  rt  r  ry  rx  r  r  r  )	r   r*   r?   r  r{  r   rz  r  rH   )r   r   r  r   r   r   r   r   test_babyl_to_babylg  s    


z)TestMessageConversion.test_babyl_to_babylN)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  n  s*   	r  c               @   s<   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd ZdS )TestProxyFileBasec             C   s   | d | | d | d | | d | d | |dd | d | |dd | d | |dd	 d S )
Nr   s   barr5   s   arr6   s   bai     r)rg   r   r_   )r   proxyr   r   r   
_test_ready  s    




zTestProxyFileBase._test_readc             C   s   t j }|d | | d|  | | d|  | | d|  | | d |d | | d|  |ddtt j   | | d|  |ddtt j   | |dd	 | |d
d|  d S )Nr   s   foos   bars   freds   bobr6      or:   s   fris   ed)r   ra   rK   rg   r   readliner   )r   r  ra   r   r   r   _test_readline  s    


z TestProxyFileBase._test_readlinec             C   s   t j }|d | | d| d| d| dg |d | |dd| g |dt|  | |dt| d| d| g |d | |d	|d| d| dg d S )
Nr   s   foos   bars   freds   bobr6   r7   r8   i  )r   ra   rK   rg   r   rI  r   )r   r  ra   r   r   r   _test_readlines  s    



z!TestProxyFileBase._test_readlinesc             C   sz   t j }|d t|}| t|d|  | t|d|  | t|d|  | t|d | tt| d S )Nr   s   foos   bars   freds   bob)	r   ra   rK   rg   iterr   nextrZ   StopIteration)r   r  ra   iteratorr   r   r   _test_iteration  s    

z!TestProxyFileBase._test_iterationc             C   s   t j }|d | | d | |t|| |dd | |dt| d|  |dt| d | |dd |dd | | d| d |  |d	 | |  d S )
Nr7   r6   r5   r  r%  s   barr   r  d   )	r   ra   rK   rg   r   tellr_   r   r   )r   r  ra   r   r   r   _test_seek_and_tell  s    


z%TestProxyFileBase._test_seek_and_tellc             C   s8   |  |j |  | |j |  | |j d S )N)r   r  r3   r   )r   r  r   r   r   _test_close  s
    zTestProxyFileBase._test_closeN)	r$   r%   r&   r  r  r  r  r  r  r   r   r   r   r  w  s   r  c               @   sT   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd Zdd Z	dd Z
dd ZdS )TestProxyFilec             C   s   t j| _t| jd| _d S )Nzwb+)r   r.   r/   r  rS  )r   r   r   r   r2     s    zTestProxyFile.setUpc             C   s   | j   | | j d S )N)rS  r3   r#   r/   )r   r   r   r   r4     s    
zTestProxyFile.tearDownc             C   sx   | j d | j  }t| j }| | | | | j  | t| j d}| | d | | j  | d S )Ns   foor   )rS  rf   r  r   
_ProxyFiler   )r   posZproxy0Zproxy1r   r   r   test_initialize  s    
zTestProxyFile.test_initializec             C   s"   | j d | t| j  d S )Ns   bar)rS  rf   r  r   r  )r   r   r   r   	test_read  s    zTestProxyFile.test_readc             C   s8   | j tdtjtjtjf d | t| j  d S )Nzfoo%sbar%sfred%sbobr   )rS  rf   bytesr   ra   r  r   r  )r   r   r   r   test_readline  s    zTestProxyFile.test_readlinec             C   s8   | j tdtjtjtjf d | t| j  d S )Nzfoo%sbar%sfred%sbobr   )rS  rf   r  r   ra   r  r   r  )r   r   r   r   test_readlines  s    zTestProxyFile.test_readlinesc             C   s8   | j tdtjtjtjf d | t| j  d S )Nzfoo%sbar%sfred%sbobr   )rS  rf   r  r   ra   r  r   r  )r   r   r   r   test_iteration  s    zTestProxyFile.test_iterationc             C   s4   | j tdtjtjf d | t| j  d S )Nz
foo%sbar%sr   )rS  rf   r  r   ra   r  r   r  )r   r   r   r   test_seek_and_tell  s    z TestProxyFile.test_seek_and_tellc             C   s4   | j tdtjtjf d | t| j  d S )Nz
foo%sbar%sr   )rS  rf   r  r   ra   r  r   r  )r   r   r   r   r     s    zTestProxyFile.test_closeN)r$   r%   r&   r2   r4   r   r  r  r  r  r  r   r   r   r   r   r    s   r  c               @   sT   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd Zdd Z	dd Z
dd ZdS )TestPartialFilec             C   s   t j| _t| jd| _d S )Nzwb+)r   r.   r/   r  rS  )r   r   r   r   r2     s    zTestPartialFile.setUpc             C   s   | j   | | j d S )N)rS  r3   r#   r/   )r   r   r   r   r4     s    
zTestPartialFile.tearDownc             C   s\   | j tdtj d d | j  }t| j dd}| | d | | j  | d S )Nr   r   r   r6   r9   r   )	rS  rf   r  r   ra   r  r   _PartialFiler   )r   r  r  r   r   r   r     s
    
zTestPartialFile.test_initializec             C   s,   | j tdd | t| j dd d S )Nz	***bar***r   r7   r:   )rS  rf   r  r  r   r  )r   r   r   r   r    s    zTestPartialFile.test_readc          
   C   sJ   | j tdtjtjtjf d | t| j dddttj   d S )Nz!!!!!foo%sbar%sfred%sbob!!!!!r   r9      r7   )	rS  rf   r  r   ra   r  r   r  r   )r   r   r   r   r    s    
zTestPartialFile.test_readlinec          
   C   sJ   | j tdtjtjtjf d | t| j dddttj   d S )Nzfoo%sbar%sfred%sbob?????r   r      r7   )	rS  rf   r  r   ra   r  r   r  r   )r   r   r   r   r    s    
zTestPartialFile.test_readlinesc          
   C   sJ   | j tdtjtjtjf d | t| j dddttj   d S )Nz____foo%sbar%sfred%sbob####r   r8      r7   )	rS  rf   r  r   ra   r  r   r  r   )r   r   r   r   r    s    
zTestPartialFile.test_iterationc          
   C   sF   | j tdtjtjf d | t| j dddttj   d S )Nz(((foo%sbar%s$$$r   r7   	   r6   )	rS  rf   r  r   ra   r  r   r  r   )r   r   r   r   r  #  s    z"TestPartialFile.test_seek_and_tellc          
   C   sF   | j tdtjtjf d | t| j dddttj   d S )Nz&foo%sbar%s^r   r5   r:   r7   )	rS  rf   r  r   ra   r  r   r  r   )r   r   r   r   r   (  s    zTestPartialFile.test_closeN)r$   r%   r&   r2   r4   r   r  r  r  r  r  r   r   r   r   r   r    s   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               @   sF   e Zd Zdd Zdd ZdddZdd	 Zd
d Zdd Zdd Z	dS )MaildirTestCasec             C   s   t j| _tj| jr$t | j ntj| jr>t | j t	| j t	tj
| jd t	tj
| jd t	tj
| jd d| _g | _d S )Nr   r   r   r5   )r   r.   _dirr   r   r   r   isfiler!   r   r   _counter	_msgfiles)r   r   r   r   r2   ;  s    zMaildirTestCase.setUpc             C   sd   t ttj| j ttj| j	d ttj| j	d ttj| j	d t| j	 d S )Nr   r   r   )
r   mapr   r!   r  r   rmdirr   r   r  )r   r   r   r   r4   I  s
    zMaildirTestCase.tearDownFc       	      C   s   t t d }| j}|  jd7  _dt|t|ddf}tj| jd|}tj| j||}t|d*}| j	
| |r|t |t W d Q R X yt|| W n8 ttfk
r   t|d}|t W d Q R X Y nX | j	
| |S )Ni@B r5   .Z
myhostnameZmydomainr   r  )r   r  r  r   strr   r   r  r  r  r<   rf   FROM_DUMMY_MESSAGElinkAttributeErrorPermissionError)	r   dirrc  tr  r:  ZtmpnameZnewnamefpr   r   r   createMessageP  s$    
zMaildirTestCase.createMessagec             C   s2   t tj| _| | j  | | j  d S )N)r   r   r   r.   rc  r   r  )r   r   r   r   test_empty_maildird  s    z"MaildirTestCase.test_empty_maildirc             C   sL   |  d ttj| _| | j  | | j  | | j  d S )Nr   )	r  r   r   r   r.   rc  r  r  r   )r   r   r   r   test_nonempty_maildir_curn  s
    
z)MaildirTestCase.test_nonempty_maildir_curc             C   sL   |  d ttj| _| | j  | | j  | | j  d S )Nr   )	r  r   r   r   r.   rc  r  r  r   )r   r   r   r   test_nonempty_maildir_newv  s
    
z)MaildirTestCase.test_nonempty_maildir_newc             C   sf   |  d |  d ttj| _| | j  | | j  | | j  | | j  d S )Nr   r   )	r  r   r   r   r.   rc  r  r  r   )r   r   r   r   test_nonempty_maildir_both~  s    

z*MaildirTestCase.test_nonempty_maildir_bothN)F)
r$   r%   r&   r2   r4   r  r  r   r!  r"  r   r   r   r   r  9  s   

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<gkj@gregorykjohnson.com>zgkj+person@localhostzfrom 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)z gkj@sundance.gregorykjohnson.comzfrom 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)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)ztby andy.gregorykjohnson.com (Postfix, from userid 1000)
        id 490CD9DD17; Wed, 13 Jul 2005 17:23:11 -0400 (EDT)zWed, 13 Jul 2005 17:23:11 -0400z."Gregory K. Johnson" <gkj@gregorykjohnson.com>zgkj@gregorykjohnson.comzSample messagez1.0z,multipart/mixed; boundary="NMuMz9nt05w80d4+"ZinlinezMutt/1.5.9i)zReturn-PathzX-Original-TozDelivered-ToReceivedzDelivered-Tor#  r#  r#  r  rf  r  r  zMime-VersionzContent-TypezContent-Dispositionz
User-Agent)z1This is a sample message.

--
Gregory K. Johnson
zRH4sICM2D1UIAA3RleHQAC8nILFYAokSFktSKEoW0zJxUPa7wzJIMhZLyfIWczLzUYj0uAHTs
3FYlAAAA
c               @   s   e Zd Zdd ZdS )MiscTestCasec             C   s   ddh}t j| t|d d S )Nra   Zfcntl)	blacklist)r   Zcheck__all__r   )r   r%  r   r   r   test__all__  s    zMiscTestCase.test__all__N)r$   r%   r&   r&  r   r   r   r   r$    s   r$  c              C   s>   t ttttttttt	t
tttttttf} tj|   t  d S )N)r   r   rb  rj  rk  rw  r  r  r  r  r  r  r  r  r  r  r  r$  r   Zrun_unittestZreap_children)Ztestsr   r   r   	test_main  s    


r'  __main__)5r   r   r  r   r  r   Zemail.messager  rA   rd   Ztestr   r<  r   r   rF  r   r-   ZTestCaser   r   r?  rD  rb  rj  rk  rw  r~  r   r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r?   rK   rC   r	   r   r$  r'  r$   r   r   r   r   <module>   s      }$  _)p/ "	
VJ07  S15


