HEX
Server: Apache
System: Linux bd12.noc223.com 4.18.0-553.121.1.lve.el8.x86_64 #1 SMP Thu Apr 30 16:40:41 UTC 2026 x86_64
User: handcraf (1693)
PHP: 8.1.28
Disabled: NONE
Upload Files
File: //opt/alt/python312/lib64/python3.12/test/__pycache__/test_mailbox.cpython-312.opt-1.pyc
�

h�e7r����ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZddlm
Z
ddlmZddlZddlZddlZddlZej&sej(d��Gd�d�ZGd�d	e�ZGd
�deej.�ZGd�d
eej.�ZGd�de�ZGd�de�ZGd�deej.�ZGd�deej.�ZGd�deej.�ZGd�deej.�ZGd�d�Z Gd�dejB�Z"Gd�dej.�Z#Gd �d!eej.�Z$Gd"�d#e$ej.�Z%Gd$�d%�Z&Gd&�d'e&e$�Z'Gd(�d)e$ej.�Z(Gd*�d+e$ej.�Z)Gd,�d-e&e$�Z*Gd.�d/eej.�Z+Gd0�d1e�Z,Gd2�d3e,ej.�Z-Gd4�d5e,ej.�Z.d6Z/d7Z0Gd8�d9ej.�Z1d:Z2e2jgd;�Z4gd<�Z5d=Z6Gd>�d?ej.�Z7d@�Z8e9dAk(rejt�yy)B�N)�support)�	os_helper)�
socket_helperztest requires gethostname()c��eZdZejej
ejejejejfZ
d�Zd�Zy)�TestBasec���|j|tjj�|j|tj�t
D]&\}}|j
||j|���(|j|j��|jt|j��tt��tt�D]�\}}|j|�}|j|tjj�|j|tj�|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       �8/opt/alt/python312/lib64/python3.12/test/test_mailbox.py�
_check_samplezTestBase._check_samples������c�5�=�=�#8�#8�9����c�7�?�?�3�)�	3�J�C���M�M�%����S�!1�2�	3�����(�(�*�+�����S�_�_�.�/��5E�1F�G�#�$4�5�	:�J�A�w��?�?�1�%�D��!�!�$��
�
�(=�(=�>��$�$�T�7�?�?�;����T�-�-�/��9�		:�c���tjj|�rtj|�ytjj|�rtj|�yyr	)�os�path�isdirr�rmtree�exists�unlink)r�targets  r!�_delete_recursivelyzTestBase._delete_recursively,sC��
�7�7�=�=�� ����V�$�
�W�W�^�^�F�
#����V�$�$r#N)
�__name__�
__module__�__qualname__rr
�MaildirMessage�mboxMessage�	MHMessage�BabylMessage�MMDFMessage�all_mailbox_typesr"r,�r#r!rrsF�� ���'�*@�*@� �,�,�g�.?�.?� �-�-�w�/B�/B�D��:�%r#rc��eZdZdZdZdZd�Zd�Zd�Ze	jd�Zd�Zd�Z
d	�Zd
�Ze	jd�j!d�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd4d�Zd�Zd�Zd�Zd�Zd�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�TestMailboxNzFrom: foo

%s
c��tj|_|j|j�|j	|j�|_yr	)r�TESTFN�_pathr,�_factory�_box�rs r!�setUpzTestMailbox.setUp;s5���%�%��
�� � ����,��M�M�$�*�*�-��	r#c�n�|jj�|j|j�yr	)r=�closer,r;r>s r!�tearDownzTestMailbox.tearDown@s"���	�	����� � ����,r#c
��g}|j|jj|jdz��|j	t|j�d�|j|jjt
jt���|j	t|j�d�|j|jjtjt���|j	t|j�d�|j|jjtjt���|j	t|j�d�|j|jjt��|j	t|j�d�|j|jjt��|j	t|j�d�|jt�5|j|jjtj tjt�d�	���ddd�|j	t|j�d
�|j	|jj#|d�|jdz�dD]#}|j%|j||��%y#1swY��xYw)Nr�������utf-8��encoding�)rDrErFrGrHrI)�appendr=�add�	_templaterrrr
�_sample_messager�message_from_string�io�BytesIO�_bytes_sample_message�assertWarns�DeprecationWarning�
TextIOWrapper�
get_stringr")r�keysrs   r!�test_addzTestMailbox.test_addDs$�������D�I�I�M�M�$�.�.�1�"4�5�6�����T�Y�Y���+����D�I�I�M�M�'�/�/�/�"B�C�D�����T�Y�Y���+����D�I�I�M�M�%�";�";�O�"L�M�N�����T�Y�Y���+����D�I�I�M�M�"�*�*�-B�"C�D�E�����T�Y�Y���+����D�I�I�M�M�/�2�3�����T�Y�Y���+����D�I�I�M�M�"7�8�9�����T�Y�Y���+�
�
�
�0�
1�	X��K�K��	�	�
�
�� � ����,A�!B�W�U�W�
X�	X�	
����T�Y�Y���+�������-�-�d�1�g�6�����8J�K�#�	3�A����t�y�y��a��1�2�	3�	X�	X�s
�AL4�4L=u{            From: foo
            Subject: Falinaptár házhozszállítással. Már rendeltél?

            0
            c�>�|jj|jjd��}|j	t|j�d�|j	|jj
|�|jjd��y)N�latin-1rD)r=rO�
_nonascii_msg�encoderr�	get_bytes�rrs  r!�"test_add_invalid_8bit_bytes_headerz.TestMailbox.test_add_invalid_8bit_bytes_headerbsp���i�i�m�m�D�.�.�5�5�i�@�A������T�Y�Y���+�������,�,�S�1����%�%�i�0�	2r#c���|jj�d}|jj|j	d��}|j|jj
|�d�y)NrDr]zZSubject: =?unknown-8bit?b?RmFsaW5hcHThciBo4Xpob3pzeuFsbO104XNzYWwuIE3hciByZW5kZWx06Ww/?=

)r^�
splitlinesr=rOr_rrY)r�subjrs   r!�&test_invalid_nonascii_header_as_stringz2TestMailbox.test_invalid_nonascii_header_as_stringhsZ���!�!�,�,�.�q�1���i�i�m�m�D�K�K�	�2�3��������-�-�c�2�
-�	.r#c�B�|jtd�5|jj|j�ddd�|jj�|j
t|j�d�|j�y#1swY�YxYw�Nz
ASCII-onlyr)	�assertRaisesRegex�
ValueErrorr=rOr^�flushrr�assertMailboxEmptyr>s r!�&test_add_nonascii_string_header_raisesz2TestMailbox.test_add_nonascii_string_header_raisesoso��
�
#�
#�J��
=�	.��I�I�M�M�$�,�,�-�	.��	�	��������T�Y�Y���+����!�		.�	.�s�&B�Bc�����Gd�dt��d���fd�}tj|tjj
d|�|j
���5|jjtjd��ddd�|jt|j�d�|jj�|j�y#1swY�YxYw)Nc��eZdZy)�JTestMailbox.test_add_that_raises_leaves_mailbox_empty.<locals>.CustomErrorN�r-r.r/r6r#r!�CustomErrorrpws�r#rrza fake errorc�������r	r6)�args�kwrr�exc_msgs  ��r!�raiserzETestMailbox.test_add_that_raises_leaves_mailbox_empty.<locals>.raiserzs����g�&�&r#�flattenuFrom: Alphösor)�	Exceptionr�patchr�	generator�BytesGeneratorrir=rOrRrrrArl)rrwrrrvs  @@r!�)test_add_that_raises_leaves_mailbox_emptyz5TestMailbox.test_add_that_raises_leaves_mailbox_emptyvs����)�)�)� ��	'��
�
�d�E�O�O�:�:�I�v�N�
�
#�
#�K��
9�	G��I�I�M�M�%�3�3�4D�E�F�	G�����T�Y�Y���+��	�	�������!�		G�	G�s�/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

        Да, они летят.
        rJc	��|jj|j�}|j|jj	|�|j�|jj|�5}|j|j
�|jjdtjj���ddd�|j|j|j�d�y#1swY�7xYw)N�
uДа, они летят.
)r=rO�_non_latin_bin_msgrr`�get_file�read�replacer%�linesepr_r�rr�fs   r!�test_add_8bit_bodyzTestMailbox.test_add_8bit_body�s����i�i�m�m�D�3�3�4��������,�,�S�1��0�0�	2�
�Y�Y�
�
��
$�	6�����Q�V�V�X�!�4�4�<�<�U� "�
�
� 1� 1� 3�5�
6�	6�	
������3��3�3�5�4�	6�		6�	6�s
�6AD�Dc�t�tjd�5}|jt�|j	d�|j
j
|�}ddd�|j|j
j�jd�tjd��y#1swY�WxYw�N�wb+rr)
�tempfile�
TemporaryFile�writerU�seekr=rOrr`�split�rr�rs   r!�test_add_binary_filez TestMailbox.test_add_binary_file�s���
�
#�
#�E�
*�	#�a�
�G�G�)�*�
�F�F�1�I��)�)�-�-��"�C�	#�	
������,�,�S�1�7�7��>�!�'�'��.�	0�		#�	#�s�AB.�.B7c��tjd�5}|j|j�|j	d�|j
j
|�}ddd�|j|j
j�jd�|jjd��y#1swY�]xYwr�)
r�r�r�r�r�r=rOrr`r�r�s   r!�test_add_binary_nonascii_filez)TestMailbox.test_add_binary_nonascii_file�s���
�
#�
#�E�
*�	#�a�
�G�G�D�+�+�,�
�F�F�1�I��)�)�-�-��"�C�	#�	
������,�,�S�1�7�7��>��#�#�)�)�%�0�	2�		#�	#�s�AB:�:Cc���tjdd��5}|jt�|j	d�|jt�5|jj|�}ddd�ddd�|j|jj�jd�tjd��y#1swY�_xYw#1swY�cxYw)N�w+rJrKrr)
r�r�r�rQr�rVrWr=rOrr`r�rUr�s   r!�test_add_text_file_warnsz$TestMailbox.test_add_text_file_warns�s���
�
#�
#�D�7�
;�	'�q�
�G�G�O�$�
�F�F�1�I��!�!�"4�5�
'��i�i�m�m�A�&��
'�	'�
	
������,�,�S�1�7�7��>�!�'�'��.�	0�
'�
'��	'�	'�s#�<C�C�0C�C	�C�C#c�>�|jt�5|jjt	j
|jdz��}ddd�|j|jj�|jdz�y#1swY�BxYw)N�0)	rVrWr=rOrS�StringIOrPrrYras  r!�test_add_StringIO_warnsz#TestMailbox.test_add_StringIO_warns�sv��
�
�
�0�
1�	C��)�)�-�-����D�N�N�S�,@� A�B�C�	C�������-�-�c�2�D�N�N�S�4H�I�	C�	C�s�<B�Bc��|jt�5|jtd�5|jjt
j|j��ddd�ddd�|jt|j�d�|jj�|j�y#1swY�axYw#1swY�exYwrh)
rVrWrirjr=rOrSr�r^rrrArlr>s r!�!test_add_nonascii_StringIO_raisesz-TestMailbox.test_add_nonascii_StringIO_raises�s���
�
�
�0�
1�	?��'�'�
�L�A�
?��	�	�
�
�b�k�k�$�*<�*<�=�>�
?�	?�	
����T�Y�Y���+��	�	�������!�	
?�
?��	?�	?�s"�C�9C�&C�C	�C�Cc�N�|j|jj�yr	)�_test_remove_or_delitemr=�remover>s r!�test_removezTestMailbox.test_remove�s���$�$�T�Y�Y�%5�%5�6r#c�N�|j|jj�yr	)r�r=�__delitem__r>s r!�test_delitemzTestMailbox.test_delitem�s���$�$�T�Y�Y�%:�%:�;r#c��������jj�jdz���jj�jdz���jt	�j�d�����jt	�j�d��jt��fd���jt��fd���j�jj���jdz��jj�jdz���jt	�j�d�����jt	�j�d��jt��fd���jt��fd���j�jj���jdz�����jt	�j�d��jt��fd���jt��fd	��y)
NrrDrEc�"���j�Sr	�r=��key0rs��r!�<lambda>z5TestMailbox._test_remove_or_delitem.<locals>.<lambda>�����D�I�I�d�O�r#c������Sr	r6)r��methods��r!r�z5TestMailbox._test_remove_or_delitem.<locals>.<lambda>�����F�4�L�r#c�"���j�Sr	r�)�key2rs��r!r�z5TestMailbox._test_remove_or_delitem.<locals>.<lambda>�r�r#c������Sr	r6)r�r�s��r!r�z5TestMailbox._test_remove_or_delitem.<locals>.<lambda>�r�r#c�"���j�Sr	r�)�key1rs��r!r�z5TestMailbox._test_remove_or_delitem.<locals>.<lambda>�r�r#c������Sr	r6)r�r�s��r!r�z5TestMailbox._test_remove_or_delitem.<locals>.<lambda>�r�r#)r=rOrPrr�assertRaises�KeyErrorrY)rr�r�r�r�s``@@@r!r�z#TestMailbox._test_remove_or_delitem�s�����y�y�}�}�T�^�^�a�/�0���y�y�}�}�T�^�^�a�/�0������T�Y�Y���+��t������T�Y�Y���+����(�$;�<����(�$8�9�������-�-�d�3�T�^�^�a�5G�H��y�y�}�}�T�^�^�a�/�0������T�Y�Y���+��t������T�Y�Y���+����(�$;�<����(�$8�9�������-�-�d�3�T�^�^�a�5G�H��t������T�Y�Y���+����(�$;�<����(�$8�9r#c�Z����jj�jdz���jj�jdz�}�jt	�j�d��jj���jt	�j�d��j
t��fd���jj���jt	�j�d��j
t��fd��y)NrrDrEc�"���j�Sr	r�r�s��r!r�z*TestMailbox.test_discard.<locals>.<lambda>�r�r#c�"���j�Sr	r�r�s��r!r�z*TestMailbox.test_discard.<locals>.<lambda>�r�r#)r=rOrPrr�discardr�r�)r�repetitionsr�r�s`  @r!�test_discardzTestMailbox.test_discard�s�����y�y�}�}�T�^�^�a�/�0���y�y�}�}�T�^�^�a�/�0������T�Y�Y���+��	�	���$������T�Y�Y���+����(�$;�<��	�	���$������T�Y�Y���+����(�$;�<r#c��|jj|jdz�}|jj|�}|j	|dd�|j	|j�d�|j
|jjd��|j|jjdd�d�|jj�|j|j�|_|jj|jdz�}|jj|�}|j	|dd�|j	|j�d�y)Nr�from�foo�0
FrD�1
)r=rOrP�getrr�assertIsNone�assertIsrAr<r;)rr�rr�s    r!�test_getzTestMailbox.test_get�s���y�y�}�}�T�^�^�a�/�0���i�i�m�m�D�!������V��e�,�������*�E�2����$�)�)�-�-��.�/��
�
�d�i�i�m�m�E�5�1�5�9��	�	�����M�M�$�*�*�-��	��y�y�}�}�T�^�^�a�/�0���i�i�m�m�D�!������V��e�,�������*�E�2r#c�|����jj�jdz���j�}�j|dd��j|j	�d��jt�fd���jj���jt��fd��y)Nrr�r�r�c�"���jdS�Nr�r�r>s�r!r�z*TestMailbox.test_getitem.<locals>.<lambda>�����D�I�I�e�,<�r#c�"���j�Sr	r�r�s��r!r�z*TestMailbox.test_getitem.<locals>.<lambda>r�r#)r=rOrPrrr�r�r�)rrr�s` @r!�test_getitemzTestMailbox.test_getitem�s�����y�y�}�}�T�^�^�a�/�0���i�i��o������V��e�,�������*�E�2����(�$<�=��	�	���$�����(�$;�<r#c���|jj|jdz�}|jjt�}|jj	|�}|j|tj�|j|dd�|j|j�d�|j|jj	|��y)Nrr�r�r�)r=rOrPrQ�get_messager
rr
rrr")rr�r��msg0s    r!�test_get_messagezTestMailbox.test_get_messages����y�y�}�}�T�^�^�a�/�0���y�y�}�}�_�-���y�y�$�$�T�*�����d�G�O�O�4�����f��u�-�����)�)�+�U�3����4�9�9�0�0��6�7r#c�~�|jj|jdz�}|jjt�}|j	|jj|�|jdzj
d��|j	|jj|�t�y)Nr�ascii�r=rOrPrQrr`r_rU�rr�r�s   r!�test_get_byteszTestMailbox.test_get_bytes
s����y�y�}�}�T�^�^�a�/�0���y�y�}�}�_�-��������,�,�T�2�
�^�^�a�
�'�'��0�	2�������,�,�T�2�4I�Jr#c��|jj|jdz�}|jjt�}|j	|jj|�|jdz�|j	|jj|�j
d�tj
d��y)Nr�
�r=rOrPrQrrYr�r�s   r!�test_get_stringzTestMailbox.test_get_strings����y�y�}�}�T�^�^�a�/�0���y�y�}�}�_�-��������-�-�d�3�T�^�^�a�5G�H�������-�-�d�3�9�9�$�?�(�.�.�t�4�	6r#c��|jj|jdz�}|jjt�}|jj	|�5}|j�}ddd�|jj	|�5}|j�}ddd�|j
jd�jtjd�|jdz�|j
jd�jtjd�t�y#1swY��xYw#1swY��xYw)Nrr�r�)r=rOrPrQr�r�r�decoder�r%r�)rr�r��file�data0�data1s      r!�
test_get_filezTestMailbox.test_get_files����y�y�}�}�T�^�^�a�/�0���y�y�}�}�_�-��
�Y�Y�
�
��
%�	 ���I�I�K�E�	 �
�Y�Y�
�
��
%�	 ���I�I�K�E�	 �������g�.�6�6�r�z�z�4�H����!�+�	-�������g�.�6�6�r�z�z�4�H�(�	*�
	 �	 ��	 �	 �s�#E�E�E	�Ec��|jjt�}|jj|�}|j	�|j	�yr	)r=rOrQr�rAr�s   r!�!test_get_file_can_be_closed_twicez-TestMailbox.test_get_file_can_be_closed_twice*s:���i�i�m�m�O�,���I�I���s�#��	���	�	���	r#c�T�|j|jjdd��y�NTF��do_keys�	do_values)�_check_iterationr=�iterkeysr>s r!�
test_iterkeyszTestMailbox.test_iterkeys1s!�����d�i�i�0�0�$�%��Pr#c�T�|j|jjdd��yr�)r�r=rZr>s r!�	test_keyszTestMailbox.test_keys5s�����d�i�i�n�n�d�e��Lr#c�T�|j|jjdd��y�NFTr�)r�r=�
itervaluesr>s r!�test_itervalueszTestMailbox.test_itervalues9s&�����d�i�i�2�2�E�(,�	�	.r#c�T�|j|jjdd��yr�)r�r=�__iter__r>s r!�	test_iterzTestMailbox.test_iter>s&�����d�i�i�0�0�%�(,�	�	.r#c�T�|j|jjdd��yr�)r�r=�valuesr>s r!�test_valueszTestMailbox.test_valuesCs!�����d�i�i�.�.����Nr#c�T�|j|jjdd��y�NTr�)r�r=�	iteritemsr>s r!�test_iteritemszTestMailbox.test_iteritemsGs&�����d�i�i�1�1�4�(,�	�	.r#c�T�|j|jjdd��yr�)r�r=�itemsr>s r!�
test_itemszTestMailbox.test_itemsLs�����d�i�i�o�o�t�t��Lr#c�6�|�D]}|jd��gg}}t|�D]W}|j|jj	|j
|z��|j|j
|z��Y|r|st
|��}	nJ|r|st
|��}
n5gg}
}	|�D]'\}}|	j|�|
j|��)|rH|jt|�t	��|jt|�t|	��|rhd}
D]E}|j|dd�|jt|j��|�|dz
}�G|jt|�|�yy)Nz	Not emptyrr�r�rD)
�fail�rangerNr=rOrP�listrr�set�
assertLess�intr)
rr�r�r�r�rrZr�r�
returned_keys�returned_valuesr�counts
             r!r�zTestMailbox._check_iterationPsq���X�	#�E��I�I�k�"�	#��2�f���{�#�	.�A��K�K��	�	�
�
�d�n�n�q�&8�9�:��M�M�$�.�.�1�,�-�	.��9� ���N�M�
�w�"�6�8�n�O�-/��?�M�$�h�
.�
��U��$�$�S�)��&�&�u�-�
.�����S��Y��M�(:�;����S��Y��M�(:�;���E�(�
��� � ��v���6�����E�$5�$5�$7� 8�+�F���
��
�
���S��[�%�0�
r#c��|jd|j�|jj|jdz�}|j	||j�|jd|j�|jj|jdz�}|j	||j�|j	||j�|jd|j�|jj|�|j||j�|j	||j�|jd|j�|jj|�|j||j�|j||j�|jd|j�y)Nr�rrD)�assertNotInr=rOrPrr�r�s   r!�
test_containszTestMailbox.test_containsksD�������	�	�*��y�y�}�}�T�^�^�a�/�0���
�
�d�D�I�I�&������	�	�*��y�y�}�}�T�^�^�a�/�0���
�
�d�D�I�I�&��
�
�d�D�I�I�&������	�	�*��	�	���������t�y�y�)��
�
�d�D�I�I�&������	�	�*��	�	���������t�y�y�)�����t�y�y�)������	�	�*r#c�2�g}t|�D]�}|jt|j�|�|j	|jj|j|z��|jt|j�|dz���t|�D]s}|jt|j�||z
�|jj||�|jt|j�||z
dz
��uy)NrD)r�rrr=rNrOrPr�)rr�rZrs    r!�test_lenzTestMailbox.test_len~s������{�#�	4�A����S����^�Q�/��K�K��	�	�
�
�d�n�n�q�&8�9�:����S����^�Q��U�3�	4��{�#�	B�A����S����^�[�1�_�=��I�I���T�!�W�%����S����^�[�1�_�q�-@�A�	Br#c�>���jj�jdz�}�j�jj	|��jdz��jj�jdz�}�j�jj	|��jdz��jdz�j|<�j�jj	|��jdz��jdz�j|<�j�jj	|��jdz�t
�j|<�j
�j|��j|�j|<�j
�j|��jdz�j|<�j�jj	|��jdz��j
�j|��jt�fd���jt�fd���jt�j�d�y)N�
original 0�
original 1�	changed 0�	changed 1c�<���jjdd�S)Nr��bar)r=�__setitem__r>s�r!r�z+TestMailbox.test_set_item.<locals>.<lambda>�s���$�)�)�"7�"7��u�"E�r#c�"���jdSr�r�r>s�r!r�z+TestMailbox.test_set_item.<locals>.<lambda>�r�r#rE)
r=rOrPrrYrQr"r�r�rr�s`  r!�
test_set_itemzTestMailbox.test_set_item�s�����y�y�}�}�T�^�^�l�:�;��������-�-�d�3����,�6�	8��y�y�}�}�T�^�^�l�:�;��������-�-�d�3����,�6�	8��.�.�;�6��	�	�$��������-�-�d�3����+�5�	7��.�.�;�6��	�	�$��������-�-�d�3����+�5�	7�)��	�	�$�����4�9�9�T�?�+��)�)�D�/��	�	�$�����4�9�9�T�?�+��.�.�<�7��	�	�$��������-�-�d�3��^�^�l�2�	4����4�9�9�T�?�+����(�E�	G����(�$<�=�����T�Y�Y���+r#c�����g}t|�D]*}�jj�j|z��,t	|�D]=\}��j�jj
���j|z��?�jj��jt�j�d�t	|�D]\}��jt��fd���!y)Nrc�:���jj��Sr	)r=rY�rrs��r!r�z(TestMailbox.test_clear.<locals>.<lambda>�s����	�	�0D�0D�S�0I�r#)r�r=rOrPrrrY�clearrr�r�)r�
iterationsrZrrs`   @r!�
test_clearzTestMailbox.test_clear�s�������z�"�	.�A��I�I�M�M�$�.�.�1�,�-�	.���o�	L�F�A�s����T�Y�Y�1�1�#�6�����8J�K�	L��	�	��������T�Y�Y���+���o�	K�F�A�s����h�(I�J�	Kr#c�T�|jj|jdz�}|j||j�|jj|jdz�}|j||j�|j	|jj|�j
�d�|j||j�|j||j�|jj|jdz�}|j||j�|j	|jj|�j
�d�|j||j�|j||j�|j	|jj|�j
�d�|j||j�|j	t|j�d�y)NrrDr�rEz2
r�)	r=rOrPrr�poprrr�rr�r�r�s    r!�test_popzTestMailbox.test_pop�ss���y�y�}�}�T�^�^�a�/�0���
�
�d�D�I�I�&��y�y�}�}�T�^�^�a�/�0���
�
�d�D�I�I�&���������t�,�8�8�:�E�B�����t�y�y�)��
�
�d�D�I�I�&��y�y�}�}�T�^�^�a�/�0���
�
�d�D�I�I�&���������t�,�8�8�:�E�B�����t�y�y�)��
�
�d�D�I�I�&���������t�,�8�8�:�E�B�����t�y�y�)�����T�Y�Y���+r#c�^���g}td�D]9}|j�jj�j|z���;g}td�D]�}�jj�\�}�j
�|��j�|�|j���jt|j��|j������jt�j�d�|D]��jt��fd���y)N�
rc�"���j�Sr	r�rs��r!r�z*TestMailbox.test_popitem.<locals>.<lambda>�s����	�	�#��r#)r�rNr=rOrP�popitemrrrrr�indexrr�r�)rrrZr�seenrrs`     @r!�test_popitemzTestMailbox.test_popitem�s�������r��	;�A��K�K��	�	�
�
�d�n�n�q�&8�9�:�	;����r��	F�A��y�y�(�(�*�H�C���M�M�#�t�$����S�$�'��K�K������S����!2�3�T�Z�Z��_�E�	F�	
����T�Y�Y���+��	@�C����h�(>�?�	@r#c�����jj�jdz���jj�jdz�}�jj�jdz�}�jj��jdz|ti��jt
�j�d��j�jj���jdz��j�jj|��jdz��j�j|��jj|�jdzf|�jdzf��jdzfg��jt
�j�d��j�jj���jdz��j�jj|��jdz��j�jj|��jdz��jt��fd���jt
�j�d��j�jj���jdz��j�jj|��jdz��j�jj|��jdz�y)	Nrrz
original 2r
rFz	changed 2rc�\���jjdd��jdzi�S)Nr�rr
)r=�updaterPr�s��r!r�z)TestMailbox.test_update.<locals>.<lambda>�s/���$�)�)�"2�"2�E�5�*.�����0L�4N�#O�r#)r=rOrPr'rQrrrYr"r�r�)rr�r�r�s`  @r!�test_updatezTestMailbox.test_update�s�����y�y�}�}�T�^�^�l�:�;���y�y�}�}�T�^�^�l�:�;���y�y�}�}�T�^�^�l�:�;���	�	���$����� <���1�	2�����T�Y�Y���+�������-�-�d�3��^�^�k�1�	3�������-�-�d�3��^�^�l�2�	4����4�9�9�T�?�+��	�	���4����+�!=�>��4�>�>�K�7�8��4�>�>�L�8�9�;�	<�	
����T�Y�Y���+�������-�-�d�3��^�^�l�2�	4�������-�-�d�3��^�^�k�1�	3�������-�-�d�3��^�^�k�1�	3����(�O�	P�	
����T�Y�Y���+�������-�-�d�3��^�^�k�1�	3�������-�-�d�3��^�^�k�1�	3�������-�-�d�3��^�^�k�1�	3r#c�P�|j|jjd�y�NT)�_test_flush_or_closer=rkr>s r!�
test_flushzTestMailbox.test_flush�s���!�!�$�)�)�/�/�4�8r#c��|jj|jdz�|jj|jdz�|jj�|jj	�|jj�|jj	�|jj�y�NrrD)r=rOrPrkr!r>s r!�test_popitem_and_flush_twicez(TestMailbox.test_popitem_and_flush_twice�s~���	�	�
�
�d�n�n�q�(�)��	�	�
�
�d�n�n�q�(�)��	�	�����	�	�����	�	�����	�	�����	�	���r#c���|jtjj|j	���|j
j
�|jtjj|j	���|j
j�|jtjj|j	���yr	)	�assertFalser%r&r)�_get_lock_pathr=�lockr�unlockr>s r!�test_lock_unlockzTestMailbox.test_lock_unlocks������������(;�(;�(=�>�?��	�	������������t�':�':�'<�=�>��	�	�������������(;�(;�(=�>�?r#c�P�|j|jjd�y�NF)r+r=rAr>s r!�
test_closezTestMailbox.test_closes���!�!�$�)�)�/�/�5�9r#c��td�D�cgc]}|j|z��}}|jj|d�|jj|d�|jj|d�|j}|�|r|jj	�|j|j�|_|jj�}|jt|�d�|D]-}|j|jj|�|��/|j	�ycc}w)NrFrrDrE)r�rPr=rOrAr<r;rZrrrrY)rr��should_call_closer�contents�oldboxrZrs        r!r+z TestMailbox._test_flush_or_closes���05�a��9�1�D�N�N�Q�&�9��9��	�	�
�
�h�q�k�"��	�	�
�
�h�q�k�"��	�	�
�
�h�q�k�"���������I�I�O�O���M�M�$�*�*�-��	��y�y�~�~�������T��A�&��	?�C��M�M�$�)�)�.�.�s�3�X�>�	?������:s�Ec	�����tjt�ttjt
�fD]�}tj���jj|���j�j�t
jdtjj�����tj���jt��fd��y)Nrc�<���jjd��Sr	)r=�
_dump_message)�outputrs��r!r�z/TestMailbox.test_dump_message.<locals>.<lambda>*s���$�)�)�"9�"9�$��"G�r#)rrRrQrSrTrUr=r?r�getvaluer�r%r�r_r��	TypeError)r�inputr@s` @r!�test_dump_messagezTestMailbox.test_dump_message s�����/�/��@�%�r�z�z�2G�'H�J�	K�E��Z�Z�\�F��I�I�#�#�E�6�2����V�_�_�.�%�-�-�e�R�Z�Z�5F�5F�5H�I�
K�		K���������)�G�	Ir#c� �|jdzS)Nz.lock)r;r>s r!r2zTestMailbox._get_lock_path,s���z�z�G�#�#r#�r)9r-r.r/�maxDiffr<rPr?rBr[�textwrap�dedentr^rbrfrmr}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�rr	rrrr$r(r,r/r5r8r+rDr2r6r#r!r8r84s?���G��H�#�I�.�
-�3�.$�H�O�O�%��M�2�.�"�"�)����
*�

��V�G�_��	6�0�2�0�J�
"�7�<�:�,
=�
3�=�8�K�6�*��Q�M�.�
.�
O�.�
M�1�6+�&
B�,�6
K�,�$@�  3�D9�	�@�:�� 
I�$r#r8c��eZdZd�Zy)�TestMailboxSuperclassc����tjd��|jt�fd��|jt�fd��|jt�fd��|jt�fd��|jt�fd��|jt�fd��|jt�fd��|jt�fd	��|jt�fd
��|jt�fd��|jt�fd��|jt�fd
��|jt�fd��|jt�fd��|jt�fd��|jt�fd��|jt�fd��|jt�fd��|jt�fd��|jt�fd��|jt�fd��|jt�fd��|jt�fd��|jt�fd��|jt�fd��|jt�fd��|jt�fd��|jt�fd��|jt�fd��y)Nr&c�&���jd�S�N�)rO��boxs�r!r�z;TestMailboxSuperclass.test_notimplemented.<locals>.<lambda>6����s�w�w�r�{�r#c�&���jd�SrN)r�rPs�r!r�z;TestMailboxSuperclass.test_notimplemented.<locals>.<lambda>7s���s�z�z�"�~�r#c�&���jd�SrN)r�rPs�r!r�z;TestMailboxSuperclass.test_notimplemented.<locals>.<lambda>8����s���r�7J�r#c�&���jd�SrN)r�rPs�r!r�z;TestMailboxSuperclass.test_notimplemented.<locals>.<lambda>9s���s�{�{�2��r#c�(���jdd�SrN)rrPs�r!r�z;TestMailboxSuperclass.test_notimplemented.<locals>.<lambda>:s���s���r�2�7N�r#c�$���j�Sr	)r�rPs�r!r�z;TestMailboxSuperclass.test_notimplemented.<locals>.<lambda>;s
���s�|�|�~�r#c�$���j�Sr	)rZrPs�r!r�z;TestMailboxSuperclass.test_notimplemented.<locals>.<lambda><�
���s�x�x�z�r#c�@���j�j�Sr	)r��__next__rPs�r!r�z;TestMailboxSuperclass.test_notimplemented.<locals>.<lambda>=s���s�~�~�7G�7P�7P�7R�r#c�@���j�j�Sr	)r�r\rPs�r!r�z;TestMailboxSuperclass.test_notimplemented.<locals>.<lambda>>s���s�|�|�~�7N�7N�7P�r#c�$���j�Sr	)r�rPs�r!r�z;TestMailboxSuperclass.test_notimplemented.<locals>.<lambda>?�
���s�z�z�|�r#c�@���j�j�Sr	)r�r\rPs�r!r�z;TestMailboxSuperclass.test_notimplemented.<locals>.<lambda>@s���s�}�}��7O�7O�7Q�r#c�$���j�Sr	)r�rPs�r!r�z;TestMailboxSuperclass.test_notimplemented.<locals>.<lambda>A�
���s�y�y�{�r#c�&���jd�SrN)r�rPs�r!r�z;TestMailboxSuperclass.test_notimplemented.<locals>.<lambda>BrRr#c�&���jd�SrN)�__getitem__rPs�r!r�z;TestMailboxSuperclass.test_notimplemented.<locals>.<lambda>CrUr#c�&���jd�SrN)r�rPs�r!r�z;TestMailboxSuperclass.test_notimplemented.<locals>.<lambda>DrUr#c�&���jd�SrN)rYrPs�r!r�z;TestMailboxSuperclass.test_notimplemented.<locals>.<lambda>Es���s�~�~�b�7I�r#c�&���jd�SrN)r`rPs�r!r�z;TestMailboxSuperclass.test_notimplemented.<locals>.<lambda>Fs���s�}�}�R�7H�r#c�&���jd�SrN)r�rPs�r!r�z;TestMailboxSuperclass.test_notimplemented.<locals>.<lambda>Gs���s�|�|�B�7G�r#c���d�vSrNr6rPs�r!r�z;TestMailboxSuperclass.test_notimplemented.<locals>.<lambda>Hs���r�S�y�r#c�&���jd�SrN)�__contains__rPs�r!r�z;TestMailboxSuperclass.test_notimplemented.<locals>.<lambda>Is���s�7G�7G��7K�r#c�$���j�Sr	)�__len__rPs�r!r�z;TestMailboxSuperclass.test_notimplemented.<locals>.<lambda>J�
���s�{�{�}�r#c�$���j�Sr	)rrPs�r!r�z;TestMailboxSuperclass.test_notimplemented.<locals>.<lambda>Krbr#c�&���jd�SrN)rrPs�r!r�z;TestMailboxSuperclass.test_notimplemented.<locals>.<lambda>LrRr#c�$���j�Sr	)r!rPs�r!r�z;TestMailboxSuperclass.test_notimplemented.<locals>.<lambda>Mror#c�&���jd�S)N))rOrO)r'rPs�r!r�z;TestMailboxSuperclass.test_notimplemented.<locals>.<lambda>Ns���s�z�z�+�7N�r#c�$���j�Sr	)rkrPs�r!r�z;TestMailboxSuperclass.test_notimplemented.<locals>.<lambda>Orbr#c�$���j�Sr	)r3rPs�r!r�z;TestMailboxSuperclass.test_notimplemented.<locals>.<lambda>PrZr#c�$���j�Sr	)r4rPs�r!r�z;TestMailboxSuperclass.test_notimplemented.<locals>.<lambda>Qr_r#c�$���j�Sr	)rArPs�r!r�z;TestMailboxSuperclass.test_notimplemented.<locals>.<lambda>Rrbr#)r�Mailboxr��NotImplementedError)rrQs @r!�test_notimplementedz)TestMailboxSuperclass.test_notimplemented3s����o�o�f�%�����-�/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.r/rzr6r#r!rKrK1s��Dr#rKc��eZdZdd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d	�Z
d
�Zdd�Zd�Z
d
�Zd�Zd�Zdd�Zd�Zd�Zd�Zd�Zd�Zd�Zej2eed�d�d��Zej2eed�d�d��Zd�Zy)�TestMaildirNc�.�tj||�Sr	)r�Maildir�rr&�factorys   r!r�zTestMaildir.<lambda>Ws������g�0N�r#c��tj|�tjdk(stj
dk(rd|j_yy)N�nt�cygwin�!)r8r?r%�name�sys�platformr=�colonr>s r!r?zTestMaildir.setUpYs6�����$���G�G�t�O�����!9�!�D�I�I�O�":r#c��|jtjtjj	|j
d��g�y�N�tmp)rr%�listdirr&�joinr;r>s r!rlzTestMaildir.assertMailboxEmpty^s.��������B�G�G�L�L����U�$C�D�b�Ir#c��tj|jdz�}|jd�|j	d�|j
j
|�}|jtjjtjj|jd|�|j
j�d����y)Nr�curr�)rr0rP�
set_subdir�set_infor=rOrr%r&r)r�r;r�)rrrs   r!�test_add_MMzTestMaildir.test_add_MMas����$�$�T�^�^�a�%7�8�����u�����U���i�i�m�m�C� ����������r�w�w�|�|�D�J�J��25�t�y�y���HH�(I�J�	Kr#c��tj|jdz�}|jd�|j	d�|j
j
|�}|j
j|�}|j|tj�|j|j�d�|j|j�d�y)Nrr��RF�FR)rr0rPr��	set_flagsr=rOr�r
r�
get_subdir�	get_flags)rrr�msg_returneds    r!�test_get_MMzTestMaildir.test_get_MMjs����$�$�T�^�^�a�%7�8�����u���
�
�d���i�i�m�m�C� ���y�y�,�,�S�1�����l�G�,B�,B�C�����0�0�2�E�:�����/�/�1�4�8r#c�`�tj|jdz�}|jd�|jj|�}|jj
|�}|j|j�d�|j|j�d�tj|jdz�}||j|<|jj
|�}|j|j�d�|j|j�d�|j|j�d�tj|jdz�}|jd	�||j|<|jd
z|j|<|jj
|�}|j|j�d�|j|j�d�|j|j�d�y)
Nr�TP�new�PTrDrOr�rEz2,SrF�Sz3
)rr0rPr�r=rOr�rr�r�rr�)rr�rr��msg1�msg2s      r!�test_set_MMzTestMaildir.test_set_MMus����%�%�d�n�n�q�&8�9�����t���i�i�m�m�D�!���y�y�,�,�S�1������0�0�2�E�:�����/�/�1�4�8��%�%�d�n�n�q�&8�9����	�	�#���y�y�,�,�S�1������0�0�2�E�:�����/�/�1�2�6�����1�1�3�U�;��%�%�d�n�n�q�&8�9���
�
�e����	�	�#�����!�+��	�	�#���y�y�,�,�S�1������0�0�2�E�:�����/�/�1�3�7�����1�1�3�U�;r#c��tj|jdz�}|jd�|j	d�|j
j
|�}Gd�dtj�}tj|j|��}|j
j|_	|j|�}|j||�y)Nrr�r�c��eZdZy)�8TestMaildir.test_consistent_factory.<locals>.FakeMessageNrqr6r#r!�FakeMessager��s��r#r��r�)rr0rPr�r�r=rOr~r;r�r�r
)rrrr�rQr�s      r!�test_consistent_factoryz#TestMaildir.test_consistent_factory�s����$�$�T�^�^�a�%7�8�����u���
�
�d���i�i�m�m�C� ��	�'�0�0�	��o�o�d�j�j�+�>���I�I�O�O��	����s�#�����d�K�0r#c�&�|j�tj|j�|_|j�|j
|j�|j|jd��|_|j�y)Nr�)rBrr~r;r=�
_check_basicsr,r<r>s r!�test_initialize_newzTestMaildir.test_initialize_new�sa���
�
���O�O�D�J�J�/��	������ � ����,��M�M�$�*�*�d�M�;��	����r#c	�N�|j�dD]\}tjtjj	tjj|j|����^tj|j�|_	|j�y)N�rOr�r�r�)rBr%�mkdirr&�normpathr�r;rr~r=r�)r�subdirs  r!�test_initialize_existingz$TestMaildir.test_initialize_existing�sj���
�
��-�	I�F��H�H�R�W�W�%�%�b�g�g�l�l�4�:�:�v�&F�G�H�	I��O�O�D�J�J�/��	����r#c���|j|jjtjj|j��|j|jj|�dD]z}tjj|j|�}tj|�tj}|jtj|�d|z��|y)Nr�zNot a directory: '%s')rr=r;r%r&�abspathr<r��stat�ST_MODEr�S_ISDIR)rr�r�r&�modes     r!r�zTestMaildir._check_basics�s�����������"�'�'�/�/�$�*�*�*E�F�������+�+�W�5�-�	P�F��7�7�<�<��
�
�F�3�D��7�7�4�=����.�D��O�O�D�L�L��.�0G�$�0N�O�	Pr#c��|jjd�|jjd�|jjd�|jt|jj	��d�|jt|jj	��td��y�N�one�two�threerF)r�r�r��r=�
add_folderrr�list_foldersr�r>s r!�test_list_folderszTestMaildir.test_list_folders�����	�	���U�#��	�	���U�#��	�	���W�%�����T�Y�Y�3�3�5�6��:�����T�Y�Y�3�3�5�6��0�1�	3r#c��|jjd�|jjd�}|j|jdz�|jtjjtjj|jd���|jjd�}|j|j|j�d�|jdz�y)N�foo.barrz.foo.barr)r=r��
get_folderrOrPrr%r&r'r�r;rrYrZ)r�folder0�folder1s   r!�test_get_folderzTestMaildir.test_get_folder�s����	�	���Y�'��)�)�&�&�y�1�����D�N�N�U�*�+�������
�
�b�g�g�l�l�4�:�:�z�&J�K�L��)�)�&�&�y�1������+�+�G�L�L�N�1�,=�>����%�/�	1r#c�z�|jjd�|jjd�|jt|jj	��d�|jt|jj	��td��|jj
d�|jt|jj	��d�|jt|jj	��td��|jjd�|jt|jj	��d�|jt|jj	��td��|jj
d�|jt|jj	��d�|jt|jj	��td��|jj
d�|jt|jj	��d	�|j|jj	�g�y�
Nr�r�rE)r�r�rD)r�r�)r�r�r�r=r�rrr�r��
remove_folderr>s r!�test_add_and_remove_foldersz'TestMaildir.test_add_and_remove_folders������	�	���U�#��	�	���U�#�����T�Y�Y�3�3�5�6��:�����T�Y�Y�3�3�5�6��N�8K�L��	�	����&�����T�Y�Y�3�3�5�6��:�����T�Y�Y�3�3�5�6��H�
�F��	�	���W�%�����T�Y�Y�3�3�5�6��:�����T�Y�Y�3�3�5�6��<L�8M�N��	�	����(�����T�Y�Y�3�3�5�6��:�����T�Y�Y�3�3�5�6��H�
�F��	�	����&�����T�Y�Y�3�3�5�6��:�������/�/�1�2�6r#c��tjj|jdd�}tjj|jdd�}t	|dd��5}|jd�ddd�t	|dd��5}|jd�ddd�|jj�|jtjj|��|jtjj|��tj|�}tj|tj�dz
d	z
|jf�|jj�|jtjj|��|jtjj|��y#1swY��nxYw#1swY��SxYw)
Nr�r�r�wrJrK�@i@�rE)r%r&r�r;�openr�r=�cleanrr)r��utime�time�st_mtimer1)r�foo_path�bar_pathr��foo_stats     r!�
test_cleanzTestMaildir.test_clean�sP���7�7�<�<��
�
�E�5�9���7�7�<�<��
�
�E�5�9��
�(�C�'�
2�	�a�
�G�G�C�L�	�
�(�C�'�
2�	�a�
�G�G�C�L�	��	�	������������x�0�1���������x�0�1��7�7�8�$��
����D�I�I�K�&�0�1�4�$�-�-�/�	0��	�	�������������1�2���������x�0�1�	�	��	�	�s�%G#�
G0�#G-�0G:c
�L�tj�}d|vr|jdd�}d|vr|jdd�}tj�}tjd�}d}t|�D�]J}|jj�}tjj|j�\}}	|j|tjjtjj|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��|jt+|d�|d|d�d|�d��|jt+|d�t+|d�d
zd|d�d|d�d��|j|d|d|d�d|�d��|}|j-t.�|j1d	�|j|j3�t.�|j5���Mt7tj8tjj|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�zFile in wrong location: '%s'zInvalid file name: '%s'rzNon-monotonic seconds: 'z
' before '�'rDzNon-monotonic milliseconds: 'rEzProcess ID mismatch: 'z
' should be 'rFzNon-sequential counter: 'rGzHost name mismatch: 'zWrong file count: ')�socket�gethostnamer�r%�getpid�re�compiler�r=�_create_tmpr&r�r�rr�r�r;�match�assertIsNotNone�groups�assertGreaterEqualrr�rUr�r�rArr�)
rr��hostname�pid�pattern�previous_groups�x�tmp_file�head�tailr�r��
file_counts
             r!�test_create_tmpzTestMaildir.test_create_tmp�s����%�%�'���(�?��'�'��W�5�H��(�?��'�'��W�5�H��i�i�k���*�*�>�?�����{�#�	�A��y�y�,�,�.�H������x�}�}�5�J�D�$����T�2�7�7�?�?�2�7�7�<�<��
�
�@E�4G�$H�;�d�B�
D��M�M�$�'�E�� � ��(A�D�(H�I��\�\�^�F��*��'�'��F�1�I���O�A�<N�8O�-�a�0�&��)�=�>��v�a�y�>�S���);�%<�<��+�+�C��q�	�N�C��PQ�@R�<S�!0��!3�V�A�Y�!@�A�� � ��V�A�Y���$�Q�i��.�/�� � ��V�A�Y���_�Q�5G�1H�1�1L�-�a�0�&��)�=�>�� � ����H�$�Q�i��3�4�%�O��N�N�0�1��M�M�!�����X�]�]�_�.C�D��N�N��=	�>����B�G�G�L�L����U�$C�D�E�
�����[� �+�/�	0r#c��|j|jji�|jj|jdz�}|jj|jdz�}|j|jji�|jj�|j|jj|tjjd|�|tjjd|�i�|jj|jdz�}|j|jj|tjjd|�|tjjd|�i�|jj�|j|jj|tjjd|�|tjjd|�|tjjd|�i�y)NrrDr�rE)	rr=�_tocrOrP�_refreshr%r&r�rs    r!�test_refreshzTestMaildir.test_refreshs������������,��y�y�}�}�T�^�^�a�/�0���y�y�}�}�T�^�^�a�/�0�����������,��	�	������������$������U�D�0I�*.������U�D�0I�*K�	L��y�y�}�}�T�^�^�a�/�0����������$������U�D�0I�*.������U�D�0I�*K�	L��	�	������������$������U�D�0I�*.������U�D�0I�*.������U�D�0I�*K�	Lr#c��|jj|jdz�}|jj|jdz�}|j|j�|_|j|jji�d|j_|jj�|jt|jjj��t||g��y)NrrD���)r=rOrPr<r;rr��_skewfactorr��sortedrZr�s   r!� test_refresh_after_safety_periodz,TestMaildir.test_refresh_after_safety_period-s����y�y�}�}�T�^�^�a�/�0���y�y�}�}�T�^�^�a�/�0���M�M�$�*�*�-��	����������,�!#��	�	���	�	���������	�	��� 3� 3� 5�6���d�|�8L�Mr#c������jt�fd���jj�jdz���j�jj
��tjjd���tjtjj�jd����j�jj�tjjd��i��jj��jt��fd���j�jji�y)Nc�:���jjd�Sr��r=�_lookupr>s�r!r�z)TestMaildir.test_lookup.<locals>.<lambda>Bs���D�I�I�,=�,=�e�,D�r#rr�c�:���jj��Sr	r�r�s��r!r�z)TestMaildir.test_lookup.<locals>.<lambda>Js���D�I�I�,=�,=�d�,C�r#)r�r�r=rOrPrr�r%r&r�r�r;r�rk)rr�s`@r!�test_lookupzTestMaildir.test_lookup@s�������(�$D�E��y�y�}�}�T�^�^�a�/�0��������*�*�4�0�"�'�'�,�,�u�d�2K�L�
�	�	�"�'�'�,�,�t�z�z�5�$�7�8���������$������U�D�0I�)J�K�	
�	�	�������(�$C�D����������,r#c�l�|jj�|jj�yr	)r=r3r4r>s r!r5zTestMaildir.test_lock_unlockMs ���	�	�����	�	���r#c��d�}|j|j|��}|jd�}|j|j|�|j	d�}|j|j|�y)Nc��yr	r6��ss r!�
dummy_factoryz.TestMaildir.test_folder.<locals>.dummy_factoryU���r#r�r�)r<r;r�r�r�)rrrQ�folder�
folder1_aliass     r!�test_folderzTestMaildir.test_folderRs_��	��m�m�D�J�J�
�m�>�����	�*���
�
�f�o�o�}�5����y�1�
��
�
�m�,�,�m�<r#c�&�td�D]4}|jjtjt
���6t
jtjj|jdd��|jD]}�y)Nrr�z	stray-dir)r�r=rOrr
rQr%r�r&r�r;)rrrs   r!�test_directory_in_folderz$TestMaildir.test_directory_in_folder^sk���r��	<�A��I�I�M�M�'�/�/�/�:�;�	<�	��������d�j�j�%��=�>��9�9�	�C��	r#�umask�test needs os.umask()c���tj|jdz�}tjd�}	|j
j
|�}tj|�tjj|j|j
j|��}tj|�j}|j|dz�y#tj|�wxYw)Nr�I)rr0rPr%r
r=rOr&r�r;r�r��st_moder1)rr�
orig_umaskrr&r�s      r!�test_file_permissionsz!TestMaildir.test_file_permissionsks����$�$�T�^�^�a�%7�8���X�X�a�[�
�	!��)�)�-�-��$�C��H�H�Z� ��w�w�|�|�D�J�J��	�	�(9�(9�#�(>�?���w�w�t�}�$�$��������&��
�H�H�Z� �s�C � C7c��tjd�}	|jjd�}tj|�tjj|jd�}tj|�}|j}|j|dz�y#tj|�wxYw)Nr�	subfolder�
maildirfolderr)
r%r
r=r�r&r�r;r�rr1)rrrr&�st�permss      r!�test_folder_file_permsz"TestMaildir.test_folder_file_permsxs����X�X�a�[�
�	!��	�	�,�,�[�9�I��H�H�Z� ��w�w�|�|�I�O�O�_�=��
�W�W�T�]���
�
�����%�%�-�)��
�H�H�Z� �s�B'�'B>c������jj�dD]c}tjtjj�jj|�tj�dz
fdz��ed�j_�jj���fd�}�jj��j|��tjj�jdd�}tj|�tj|��jj��j|��y)N)r�r�rHrEr�c�4���jj�uSr	)r=r�)�orig_tocrs��r!�	refreshedz*TestMaildir.test_reread.<locals>.refreshed�s����9�9�>�>��1�1r#r�z
stray-file)r=r�r%r�r&r�r;r�r�r�r1r�create_empty_filer*r)rr�r�filenamers`   @r!�test_rereadzTestMaildir.test_reread�s�����	�	����%�	)�F��H�H�R�W�W�\�\�$�)�)�/�/�6�:��i�i�k�!�m�%�a�'�
)�	)�!#��	�	��
�9�9�>�>��	2�	
�	�	���������%�
�7�7�<�<��
�
�E�<�@���#�#�H�-�
�	�	�(���	�	�������	��$r#r	rF)r-r.r/r<r?rlr�r�r�r�r�r�r�r�r�r�r�r�r�r�rr5r
r�unittest�
skipUnless�hasattrr%rrr r6r#r!r|r|Us���N�H�"�
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��eZdZdZd�Zd�Zy)�_TestSingleFilez&Common tests for single-file mailboxesc��tj|j�j}|jj|jdz�|jj�tj|j�j}|j||�|jj�|j|j�|_|jt|j�d�yr.)r%r�r;�st_inor=rOrPrkrrAr<r)r�inode_before�inode_afters   r!�test_add_doesnt_rewritez'_TestSingleFile.test_add_doesnt_rewrite�s����w�w�t�z�z�*�1�1���	�	�
�
�d�n�n�q�(�)��	�	�����g�g�d�j�j�)�0�0������{�3�	
�	�	�����M�M�$�*�*�-��	�����T�Y�Y���+r#c��tj|j�jdz}tj|j|�|j
j
|jdz�|j
j
|jdz�}|j
j|�|j
j�|jtj|j�j|�y)Ni�rrD)r%r�r;r�chmodr=rOrPr�rkr)rr�rs   r!�test_permissions_after_flushz,_TestSingleFile.test_permissions_after_flush�s����w�w�t�z�z�"�*�*�U�2��
������T�"��	�	�
�
�d�n�n�q�(�)��I�I�M�M�$�.�.�1�,�-���	�	������	�	�������������,�4�4�d�;r#N)r-r.r/�__doc__r*r-r6r#r!r%r%�s��0�,�(<r#r%c���eZdZ�fd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zej�ejeed
�d�d���Zd
�Z�xZS)�
_TestMboxMMDFc�*��t�|��|jj�|j	|j
�t
jt
j|j
�dz�D]}tj|��y�Nz.*�
�superrBr=rAr,r;�glob�escaperr*�r�lock_remnant�	__class__s  �r!rBz_TestMboxMMDF.tearDown��f���
�����	�	����� � ����,� �I�I�d�k�k�$�*�*�&=��&D�E�	+�L����\�*�	+r#c��t|jd�5}|j|j�g�ddd�y#1swYyxYw�N�rb�r�r;r�	readlines�rr�s  r!rlz _TestMboxMMDF.assertMailboxEmpty��=��
�$�*�*�d�
#�	0�q����Q�[�[�]�B�/�	0�	0�	0���!A�A
c��d}|jj||jdzz�}|jj|tz�}|j	|jj|d��|jdzj
d��|j	|jj|d��t�|j	|jj|d��||jdzzj
d��|j	|jj|d��|j
d�tz�y)N�From foo@bar blah
rF��from_r�Tr��r�unixfromr�r�s    r!�test_get_bytes_fromz!_TestMboxMMDF.test_get_bytes_from�s��(���y�y�}�}�X�����(:�:�;���y�y�}�}�X��7�8��������,�,�T��,�?�
�^�^�a�
�'�'��0�	2�������,�,�T��,�?�!�	#�������,�,�T��,�>�
�����*�
*�2�2�7�;�	=�������,�,�T��,�>��O�O�G�$�'<�<�	>r#c���d}|jj||jdzz�}|jj|tz�}|j	|jj|d��|jdz�|j	|jj|d��j
d�tj
d��|j	|jj|d��||jdzz�|j	|jj|d��j
d�|tzj
d��y)NrDrFrEr�Tr�rGs    r!�test_get_string_fromz"_TestMboxMMDF.test_get_string_from�s#��(���y�y�}�}�X�����(:�:�;���y�y�}�}�X��7�8��������-�-�d�%�-�@����!�+�	-�������-�-�d�%�-�@�F�F�t�L�(�.�.�t�4�	6�������-�-�d�$�-�?�!�D�N�N�Q�$6�6�	8�������-�-�d�$�-�?�E�E�d�K�"�_�4�;�;�D�A�	Cr#c�H�|jjd�}|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=rOr�get_from�get_unixfromrras  r!�test_add_from_stringz"_TestMboxMMDF.test_add_from_stringsy���i�i�m�m�A�B��������3��0�0�2�N�C�������3��4�4�6�8K�L�������3��3�3�5�u�=r#c�H�|jjd�}|j|j|j�d�|j|j|j	�d�|j|j|j�d�y)NsFrom foo@bar blah
From: foo

0
rNrOr�rPras  r!�test_add_from_bytesz!_TestMboxMMDF.test_add_from_bytes	sy���i�i�m�m�B�C��������3��0�0�2�N�C�������3��4�4�6�8K�L�������3��3�3�5�u�=r#c��tjtjfD]%}|d�}|jj	|�}�'y)NrM)rr1r4r=rO)r�class_rrs    r!�test_add_mbox_or_mmdf_messagez+_TestMboxMMDF.test_add_mbox_or_mmdf_messages?���*�*�G�,?�,?�@�	%�F��>�?�C��)�)�-�-��$�C�	%r#c���td�D�cgc]}|j|z��}}|D]}|jj|��|jj	�t
jj|j�}|j|j�|_|jt|j�d�|jj�D]-}|j|jj|�|��/|jj	�|j|t
jj|j��ycc}w)NrF)r�rPr=rOrAr%r&�getmtimer;r<rrr�rrY)rrr�r�mtimers      r!�test_open_close_openz"_TestMboxMMDF.test_open_close_opens��.3�A�h�7��$�.�.�1�$�7��7��	!�E��I�I�M�M�%� �	!��	�	������� � ����,���M�M�$�*�*�-��	�����T�Y�Y���+��9�9�%�%�'�	=�C��M�M�$�)�)�.�.�s�3�V�<�	=��	�	����������� 0� 0���� <�=��8s�E.c���|jjt�td�D]*}|jj|j|z��,|jjt�|jj
j
�|jj
jd�|jj
j�}|jj�t|jd�5}|j||j��ddd�|j|j�|_y#1swY�*xYw)NrFrr=)r=rOrQr�rP�_filerkr�r�rAr�r;rr<)rrr;r�s    r!�test_add_and_closez _TestMboxMMDF.test_add_and_close$s����	�	�
�
�o�&��q��	.�A��I�I�M�M�$�.�.�1�,�-�	.��	�	�
�
�o�&��	�	�������	�	�����Q���9�9�?�?�'�'�)���	�	����
�$�*�*�d�
#�	1�q����X�q�v�v�x�0�	1��M�M�$�*�*�-��	�	1�	1�s�!E�E'�
socketpairzTest needs socketpair().c�z�tj�\}}|j|j�|j|j�t	j
�}|dk(rl	|jj�|jd�|jd�|jj�t	jd�|jd�	|jtj|jj�|jd�tj |d��|jj�|jj�y#t	jd�wxYw#|jd�tj |d��wxYw)Nr�crD�p)�exitcode)r�r`�
addCleanuprAr%�forkr=r3�send�recvr4�_exitr�r�ExternalClashErrorr�wait_process)r�c�pr�s    r!�test_lock_conflictz _TestMboxMMDF.test_lock_conflict2s)��
� � �"���1������� ������� ��g�g�i���!�8�	
��	�	��� ����t�����q�	��	�	� � �"������	
���q�	�	2����g�8�8�"�i�i�n�n�
.�
�F�F�4�L�� � ��q�1��	�	�����	�	�����������
�F�F�4�L�� � ��q�1�s�(AE6�%4F�6F
�*F:c��d}|jj|�}|jj�|jj�|j	|j
�|_|jj
�|jj|�}|jj�|j|jj�|jj�y)NzSubject: sub

body
)	r=rOrkrAr<r;r3r�_locked)rrr�r�s    r!�test_relockz_TestMboxMMDF.test_relockWs���'���y�y�}�}�S�!���	�	�����	�	�����M�M�$�*�*�-��	��	�	�����y�y�}�}�S�!���	�	��������	�	�)�)�*��	�	���r#)r-r.r/rBrlrIrKrSrUrXr\r_r�
requires_forkr!r"r#r�rnrq�
__classcell__�r9s@r!r0r0�sv���+�0�>�C�>�>�%�>�.��W�����X������6�8R�S�!�T��!�F
r#r0c�`�eZdZdd�Zej
eed�d�d��Zd�Z	d�Z
y)	�TestMboxNc�.�tj||�Sr	)r�mboxrs   r!r�zTestMbox.<lambda>i������T�7�0K�r#r
rc�4�	tjd�}|jj�tj|j
�t
j|j
d��|_|jjd�|jj�tj|�tj|j
�}|j}|j|dz�y#tj�wxYw)N�?T)�createrOr)r%r
r=rAr*r;rrxrOr�rr1)r�	old_umaskrrs    r!�test_file_permszTestMbox.test_file_permsks���
	 ������I��I�I�O�O���I�I�d�j�j�!����T�Z�Z��=�D�I��I�I�M�M�"���I�I�O�O���H�H�Y��
�W�W�T�Z�Z�
 ���
�
�����%�%�-�)��	
�H�H�Y��s�B)D�Dc��tjj�}d|d<|jd�|jj|�}|jj
|�}|j|j�d�y)Nzjohn@example.com�FromzNo newline at the endzNo newline at the end
)	rrr
�set_payloadr=rOr�rr)rrrs   r!�test_terminating_newlinez!TestMbox.test_terminating_newline~sl���-�-�'�'�)��,�������3�4��I�I�M�M�'�"���)�)�-�-��"������,�,�.�0I�Jr#c��|jjd�t|jd��5}|j	�}|j|ddd�ddd�|jjd�t|jd��5}|j	�}|j|ddd�ddd�y#1swY�jxYw#1swYyxYw)NzFrom: foo

0rJrKr�z0

z
From: foo

0
)r=rOr�r;r�r)rr��datas   r!�test_message_separatorzTestMbox.test_message_separator�s����	�	�
�
�&�'�
�$�*�*�w�
/�	1�1��6�6�8�D����T�"�#�Y��0�	1�	
�	�	�
�
�(�)�
�$�*�*�w�
/�	1�1��6�6�8�D����T�"�#�Y��0�	1�	1�	1�	1��
	1�	1�s�&C�&C�C�Cr	)r-r.r/r<r!r"r#r%r~r�r�r6r#r!rvrvgs<��K�H��X�����W�-�/F�G�*�H�*�$K�
1r#rvc��eZdZdd�Zy)�TestMMDFNc�.�tj||�Sr	)r�MMDFrs   r!r�zTestMMDF.<lambda>�ryr#r	)r-r.r/r<r6r#r!r�r��s��K�Hr#r�c�J�eZdZdd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d	�Z
d
�Zd�Zy)
�TestMHNc�.�tj||�Sr	)r�MHrs   r!r�zTestMH.<lambda>�s���
�
�4��0I�r#c�d�|jtj|j�dg�y)Nz
.mh_sequences)rr%r�r;r>s r!rlzTestMH.assertMailboxEmpty�s"��������D�J�J�/�/�1B�Cr#c��|jjd�|jjd�|jjd�|jt|jj	��d�|jt|jj	��td��yr�r�r>s r!r�zTestMH.test_list_folders�r�r#c��d�}|j|j|�|_|jjd�}|jj	d�}|j|jdz�|jtjjtjj|jd���|jj	d�}|j|j|j�d�|jdz�|j|j|jj�|j|j|jj�y)Nc��yr	r6rs r!rz-TestMH.test_get_folder.<locals>.dummy_factory�rr#r�rr)r<r;r=r�r�rOrPrr%r&r'r�rrYrZr�)rr�
new_folderr�r�s     r!r�zTestMH.test_get_folder�s
��	��M�M�$�*�*�m�<��	��Y�Y�)�)�)�4�
��)�)�&�&�y�1�����D�N�N�U�*�+�������
�
�b�g�g�l�l�4�:�:�y�&I�J�K��)�)�&�&�y�1������+�+�G�L�L�N�1�,=�>����%�/�	1�
	
�
�
�j�)�)�4�9�9�+=�+=�>��
�
�g�&�&��	�	�(:�(:�;r#c�z�|jjd�|jjd�|jt|jj	��d�|jt|jj	��td��|jj
d�|jt|jj	��d�|jt|jj	��td��|jjd�|jt|jj	��d�|jt|jj	��td��|jj
d�|jt|jj	��d�|jt|jj	��td��|jj
d�|jt|jj	��d	�|j|jj	�g�yr�r�r>s r!r�z"TestMH.test_add_and_remove_folders�r�r#c��|j|jj�i�tj|j
dz�}|j
d�|jj|�}|j|jj�d|gi�tj|j
dz�}|jgd��|jj|�}|j|jj�||g|g|gd��|jdg�||j|<|j|jj�|g|g|g|gd��|jj|�|j|jj�d|gi�y)Nrr�rD)r�repliedr��r�rr��flagged)r�rr�r�)
rr=�
get_sequencesrr2rP�add_sequencerO�
set_sequencesr��rr�r�r�r�s     r!�test_sequenceszTestMH.test_sequences�sn��������0�0�2�B�7�� � ����!�!3�4�����%� ��y�y�}�}�T�"��������0�0�2�U�D�6�N�C�� � ����!�!3�4�����4�5��y�y�}�}�T�"��������0�0�2�!�4�L���4�&�I�	K����I�;�'���	�	�$��������0�0�2�!�F�4�&�T�F�!%��(�	)�	
�	�	�����������0�0�2�Y��v�4F�Gr#c���tj|jdz�}|jd�|jj|�}|jj
|�}y)Nrr�)rr2rPr�r=rOr�)rr�r��refmsg0s    r!�test_issue2625zTestMH.test_issue2625�sO��� � ����!�!3�4�����%� ��y�y�}�}�T�"���)�)�'�'��-�r#c��tj|jdz�}|jj	|�}|jj�|jj
|�|jj�y)Nr)rr2rPr=rOr3r�r4)rr�r�s   r!�test_issue7627zTestMH.test_issue7627�s]��� � ����!�!3�4���y�y�}�}�T�"���	�	�����	�	������	�	���r#c	���tj|jdz�}tj|jdz�}tj|jdz�}tj|jdz�}|jddg�|jdg�|jddg�|jgd��|jj|�}|jj|�}|jj|�}|jj|�}|j
|jj�||||g|g|g|g|gd	��|jj|�|j
|jj�|||g|g|g|gd
��|jj�|j
|jj�gd��|}|dz}|dz}|j
|jj�gd�dgdgdgd
��|jj|�}|jj|�}|jj|�}|jj|�}|jj|�|jj|�|jj�|jj�|jj�|j
|jj�gd�dgdgdgd
��y)
NrrDrErFr��unseenr�r�)r�r�r�rr�)r�r�rr�)rDrErF)rDrErFrGrH)
rr2rPr�r=rOrr�r��packrZr3r4)	rr�r�r��msg3r�r�r��key3s	         r!�	test_packzTestMH.test_pack�s���� � ����!�!3�4��� � ����!�!3�4��� � ����!�!3�4��� � ����!�!3�4�����E�8�,�-����E�7�#����E�9�-�.����4�5��y�y�}�}�T�"���y�y�}�}�T�"���y�y�}�}�T�"���y�y�}�}�T�"��������0�0�2�!�$�t�D�1�T�F�!%��t�f���H�	I�	
�	�	�����������0�0�2�!�$�t�,��v�d�V�!%��(�	)�	
�	�	������������)�9�5����a�x���a�x��������0�0�2�%���A�3�1�#�N�	P��y�y�}�}�T�"���y�y�}�}�T�"���y�y�}�}�T�"���y�y�}�}�T�"���	�	������	�	������	�	�����	�	�����	�	����������0�0�2�+� !�s�1�#�!��>�	?r#c�V�tjj|jd�S)Nz.mh_sequences.lock)r%r&r�r;r>s r!r2zTestMH._get_lock_paths���w�w�|�|�D�J�J�(<�=�=r#r	)
r-r.r/r<rlr�r�r�r�r�r�r�r2r6r#r!r�r��s7��I�H�D�3�<�&7�&H�(.��*?�X>r#r�c�2��eZdZdd�Zd�Z�fd�Zd�Z�xZS)�	TestBabylc�.�tj||�Sr	)r�Babylrs   r!r�zTestBabyl.<lambda>#s���
�
�d�G�0L�r#c��t|jd�5}|j|j�g�ddd�y#1swYyxYwr<r>r@s  r!rlzTestBabyl.assertMailboxEmpty%rArBc�*��t�|��|jj�|j	|j
�t
jt
j|j
�dz�D]}tj|��yr2r3r7s  �r!rBzTestBabyl.tearDown)r:r#c���|j|jj�g�tj|j
dz�}|j
d�|jj|�}|j|jj�dg�tj|j
dz�}|jgd��|jj|�}|jt|jj��tddg��|jddg�||j|<|jt|jj��tgd���|jj|�|jt|jj��tdg��y)	Nrr�rD)r�answeredr�r�blah�filed)r�rr�)rr=�
get_labelsrr3rP�	add_labelrO�
set_labelsr�r�r�s     r!�test_labelszTestBabyl.test_labels0s[��������-�-�/��4��#�#�D�N�N�Q�$6�7�����u���y�y�}�}�T�"��������-�-�/�%��9��#�#�D�N�N�Q�$6�7�����2�3��y�y�}�}�T�"������T�Y�Y�1�1�3�4�c�5�%�.�6I�J������)�*���	�	�$������T�Y�Y�1�1�3�4��/�0�	2��	�	���������T�Y�Y�1�1�3�4�c�6�(�m�Dr#r	)r-r.r/r<rlrBr�rsrts@r!r�r�!s���L�H�0�+�Er#r�c��eZdZd�Zd�Zy)�FakeFileLikeObjectc��d|_yr7��closedr>s r!�__init__zFakeFileLikeObject.__init__Es	����r#c��d|_yr*r�r>s r!rAzFakeFileLikeObject.closeHs	����r#N)r-r.r/r�rAr6r#r!r�r�Cs���r#r�c��eZdZd�Zd�Zy)�FakeMailBoxc��tjj|dd��td�D�cgc]}t	���c}|_ycc}w)NrOc��yr	r6)r�s r!r�z&FakeMailBox.__init__.<locals>.<lambda>Os�r#r)rrxr�r�r��files)rrs  r!r�zFakeMailBox.__init__Ns6����� � ��r�+<�=�49�"�I�>�q�(�*�>��
��>s�A
c� �|j|Sr	)r�ras  r!r�zFakeMailBox.get_fileRs���z�z�#��r#N)r-r.r/r�r�r6r#r!r�r�Ls��?�r#r�c��eZdZd�Zy)�TestFakeMailBoxc�"�t�}td�D]*}|j|j|j��,td�D]}||�	td�D]*}|j|j|j��,y)Nr)r�r�r1r�r�r)rrQrs   r!�test_closing_fdzTestFakeMailBox.test_closing_fdXs���m���r��	2�A����S�Y�Y�q�\�0�0�1�	2��r��	�A���F�	��r��	1�A��O�O�C�I�I�a�L�/�/�0�	1r#N)r-r.r/r�r6r#r!r�r�Vs��1r#r�c�l�eZdZejZd�Zd�Zd�Zd�Z	d�Z
d�Zd�Zd�Z
d	�Zd
�Zd�Zd�Zy
)�TestMessagec�.�tj|_yr	)rr:r;r>s r!r?zTestMessage.setUpfs���%�%��
r#c�:�|j|j�yr	)r,r;r>s r!rBzTestMessage.tearDownis��� � ����,r#c��tjt�}|j|�}|j	|�|j|�yr	)rrRrQr<�_post_initialize_hookr"�r�eMMrs   r!�test_initialize_with_eMMz$TestMessage.test_initialize_with_eMMls<���'�'��8���m�m�C� ���"�"�3�'����3�r#c�r�|jt�}|j|�|j|�yr	)r<rQr�r"�rrs  r!�test_initialize_with_stringz'TestMessage.test_initialize_with_stringss,���m�m�O�,���"�"�3�'����3�r#c��t|jdd��5}|jt�|j	d�|j|�}|j
|�|j|�ddd�y#1swYyxYw)Nr�rJrKr)r�r;r�rQr�r<r�r"�rr�rs   r!�test_initialize_with_filez%TestMessage.test_initialize_with_fileysj��
�$�*�*�d�W�
5�	$��
�G�G�O�$�
�F�F�1�I��-�-��"�C��&�&�s�+����s�#�	$�	$�	$�s�AA<�<Bc��t|jd�5}|jt�|j	d�|j|�}|j
|�|j|�ddd�y#1swYyxYw)Nr�r)r�r;r�rUr�r<r�r"r�s   r!� test_initialize_with_binary_filez,TestMessage.test_initialize_with_binary_file�si��
�$�*�*�e�
$�	$��
�G�G�)�*�
�F�F�1�I��-�-��"�C��&�&�s�+����s�#�	$�	$�	$�s�AA:�:Bc���|j�}|j|�|j|tjj
�|j|tj
�|j||j�|j|j�g�|j|j��|j|j��yr	)
r<r�r
rrr
rrrZr1rr�rr�s  r!�test_initialize_with_nothingz(TestMessage.test_initialize_with_nothing�s����m�m�o���"�"�3�'����c�5�=�=�#8�#8�9����c�7�?�?�3����c�4�=�=�1��������R�(�����)�)�+�,����#�/�/�+�,r#c�8���jt�fd��y)Nc�6���jt��Sr	)r<�objectr>s�r!r�z9TestMessage.test_initialize_incorrectly.<locals>.<lambda>�s���T�]�]�6�8�-D�r#)r�rBr>s`r!�test_initialize_incorrectlyz'TestMessage.test_initialize_incorrectly�s������)�%D�Er#c���tjt�}|jt�}|jD].}|j||jdj
|���0y)Nz{} attribute does not exist)rrRrQr<�__dict__r�format)rr�r�attrs    r!�test_all_eMM_attributes_existz)TestMessage.test_all_eMM_attributes_exist�sU���'�'��8���m�m�O�,���L�L�	<�D��M�M�$����-�4�4�T�:�
<�	<r#c��tjt�}|j�}|j	|�|j|�yr	)rrRrQr<�_become_messager"r�s   r!�test_become_messagezTestMessage.test_become_message�s9���'�'��8���m�m�o�����C� ����3�r#c�����|j��|jD]}|���j���tjj��|j
t��fd��y)Nc�&���j��Sr	)�_explain_to)r�	other_msgs��r!r�z-TestMessage.test_explain_to.<locals>.<lambda>�s���S�_�_�Y�-G�r#)r<r5r�rrr
r�rB)rrWrr�s  @@r!�test_explain_tozTestMessage.test_explain_to�s]����m�m�o���,�,�	'�F���I��O�O�I�&�	'��M�M�)�)�+�	����)�%G�Hr#c��yr	r6r�s  r!r�z!TestMessage._post_initialize_hook�s��r#N)r-r.r/rr
r<r?rBr�r�r�r�r�r�r�r�r�r�r6r#r!r�r�bsI�����H�&�-� � �$�$�	-�F�<� �I�
r#r�c�H�eZdZejZd�Zd�Zd�Zd�Z	d�Z
d�Zy)�TestMaildirMessagec�t�|j|jd�|j|jd�y)Nr�rO)r�_subdir�_infor�s  r!r�z(TestMaildirMessage._post_initialize_hook�s*��������e�,�������B�'r#c�2��tjt��|j�j	�d��jd�|j�j	�d��jd�|j�j	�d�|j
t�fd��|j�j	�d��jd�|j�j	�d�|j��y)Nr�r�c�&���jd�Sr�)r��rs�r!r�z0TestMaildirMessage.test_subdir.<locals>.<lambda>�s���c�n�n�U�.C�r#)	rr0rQrr�r�r�rjr"r�s @r!�test_subdirzTestMaildirMessage.test_subdir�s�����$�$�_�5��������)�5�1����u��������)�5�1����u��������)�5�1����*�&C�D�������)�5�1����u��������)�5�1����3�r#c���tjt�}|j|j	�d�|j|j�d�|j
d�|j|j�d�|j|j	�d�|j
d�|j|j	�d�|jd�|j|j	�d�|jd�|j|j	�d	�|j|j�d�|j|�y)
NrOr��F�SDTP�DPST�FT�DFPST�TDRP�FS)
rr0rQrr�r�r��add_flag�remove_flagr"r�s  r!�
test_flagszTestMaildirMessage.test_flags�s���$�$�_�5���������"�-�������)�5�1��
�
�c��������)�5�1��������#�.��
�
�f���������&�1����T���������'�2�������������$�/�������)�5�1����3�r#c��tjt�}|jt	|j�t
j�z
�d�|jd�|j|j�d�y)N�<�)	rr0rQr�abs�get_dater��set_daterr�s  r!�	test_datezTestMaildirMessage.test_date�sX���$�$�_�5������C�L�L�N�T�Y�Y�[�8�9�2�>����S����������-r#c�.��tjt��|j�j	�d��jd�|j�j	�d�|j
t�fd��|j��y)NrOz	1,foo=barc�&���jd�Sr	)r�r�s�r!r�z.TestMaildirMessage.test_info.<locals>.<lambda>�s���S�\�\�$�-?�r#)	rr0rQr�get_infor�r�rBr"r�s @r!�	test_infozTestMaildirMessage.test_info�sj����$�$�_�5����������,����[�!���������5����)�%?�@����3�r#c� �tjt�}|j|j	�d�|jd�|j|j
�d�|j|j	�d�|jd�|j|j
�d�|j|j	�d�|jd�|j|j
�d�|j|j	�d�|jd�|j|j
�d�|j|j	�d�|j|�y)	NrO�SFr�z2,FSz1,�RPT�Dz2,D)rr0rQrr
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.r/rr0r<r�r�rrrrr6r#r!r�r��s+���%�%�H�(� � �".� � r#r�c�D�eZdZejZd�Zd�Zd�Zd�Z	dd�Z
y)�_TestMboxMMDFMessagec�&�|j|�yr	)�_check_fromr�s  r!r�z*_TestMboxMMDFMessage._post_initialize_hooks������r#c��tjt�}|jd�tj|�}|j|j
�d�|j|j�d�y)NrOrN)rr
rQ�set_unixfromr1rrQrRr�s  r!�test_initialize_with_unixfromz2_TestMboxMMDFMessage.test_initialize_with_unixfrom	s_���o�o�o�.�����,�-��!�!�#�&����������8�����)�)�+�-@�Ar#c�f�tjt�}|j|�|j	|j��|j
d�|j|j�d�|j	|j��|j
dd�|j|d�|j	|j��|j
dtj��|j|d�|j	|j��y)Nzfoo bar�foo@barTz	blah@temp)rr1rQrr�rR�set_fromrrQr��	localtimer�s  r!�	test_fromz_TestMboxMMDFMessage.test_froms����!�!�/�2����������#�*�*�,�-����Y����������3����#�*�*�,�-����Y��%�����i�(����#�*�*�,�-����[�$�.�.�"2�3�����k�*����#�*�*�,�-r#c� �tjt�}|j|j	�d�|jd�|j|j	�d�|jd�|j|j	�d�|j
d�|j|j	�d�|jd�|j|j	�d�|j|�y)	NrOr��XODR�RODX�FA�RODFAX�FDXA�RO)	rr1rQrr�r�r�r�r"r�s  r!rz_TestMboxMMDFMessage.test_flags s����!�!�/�2���������"�-��
�
�c���������#�.��
�
�f���������&�1����T���������(�3�������������$�/����3�r#Nc�x�|�d}|jtj|dz|j���y)Nz
MAILER-DAEMONz. \w{3} \w{3} [\d ]\d [\d ]\d:\d{2}:\d{2} \d{4})r�r�r�rQ)rr�senders   r!rz _TestMboxMMDFMessage._check_from.s7���>�$�F����R�X�X��J�J����� �	!r#r	)r-r.r/r�_mboxMMDFMessager<r�rrrrr6r#r!rrs'���'�'�H��B�
.� �!r#rc�$�eZdZejZy)�TestMboxMessageN)r-r.r/rr1r<r6r#r!r(r(7�
���"�"�Hr#r(c�0�eZdZejZd�Zd�Zy)�
TestMHMessagec�<�|j|jg�yr	)r�
_sequencesr�s  r!r�z#TestMHMessage._post_initialize_hook@s���������,r#c��tjt�}|j|j	�g�|jdg�|j|j	�dg�|jg�|j|j	�g�|j
d�|j|j	�dg�|j
d�|j|j	�ddg�|j
d�|j|j	�ddg�|jd�|j|j	�dg�|j
d�|j|j	�ddg�|jd�|j|j	�ddg�|jddg�|j|j	�ddg�y)N�foobarr�r�r�)rr2rQrr�r�r��remove_sequencer�s  r!r�zTestMHMessage.test_sequencesCs�������0������*�*�,�b�1����8�*�%�����*�*�,�x�j�9����"������*�*�,�b�1�����"�����*�*�,�x�j�9�����#�����*�*�,�x��.C�D�����#�����*�*�,�x��.C�D����H�%�����*�*�,�y�k�:�����"�����*�*�,�y�(�.C�D����I�&�����*�*�,�y�(�.C�D����8�Y�/�0�����*�*�,�x��.C�Dr#N)r-r.r/rr2r<r�r�r6r#r!r+r+<s��� � �H�-�Er#r+c�6�eZdZejZd�Zd�Zd�Zy)�TestBabylMessagec�<�|j|jg�yr	)r�_labelsr�s  r!r�z&TestBabylMessage._post_initialize_hook_s��������b�)r#c��tjt�}|j|j	�g�|jdg�|j|j	�dg�|jg�|j|j	�g�|j
d�|j|j	�dg�|j
d�|j|j	�ddg�|j
d�|j|j	�ddg�|jd�|j|j	�dg�|j
d�|j|j	�ddg�|jd�|j|j	�ddg�|jddg�|j|j	�ddg�y)Nr/r��resentr�r�)rr3rQrr�r�r��remove_labelr�s  r!r�zTestBabylMessage.test_labelsbs����"�"�?�3��������)�2�.�����z�"�������)�H�:�6����r��������)�2�.��
�
�g��������)�G�9�5��
�
�h��������)�G�X�+>�?��
�
�h��������)�G�X�+>�?�����!�������)�H�:�6��
�
�h��������)�H�h�+?�@�����"�������)�H�h�+?�@�����*�-�.�������)�H�j�+A�Br#c��tjt�}|j�}|j	|j�g�|j
|j��d|d<d|d<|j	|j�j�g�|j|�|j�}|j	|j�ddg�|j	|dd�|j	|dd�|j
|j��|j�|j	|j�ddg�|j
|j��|j�}|j	|j�gd��dD]}|j	||||��y)Nz
FooBar 1.0�
User-Agent�Blahz
X-Whatever)r9�Dater��To�Subject)
rr3rQ�get_visiblerrZr�r�set_visible�update_visible)rr�visible�headers    r!�test_visiblezTestBabylMessage.test_visibleys���"�"�?�3���/�/�#����������,����'�-�-�/�0� ,���� &����������*�/�/�1�2�6����� ��/�/�#���������,��)E�F������.��=������.��7����'�-�-�/�0������������,��)E�F����'�-�-�/�0��/�/�#���������*5�	6�E�	;�F����W�V�_�c�&�k�:�	;r#N)	r-r.r/rr3r<r�r�rCr6r#r!r2r2[s���#�#�H�*�C�.;r#r2c�$�eZdZejZy)�TestMMDFMessageN)r-r.r/rr4r<r6r#r!rErE�r)r#rEc��eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zy)�TestMessageConversionc��|jD]4}tjt�}||�}|j	|��6yr	)r5rr
rQr")rrW�	msg_plainrs    r!�test_plain_to_xz%TestMessageConversion.test_plain_to_x�s=���,�,�	$�F�����8�I���#�C����s�#�	$r#c��|jD]4}|t�}tj|�}|j	|��6yr	)r5rQrr
r")rrWrrIs    r!�test_x_to_plainz%TestMessageConversion.test_x_to_plain�s=���,�,�	*�F���)�C�����,�I����y�)�	*r#c�`�|jD]}|t�}|j|��!yr	)r5rUr")rrWrs   r!�test_x_from_bytesz'TestMessageConversion.test_x_from_bytes�s0���,�,�	$�F��.�/�C����s�#�	$r#c�Z��|jD]�|jt�fd���y)Nc����d�Sr7r6)rWs�r!r�z9TestMessageConversion.test_x_to_invalid.<locals>.<lambda>�s������r#)r5r�rB)rrWs @r!�test_x_to_invalidz'TestMessageConversion.test_x_to_invalid�s+����,�,�	@�F����i�)>�?�	@r#c��|jD�cic]}||t�j��}}|jD]y}|jD]h}||ur�|t�}||�}||D�cgc]}|||vr|��
}}|D]/}	|j|	|jdj	||���1�j�{ycc}wcc}w)Nzwhile converting {} to {})r5rQr�rr�)
rrW�	reference�class1�class2�sourcer+�a�
type_specificr�s
          r!�3test_type_specific_attributes_removed_on_conversionzITestMessageConversion.test_type_specific_attributes_removed_on_conversion�s���&*�&<�&<�>�"��V�O�4�=�=�=�>�	�>��,�,�
	L�F��0�0�	
L���V�#����0������,5�f�,=�!B�q�&'�y��/@�&@�"#�!B�
�!B�)�L�D��$�$�T�6�?�?�3�:�:�6�6�J�L�L�	
L�
	L��>��!Bs�B8�-B=c��tjt�}|jd�|j	d�|j�}tj|�}|j
|�|j|j�d�|j|j�d�|j|j�|�y)N�DFPRSTr�)
rr0rQr�r�rr"rr�r�)r�msg_maildir�daters    r!�test_maildir_to_maildirz-TestMessageConversion.test_maildir_to_maildir�s����,�,�_�=�����h�'����u�%��#�#�%���$�$�[�1�����3���������(�3�������)�5�1���������.r#c�n�d}tjtjfD�]}tjt�}|jd�|D]�\}}|j
|�||�}|j|j�|�|j|j�dtjtjd��z�|j|j����|jd�|j||�j�d���y)N))rrO�r�r�)�PrO)�R�A)r�rb)�Tr)r[�RDFArzMAILER-DAEMON %sr��RODFA)rr1r4r0rQrr�rr�rQr��asctime�gmtimer�rRr�)r�pairsrWr\�setting�resultrs       r!�test_maildir_to_mboxmmdfz.TestMessageConversion.test_maildir_to_mboxmmdf�s��1���*�*�G�,?�,?�@�	G�F�!�0�0��A�K�� � ��%�#(�
6�����%�%�g�.��[�)��� � �����&�9�� � �����1C�!�\�\�$�+�+�c�*:�;�2<�=��!�!�#�"2�"2�"4�5�

6�
�"�"�5�)����V�K�0�:�:�<�g�F�	Gr#c	��tjt�}ddgfdddgfddgfdddgfdgfd	dgfd
ddgff}|D]I\}}|j|�|j	tj
|�j
�|��Ky)Nrr�r�r�rarbr�r�rdr[)rr0rQr�rr2r��rr\rirjrks     r!�test_maildir_to_mhz(TestMessageConversion.test_maildir_to_mh�s����,�,�_�=����z�"�S�8�Y�*?�$@���z�"�S�8�Y�*?�$@�3��)���z�"�X�	�9�/E�$F�H�� %�	%�O�G�V��!�!�'�*����W�.�.�{�;�I�I�K�#�
%�	%r#c	��tjt�}ddgfddgfdddgfdddgfdgfd	dd
gfdgd�ff}|D]I\}}|j|�|j	tj
|�j
�|��Ky)
Nrr�r�ra�	forwardedrbr�r�rd�deletedr[)rrr�rq)rr0rQr�rr3r�rns     r!�test_maildir_to_babylz+TestMessageConversion.test_maildir_to_babyl�s����,�,�_�=����z�"�S�8�*�$5���+�.�/�#��*�7M�1N��r��S�8�Y�"7�8��@�A�C�� %�	%�O�G�V��!�!�'�*����W�1�1�+�>�I�I�K�#�
%�	%r#c��tjtjfD]�}|t�}|j	dtjd��d}|D]k\}}|j|�tj|�}|j|j�|�|j|j�d��m|jd�|jtj|�j�d���y)Nrr))rbr�)�OrO)rrdr`)rcrb)rf�FRSTrur�)
rr1r4rQrr�rhr�r0rr�rr�)rrW�msg_mboxMMDFrirjrkrs       r!�test_mboxmmdf_to_maildirz.TestMessageConversion.test_mboxmmdf_to_maildir�s����*�*�G�,?�,?�@�	$�F�!�/�2�L��!�!�)�T�[�[��-=�>�(�E�#(�
6�����&�&�w�/��,�,�\�:��� � �����&�9�� � ������5�	
6�

�"�"�3�'����W�3�3�L�A�L�L�N�"�
$�	$r#c��tjtjfD]�}|t�}|j	d�|jd�|j
|j��tjtjfD]i}||�}|j|j�d�|j|j�d�|j
|j���k��y)Nrfr)rr1r4rQr�rr�rRrr�rQ)rrWrw�class2_r�s     r!�test_mboxmmdf_to_mboxmmdfz/TestMessageConversion.test_mboxmmdf_to_mboxmmdfs����*�*�G�,?�,?�@�		7�F�!�/�2�L��"�"�7�+��!�!�)�,����l�7�7�9�:�#�/�/��1D�1D�E�
7���|�,��� � ����!1�7�;�� � �����)�<��!�!�$�"3�"3�"5�6�	
7�		7r#c	�:�tjtjfD]x}|t�}dgfddgfddgfdddgfdddgfd	ddgff}|D]I\}}|j	|�|jtj|�j�|��K�zy)
Nrbrur�rr�r�rcr�rf)rr1r4rQr�rr2r�)rrWrwrirjrks      r!�test_mboxmmdf_to_mhz)TestMessageConversion.test_mboxmmdf_to_mhs����*�*�G�,?�,?�@�		)�F�!�/�2�L��2�Y��x�j� 1�C�(��3D��H�i�0�1��H�i�0�1��	�9�5�6�8�E�$)�
)�����&�&�w�/�� � ��!2�!2�<�!@�!N�!N�!P�!'�)�
)�
		)r#c	�:�tjtjfD]x}|t�}dgfddgfdddgfddgfdddgfd	ddgff}|D]I\}}|j	|�|jtj|�j�|��K�zy)
Nrbrur�rrrr�rcr�rf)rr1r4rQr�rr3r�)rrWrrirjrks      r!�test_mboxmmdf_to_babylz,TestMessageConversion.test_mboxmmdf_to_babyls����*�*�G�,?�,?�@�	Q�F���)�C��2�Y��x�j� 1��H�i�0�1�C�(��3D��H�j�1�2��	�:�6�7�9�E�$)�
Q�����
�
�g�&�� � ��!5�!5�c�!:�!E�!E�!G��P�
Q�
	Qr#c��d}|D]�\}}tjt�}|j|�|j	tj
|�j
�|�|j	tj
|�j�d���tjt�}|jd�|jd�|jd�|j	tj
|�j
�d�|j	tj
|�j�d�y)N)�r�rO)r��RS)r�r�r�r�r�r�r�)rr2rQr�rr0r�r��rrirjrkrs     r!�test_mh_to_maildirz(TestMessageConversion.test_mh_to_maildir+s��F��$�	N�O�G�V��#�#�O�4�C����W�%����W�3�3�C�8�B�B�D�f�M����W�3�3�C�8�C�C�E�u�M�		N�
����0������"�����#�����#�����/�/��4�>�>�@�$�G�����/�/��4�?�?�A�5�Ir#c�4�d}|D]z\}}tjt�}|j|�tjtj
fD](}|j
||�j�|��*�|tjt�}|jd�|jd�|jd�tjtj
fD](}|j
||�j�d��*y)N)�r�ru)r��ROA)r��ROFr�r�r��OFA)rr2rQr�r1r4rr�)rrirjrkrrWs      r!�test_mh_to_mboxmmdfz)TestMessageConversion.test_mh_to_mboxmmdf:s���I��$�	B�O�G�V��#�#�O�4�C����W�%�"�.�.��0C�0C�D�
B��� � ����!6�!6�!8�&�A�
B�	B�
����0������"�����#�����#��*�*�G�,?�,?�@�	=�F����V�C�[�2�2�4�e�<�	=r#c��tjt�}|jd�|jd�|jd�|j	tj|�j�gd��y)Nr�r�r�)r�r�r�)rr2rQr�rr�r�s  r!�
test_mh_to_mhz#TestMessageConversion.test_mh_to_mhIsc������0������"�����#�����#�����*�*�3�/�=�=�?�9�	;r#c���ddgfddgfdgff}|D]b\}}tjt�}|j|�|j	tj
|�j
�|��dtjt�}|jd�|jd�|jd�|j	tj
|�j
�ddg�y)Nr�r�r�r�)rr2rQr�rr3r�r�s     r!�test_mh_to_babylz&TestMessageConversion.test_mh_to_babylRs����X�J�'�)�j�\�)B��R��"��$�	M�O�G�V��#�#�O�4�C����W�%����W�1�1�#�6�A�A�C�V�L�	M�����0������"�����#�����#�����-�-�c�2�=�=�?�"�J�/�	1r#c�j�d}|D]�\}}tjt�}|j|�|j	tj
|�j
�|�|j	tj
|�j�d���tjt�}dD]}|j|��|j	tj
|�j
�d�|j	tj
|�j�d�y)N)r�)rr�ST)r�r�)r�r�)rq�PS)�editedr�)r6r�r��r�rrr�r�rqr�r6�PRT)rr3rQr�rr0r�r��rrirjrkr�labels      r!�test_babyl_to_maildirz+TestMessageConversion.test_babyl_to_maildiras���#�� %�	N�O�G�V��&�&��7�C��M�M�'�"����W�3�3�C�8�B�B�D�f�M����W�3�3�C�8�C�C�E�u�M�		N�
�"�"�?�3��*�	!�E��M�M�%� �	!�	
����/�/��4�>�>�@�%�H�����/�/��4�?�?�A�5�Ir#c��d}|D]z\}}tjtjfD]R}tjt�}|j|�|j
||�j�|��T�|tjt�}dD]}|j|��tjtjfD](}|j
||�j�d��*y)N)r�)rr�ROD)r�r#)r�r�)rqr#)r�r#)r6r#r��ODA)rr1r4r3rQr�rr�)rrirjrkrWrr�s       r!�test_babyl_to_mboxmmdfz,TestMessageConversion.test_babyl_to_mboxmmdfrs���#�� %�	B�O�G�V�"�.�.��0C�0C�D�
B���*�*�?�;���
�
�g�&�� � ����!6�!6�!8�&�A�
B�	B�
�"�"�?�3��*�	!�E��M�M�%� �	!��*�*�G�,?�,?�@�	=�F����V�C�[�2�2�4�e�<�	=r#c���ddgfdgfdgfddgfdgfdgfdgff}|D]b\}}tjt�}|j|�|j	tj
|�j
�|��dtjt�}d	D]}|j|��|j	tj
|�j
�ddg�y)
Nr�rrr�r�r�rqr�r6r�)rr3rQr�rr2r�r�s      r!�test_babyl_to_mhz&TestMessageConversion.test_babyl_to_mh�s����X�J�'�)�R��7�B�-��y�k�*�[�"�,=��"�~��B��!�� %�	M�O�G�V��&�&��7�C��M�M�'�"����W�.�.�s�3�A�A�C�V�L�	M��"�"�?�3��*�	!�E��M�M�%� �	!�	
����*�*�3�/�=�=�?�"�I�.�	0r#c�6�tjt�}|j�dD]}|j	|��tj|�}|j|j
�gd��|j|j�j�|j�j��|j�j�D]6}|j|j�||j�|��8y)Nr�)	rr3rQr@r�rr�r>rZ)rrr�r�rs     r!�test_babyl_to_babylz)TestMessageConversion.test_babyl_to_babyl�s����"�"�?�3������*�	!�E��M�M�%� �	!��#�#�C�(��������*�-7�	8�	
������*�/�/�1�4�3C�3C�3E�3J�3J�3L�M��?�?�$�)�)�+�	N�C����S�_�_�.�s�3�T�5E�5E�5G��5L�M�	Nr#N)r-r.r/rJrLrNrQrYr^rlrorsrxr{r}rr�r�r�r�r�r�r�r�r6r#r!rGrG�sr��$�*�$�@�

L�
/�G�"	%�
%�$� 7�)�
Q�
J�
=�;�
1�J�"=�"0� 
Nr#rGc�0�eZdZd�Zd�Zd�Zd�Zd�Zd�Zy)�TestProxyFileBasec���|jd�|j|j�d�|jd�|j|j�d�|jd�|j|jd�d�|jd�|j|jd�d�|jd�|j|jd�d	�y)
Nr�barrDsarrEsba������r)r�rr��r�proxys  r!�
_test_readzTestProxyFileBase._test_read�s���
�
�
�1�
��������v�.�
�
�
�1�
��������u�-�
�
�
�1�
�������A���.�
�
�
�1�
�������B���/�
�
�
�1�
�������D�)�4�0r#c�d�tjj�}|jd�|j	|j�d|z�|j	|j�d|z�|j	|j�d|z�|j	|j�d�|jd�|j	|j�d|z�|jddt
tj�zz�|j	|j�d|z�|jddt
tj�zz�|j	|jd�d	�|j	|jd
�d|z�y)Nr�foor��fred�bobrE�orIsfri����sed)r%r�r_r�r�readliner�rr�r�s   r!�_test_readlinez TestProxyFileBase._test_readline�s>���*�*�#�#�%��
�
�
�1�
�������)�6�G�+;�<�������)�6�G�+;�<�������)�7�W�+<�=�������)�6�2�
�
�
�1�
�������)�4�'�>�:�
�
�
�1�q�3�r�z�z�?�*�*�+�������)�7�W�+<�=�
�
�
�1�q�3�r�z�z�?�*�*�+��������*�E�2��������,�e�g�o�>r#c�D�tjj�}|jd�|j	|j�d|zd|zd|zdg�|jd�|j	|jd�d|zg�|jdt
|�z�|j	|jdt
|�z�d|zd|zg�|jd�|j	|jd	�|d|zd|zdg�y)
Nrr�r�r�r�rErFrGr�)r%r�r_r�rr?rr�s   r!�_test_readlinesz!TestProxyFileBase._test_readlines�s���*�*�#�#�%��
�
�
�1�
�������*�V�g�-=�+1�G�+;�+2�W�+<�f�-F�	G�	�
�
�1�
��������+�f�w�.>�-?�@�
�
�
�1�s�7�|�#�$��������S��\�)9�:��w�&��'�(9�:�	<�
�
�
�1�
��������.��&�7�:J�/6��/@�&�1J�	Kr#c��tjj�}|jd�t	|�}|jt
|�d|z�|jt
|�d|z�|jt
|�d|z�|jt
|�d�|jtt|�y)Nrr�r�r�r�)	r%r�r_r��iterr�nextr��
StopIteration)rr�r��iterators    r!�_test_iterationz!TestProxyFileBase._test_iteration�s����*�*�#�#�%��
�
�
�1�
���;������h���'�)9�:�����h���'�)9�:�����h���7�):�;�����h���0����-��x�8r#c���tjj�}|jd�|j	|j�d�|j	|j
t|��|�|jdd�|j	|j
dt|�z�d|z�|jdt|�z
d�|j	|j
d�d�|jdd�|j	|j
�d|zdz|z�|jd	�|j|j
��y)
NrFrErDr�r�r�rr��d)	r%r�r_r�r�tellr�rr1r�s   r!�_test_seek_and_tellz%TestProxyFileBase._test_seek_and_tell�s���*�*�#�#�%��
�
�
�1�
��������q�)�������C��L�1�7�;�
�
�
�1�a��������A��G��$4�5�t�g�~�F�
�
�
�2��G��$�a�(�������A���/�
�
�
�1�a���������t�g�~��'>��'H�I�
�
�
�3���������&r#c���|j|j�|j�|j|j�|j�|j|j�yr	)r1r�rArr�s  r!�_test_closezTestProxyFileBase._test_close�sF��������&�
���
�������%�
���
�������%r#N)	r-r.r/r�r�r�r�r�r�r6r#r!r�r��s!��1�?� K� 	9�
'�&r#r�c�B�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zy
)�
TestProxyFilec�d�tj|_t|jd�|_y�Nr��rr:r;r�r^r>s r!r?zTestProxyFile.setUp��!���%�%��
��$�*�*�e�,��
r#c�n�|jj�|j|j�yr	�r^rAr,r;r>s r!rBzTestProxyFile.tearDown��$���
�
����� � ����,r#c��|jjd�|jj�}tj|j�}|j|j�|�|j|jj�|�tj|jd�}|j|j�d�|j|jj�|�y)Nr�r)r^r�r�r�
_ProxyFiler)r�pos�proxy0�proxy1s    r!�test_initializezTestProxyFile.test_initializes����
�
���� ��j�j�o�o����#�#�D�J�J�/����������,���������*�C�0��#�#�D�J�J��2����������*���������*�C�0r#c��|jjd�|jtj|j��y)Nr�)r^r�r�rr�r>s r!�	test_readzTestProxyFile.test_reads/���
�
���� �����*�*�4�:�:�6�7r#c��|jjtdtj�dtj�dtj�d�d��|jt
j|j��y�Nr�r�fred�bobr�)r^r��bytesr%r�r�rr�r>s r!�
test_readlinezTestProxyFile.test_readlinesU���
�
�����
�
�B�J�J�24�*�*� >�?F�H�	I����G�.�.�t�z�z�:�;r#c��|jjtdtj�dtj�dtj�d�d��|jt
j|j��yr�)r^r�r�r%r�r�rr�r>s r!�test_readlineszTestProxyFile.test_readlines�U���
�
�����
�
�B�J�J�24�*�*� >�?F�H�	I����W�/�/��
�
�;�<r#c��|jjtdtj�dtj�dtj�d�d��|jt
j|j��yr�)r^r�r�r%r�r�rr�r>s r!�test_iterationzTestProxyFile.test_iterationr�r#c���|jjtdtj�dtj��d��|jt
j|j��y�Nr�rr�)r^r�r�r%r�r�rr�r>s r!�test_seek_and_tellz TestProxyFile.test_seek_and_tellsE���
�
����r�z�z�2�:�:�F��P�Q�� � ��!3�!3�D�J�J�!?�@r#c���|jjtdtj�dtj��d��|jt
j|j��yr�)r^r�r�r%r�r�rr�r>s r!r8zTestProxyFile.test_close"sE���
�
����r�z�z�2�:�:�F��P�Q�����+�+�D�J�J�7�8r#N�r-r.r/r?rBr�r�r�r�r�r�r8r6r#r!r�r��s0��-�-�	1�8�<�
=�
=�
A�9r#r�c�B�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zy
)�TestPartialFilec�d�tj|_t|jd�|_yr�r�r>s r!r?zTestPartialFile.setUp)r�r#c�n�|jj�|j|j�yr	r�r>s r!rBzTestPartialFile.tearDown-r�r#c��|jjtdtjzdzd��|jj�}t
j|jdd�}|j|j�d�|j|jj�|�y)Nr�rr�rErHr)	r^r�r�r%r�r�r�_PartialFiler)rr�r�s   r!r�zTestPartialFile.test_initialize1s����
�
����u�r�z�z�1�E�9�7�C�D��j�j�o�o����$�$�T�Z�Z��A�6���������q�)���������*�C�0r#c��|jjtdd��|jt	j
|jdd��y)Nz	***bar***r�rFrI)r^r�r�r�rr�r>s r!r�zTestPartialFile.test_read9s:���
�
����{�G�4�5�����,�,�T�Z�Z��A�>�?r#c�P�|jjtdtj�dtj�dtj�d�d��|jt
j|jdddttj�zz��y)	Nz!!!!!foorr�zbob!!!!!r�rH�rF)	r^r�r�r%r�r�rr�rr>s r!r�zTestPartialFile.test_readline=sr���
�
�����*�*�b�j�j�"�*�*� >�?F�H�	I����G�0�0����Q�13�a�#�b�j�j�/�6I�1I�K�	Lr#c�P�|jjtdtj�dtj�dtj�d�d��|jt
j|jdddttj�zz��y)	Nr�rr�zbob?????r�r�
rF)	r^r�r�r%r�r�rr�rr>s r!r�zTestPartialFile.test_readlinesC�r���
�
�����*�*�b�j�j�"�*�*� >�?F�H�	I����W�1�1�$�*�*�a�24�q�3�r�z�z�?�7J�2J�L�	Mr#c�P�|jjtdtj�dtj�dtj�d�d��|jt
j|jdddttj�zz��y)	N�____foorr�zbob####r�rG�rF)	r^r�r�r%r�r�rr�rr>s r!r�zTestPartialFile.test_iterationIr�r#c�.�|jjtdtj�dtj�d�d��|jt
j|jdddttj�zz��y)Nz(((foorz$$$r�rF�	rE)	r^r�r�r%r�r�rr�rr>s r!r�z"TestPartialFile.test_seek_and_tellOsb���
�
����R�Z�Z����L�g�V�W�� � ��!5�!5�d�j�j�!�67�!�c�"�*�*�o�:M�6M�"O�	Pr#c�.�|jjtdtj�dtj�d�d��|jt
j|jdddttj�zz��y)Nz&foor�^r�rDrIrF)	r^r�r�r%r�r�rr�rr>s r!r8zTestPartialFile.test_closeTsb���
�
�������R�Z�Z�H�'�R�S�����-�-�d�j�j�!�./�!�c�"�*�*�o�2E�.E�G�	Hr#Nr�r6r#r!r�r�'s5��-�-�1�@�L�M�M�P�
Hr#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�eZdZd�Zd�Zd	d�Zd�Zd�Zd�Zd�Z	y)
�MaildirTestCasec��tj|_tjj|j�r tj|j�nHtjj|j�rtj|j�tj|j�tjtjj|jd��tjtjj|jd��tjtjj|jd��d|_g|_y)Nr�r�r�rD)
rr:�_dirr%r&r'r(�isfiler*r�r��_counter�	_msgfilesr>s r!r?zMaildirTestCase.setUpgs����$�$��	�
�7�7�=�=����#����T�Y�Y�'�
�W�W�^�^�D�I�I�
&����T�Y�Y�'�
�������
��������d�i�i��/�0�
��������d�i�i��/�0�
��������d�i�i��/�0���
���r#c�
�tttj|j��tjtjj|jd��tjtjj|jd��tjtjj|jd��tj|j�y)Nr�r�r�)
r��mapr%r*r�r�rmdirr&r�r�r>s r!rBzMaildirTestCase.tearDownus����S����D�N�N�
+�,���������T�Y�Y��6�7���������T�Y�Y��6�7���������T�Y�Y��6�7�����	�	�"r#c�R�ttj�dz�}|j}|xjdz
c_djt	|�t	|�ddf�}t
jj|jd|�}t
jj|j||�}t|dd�	�5}|jj|�|r|jt�|jt�ddd�	tj||�|jj|�|S#1swY�=xYw#tt f$r:t|d�5}|jt�ddd�n#1swYnxYwY�qwxYw)
Ni@BrD�.�
myhostname�mydomainr�r�rJrK)rr�r�r��strr%r&r�r�r�rNr��FROM_�
DUMMY_MESSAGE�link�AttributeError�PermissionError)	r�dirrx�tr�r�tmpname�newname�fps	         r!�
createMessagezMaildirTestCase.createMessage|s>����	�	��g�%�&���m�m���
�
���
��8�8�S��V�S��X�|�Z�H�I���'�'�,�,�t�y�y�%��:���'�'�,�,�t�y�y�#�x�8��
�'�3��
1�	$�R��N�N�!�!�'�*��������H�H�]�#�		$�
	(��G�G�G�W�%�	
�����g�&���	$�	$����0�	(��g�s�#�
(�r�����'�
(�
(�
(��	(�s7�
AE�E�E�F&�8F�	F&�F 	�F&�%F&c��tjtj�|_|j|jj
��|j|jj
��y)zTest an empty maildir mailboxN)rr~rr:rxr�r�r>s r!�test_empty_maildirz"MaildirTestCase.test_empty_maildir�sN���O�O�I�$4�$4�5��	�	
���$�)�)�.�.�*�+����$�)�)�.�.�*�+r#c�l�|jd�tjtj�|_|j
|j
j��|j|j
j��|j|j
j��y)Nr��	r
rr~rr:rxr�r�r�r>s r!�test_nonempty_maildir_curz)MaildirTestCase.test_nonempty_maildir_cur��q�����5�!��O�O�I�$4�$4�5��	����T�Y�Y�^�^�-�.����$�)�)�.�.�*�+����$�)�)�.�.�*�+r#c�l�|jd�tjtj�|_|j
|j
j��|j|j
j��|j|j
j��y)Nr�rr>s r!�test_nonempty_maildir_newz)MaildirTestCase.test_nonempty_maildir_new�rr#c���|jd�|jd�tjtj�|_|j
|j
j��|j
|j
j��|j|j
j��|j|j
j��y)Nr�r�rr>s r!�test_nonempty_maildir_bothz*MaildirTestCase.test_nonempty_maildir_both�s������5�!����5�!��O�O�I�$4�$4�5��	����T�Y�Y�^�^�-�.����T�Y�Y�^�^�-�.����$�)�)�.�.�*�+����$�)�)�.�.�*�+r#N)F)
r-r.r/r?rBr
rrrrr6r#r!r�r�es%���#��(,�,�,�,r#r�aKReturn-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�))zReturn-Pathz<gkj@gregorykjohnson.com>)z
X-Original-To�gkj+person@localhost)�Delivered-Tor)�Receivedz�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))rz gkj@sundance.gregorykjohnson.com)rz�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))rz�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))rztby andy.gregorykjohnson.com (Postfix, from userid 1000)
        id 490CD9DD17; Wed, 13 Jul 2005 17:23:11 -0400 (EDT))r;zWed, 13 Jul 2005 17:23:11 -0400)r�z."Gregory K. Johnson" <gkj@gregorykjohnson.com>)r<zgkj@gregorykjohnson.com)r=zSample message)zMime-Versionz1.0)zContent-Typez,multipart/mixed; boundary="NMuMz9nt05w80d4+")zContent-Disposition�inline)r9zMutt/1.5.9i)z1This is a sample message.

--
Gregory K. Johnson
zRH4sICM2D1UIAA3RleHQAC8nILFYAokSFktSKEoW0zJxUPa7wzJIMhZLyfIWczLzUYj0uAHTs
3FYlAAAA
c��eZdZd�Zy)�MiscTestCasec�@�tj|tddh��y)Nr��fcntl)�not_exported)r�check__all__rr>s r!�test__all__zMiscTestCase.test__all__
	s�����T�7�+4�g�*>�	@r#N)r-r.r/r"r6r#r!rr	s��@r#rc�,�tj�yr	)r�
reap_childrenr6r#r!�tearDownModuler%	s�����r#�__main__);r%r�r�r�r�r�
email.messager�rSr��testr�test.supportrrr!rHrr5�has_gethostname�SkipTestrr8�TestCaserKr|r%r0rvr�r�r�r�rxr�r�r�r�rr(r+r2rErGr�r�r�rrr�rQr_rUrrrr%r-�mainr6r#r!�<module>r.s���	�
���
���	�	���"�&������$�$�
�(�
�
�9�
:�:�%�%�8z$�(�z$�z!D�H�h�&7�&7�!D�HX%�+�x�0�0�X%�v
&<�k�&<�RK�O�K�\+1�}�h�/�/�+1�\L�}�h�/�/�L�
D>�[�(�+�+�D>�NE���!2�!2�E�D���'�/�/��	1�h�'�'�	1�S
�(�H�-�-�S
�lG ��h�&7�&7�G �T2!�2!�j#�*�K�#�
E�K��!2�!2�E�>4;�{�H�$5�$5�4;�n#�*�K�#�
IN�H�h�&7�&7�IN�XP&��P&�f.9�%�x�'8�'8�.9�b0H�'��):�):�0H�j	B���
�M,�h�'�'�M,�d-��^(�.�.�w�7����4��@�8�$�$�@���z���H�M�M�O�r#