HEX
Server: Microsoft-IIS/10.0
System: Windows NT ITPWINWEBSVR22 10.0 build 20348 (Windows Server 2022) AMD64
User: www.conferencesearch.co.uk (0)
PHP: 8.3.30
Disabled: NONE
Upload Files
File: D:/Python311/Lib/test/__pycache__/test_zipfile.cpython-311.opt-2.pyc
�

��Vc�!��(	�ddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlmZddlZddlZddlmZddlmZmZmZddlmZddlmZmZmZmZmZmZm Z ddl!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'e"dzZ(e"dzZ)d	Z*d
Z+gd�Z,d�Z-Gd
�d��Z.Gd�de.ej/��Z0e��Gd�de.ej/����Z1e��Gd�de.ej/����Z2e��Gd�de.ej/����Z3Gd�d��Z4Gd�de4ej/��Z5e��Gd�de4ej/����Z6e��Gd�de4ej/����Z7e��Gd�d e4ej/����Z8Gd!�d"��Z9Gd#�d$e9ej/��Z:e��Gd%�d&e9ej/����Z;e��Gd'�d(e9ej/����Z<e��Gd)�d*e9ej/����Z=Gd+�d,ej/��Z>Gd-�d.ej/��Z?Gd/�d0ej/��Z@Gd1�d2��ZAGd3�d4eAej/��ZBe��Gd5�d6eAej/����ZCe��Gd7�d8eAej/����ZDe��Gd9�d:eAej/����ZEGd;�d<ej/��ZFGd=�d>��ZGGd?�d@eGej/��ZHe��GdA�dBeGej/����ZIe��GdC�dDeGej/����ZJe��GdE�dFeGej/����ZKGdG�dH��ZLGdI�dJ��ZMGdK�dLej/��ZNe��GdM�dNej/����ZOGdO�dPej/��ZPGdQ�dRej/��ZQGdS�dTej/��ZRGdU�dVej/��ZSeTZUGdW�dX��ZVdY�ZWdZ�ZXd[�ZYGd\�d]ej/��ZZGd^�d_ej/��Z[e\d`krej]��dSdS)a�N)�
TemporaryFile)�randint�random�	randbytes)�
script_helper)�findfile�
requires_zlib�requires_bz2�
requires_lzma�captured_stdout�captured_stderr�requires_subprocess)�TESTFN�unlink�rmtree�temp_dir�temp_cwd�fd_count�2�d���zipfile_datafiles))�	_ziptest1�
1q2w3e4r5t)zziptest2dir/_ziptest2�
qawsedrftg)z!ziptest2dir/ziptest3dir/_ziptest3�
azsxdcfvgb)z-ziptest2dir/ziptest3dir/ziptest4dir/_ziptest3�
6y7u8i9o0pc#�8K�tV�t��5}|V�|�|j��ddd��n#1swxYwYt	j��5}|V�|�|j��ddd��dS#1swxYwYdS�N)�TESTFN2r�assertFalse�closed�io�BytesIO)�test�fs  �%D:\Python311\Lib\test\test_zipfile.py�	get_filesr(+s����
�M�M�M�	���#�A����������"�"�"�#�#�#�#�#�#�#�#�#�#�#����#�#�#�#�
����#�����������"�"�"�#�#�#�#�#�#�#�#�#�#�#�#����#�#�#�#�#�#s#�A�A	�A	�#B�B�Bc���eZdZed���Zd�Zd"d�Zd"d�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z!d �Z"d!�Z#dS)#�AbstractTestsWithSourceFilec��d�tt��D��|_d�|j��|_dS)Nc�P�g|]#}td|t��fzd����$S)z'Zipfile test line %d. random float: %f
�ascii)�bytesr��.0�is  r'�
<listcomp>z:AbstractTestsWithSourceFile.setUpClass.<locals>.<listcomp>7sH��8�8�8���H� �&�(�(�m�,�-4�6�6�8�8�8�r3)�range�FIXEDTEST_SIZE�line_gen�join�data��clss r'�
setUpClassz&AbstractTestsWithSourceFile.setUpClass5sE��8�8�!&�~�!6�!6�8�8�8����8�8�C�L�)�)����r3c��ttd��5}|�|j��ddd��dS#1swxYwYdS�N�wb��openr�writer8��self�fps  r'�setUpz!AbstractTestsWithSourceFile.setUp<���
�&�$�
�
�	 �2��H�H�T�Y����	 �	 �	 �	 �	 �	 �	 �	 �	 �	 �	 �	 ����	 �	 �	 �	 �	 �	 ��>�A�ANc��||d�}tj|dfi|��5}|�td��|�tt��|�d|j��|�dd���5}|jD]}|�|���	ddd��n#1swxYwYddd��dS#1swxYwYdS)N)�compression�
compresslevel�w�another.name�strfile�written-open-w��mode)�zipfile�ZipFilerAr�writestrr8r@r6)rCr&rIrJ�kwargs�zipfp�lines       r'�make_test_archivez-AbstractTestsWithSourceFile.make_test_archiveAsX��!,�}�M�M��
�_�Q��
.�
.�v�
.�
.�	"�%��K�K���/�/�/��K�K���'�'�'��N�N�9�d�i�0�0�0����,�3��7�7�
"�1� �M�"�"�D��G�G�D�M�M�M�M�"�
"�
"�
"�
"�
"�
"�
"�
"�
"�
"�
"����
"�
"�
"�
"�		"�	"�	"�	"�	"�	"�	"�	"�	"�	"�	"�	"����	"�	"�	"�	"�	"�	"s6�A.C� B4�(C�4B8	�8C�;B8	�<C�C�Cc	�~�|�|||��tj|d|��5}|�|�t
��|j��|�|�d��|j��|�|�d��|j��tj��}|�	|���|�
��}|���}|�t|��d��|�
d|d��|�
d|d��|�
d	|d��|d
���\}}	}
}|�|d��|�t!j|	d����|�t!j|
d����|�|t%t|j������|���}|�t|��d
��|�
t
|��|�
d|��|�
d|��|�
d|��|���}
d�|
D��}|�t|��d
��|�
t
|��|�
d|��|�
d|��|�
d|��|
D]/}|�|jt|j�����0t
dddfD]_}|�|��}|�|j|��|�|jt|j�����`|���ddd��dS#1swxYwYdS)N�rrLrM)�file��	File Namer�Modified�Size��%Y-%m-%d�%H:%M:%S�rNc��g|]	}|j��
S���filenamer/s  r'r2z8AbstractTestsWithSourceFile.zip_test.<locals>.<listcomp>p���/�/�/�A�Q�Z�/�/�/r3)rWrQrR�assertEqual�readrr8r#�StringIO�printdir�getvalue�
splitlines�len�assertIn�split�
assertTrue�time�strptime�str�namelist�infolist�	file_size�getinforf�testzip)rCr&rIrJrUrD�	directory�lines�fn�date�time_�size�names�infosr1�nm�infos                 r'�zip_testz$AbstractTestsWithSourceFile.zip_testLs������q�+�}�=�=�=��_�Q��[�
1�
1�0	�U����U�Z�Z��/�/���;�;�;����U�Z�Z��7�7���C�C�C����U�Z�Z�	�2�2�D�I�>�>�>�����B��N�N��N�#�#�#����
�
�I��(�(�*�*�E����S��Z�Z��+�+�+��M�M�+�u�Q�x�0�0�0��M�M�*�e�A�h�/�/�/��M�M�&�%��(�+�+�+�$)�!�H�N�N�$4�$4�!�B��e�T����R��0�0�0��O�O�D�M�$�
�;�;�<�<�<��O�O�D�M�%��<�<�=�=�=����T�3�s�4�9�~�~�#6�#6�7�7�7��N�N�$�$�E����S��Z�Z��+�+�+��M�M�&�%�(�(�(��M�M�.�%�0�0�0��M�M�)�U�+�+�+��M�M�*�E�2�2�2��N�N�$�$�E�/�/��/�/�/�E����S��Z�Z��+�+�+��M�M�&�%�(�(�(��M�M�.�%�0�0�0��M�M�)�U�+�+�+��M�M�*�E�2�2�2��
>�
>��� � ���c�$�)�n�n�=�=�=�=��~�y�:J�K�
A�
A���}�}�R�(�(��� � ����3�3�3�� � ����T�Y���@�@�@�@�
�M�M�O�O�O�a0	�0	�0	�0	�0	�0	�0	�0	�0	�0	�0	�0	����0	�0	�0	�0	�0	�0	s�O7P2�2P6�9P6c�`�t|��D]}|�||j���dSr�r(r�rI�rCr&s  r'�
test_basicz&AbstractTestsWithSourceFile.test_basic��;���4���	/�	/�A��M�M�!�T�-�.�.�.�.�	/�	/r3c���|�||��tj|d|��5}g}|�t��5}	|�d��}|sn|�|���.	ddd��n#1swxYwYg}|�d��5}	|�d��}|sn|�|���.	ddd��n#1swxYwY|�d�|��|j	��|�d�|��|j	��ddd��dS#1swxYwYdS�NrYT�rLr3)
rWrQrRr@rri�appendrhr7r8)	rCr&rIrU�zipdata1�zipopen1�	read_data�zipdata2�zipopen2s	         r'�
zip_open_testz)AbstractTestsWithSourceFile.zip_open_test�s'�����q�+�.�.�.��_�Q��[�
1�
1�	<�U��H����F�#�#�
/�x�/� (�
�
�c� 2� 2�I�$����O�O�I�.�.�.�	/��	
/�
/�
/�
/�
/�
/�
/�
/�
/�
/�
/����
/�
/�
/�
/��H����N�+�+�
/�x�/� (�
�
�c� 2� 2�I�$����O�O�I�.�.�.�	/��	
/�
/�
/�
/�
/�
/�
/�
/�
/�
/�
/����
/�
/�
/�
/�
���S�X�X�h�/�/���;�;�;����S�X�X�h�/�/���;�;�;�%	<�	<�	<�	<�	<�	<�	<�	<�	<�	<�	<�	<����	<�	<�	<�	<�	<�	<sZ�E�
0B�;E�B	�E�B	�E�)0C&�E�&C*	�*E�-C*	�.AE�E�!Ec�`�t|��D]}|�||j���dSr�r(r�rIr�s  r'�	test_openz%AbstractTestsWithSourceFile.test_open��=���4���	4�	4�A����q�$�"2�3�3�3�3�	4�	4r3c��tjt��}|�||j��tj|d|j��5}|�|jt��ddd��dS#1swxYwYdS�NrY)
�pathlib�Pathr r�rIrQrR�assertIsInstancerfrt)rC�pathrUs   r'�test_open_with_pathlikez3AbstractTestsWithSourceFile.test_open_with_pathlike�s����|�G�$�$�����4��!1�2�2�2�
�_�T�3��(8�
9�
9�	7�U��!�!�%�.�#�6�6�6�	7�	7�	7�	7�	7�	7�	7�	7�	7�	7�	7�	7����	7�	7�	7�	7�	7�	7s�!A>�>B�Bc���|�||��tj|d|��5}g}|�t��5}	|�t
dd����}|sn|�|���<	ddd��n#1swxYwY|�d�	|��|j
��ddd��dS#1swxYwYdS�NrYTr_�r3)rWrQrRr@rrirr�rhr7r8)rCr&rIrUr�r�r�s       r'�zip_random_open_testz0AbstractTestsWithSourceFile.zip_random_open_test�se�����q�+�.�.�.��_�Q��[�
1�
1�		<�U��H����F�#�#�
/�x�/� (�
�
�g�a��.>�.>� ?� ?�I�$����O�O�I�.�.�.�	/��	
/�
/�
/�
/�
/�
/�
/�
/�
/�
/�
/����
/�
/�
/�
/�
���S�X�X�h�/�/���;�;�;�		<�		<�		<�		<�		<�		<�		<�		<�		<�		<�		<�		<����		<�		<�		<�		<�		<�		<s5�C�
>B�	C�B	�C�B	�1C�C�"Cc�`�t|��D]}|�||j���dSr�r(r�rIr�s  r'�test_random_openz,AbstractTestsWithSourceFile.test_random_open��=���4���	;�	;�A��%�%�a��)9�:�:�:�:�	;�	;r3c��|�||��tj|d��5}|�t��5}g}	|�d��}|sn|�|���.	ddd��n#1swxYwYddd��n#1swxYwY|�d�|��|j	��dS)NrYT���r3)
rWrQrRr@r�read1r�rhr7r8�rCr&rIrU�zipopen�zipdatar�s       r'�zip_read1_testz*AbstractTestsWithSourceFile.zip_read1_test�sQ�����q�+�.�.�.��_�Q��
$�
$�	*��
�Z�Z��
�
�	*�#*��G�
*�#�M�M�"�-�-�	� ������y�)�)�)�	
*��
	*�	*�	*�	*�	*�	*�	*�	*�	*�	*�	*����	*�	*�	*�	*�	*�	*�	*�	*�	*�	*�	*�	*�	*�	*�	*����	*�	*�	*�	*�	
������'�*�*�D�I�6�6�6�6�6s5�B�2B�:B�B
	�
B�
B
	�B�B!�$B!c�`�t|��D]}|�||j���dSr)r(r�rIr�s  r'�
test_read1z&AbstractTestsWithSourceFile.test_read1�s=���4���	5�	5�A�����4�#3�4�4�4�4�	5�	5r3c��|�||��tj|d��5}|�t��5}g}	|�d��}|�t|��d��|sn|�|���Q	ddd��n#1swxYwYddd��n#1swxYwY|�	d�
|��|j��dS)NrYT�
r3)rWrQrRr@rr��assertLessEqualrnr�rhr7r8r�s       r'�zip_read1_10_testz-AbstractTestsWithSourceFile.zip_read1_10_test�sm�����q�+�.�.�.��_�Q��
$�
$�	*��
�Z�Z��
�
�	*�#*��G�
*�#�M�M�"�-�-�	��$�$�S��^�^�R�8�8�8� ������y�)�)�)�
*��	*�	*�	*�	*�	*�	*�	*�	*�	*�	*�	*����	*�	*�	*�	*�	*�	*�	*�	*�	*�	*�	*�	*�	*�	*�	*����	*�	*�	*�	*�	
������'�*�*�D�I�6�6�6�6�6s6�C�AB)�C�)B-	�-C�0B-	�1C�C�Cc�`�t|��D]}|�||j���dSr)r(r�rIr�s  r'�
test_read1_10z)AbstractTestsWithSourceFile.test_read1_10��=���4���	8�	8�A��"�"�1�d�&6�7�7�7�7�	8�	8r3c��|�||��tj|d��5}|�t��5}d}	|���}|sn#||z
}|�d��}|sn||z
}�:ddd��n#1swxYwYddd��n#1swxYwY|�||j��dS)NrYr3T�d)	rWrQrRr@r�readlinerirhr8)rCr&rIrUr�r8ris       r'�zip_readline_read_testz2AbstractTestsWithSourceFile.zip_readline_read_test�s\�����q�+�.�.�.��_�Q��
$�
$�	��
�Z�Z��
�
�	�#*��D�	
��'�'�)�)����������|�|�C�(�(���������	
�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	
����t�y�)�)�)�)�)s5�B(�>B�B(�B	�B(�B	�B(�(B,�/B,c�`�t|��D]}|�||j���dSr)r(r�rIr�s  r'�test_readline_readz.AbstractTestsWithSourceFile.test_readline_read�s=���4���	=�	=�A��'�'��4�+;�<�<�<�<�	=�	=r3c�\�|�||��tj|d��5}|�t��5}|jD],}|���}|�||���-	ddd��n#1swxYwYddd��dS#1swxYwYdSr�)rWrQrRr@rr6r�rh)rCr&rIrUr�rV�linedatas       r'�zip_readline_testz-AbstractTestsWithSourceFile.zip_readline_test�s1�����q�+�.�.�.��_�Q��
$�
$�	5�����F�#�#�
5�w� �M�5�5�D�&�/�/�1�1�H��$�$�X�t�4�4�4�4�5�
5�
5�
5�
5�
5�
5�
5�
5�
5�
5�
5����
5�
5�
5�
5�	5�	5�	5�	5�	5�	5�	5�	5�	5�	5�	5�	5����	5�	5�	5�	5�	5�	5s5�B!�5B	�=B!�	B
	�
B!�B
	�B!�!B%�(B%c�`�t|��D]}|�||j���dSr)r(r�rIr�s  r'�
test_readlinez)AbstractTestsWithSourceFile.test_readliner�r3c�~�|�||��tj|d��5}|�t��5}|���}ddd��n#1swxYwYt
|j|��D]\}}|�||���	ddd��dS#1swxYwYdSr�)	rWrQrRr@r�	readlines�zipr6rh)rCr&rIrUr��ziplinesrV�ziplines        r'�zip_readlines_testz.AbstractTestsWithSourceFile.zip_readlines_test	s?�����q�+�.�.�.��_�Q��
$�
$�	0�����F�#�#�
/�w�"�,�,�.�.��
/�
/�
/�
/�
/�
/�
/�
/�
/�
/�
/����
/�
/�
/�
/�!$�T�]�H�!=�!=�
0�
0�
��g�� � ��$�/�/�/�/�
0�	0�	0�	0�	0�	0�	0�	0�	0�	0�	0�	0�	0����	0�	0�	0�	0�	0�	0s5�B2�A(�B2�(A,	�,B2�/A,	�04B2�2B6�9B6c�`�t|��D]}|�||j���dSr)r(r�rIr�s  r'�test_readlinesz*AbstractTestsWithSourceFile.test_readlines�=���4���	9�	9�A��#�#�A�t�'7�8�8�8�8�	9�	9r3c�V�|�||��tj|d��5}|�t��5}t|j|��D]\}}|�||���	ddd��n#1swxYwYddd��dS#1swxYwYdSr�)rWrQrRr@rr�r6rh)rCr&rIrUr�rVr�s       r'�zip_iterlines_testz.AbstractTestsWithSourceFile.zip_iterlines_tests.�����q�+�.�.�.��_�Q��
$�
$�	4�����F�#�#�
4�w�%(����%@�%@�4�4�M�D�'��$�$�W�d�3�3�3�3�4�
4�
4�
4�
4�
4�
4�
4�
4�
4�
4�
4����
4�
4�
4�
4�	4�	4�	4�	4�	4�	4�	4�	4�	4�	4�	4�	4����	4�	4�	4�	4�	4�	4s5�B�2B�:B�B
	�
B�
B
	�B�B"�%B"c�`�t|��D]}|�||j���dSr)r(r�rIr�s  r'�test_iterlinesz*AbstractTestsWithSourceFile.test_iterlines r�r3c��	tjtd|j��5}|�dd��ddd��n#1swxYwYtjtd|j��5}|�d��5}|�|�d��d��|�|�d��d��ddd��n#1swxYwYddd��dS#1swxYwYdS)NrKrM�12rYr_�1�2)rQrRr rIrSr@rhri)rCrU�openobjs   r'�test_low_compressionz0AbstractTestsWithSourceFile.test_low_compression$s���L�
�_�W�c�4�+;�
<�
<�	,���N�N�9�d�+�+�+�	,�	,�	,�	,�	,�	,�	,�	,�	,�	,�	,����	,�	,�	,�	,��_�W�c�4�+;�
<�
<�	8�����I�&�&�
8�'�� � ����a���$�7�7�7�� � ����a���$�7�7�7�
8�
8�
8�
8�
8�
8�
8�
8�
8�
8�
8����
8�
8�
8�
8�	8�	8�	8�	8�	8�	8�	8�	8�	8�	8�	8�	8����	8�	8�	8�	8�	8�	8sH�A�A	�A	�0C=�AC%�C=�%C)	�)C=�,C)	�-C=�=D�Dc���tjtd��}|�dd|j���|�d��}|�|j|j��dS)NrK�b.txt�hello world��
compress_type)rQrRr rSrIrxrhr�)rCrUr�s   r'�test_writestr_compressionz5AbstractTestsWithSourceFile.test_writestr_compression0sa������-�-��
���w�
�T�=M��N�N�N��}�}�W�%�%������+�T�-=�>�>�>�>�>r3c���tjtdd���}|�dd|j���|�dd|jd�	��|�d��}|�|j|j��|�|jd��|�d��}|�|j|j��|�|jd��dS)
NrKr_�rJ�a.txtr�r�r��)r�rJ)	rQrRr rSrIrxrhr��_compresslevel)rCrU�a_info�b_infos    r'�test_writestr_compresslevelz7AbstractTestsWithSourceFile.test_writestr_compresslevel6s�������A�>�>�>��
���w�
�T�=M��N�N�N�
���w�
�T�=M�%&�	�	(�	(�	(����w�'�'������-�t�/?�@�@�@�����.��2�2�2����w�'�'������-�t�/?�@�@�@�����.��2�2�2�2�2r3c��dD]�}|dz}t|��}tjtj��d|j��5}|�d|��|�dd��5}|�|��}|�	t|��|��ddd��n#1swxYwYddd��n#1swxYwY��dS)N)r_i�iii@r_rK�foorY)rrQrRr#r$rIrSr@rirhrn)rC�	test_sizerw�junk�zipfrD�bufs       r'�test_read_return_sizez1AbstractTestsWithSourceFile.test_read_return_sizeFsJ��6�	:�	:�I�!�A�
�I��Y�'�'�D�������s�D�4D�E�E�
:���
�
�e�T�*�*�*��Y�Y�u�c�*�*�:�b��'�'�)�,�,�C��$�$�S��X�X�y�9�9�9�:�:�:�:�:�:�:�:�:�:�:����:�:�:�:�
:�
:�
:�
:�
:�
:�
:�
:�
:�
:�
:����
:�
:�
:�
:��	:�	:s6�-C�29B7�+C�7B;�;C�>B;�?C�C	�C	c�<�tj��}tj|d���5}|�d|j|j���|���}ddd��n#1swxYwY|���}tj|��}tj|��5}|�	d��5}|�
|dz
��|�t��5|�
��ddd��n#1swxYwYddd��n#1swxYwYddd��n#1swxYwYtj|��}tj|��5}|�	d��5}|�
|dz
��|�t��5|�
d��r	|�
d���ddd��n#1swxYwYddd��n#1swxYwYddd��n#1swxYwYtj|��}tj|��5}|�	d��5}|�
|dz
��|�t��5|�d��r	|�d���ddd��n#1swxYwYddd��n#1swxYwYddd��dS#1swxYwYdS)NrKrOrMr��r�)r#r$rQrRrSr8rI�tellrlr@�truncate�assertRaises�EOFErrorrir�)rCrDr��
end_offset�zipfiledatar�s      r'�test_truncated_zipfilez2AbstractTestsWithSourceFile.test_truncated_zipfileRs#��
�Z�\�\��
�_�R�c�
*�
*�
*�	#�d��M�M�)�T�Y�d�>N�M�O�O�O������J�	#�	#�	#�	#�	#�	#�	#�	#�	#�	#�	#����	#�	#�	#�	#��k�k�m�m��
�Z��
$�
$��
�_�R�
 �
 �	#�D����9�%�%�
#�����J��O�,�,�,��&�&�x�0�0�#�#��L�L�N�N�N�#�#�#�#�#�#�#�#�#�#�#����#�#�#�#�
#�
#�
#�
#�
#�
#�
#�
#�
#�
#�
#����
#�
#�
#�
#�	#�	#�	#�	#�	#�	#�	#�	#�	#�	#�	#����	#�	#�	#�	#��Z��
$�
$��
�_�R�
 �
 �	�D����9�%�%�
�����J��O�,�,�,��&�&�x�0�0���!�,�,�s�+�+���"�,�,�s�+�+��������������������
�
�
�
�
�
�
�
�
�
�
����
�
�
�
�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	��Z��
$�
$��
�_�R�
 �
 �	�D����9�%�%�
�����J��O�,�,�,��&�&�x�0�0���!�-�-��,�,���"�-�-��,�,��������������������
�
�
�
�
�
�
�
�
�
�
����
�
�
�
�	�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	�	s�7A-�-A1�4A1�4E�
3D5�=D�D5�D"�"D5�%D"�&D5�)E�5D9	�9E�<D9	�=E�E�E�?H.�3H�,H�4H�H�H�H�H�H.�H	�H.�H	�H.�.H2�5H2�!L�73K9�*,K"�K9�"K&�&K9�)K&�*K9�-L�9K=	�=L�K=	�L�L�Lc�T�d}t|��D�]�}tj|d|j��5}|�t
|��t
|��}|�d|��ddd��n#1swxYwYtj|d��5}t
|��}t|t��r|�d|z|��n|�d|z|��|�d|��t
|�
|����}|�d|z|��|�d|��|�d	|��|jtjkr,|�d
|��|�d|��|�|��5}t
|��}|�d|z|��|�d|��|jtjkr|�d
|��ddd��n#1swxYwY|�d
t
|����ddd��n#1swxYwY|�d
t
|�������dS)Nz	file.namerKzmode='w'rYzfilename=%rzfile=%rzmode='r'z	filemode=z
file_size=zcompress_type=zcompress_size=zname=%rz[closed])
r(rQrRrIrAr�reprro�
isinstancertrx�
ZIP_STOREDr@)rC�fnamer&rUrYr�s      r'�	test_reprz%AbstractTestsWithSourceFile.test_reprps#�����4���	3�	3�A����C��)9�:�:�
-�e����F�E�*�*�*���K�K���
�
�j�!�,�,�,�
-�
-�
-�
-�
-�
-�
-�
-�
-�
-�
-����
-�
-�
-�
-�
���C�(�(�
9�E���K�K���a��%�%�4��M�M�-�!�"3�Q�7�7�7�7��M�M�)�a�-��3�3�3��
�
�j�!�,�,�,�����u�-�-�.�.���
�
�m�e�3�Q�7�7�7��
�
�k�1�-�-�-��
�
�l�A�.�.�.��#�w�'9�9�7��M�M�"2�A�6�6�6��M�M�"2�A�6�6�6��Z�Z��&�&�;�'��W�
�
�A��M�M�)�e�"3�Q�7�7�7��M�M�*�a�0�0�0��'�7�+=�=�;��
�
�&6��:�:�:�;�;�;�;�;�;�;�;�;�;�;����;�;�;�;��
�
�j�$�w�-�-�8�8�8�)
9�
9�
9�
9�
9�
9�
9�
9�
9�
9�
9����
9�
9�
9�
9�*
�M�M�*�d�5�k�k�2�2�2�2�7	3�	3sJ�AA=�=B	�B	�D+I8�A*H>�2I8�>I�I8�I�&I8�8I<	�?I<	c�d�t|��D]}|�||jd���� dS)N�	r�r�r�s  r'�test_compresslevel_basicz4AbstractTestsWithSourceFile.test_compresslevel_basic�sC���4���	@�	@�A��M�M�!�T�-�Q�M�?�?�?�?�	@�	@r3c��	tjtdd���5}|�td��|�tdd���|�d��}|�d��}|�|jd��|�|jd��ddd��dS#1swxYwYdS)NrKr_r��
compress_1�
compress_9r�)rQrRr rArrxrhr�)rCrU�one_info�	nine_infos    r'�test_per_file_compresslevelz7AbstractTestsWithSourceFile.test_per_file_compresslevel�s���	�
�_�W�c��
;�
;�
;�	:�u��K�K���-�-�-��K�K���A�K�>�>�>��}�}�\�2�2�H��
�
�l�3�3�I����X�4�a�8�8�8����Y�5�q�9�9�9�
	:�	:�	:�	:�	:�	:�	:�	:�	:�	:�	:�	:����	:�	:�	:�	:�	:�	:s�BC�C�Cc����G��fd�dtj��}d�	|��}d�tj|d|j��5}|�dd��5}|�d��ddd��n#1swxYwYd�	|�dd��5}|�d	��ddd��n#1swxYwY	d�ddd��n�#t$r�d
z
�YnwxYw	d�n#d�wxYw	ddd��n#1swxYwYtjtj|�������5}|�	|�
��dg��|�	|�d��d��ddd��n#1swxYwY���tjtj|�������5}|�	|�
��ddg��|�	|�d��d��|�	|�d��d	��ddd��dS#1swxYwYdS)Nc�$���eZdZ���fd�Z�xZS)�CAbstractTestsWithSourceFile.test_writing_errors.<locals>.BrokenFilec�r������krt��dz
�t���|��dS�Nr_)�OSError�superrA)rCr8�	__class__�count�stops  ���r'rAzIAbstractTestsWithSourceFile.test_writing_errors.<locals>.BrokenFile.write�sA�������}�&�%�
��Q�J�E����
�
�d�#�#�#�#�#r3)�__name__�
__module__�__qualname__rA�
__classcell__)r	r
rs@��r'�
BrokenFiler�sC��������
$�
$�
$�
$�
$�
$�
$�
$�
$�
$�
$r3rrTrK�file1sdata1�file2sdata2r_)r#r$rQrRrIr@rArrlrhruri)rCr�testfilerUr&r
rs     @@r'�test_writing_errorsz/AbstractTestsWithSourceFile.test_writing_errors�s�����	$�	$�	$�	$�	$�	$�	$�	$���	$�	$�	$���	@�!�z�|�|�H��E����3��0@�A�A�
!�U��Z�Z���-�-�&���G�G�H�%�%�%�&�&�&�&�&�&�&�&�&�&�&����&�&�&�&���!����G�S�1�1�*�Q�����)�)�)�*�*�*�*�*�*�*�*�*�*�*����*�*�*�*�
� �E�
!�
!�
!�
!�
!�
!�
!�������A�I�D�D�D������!�E�E��D�E�L�L�L�L�E�
!�
!�
!�
!�
!�
!�
!�
!�
!�
!�
!����
!�
!�
!�
!�����H�,=�,=�,?�,?�!@�!@�A�A�
@�U�� � ����!1�!1�G�9�=�=�=�� � ����G�!4�!4�h�?�?�?�
@�
@�
@�
@�
@�
@�
@�
@�
@�
@�
@����
@�
@�
@�
@�!	@�(�_�R�Z��(9�(9�(;�(;�<�<�
=�
=�	<�����U�^�^�-�-���/A�B�B�B����U�Z�Z��0�0�(�;�;�;����U�Z�Z��0�0�(�;�;�;�	<�	<�	<�	<�	<�	<�	<�	<�	<�	<�	<�	<����	<�	<�	<�	<�	<�	<s��D�B�5D�B	�D�B	�	D�C!�%C�;C!�C	�C!�C	�C!�D�!C3�0C:�2C3�3C:�7D�:C>�>D�D�D�AF0�0F4�7F4�5A=I?�?J�Jc�V�tt��tt��dSr�rrr �rCs r'�tearDownz$AbstractTestsWithSourceFile.tearDown�����v�����w�����r3r)$rr
r�classmethodr;rErWr�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�rrrrdr3r'r*r*4s
�������*�*��[�*� � � �
	"�	"�	"�	"�4�4�4�4�l/�/�/�<�<�<�04�4�4�7�7�7�
<�
<�
<�;�;�;�
7�
7�
7�5�5�5�7�7�7� 8�8�8�*�*�*�(=�=�=�
5�5�5�8�8�8�0�0�0�9�9�9�4�4�4�9�9�9�
8�
8�
8�?�?�?�3�3�3� 
:�
:�
:����<3�3�3�>@�@�@�	:�	:�	:�"<�"<�"<�J����r3r*c�t�eZdZejZdZd�Zd�Zd�Z	d�Z
d�Zd�Zd�Z
d	�Zd
�Zd�Zd�Zd
�Zd�Zd�ZdS)�StoredTestsWithSourceFileNc�N�|�||��tj|d��5}|�d��}|�|jd��|�d��}|�|jd��ddd��dS#1swxYwYdS)NrYrM��rN)rWrQrRrxrh�
external_attr)rCr&rIrU�zinfo�zinfo2s      r'�zip_test_writestr_permissionsz7StoredTestsWithSourceFile.zip_test_writestr_permissions�s���
	
���q�+�.�.�.�
�_�Q��
$�
$�	@���M�M�)�,�,�E����U�0�+�>�>�>��]�]�#3�4�4�F����V�1�;�?�?�?�	@�	@�	@�	@�	@�	@�	@�	@�	@�	@�	@�	@����	@�	@�	@�	@�	@�	@s�A!B�B�!Bc�j�t|��D]"}|�|tj���#dSr)r(r"rQr�r�s  r'�test_writestr_permissionsz3StoredTestsWithSourceFile.test_writestr_permissions�sA���4���	F�	F�A��.�.�q�'�2D�E�E�E�E�	F�	Fr3c��tjtdtj��5}|�t
d��ddd��n#1swxYwYtjtdtj��5}|�|���dg��ddd��dS#1swxYwYdS)NrK�	/absoluterY�absolute�rQrRr r�rArrhru�rCrUs  r'�test_absolute_arcnamesz0StoredTestsWithSourceFile.test_absolute_arcnames�s��
�_�W�c�7�+=�
>�
>�	-�%��K�K���,�,�,�	-�	-�	-�	-�	-�	-�	-�	-�	-�	-�	-����	-�	-�	-�	-��_�W�c�7�+=�
>�
>�	=�%����U�^�^�-�-�
�|�<�<�<�	=�	=�	=�	=�	=�	=�	=�	=�	=�	=�	=�	=����	=�	=�	=�	=�	=�	=s#�A�A�A�>*B5�5B9�<B9c���	tjtdtj��5}|�t
t
��ddd��n#1swxYwYtjtdtj��5}|�d|j��|�|�	��t
dg��ddd��dS#1swxYwYdS)NrK�arM)
rQrRr r�rArrSr8rhrur)s  r'�test_append_to_zip_filez1StoredTestsWithSourceFile.test_append_to_zip_file�sJ��4�
�_�W�c�7�+=�
>�
>�	(�%��K�K���'�'�'�	(�	(�	(�	(�	(�	(�	(�	(�	(�	(�	(����	(�	(�	(�	(��_�W�c�7�+=�
>�
>�	D�%��N�N�9�d�i�0�0�0����U�^�^�-�-��	�/B�C�C�C�	D�	D�	D�	D�	D�	D�	D�	D�	D�	D�	D�	D����	D�	D�	D�	D�	D�	Ds$�!A�A�A�AC�C �#C c�f�	d}ttd��5}|�|��ddd��n#1swxYwYtjtdtj��5}|�tt��ddd��n#1swxYwYttd��5}|�t|����tj|d��5}|�	|�
��tg��|�	|�t��|j��ddd��n#1swxYwYddd��n#1swxYwYttd��5}|�	|�t|����|��|���}ddd��n#1swxYwYtj|��5}tj|��5}|�	|�
��tg��|�	|�t��|j��ddd��n#1swxYwYddd��dS#1swxYwYdS)N�I am not a ZipFile!I am not a ZipFile!I am not a ZipFile!I am not a ZipFile!I am not a ZipFile!I am not a ZipFile!I am not a ZipFile!I am not a ZipFile!I am not a ZipFile!I am not a ZipFile!r>r,�rbrY)r@r rArQrRr�r�seekrnrhrurir8r#r$)rCr8r&rUr��bios      r'�test_append_to_non_zip_filez5StoredTestsWithSourceFile.test_append_to_non_zip_file�s���G�)��
�'�4�
 �
 �	�A�
�G�G�D�M�M�M�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	��_�W�c�7�+=�
>�
>�	(�%��K�K���'�'�'�	(�	(�	(�	(�	(�	(�	(�	(�	(�	(�	(����	(�	(�	(�	(��'�4�
 �
 �	@�A�
�F�F�3�t�9�9�������C�(�(�
@�E�� � ����!1�!1�F�8�<�<�<�� � ����F�!3�!3�T�Y�?�?�?�
@�
@�
@�
@�
@�
@�
@�
@�
@�
@�
@����
@�
@�
@�
@�	@�	@�	@�	@�	@�	@�	@�	@�	@�	@�	@����	@�	@�	@�	@�
�'�4�
 �
 �	#�A����Q�V�V�C��I�I�.�.��5�5�5��&�&�(�(�K�	#�	#�	#�	#�	#�	#�	#�	#�	#�	#�	#����	#�	#�	#�	#��Z��
$�
$�	<��W�_�S�-A�-A�	<�U����U�^�^�-�-��x�8�8�8����U�Z�Z��/�/���;�;�;�	<�	<�	<�	<�	<�	<�	<�	<�	<�	<�	<����	<�	<�	<�	<�	<�	<�	<�	<�	<�	<�	<�	<�	<�	<�	<�	<����	<�	<�	<�	<�	<�	<s��;�?�?�+!B�B�B�88E5�0A"E�E5�E"	�"E5�%E"	�&E5�5E9�<E9�AG,�,G0�3G0�J&� A"J�J&�J	�J&�J	�J&�&J*�-J*c��tj��5}tj|dtj��5}|�tt��ddd��n#1swxYwY|���}ddd��n#1swxYwYd}ttd��5}|�|��|�|��ddd��n#1swxYwYtjt��5}|�
|���tg��|�
|�t��|j
��ddd��dS#1swxYwYdS)NrKr/r>)r#r$rQrRr�rArrlr@r rhrurir8�rCr2rUr�r8r&s      r'�test_read_concatenated_zip_filez9StoredTestsWithSourceFile.test_read_concatenated_zip_files-��
�Z�\�\�	)�S����c�7�+=�>�>�
,�%����F�F�+�+�+�
,�
,�
,�
,�
,�
,�
,�
,�
,�
,�
,����
,�
,�
,�
,��,�,�.�.�K�	)�	)�	)�	)�	)�	)�	)�	)�	)�	)�	)����	)�	)�	)�	)�)��
�'�4�
 �
 �	!�A�
�G�G�D�M�M�M�
�G�G�K� � � �	!�	!�	!�	!�	!�	!�	!�	!�	!�	!�	!����	!�	!�	!�	!��_�W�
%�
%�	<�����U�^�^�-�-��x�8�8�8����U�Z�Z��/�/���;�;�;�	<�	<�	<�	<�	<�	<�	<�	<�	<�	<�	<�	<����	<�	<�	<�	<�	<�	<sY�!B
�!A"�B
�"A&	�&B
�)A&	�*B
�
B�B�/+C&�&C*�-C*�
A"E9�9E=�E=c��tj��5}tj|dtj��5}|�tt��ddd��n#1swxYwY|���}ddd��n#1swxYwYddz}ttd��5}|�|��|�|��ddd��n#1swxYwYtjtd��5}|�
|���tg��|�d|j
��ddd��n#1swxYwYttd��5}|�
|�t|����|��|���}ddd��n#1swxYwYtj|��5}tj|��5}|�
|���tdg��|�
|�t��|j
��|�
|�d��|j
��ddd��n#1swxYwYddd��dS#1swxYwYdS)NrKsI am not a ZipFile!i@Br>r,rMr0)r#r$rQrRr�rArrlr@r rhrurSr8rirnr5s      r'�$test_append_to_concatenated_zip_filez>StoredTestsWithSourceFile.test_append_to_concatenated_zip_files���
�Z�\�\�	)�S����c�7�+=�>�>�
,�%����F�F�+�+�+�
,�
,�
,�
,�
,�
,�
,�
,�
,�
,�
,����
,�
,�
,�
,��,�,�.�.�K�	)�	)�	)�	)�	)�	)�	)�	)�	)�	)�	)����	)�	)�	)�	)�&�g�-��
�'�4�
 �
 �	!�A�
�G�G�D�M�M�M�
�G�G�K� � � �	!�	!�	!�	!�	!�	!�	!�	!�	!�	!�	!����	!�	!�	!�	!��_�W�c�
*�
*�	1�e����U�^�^�-�-��x�8�8�8��N�N�9�d�i�0�0�0�	1�	1�	1�	1�	1�	1�	1�	1�	1�	1�	1����	1�	1�	1�	1��'�4�
 �
 �	#�A����Q�V�V�C��I�I�.�.��5�5�5��&�&�(�(�K�	#�	#�	#�	#�	#�	#�	#�	#�	#�	#�	#����	#�	#�	#�	#��Z��
$�
$�	?��W�_�S�-A�-A�	?�U����U�^�^�-�-��	�/B�C�C�C����U�Z�Z��/�/���;�;�;����U�Z�Z�	�2�2�D�I�>�>�>�	?�	?�	?�	?�	?�	?�	?�	?�	?�	?�	?����	?�	?�	?�	?�	?�	?�	?�	?�	?�	?�	?�	?�	?�	?�	?�	?����	?�	?�	?�	?�	?�	?s��!B
�!A"�B
�"A&	�&B
�)A&	�*B
�
B�B�2+C)�)C-�0C-�A
E$�$E(�+E(�AG�G�"G�:K�BJ,� K�,J0	�0K�3J0	�4K�K�Kc���tjtdtj��5}|�t
t
��ddd��n#1swxYwYt
tdd���5}|�d��ddd��n#1swxYwYtjtd��5}|�|tj��ddd��dS#1swxYwYdS)NrKr,�utf-8��encodingz
rY)rQrRr r�rArr@r��rCrUr&s   r'�test_ignores_newline_at_endz5StoredTestsWithSourceFile.test_ignores_newline_at_end)s���
�_�W�c�7�+=�
>�
>�	(�%��K�K���'�'�'�	(�	(�	(�	(�	(�	(�	(�	(�	(�	(�	(����	(�	(�	(�	(�
�'�3��
1�
1�
1�	%�Q�
�G�G�O�$�$�$�	%�	%�	%�	%�	%�	%�	%�	%�	%�	%�	%����	%�	%�	%�	%�
�_�W�c�
*�
*�	:�e��!�!�%���9�9�9�	:�	:�	:�	:�	:�	:�	:�	:�	:�	:�	:�	:����	:�	:�	:�	:�	:�	:s5�!A�A�A�5B�B�B�<!C*�*C.�1C.c�2�tjtdtj��5}d|_|�tt��ddd��n#1swxYwYttdd���5}|�d��ddd��n#1swxYwYtjtd��5}|�|tj��|�	|jd��ddd��dS#1swxYwYdS)NrK�this is a commentr,r:r;zabcdef
rY)
rQrRr r��commentrArr@r�rhr=s   r'�)test_ignores_stuff_appended_past_commentszCStoredTestsWithSourceFile.test_ignores_stuff_appended_past_comments1s���
�_�W�c�7�+=�
>�
>�	(�%�0�E�M��K�K���'�'�'�	(�	(�	(�	(�	(�	(�	(�	(�	(�	(�	(����	(�	(�	(�	(��'�3��
1�
1�
1�	"�Q�
�G�G�L�!�!�!�	"�	"�	"�	"�	"�	"�	"�	"�	"�	"�	"����	"�	"�	"�	"�
�_�W�c�
*�
*�	B�e��!�!�%���9�9�9����U�]�,@�A�A�A�	B�	B�	B�	B�	B�	B�	B�	B�	B�	B�	B�	B����	B�	B�	B�	B�	B�	Bs5�(A�A�!A�<B�B"�%B"�<D�D�Dc�|�	tjtd��5}|�t��ttd��5}|�|�t��|�����ddd��n#1swxYwYddd��dS#1swxYwYdS)NrKr0)rQrRr rArr@rhrir=s   r'�test_write_default_namez1StoredTestsWithSourceFile.test_write_default_name;s��	)�
�_�W�c�
*�
*�	?�e��K�K������f�d�#�#�
?�q�� � ����F�!3�!3�Q�V�V�X�X�>�>�>�
?�
?�
?�
?�
?�
?�
?�
?�
?�
?�
?����
?�
?�
?�
?�	?�	?�	?�	?�	?�	?�	?�	?�	?�	?�	?�	?����	?�	?�	?�	?�	?�	?s6�0B1�AB�
B1�B	�B1� B	�!B1�1B5�8B5c���d}tjtd���5}|�|d��ddd��n#1swxYwYtjtd���5}|�|��5}|���|�t|j��|�t|j	d��|�t|j
��|�t|j��|�t|j��ddd��n#1swxYwYddd��dS#1swxYwYdS)N�somefile.txtrKrO�bogusrYr)
rQrRr rSr@�closer��
ValueErrorrir1r��readable�seekable)rCr�rU�fids    r'�test_io_on_closed_zipextfilez6StoredTestsWithSourceFile.test_io_on_closed_zipextfileCs�����
�_�W�3�
/�
/�
/�	+�5��N�N�5�'�*�*�*�	+�	+�	+�	+�	+�	+�	+�	+�	+�	+�	+����	+�	+�	+�	+��_�W�3�
/�
/�
/�	<�5����E�"�"�
<�c��	�	�����!�!�*�c�h�7�7�7��!�!�*�c�h��:�:�:��!�!�*�c�h�7�7�7��!�!�*�c�l�;�;�;��!�!�*�c�l�;�;�;�

<�
<�
<�
<�
<�
<�
<�
<�
<�
<�
<����
<�
<�
<�
<�	<�	<�	<�	<�	<�	<�	<�	<�	<�	<�	<�	<����	<�	<�	<�	<�	<�	<sH�A�A�A�'E�=B6D?�3E�?E	�E�E	�E�E�Ec�P�	tjtd���5}|�dd��ddd��n#1swxYwYtjtd���5}|�t
|jt��ddd��n#1swxYwYtjtd���5}|�t
��5|�td���ddd��n#1swxYwYddd��dS#1swxYwYdS)NrKrOrFrGrY)	rQrRr rSr�rIrArr@r)s  r'�test_write_to_readonlyz0StoredTestsWithSourceFile.test_write_to_readonlyQs���	 �
�_�W�3�
/�
/�
/�	4�5��N�N�>�7�3�3�3�	4�	4�	4�	4�	4�	4�	4�	4�	4�	4�	4����	4�	4�	4�	4��_�W�3�
/�
/�
/�	?�5����j�%�+�v�>�>�>�	?�	?�	?�	?�	?�	?�	?�	?�	?�	?�	?����	?�	?�	?�	?��_�W�3�
/�
/�
/�	-�5��"�"�:�.�.�
-�
-��
�
�6��
�,�,�,�
-�
-�
-�
-�
-�
-�
-�
-�
-�
-�
-����
-�
-�
-�
-�	-�	-�	-�	-�	-�	-�	-�	-�	-�	-�	-�	-����	-�	-�	-�	-�	-�	-sY�A�A�A�&'B�B� B�?D�D�7D�D	�D�
D	�D�D�"Dc���tjtd��tjt
d��5}|�t|jt��ddd��n#1swxYwYtjt
dd���5}|�t��|�	t��}|�
|jd��ddd��dS#1swxYwYdS)N)rrrKF��strict_timestamps�i�r_r_rrr)�os�utimerrQrRr r�rIrArxrh�	date_time)rCrUr s   r'�test_add_file_before_1980z3StoredTestsWithSourceFile.test_add_file_before_1980^s[��
���� � � �
�_�W�c�
*�
*�	?�e����j�%�+�v�>�>�>�	?�	?�	?�	?�	?�	?�	?�	?�	?�	?�	?����	?�	?�	?�	?��_�W�c�U�
C�
C�
C�	E�u��K�K������M�M�&�)�)�E����U�_�.C�D�D�D�	E�	E�	E�	E�	E�	E�	E�	E�	E�	E�	E�	E����	E�	E�	E�	E�	E�	Es$�'A(�(A,�/A,�AC,�,C0�3C0c�H�d}	tj|��n)#t$r|�d|�d���YnwxYw	t	jt||f��n%#t$r|�d��YnwxYwt	jt��j}|dkr|�d|����tj
td��5}|�tj|jt��ddd��n#1swxYwYtj
tdd�	��5}|�t��|�t��}|�|jd
��ddd��dS#1swxYwYdS)Nl�&�
ztime.localtime(z) raises OverflowErrorz/Host fs cannot set timestamp to required value.l�b� �fz,Linux VFS/XFS kernel bug detected: mtime_ns=rKFrQ)i;����;r\)rr�	localtime�
OverflowError�skipTestrTrUr�stat�st_mtime_nsrQrRr r��struct�errorrArxrhrV)rC�ts�mtime_nsrUr s     r'�test_add_file_after_2107z2StoredTestsWithSourceFile.test_add_file_after_2107isQ��
��	H��N�2�������	H�	H�	H��M�M�F�B�F�F�F�G�G�G�G�G�	H����	M��H�V�b�"�X�&�&�&�&���	M�	M�	M��M�M�K�L�L�L�L�L�	M�����7�6�?�?�.���*�+�		M�
�M�M�K��K�K�L�L�L�
�_�W�c�
*�
*�	A�e����f�l�E�K��@�@�@�	A�	A�	A�	A�	A�	A�	A�	A�	A�	A�	A����	A�	A�	A�	A��_�W�c�U�
C�
C�
C�	J�u��K�K������M�M�&�)�)�E����U�_�.H�I�I�I�	J�	J�	J�	J�	J�	J�	J�	J�	J�	J�	J�	J����	J�	J�	J�	J�	J�	JsC��#?�?�A � B�B�,D�D�D�:AF�F�F)rr
rrQr�rIr�r"r$r*r-r3r6r8r>rBrDrMrOrWrfrdr3r'rr�s�������$�K���@�@�@�F�F�F�=�=�=�D�D�D�<�<�<�.<�<�<�?�?�?�,:�:�:�B�B�B�?�?�?�<�<�<�-�-�-�	E�	E�	E�J�J�J�J�Jr3rc�"�eZdZejZd�ZdS)�DeflateTestsWithSourceFilec���	tjtd��5}|�tdtj��|�tdtj��|�d��}|�d��}|�|j	tj��|�|j	tj��ddd��dS#1swxYwYdS)NrK�storeme�	deflateme)
rQrRr rArr��ZIP_DEFLATEDrxrhr�)rCrU�sinfo�dinfos    r'�test_per_file_compressionz4DeflateTestsWithSourceFile.test_per_file_compression�s��	 �
�_�W�c�
*�
*�	H�e��K�K��	�7�+=�>�>�>��K�K���W�-A�B�B�B��M�M�)�,�,�E��M�M�+�.�.�E����U�0�'�2D�E�E�E����U�0�'�2F�G�G�G�
	H�	H�	H�	H�	H�	H�	H�	H�	H�	H�	H�	H����	H�	H�	H�	H�	H�	Hs�CC*�*C.�1C.N)rr
rrQrlrIrordr3r'rhrh�s2�������&�K�	H�	H�	H�	H�	Hr3rhc��eZdZejZdS)�Bzip2TestsWithSourceFileN�rr
rrQ�	ZIP_BZIP2rIrdr3r'rqrq���������#�K�K�Kr3rqc��eZdZejZdS)�LzmaTestsWithSourceFileN�rr
rrQ�ZIP_LZMArIrdr3r'rvrv���������"�K�K�Kr3rvc�H�eZdZed���Zd�Zd�Zd�Zd�Zd�Z	d�Z
dS)	�AbstractTestZip64InSmallFilesc�x�d�tdt��D��}d�|��|_dS)Nc3�<K�|]}td|zd��V��dS)zTest of zipfile line %d.r-N)r.r/s  r'�	<genexpr>z;AbstractTestZip64InSmallFiles.setUpClass.<locals>.<genexpr>�sF����7�7���4�q�8�'�B�B�7�7�7�7�7�7r3r�
)r4r5r7r8)r:r6s  r'r;z(AbstractTestZip64InSmallFiles.setUpClass�sA��7�7�"�1�n�5�5�7�7�7���:�:�h�'�'����r3c�
�tj|_tj|_dt_dt_ttd��5}|�|j��ddd��dS#1swxYwYdS)Nrr�r>)	rQ�ZIP64_LIMIT�_limit�ZIP_FILECOUNT_LIMIT�_filecount_limitr@rrAr8rBs  r'rEz#AbstractTestZip64InSmallFiles.setUp�s����)��� '� ;���"���&'��#��&�$�
�
�	 �2��H�H�T�Y����	 �	 �	 �	 �	 �	 �	 �	 �	 �	 �	 �	 ����	 �	 �	 �	 �	 �	 s�A8�8A<�?A<c	�	�tj|d|d���5}|�td��|�tt��|�d|j��ddd��n#1swxYwYtj|d|��5}|�|�t��|j��|�|�d��|j��|�|�d��|j��tj	��}|�
|��|���}|���}|�t|��d��|�d|d	��|�d
|d	��|�d|d	��|d���\}}}	}
|�|d��|�t#j|d
����|�t#j|	d����|�|
t't|j������|���}|�t|��d��|�t|��|�d|��|�d|��|���}d�|D��}|�t|��d��|�t|��|�d|��|�d|��|D]/}
|�|
jt|j�����0tddfD]_}|�|��}|�|j|��|�|jt|j�����`|���ddd��dS#1swxYwYdS)NrKT��
allowZip64rLrMrYrbr\rr]r^r_r`ra�c��g|]	}|j��
Srdrer/s  r'r2z:AbstractTestZip64InSmallFiles.zip_test.<locals>.<listcomp>�rgr3)rQrRrArrSr8rhrir#rjrkrlrmrnrorprqrrrsrtrurvrwrxrfry)rCr&rIrUrDrzr{r|r}r~rr�r�r1r�r�s                r'r�z&AbstractTestZip64InSmallFiles.zip_test�sP��
�_�Q��[�T�
B�
B�
B�	1�e��K�K���/�/�/��K�K���'�'�'��N�N�9�d�i�0�0�0�	1�	1�	1�	1�	1�	1�	1�	1�	1�	1�	1����	1�	1�	1�	1��_�Q��[�
1�
1�/	�U����U�Z�Z��/�/���;�;�;����U�Z�Z��7�7���C�C�C����U�Z�Z�	�2�2�D�I�>�>�>�����B��N�N�2�������
�
�I��(�(�*�*�E����S��Z�Z��+�+�+��M�M�+�u�Q�x�0�0�0��M�M�*�e�A�h�/�/�/��M�M�&�%��(�+�+�+�$)�!�H�N�N�$4�$4�!�B��e�T����R��0�0�0��O�O�D�M�$�
�;�;�<�<�<��O�O�D�M�%��<�<�=�=�=����T�3�s�4�9�~�~�#6�#6�7�7�7��N�N�$�$�E����S��Z�Z��+�+�+��M�M�&�%�(�(�(��M�M�.�%�0�0�0��M�M�)�U�+�+�+��N�N�$�$�E�/�/��/�/�/�E����S��Z�Z��+�+�+��M�M�&�%�(�(�(��M�M�.�%�0�0�0��M�M�)�U�+�+�+��
>�
>��� � ���c�$�)�n�n�=�=�=�=��~�y�9�
A�
A���}�}�R�(�(��� � ����3�3�3�� � ����T�Y���@�@�@�@�
�M�M�O�O�O�_/	�/	�/	�/	�/	�/	�/	�/	�/	�/	�/	�/	����/	�/	�/	�/	�/	�/	s%�AA<�<B�B�O	Q3�3Q7�:Q7c�`�t|��D]}|�||j���dSrr�r�s  r'r�z(AbstractTestZip64InSmallFiles.test_basic�r�r3c���tjtd|jd���}d|_d}t|��D]$}|�d|zd|dzd	zz���%|�t|�	����|��|�
��tjtd
|j��}|�t|�	����|��t|��D]L}|�d|z���d��}|�|d|dzd	zz���M|�
��dS)NrKTr�r���foo%08d�%dr��9rYr-)
rQrRrrI�debugr4rSrhrnrurHri�decode)rCr��numfilesr1�zipf2�contents      r'�test_too_many_filesz1AbstractTestZip64InSmallFiles.test_too_many_files�sO����v�s�D�,<�*.�0�0�0����
����x���	=�	=�A��M�M�)�a�-���A����);�<�<�<�<�����T�]�]�_�_�-�-�x�8�8�8��
�
��������T�-=�>�>������U�^�^�-�-�.�.��9�9�9��x���	:�	:�A��j�j��Q��/�/�6�6�w�?�?�G����W�d�a��d�R�i�&8�9�9�9�9�
���
�
�
�
�
r3c��tjtd|jd���}d|_d}t|��D]$}|�d|zd|dzd	zz���%|�t|�	����|��|�
tj��5|�d|zd
��ddd��n#1swxYwY|�t|�	����|��|���tjtd|jd���}d|_|�t|�	����|��|�
tj��5|�d|zd
��ddd��n#1swxYwY|�t|�	����|��|���tjtd|jd���}d|_|�t|�	����|��d
}t||��D]$}|�d|zd|dzd	zz���%|�t|�	����|��|���tjtd|j��}|�t|�	����|��t|��D]L}|�
d|z���d��}|�|d|dzd	zz���M|���dS)NrKFr�r�r�r�r�r�r�r3r,Tr�rYr-)rQrRrrIr�r4rSrhrnrur��LargeZipFilerHrir�)rCr�r�r1�	numfiles2r�r�s       r'�test_too_many_files_appendz8AbstractTestZip64InSmallFiles.test_too_many_files_append	s�����v�s�D�,<�*/�1�1�1����
����x���	=�	=�A��M�M�)�a�-���A����);�<�<�<�<�����T�]�]�_�_�-�-�x�8�8�8�
�
�
�w�3�
4�
4�	5�	5��M�M�)�h�.��4�4�4�	5�	5�	5�	5�	5�	5�	5�	5�	5�	5�	5����	5�	5�	5�	5�����T�]�]�_�_�-�-�x�8�8�8��
�
������v�s�D�,<�*/�1�1�1����
�����T�]�]�_�_�-�-�x�8�8�8�
�
�
�w�3�
4�
4�	5�	5��M�M�)�h�.��4�4�4�	5�	5�	5�	5�	5�	5�	5�	5�	5�	5�	5����	5�	5�	5�	5�����T�]�]�_�_�-�-�x�8�8�8��
�
������v�s�D�,<�*.�0�0�0����
�����T�]�]�_�_�-�-�x�8�8�8��	��x��+�+�	=�	=�A��M�M�)�a�-���A����);�<�<�<�<�����T�]�]�_�_�-�-�y�9�9�9��
�
��������T�-=�>�>������U�^�^�-�-�.�.�	�:�:�:��y�!�!�	:�	:�A��j�j��Q��/�/�6�6�w�?�?�G����W�d�a��d�R�i�&8�9�9�9�9�
���
�
�
�
�
s$�4C�C�!C�+G�G�Gc��|jt_|jt_tt��tt��dSr)r�rQr�r�r�rrr rs r'rz&AbstractTestZip64InSmallFiles.tearDown0s1��"�k���&*�&;��#��v�����w�����r3N)rr
rrr;rEr�r�r�r�rrdr3r'r{r{�s��������(�(��[�(�
 � � �7�7�7�r/�/�/����&%�%�%�N����r3r{c�T�eZdZejZd�Zd�Zd�Zd�Z	d�Z
			dd�Zd�Zd	�Z
d
S)�StoredTestZip64InSmallFilesc��tj|d|d���5}|�tj|jt
d��ddd��dS#1swxYwYdS�NrKFr�rL)rQrRr�r�rAr�rCr&rIrUs    r'�large_file_exception_testz5StoredTestZip64InSmallFiles.large_file_exception_test;s���
�_�Q��[�U�
C�
C�
C�	C�u����g�2�#�k�6�>�
C�
C�
C�	C�	C�	C�	C�	C�	C�	C�	C�	C�	C�	C�	C����	C�	C�	C�	C�	C�	C��-A�A�Ac��tj|d|d���5}|�tj|jd|j��ddd��dS#1swxYwYdSr�)rQrRr�r�rSr8r�s    r'�large_file_exception_test2z6StoredTestZip64InSmallFiles.large_file_exception_test2@s���
�_�Q��[�U�
C�
C�
C�	I�u����g�2�#�n�n�d�i�
I�
I�
I�	I�	I�	I�	I�	I�	I�	I�	I�	I�	I�	I�	I����	I�	I�	I�	I�	I�	Ir�c��t|��D]B}|�|tj��|�|tj���CdSr)r(r�rQr�r�r�s  r'�test_large_file_exceptionz5StoredTestZip64InSmallFiles.test_large_file_exceptionEsZ���4���	C�	C�A��*�*�1�g�.@�A�A�A��+�+�A�w�/A�B�B�B�B�	C�	Cr3c��tjtdtjd���5}|�t
d��ddd��n#1swxYwYtjtdtj��5}|�|���dg��ddd��dS#1swxYwYdS)NrKTr�r&rYr'r(r)s  r'r*z2StoredTestZip64InSmallFiles.test_absolute_arcnamesJs(��
�_�W�c�7�+=�(,�.�.�.�	-�16��K�K���,�,�,�	-�	-�	-�	-�	-�	-�	-�	-�	-�	-�	-����	-�	-�	-�	-��_�W�c�7�+=�
>�
>�	=�%����U�^�^�-�-�
�|�<�<�<�	=�	=�	=�	=�	=�	=�	=�	=�	=�	=�	=�	=����	=�	=�	=�	=�	=�	=s#�A�A�A�*B7�7B;�>B;c��tjtdd���5}|�d|j��ddd��n#1swxYwYtjtdd���5}|�d��}|j}ddd��n#1swxYwYtjtdd���5}|�d|j��ddd��n#1swxYwYtjtdd���5}|�d��}|�|j|��ddd��dS#1swxYwYdS)NrKTr�rMrYr,�strfile2)rQrRr rSr8rx�extrarh)rCrUr r�s    r'�test_appendz'StoredTestZip64InSmallFiles.test_appendRs&���_�W�c�d�
;�
;�
;�	1�u��N�N�9�d�i�0�0�0�	1�	1�	1�	1�	1�	1�	1�	1�	1�	1�	1����	1�	1�	1�	1�
�_�W�c�d�
;�
;�
;�	 �u��M�M�)�,�,�E��K�E�	 �	 �	 �	 �	 �	 �	 �	 �	 �	 �	 ����	 �	 �	 �	 ��_�W�c�d�
;�
;�
;�	2�u��N�N�:�t�y�1�1�1�	2�	2�	2�	2�	2�	2�	2�	2�	2�	2�	2����	2�	2�	2�	2�
�_�W�c�d�
;�
;�
;�	1�u��M�M�)�,�,�E����U�[�%�0�0�0�	1�	1�	1�	1�	1�	1�	1�	1�	1�	1�	1�	1����	1�	1�	1�	1�	1�	1sG�A�A	�A	�,B�B�B�<C$�$C(�+C(�1E	�	E
�E
Fc��	d}d}g}	g}
|}|r.d}|r*|	�|��|
�|��tjd|��}|}|r.d}|r*|	�|��|
�|��tjd|��}|}
|rd}
|r|
�|��tjd|
��}
tjddt|	��zzddt|	��zg|	�R�}tjddt|
��zzddt|
��zg|
�R�}tjdd	dt|
��zz��}tjdd
dt|	��zz��}tjdddt|	��zz��}tjdddt|
��zz��}d
}d}tjdt|����}d|z|z|z|z|z|z|zdz|z|z|z|zdz|
z|z|zdzdzdz|z|zdzdzdzdz}|S)N�r����<Lz<HH�Qr_z<Q�:�2z<Hrbstest.txt�test1234sPK!�%��sPK--!�%��s
�sPK,--ss
sPKlssPK:2s)r�rb�packrn)rC�file_size_64_set�file_size_extra�compress_size_64_set�compress_size_extra�header_offset_64_set�header_offset_extra�actual_size�actual_header_offset�local_zip64_fields�central_zip64_fieldsrw�
compress_size�
header_offset�local_extra�
central_extra�central_dir_size�offset_to_central_dir�local_extra_length�central_extra_lengthrfr��filename_length�zip64_contentss                        r'�make_zip64_filez+StoredTestZip64InSmallFiles.make_zip64_file`sg��
	��� ����!���	��	9�"�I��
9�"�)�)�+�6�6�6�$�+�+�K�8�8�8��K��i�0�0�	�#�
��	9�&�M�"�
9�"�)�)�+�6�6�6�$�+�+�K�8�8�8���D�-�8�8�
�,�
��	B�&�M�"�
B�$�+�+�,@�A�A�A���D�-�8�8�
��k��C��.�/�/�/�/��
�c�$�%�%�%�
� �	
�
�
�����C��0�1�1�1�1��
�c�&�'�'�'�
�"�	
�
�
�
�"�;�t�R�!�c�:N�6O�6O�2O�-O�P�P�� &��D�"�q�3�?Q�;R�;R�7R�2R� S� S��#�[��q�1�s�;M�7N�7N�3N�/N�O�O��%�{�4��Q��=Q�9R�9R�5R�1R�S�S������ �+�d�C��M�M�:�:��
L��
��
��
�!�	
!�
�
��

��
�P�	
P��

��
��
�#�

#�:�
:��
� �!
�"�#
�&?�'
?�(N�)
N�*:�+
:�,�-
�.$�/
$�2M�3
M�4�5
�8N�9
N�:"�;
"�	�B�r3c�	�	|�d���}|�tj��5}tjtj|����ddd��n#1swxYwY|�dt|j	���
����|�ddd���}|�tj��5}tjtj|����ddd��n#1swxYwY|�dt|j	���
����|�d���}|�tj��5}tjtj|����ddd��n#1swxYwY|�dt|j	���
����|�ddddd���}|�tj��5}tjtj|����ddd��n#1swxYwY|�dt|j	���
����|�d	ddd�
��}|�tj��5}tjtj|����ddd��n#1swxYwY|�dt|j	���
����|�ddd	d���}|�tj��5}tjtj|����ddd��n#1swxYwY|�dt|j	���
����|�d	d	d���}|�tj��5}tjtj|����ddd��n#1swxYwY|�dt|j	���
����dS)
NT)r�z	file size)r�r�r�z
compress size)r�)r�r�r�r�r�z
header offsetF)r�r�r�r�)r�r�r�r�)r�r�r�)r�r�rQ�
BadZipFilerRr#r$rort�	exception�lower)rC�missing_file_size_extra�e�missing_compress_size_extra�missing_header_offset_extras     r'�test_bad_zip64_extraz0StoredTestZip64InSmallFiles.test_bad_zip64_extra�sW��	�"#'�"6�"6�!�#7�#
�#
���
�
�w�1�
2�
2�	A�a��O�B�J�'>�?�?�@�@�@�	A�	A�	A�	A�	A�	A�	A�	A�	A�	A�	A����	A�	A�	A�	A��
�
�k�3�q�{�#3�#3�#9�#9�#;�#;�<�<�<�'+�&:�&:�!� �!%�';�'
�'
�#�
�
�
�w�1�
2�
2�	E�a��O�B�J�'B�C�C�D�D�D�	E�	E�	E�	E�	E�	E�	E�	E�	E�	E�	E����	E�	E�	E�	E��
�
�o�s�1�;�'7�'7�'=�'=�'?�'?�@�@�@�'+�&:�&:�!%�';�'
�'
�#��
�
�w�1�
2�
2�	E�a��O�B�J�'B�C�C�D�D�D�	E�	E�	E�	E�	E�	E�	E�	E�	E�	E�	E����	E�	E�	E�	E��
�
�o�s�1�;�'7�'7�'=�'=�'?�'?�@�@�@�
'+�&:�&:�!� �!%� $�!%�';�'
�'
�#��
�
�w�1�
2�
2�	E�a��O�B�J�'B�C�C�D�D�D�	E�	E�	E�	E�	E�	E�	E�	E�	E�	E�	E����	E�	E�	E�	E��
�
�o�s�1�;�'7�'7�'=�'=�'?�'?�@�@�@�'+�&:�&:�"�!%� $�!%�	';�'
�'
�#��
�
�w�1�
2�
2�	E�a��O�B�J�'B�C�C�D�D�D�	E�	E�	E�	E�	E�	E�	E�	E�	E�	E�	E����	E�	E�	E�	E��
�
�o�s�1�;�'7�'7�'=�'=�'?�'?�@�@�@�'+�&:�&:�!� �!&�!%�	';�'
�'
�#��
�
�w�1�
2�
2�	E�a��O�B�J�'B�C�C�D�D�D�	E�	E�	E�	E�	E�	E�	E�	E�	E�	E�	E����	E�	E�	E�	E��
�
�o�s�1�;�'7�'7�'=�'=�'?�'?�@�@�@�'+�&:�&:�"�!&�!%�';�'
�'
�#�
�
�
�w�1�
2�
2�	E�a��O�B�J�'B�C�C�D�D�D�	E�	E�	E�	E�	E�	E�	E�	E�	E�	E�	E����	E�	E�	E�	E��
�
�o�s�1�;�'7�'7�'=�'=�'?�'?�@�@�@�@�@s}�'A*�*A.�1A.�&'D�D� D�'G�G
�
G
�'I7�7I;�>I;�4'L'�'L+�.L+�$'O�O�O�'R�R
�
R
c��d}d}d}d}ddd�ddd�ddd�f}tdt|��dz��D�]}tj||��D]�}i}|D]}	|�|	���tjtj|j	d	i|������5}
|
�
��d}|�|j|��|�|j
|��|�|j|��|�|
�|��|��ddd��n#1swxYwY����dS)
Nr�rr�T)r�r�)r�r�)r�r�r_rd)r4rn�	itertools�combinations�updaterQrRr#r$r�rvrhrwr�r�ri)rC�expected_file_size�expected_compress_size�expected_header_offset�expected_content�paramsrY�comborT�c�zfr s            r'� test_generated_valid_zip64_extraz<StoredTestZip64InSmallFiles.test_generated_valid_zip64_extra!s�����!"��!"��&��
"&�$�?�?�%)�$�G�G�%)�$�G�G�
���q�#�f�+�+��/�*�*�
	G�
	G�A�"�/���:�:�	
G�	
G�����%�%�A��M�M�!�$�$�$�$��_�R�Z�0D��0D�0N�0N�v�0N�0N�%O�%O�P�P�G�TV��K�K�M�M�!�,�E��$�$�U�_�6H�I�I�I��$�$�U�%8�:P�Q�Q�Q��$�$�U�%8�:P�Q�Q�Q��$�$�R�W�W�U�^�^�5E�F�F�F�G�G�G�G�G�G�G�G�G�G�G����G�G�G�G��		
G�
	G�
	Gs�BD?�?E�EN)FFFFFF)rr
rrQr�rIr�r�r�r*r�r�r�r�rdr3r'r�r�7s��������$�K�C�C�C�
I�I�I�
C�C�C�
=�=�=�1�1�1�7<�8=�8=�a�a�a�a�F\A�\A�\A�|G�G�G�G�Gr3r�c��eZdZejZdS)�DeflateTestZip64InSmallFilesN�rr
rrQrlrIrdr3r'r�r�=��������&�K�K�Kr3r�c��eZdZejZdS)�Bzip2TestZip64InSmallFilesNrrrdr3r'r�r�Brtr3r�c��eZdZejZdS)�LzmaTestZip64InSmallFilesNrwrdr3r'r�r�Gryr3r�c�&�eZdZd�Zd�Zd�Zd�ZdS)�AbstractWriterTestsc�.�tt��dSr�rr rs r'rzAbstractWriterTests.tearDownO����w�����r3c���d}tjtd|j��5}|�dd��}|�|��|���|�|j��|���|�|j��|�	|�
d��|��ddd��dS#1swxYwYdS)N�contentrKr%)rQrRr rIr@rArHrqr"rhri�rCr8r�rKs    r'�test_close_after_closez*AbstractWriterTests.test_close_after_closeRs����
�_�W�c�4�+;�
<�
<�	6���	�	�&�#�&�&�A�
�G�G�D�M�M�M�
�G�G�I�I�I��O�O�A�H�%�%�%�
�G�G�I�I�I��O�O�A�H�%�%�%����T�Y�Y�v�.�.��5�5�5�	6�	6�	6�	6�	6�	6�	6�	6�	6�	6�	6�	6����	6�	6�	6�	6�	6�	6s�B1C!�!C%�(C%c���d}tjtd|j��5}|�dd��}|�|��|���|�|j��|�	t|jd��|�|�d��|��ddd��dS#1swxYwYdS)Nr�rKr%r3)
rQrRr rIr@rArHrqr"r�rIrhrir�s    r'�test_write_after_closez*AbstractWriterTests.test_write_after_close]s�����
�_�W�c�4�+;�
<�
<�	6���	�	�&�#�&�&�A�
�G�G�D�M�M�M�
�G�G�I�I�I��O�O�A�H�%�%�%����j�!�'�3�7�7�7����T�Y�Y�v�.�.��5�5�5�
	6�	6�	6�	6�	6�	6�	6�	6�	6�	6�	6�	6����	6�	6�	6�	6�	6�	6s�B$C�C�Cc��tjdgd���}t|��|jz}tjtj��d|j��5}|�dd��5}|�	|�
|��|��ddd��n#1swxYwY|�	|�d��j|��ddd��dS#1swxYwYdS)Nr�)r_r�r�rbr[rKr8)
�arrayrn�itemsizerQrRr#r$rIr@rhrArxrw)rC�q�LENGTHr�r8s     r'�test_issue44439z#AbstractWriterTests.test_issue44439gse���K��_�_�_�-�-���Q���!�*�$��
�_�R�Z�\�\�3��0@�
A�
A�	D�S����&�#�&�&�
8�$�� � ����A����7�7�7�
8�
8�
8�
8�
8�
8�
8�
8�
8�
8�
8����
8�
8�
8�
8����S�[�[��0�0�:�F�C�C�C�	D�	D�	D�	D�	D�	D�	D�	D�	D�	D�	D�	D����	D�	D�	D�	D�	D�	Ds6�C.�2*B(�C.�(B,	�,C.�/B,	�01C.�.C2�5C2N)rr
rrr�r�r�rdr3r'r�r�MsU���������	6�	6�	6�6�6�6�D�D�D�D�Dr3r�c��eZdZejZdS)�StoredWriterTestsN�rr
rrQr�rIrdr3r'r�r�os�������$�K�K�Kr3r�c��eZdZejZdS)�DeflateWriterTestsNr�rdr3r'r�r�rs�������&�K�K�Kr3r�c��eZdZejZdS)�Bzip2WriterTestsNrrrdr3r'r�r�vs�������#�K�K�Kr3r�c��eZdZejZdS)�LzmaWriterTestsNrwrdr3r'rrzs�������"�K�K�Kr3rc�P�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
dS)
�PyZipFileTestsc�J�|dz|vr|�|dz|��dSdS)N�or�)ro)rC�namerus   r'�assertCompiledInzPyZipFileTests.assertCompiledIn�s;���#�:�X�%�	0��M�M�$��*�h�/�/�/�/�/�	0�	0r3c���tj|tjtjtjv���s|�d��tj�|d��}	tj|tjtj	z��}tj
|��n%#t$r|�d��YnwxYwt|��dS)N)�
effective_idsz/requires write access to the installed locationztest_zipfile.try)
rT�access�W_OK�supports_effective_idsr_r�r7r@�O_WRONLY�O_CREATrH�	Exceptionr)rCr�rf�fds    r'�requiresWriteAccessz"PyZipFileTests.requiresWriteAccess�s����y��r�w�')�y�B�4M�'M�O�O�O�	M��M�M�K�L�L�L��7�<�<��&8�9�9��	M����2�;���#;�<�<�B��H�R�L�L�L�L���	M�	M�	M��M�M�K�L�L�L�L�L�	M�����x�����s�.AB/�/C�Cc�x�|�tj�t����t��5}t
j|d��5}t}|�d��r�|�	tj
��}tj�2|�|�	tj����d|vr tj�|��}n
|dd�}|�|��tj�|��}|�||�����|�||�����ddd��n#1swxYwYddd��n#1swxYwYt��5}t
j|d��5}t}|�d��r
|dd�}|�|d��d�dtj�|����}|�||�����|�||�����ddd��n#1swxYwYddd��dS#1swxYwYdS)NrK�.pyc�__pycache__r��testpackage�/)rrTr��dirname�__file__rrQ�	PyZipFile�endswithrp�sep�altsep�extend�	importlib�util�source_from_cache�writepy�basename�assertNotInrur)rC�trUr|�
path_split�bns      r'�test_write_pyfilez PyZipFileTests.test_write_pyfile�s@��� � ������!:�!:�;�;�;�
�_�_�	8��7�#4�Q��#<�#<�	8���B��{�{�6�"�"�
!��X�X�b�f�-�-�
��9�;��%�%�b�h�h�r�y�&9�&9�:�:�:� �J�.�!�"��9�9�"�=�=�B�B��C�R�C��B��M�M�"������!�!�"�%�%�B����R����!1�!1�2�2�2��!�!�"�e�n�n�&6�&6�7�7�7�	8�	8�	8�	8�	8�	8�	8�	8�	8�	8�	8����	8�	8�	8�	8�	8�	8�	8�	8�	8�	8�	8�	8�	8�	8�	8����	8�	8�	8�	8�"�_�_�		8��7�#4�Q��#<�#<�		8���B��{�{�6�"�"�
�����W���M�M�"�m�,�,�,�)�M�M�2�7�+;�+;�B�+?�+?�+?�@�B����R����!1�!1�2�2�2��!�!�"�e�n�n�&6�&6�7�7�7�		8�		8�		8�		8�		8�		8�		8�		8�		8�		8�		8����		8�		8�		8�		8�		8�		8�		8�		8�		8�		8�		8�		8�		8�		8�		8�		8����		8�		8�		8�		8�		8�		8sn�F+�D,F�F+�F	�F+�F	�F+�+F/�2F/�J/�B1J�J/�J	�J/�J	�J/�/J3�6J3c���ddl}tj�|j��}|�|��t
��5}tj|d��5}|�	|��|�
��}|�d|��|�d|��ddd��n#1swxYwYddd��dS#1swxYwYdS)NrrKzemail/__init__.pyzemail/mime/text.py)�emailrTr�rrrrrQrr rur)rCr(�
packagedirr#rUr�s      r'�test_write_python_packagez(PyZipFileTests.test_write_python_package�sT�������W�_�_�U�^�4�4�
�� � ��,�,�,�
�_�_�	?��7�#4�Q��#<�#<�	?���M�M�*�%�%�%��N�N�$�$�E��!�!�"5�u�=�=�=��!�!�"6��>�>�>�	?�	?�	?�	?�	?�	?�	?�	?�	?�	?�	?����	?�	?�	?�	?�	?�	?�	?�	?�	?�	?�	?�	?�	?�	?�	?�	?����	?�	?�	?�	?�	?�	?s7�C�"AC�8C�C	�C�C	�C�C �#C c	�"�ddl}tj�|j��}|�|��t
��5}tj|d��5}t��5}|�
|��ddd��n#1swxYwY|���}|�d|v��t��5}|�
|d����ddd��n#1swxYwY|���}|�d|v��d�}t��5}|�
t��5|�
||���ddd��n#1swxYwYddd��n#1swxYwY|���}|rt|��|�d|v��ddd��n#1swxYwYddd��dS#1swxYwYdS)NrrK�SyntaxErrorc��dS)NFrd)�whatevers r'�<lambda>zCPyZipFileTests.test_write_filtered_python_package.<locals>.<lambda>�s��e�r3��
filterfuncc�h�tj�|���d��S)N�bad)rTr�r!�
startswith)r�s r'�filterzAPyZipFileTests.test_write_filtered_python_package.<locals>.filter�s)���7�+�+�D�1�1�<�<�U�C�C�C�Cr3)r%rTr�rrrrrQrrr rlrq�assertWarns�UserWarning�print)rCr%r)r#rU�	reportSIO�	reportStrr5s        r'�"test_write_filtered_python_packagez1PyZipFileTests.test_write_filtered_python_package�s{�������W�_�_�T�]�3�3�
�� � ��,�,�,�
�_�_�	<��7�#4�Q��#<�#<�	<��!�"�"�
*�i��
�
�j�)�)�)�
*�
*�
*�
*�
*�
*�
*�
*�
*�
*�
*����
*�
*�
*�
*�!�*�*�,�,�I��O�O�M�Y�6�7�7�7�!�"�"�
M�i��
�
�j�5K�5K�
�L�L�L�
M�
M�
M�
M�
M�
M�
M�
M�
M�
M�
M����
M�
M�
M�
M�!�*�*�,�,�I��O�O�M��:�;�;�;�
D�
D�
D� �"�"�
=�i��1A�1A�+�1N�1N�
=�
=��
�
�j�V�
�<�<�<�
=�
=�
=�
=�
=�
=�
=�
=�
=�
=�
=����
=�
=�
=�
=�
=�
=�
=�
=�
=�
=�
=�
=�
=�
=�
=����
=�
=�
=�
=�!�*�*�,�,�I��
!��i� � � ��O�O�M��:�;�;�;�/	<�	<�	<�	<�	<�	<�	<�	<�	<�	<�	<����	<�	<�	<�	<�	<�	<�	<�	<�	<�	<�	<�	<�	<�	<�	<�	<����	<�	<�	<�	<�	<�	<s��H�"G,�1B�G,�B�G,�B�<G,�C<�0G,�<D�G,�D�?G,�F�F	�6F�F
�F�	F
�
F�
G,�F�G,� F�!?G,� H�,G0	�0H�3G0	�4H�H�Hc���ddl}tj�|j��}|�|��d}d}t
��5}tj|d|���5}|�	|��|�
��}|�d|z|��|�d|z|��ddd��n#1swxYwYddd��dS#1swxYwYdS)	NrFr_rrK)�optimizezemail/__init__zemail/mime/text)r(rTr�rrrrrQrr ruro)rCr(r)�optlevel�extr#rUr�s        r'�test_write_with_optimizationz+PyZipFileTests.test_write_with_optimization�si�������W�_�_�U�^�4�4�
�� � ��,�,�,�'(����
�_�_�	:��
�
�q�#��
9�
9�
9�	:�=B��M�M�*�%�%�%��N�N�$�$�E��M�M�*�S�0�%�8�8�8��M�M�+�c�1�5�9�9�9�
	:�	:�	:�	:�	:�	:�	:�	:�	:�	:�	:����	:�	:�	:�	:�	:�	:�	:�	:�	:�	:�	:�	:�	:�	:�	:�	:����	:�	:�	:�	:�	:�	:s7�C(�(AC�C(�C	�C(�C	�C(�(C,�/C,c�f�tjt��	ttj�td��dd���5}|�d��ddd��n#1swxYwYttj�td��dd���5}|�d��ddd��n#1swxYwYttj�td��dd���5}|�d	��ddd��n#1swxYwYt��5}tj	|d��5}|�
t��|���}|�d|��|�d|��|�
d|��ddd��n#1swxYwYddd��n#1swxYwYtt��dS#tt��wxYw)
N�mod1.pyrKr:r;�
print(42)
�mod2.py�print(42 * 42)
zmod2.txtzbla bla bla
�rT�mkdirr r@r�r7rArrQrr rurr"r�rCrDr#rUr�s     r'�test_write_python_directoryz*PyZipFileTests.test_write_python_directory�s��
������	��b�g�l�l�7�I�6�6��g�N�N�N�
(�RT�����'�'�'�
(�
(�
(�
(�
(�
(�
(�
(�
(�
(�
(����
(�
(�
(�
(��b�g�l�l�7�I�6�6��g�N�N�N�
-�RT����+�,�,�,�
-�
-�
-�
-�
-�
-�
-�
-�
-�
-�
-����
-�
-�
-�
-��b�g�l�l�7�J�7�7��w�O�O�O�
*�SU�����)�)�)�
*�
*�
*�
*�
*�
*�
*�
*�
*�
*�
*����
*�
*�
*�
*����
4�A�w�'8��C�'@�'@�
4�E��
�
�g�&�&�&����(�(���%�%�i��7�7�7��%�%�i��7�7�7�� � ��U�3�3�3�

4�
4�
4�
4�
4�
4�
4�
4�
4�
4�
4����
4�
4�
4�
4�
4�
4�
4�
4�
4�
4�
4�
4�
4�
4�
4����
4�
4�
4�
4�
�7�O�O�O�O�O��F�7�O�O�O�O���s��5H�A2�&H�2A6�6H�9A6�:8H�2C�H�C�H�C�8H�D6�*H�6D:�:H�=D:�>H�G9�%A1G"�G9�"G&	�&G9�)G&	�*G9�-H�9G=�=H�G=�H�H0c�|�tjt��	ttj�td��dd���5}|�d��ddd��n#1swxYwYttj�td��dd���5}|�d��ddd��n#1swxYwYt��5}tj	|d��5}|�
td��	��|���}|�d|��|�
d|��ddd��n#1swxYwYddd��n#1swxYwYtt��dS#tt��wxYw)
NrBrKr:r;rCrDrEc�.�|�d��S)NrD)r)r|s r'r/zEPyZipFileTests.test_write_python_directory_filtered.<locals>.<lambda>s��68�k�k�)�6L�6L�2L�r3r0rFrHs     r'�$test_write_python_directory_filteredz3PyZipFileTests.test_write_python_directory_filteredsw��
������	��b�g�l�l�7�I�6�6��g�N�N�N�
(�RT�����'�'�'�
(�
(�
(�
(�
(�
(�
(�
(�
(�
(�
(����
(�
(�
(�
(��b�g�l�l�7�I�6�6��g�N�N�N�
-�RT����+�,�,�,�
-�
-�
-�
-�
-�
-�
-�
-�
-�
-�
-����
-�
-�
-�
-����
3�A�w�'8��C�'@�'@�
3�E��
�
�g�3M�3M�
�N�N�N����(�(���%�%�i��7�7�7�� � ��E�2�2�2�

3�
3�
3�
3�
3�
3�
3�
3�
3�
3�
3����
3�
3�
3�
3�
3�
3�
3�
3�
3�
3�
3�
3�
3�
3�
3����
3�
3�
3�
3�
�7�O�O�O�O�O��F�7�O�O�O�O���s��5F%�A2�&F%�2A6�6F%�9A6�:8F%�2C�F%�C�F%�C�F%�-F�AE-�!F�-E1	�1F�4E1	�5F�8F%�F�F%�F�F%�%F;c��t��5}tj|d��5}ttdd���5}|�d��ddd��n#1swxYwY|�t|jt��tt��ddd��n#1swxYwYddd��dS#1swxYwYdS)NrKr:r;z!most definitely not a python file)
rrQrr@rrAr��RuntimeErrorr r)rCr#rUr&s    r'�test_write_non_pyfilez$PyZipFileTests.test_write_non_pyfilesp��
�_�_�	��7�#4�Q��#<�#<�	���f�c�G�4�4�4�
=�����;�<�<�<�
=�
=�
=�
=�
=�
=�
=�
=�
=�
=�
=����
=�
=�
=�
=����l�E�M�6�B�B�B��6�N�N�N�		�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	�	sW�C�B0�A�B0�A#�#B0�&A#�'=B0�$C�0B4	�4C�7B4	�8C�C�Cc	��tjt��	ttj�td��dd���5}|�d��ddd��n#1swxYwYt��5}tj	|d��5}t��5}|�tj�td����ddd��n#1swxYwY|�d|�
����|���}|�d|��|�d|��ddd��n#1swxYwYddd��n#1swxYwYt!t��dS#t!t��wxYw)NrBrKr:r;zBad syntax in python file
r,zmod1.pyc)rTrGr r@r�r7rArrQrrr rorlrur"r)rCrDr#rU�sr�s      r'�test_write_pyfile_bad_syntaxz+PyZipFileTests.test_write_pyfile_bad_syntaxsn��
������	��b�g�l�l�7�I�6�6��g�N�N�N�
8�RT����6�7�7�7�
8�
8�
8�
8�
8�
8�
8�
8�
8�
8�
8����
8�
8�
8�
8����
4�A�w�'8��C�'@�'@�
4�E�$�&�&�D�!��M�M�"�'�,�,�w�	�"B�"B�C�C�C�D�D�D�D�D�D�D�D�D�D�D����D�D�D�D��
�
�m�Q�Z�Z�\�\�:�:�:����(�(���
�
�i��/�/�/�� � ��U�3�3�3�
4�
4�
4�
4�
4�
4�
4�
4�
4�
4�
4����
4�
4�
4�
4�
4�
4�
4�
4�
4�
4�
4�
4�
4�
4�
4����
4�
4�
4�
4�
�7�O�O�O�O�O��F�7�O�O�O�O���s��5F,�A2�&F,�2A6�6F,�9A6�:F,�F�!E4�09C5�)E4�5C9�9E4�<C9�=A+E4�(F�4E8	�8F�;E8	�<F�?F,�F�F,�F�F,�,Gc��tjt��	ttj�td��dd���5}|�d��ddd��n#1swxYwYt��5}tj	|d��5}|�
tjt��dz��|�
��}|�d|��ddd��n#1swxYwYddd��n#1swxYwYtt��dS#tt��wxYw)NrBrKr:r;rC)rTrGr r@r�r7rArrQrr r�r�rurrrHs     r'�test_write_pathlikez"PyZipFileTests.test_write_pathlike2s���
������		��b�g�l�l�7�I�6�6��g�N�N�N�
(�RT�����'�'�'�
(�
(�
(�
(�
(�
(�
(�
(�
(�
(�
(����
(�
(�
(�
(����
8�A�w�'8��C�'@�'@�
8�E��
�
�g�l�7�3�3�i�?�@�@�@����(�(���%�%�i��7�7�7�
8�
8�
8�
8�
8�
8�
8�
8�
8�
8�
8����
8�
8�
8�
8�
8�
8�
8�
8�
8�
8�
8�
8�
8�
8�
8����
8�
8�
8�
8�

�7�O�O�O�O�O��F�7�O�O�O�O���sx�5D?�A2�&D?�2A6�6D?�9A6�:D?�D�!AD�;D�D	�D�D	�D�D?�D"�"D?�%D"�&D?�?EN)rr
rrrr&r*r;r@rIrLrOrRrTrdr3r'rrs�������0�0�0����8�8�8�<?�?�?�<�<�<�<
:�
:�
:����.���(������,����r3rc��eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zejejjd
kd��d���Zejejjdkd��d���Zd�ZdS)�ExtractTestsc���tjtdtj��5}tD]\}}|�||���	ddd��dS#1swxYwYdS)NrK)rQrRr r��SMALL_TEST_DATArS�rCrU�fpath�fdatas    r'�make_test_filezExtractTests.make_test_fileBs���
�_�W�c�7�+=�
>�
>�	-�%� /�
-�
-���u����u�e�,�,�,�,�
-�	-�	-�	-�	-�	-�	-�	-�	-�	-�	-�	-�	-����	-�	-�	-�	-�	-�	-s�$A�A�Ac	���t��5|���tjtd��5}t
D]�\}}|�|��}tj�	tj
��|��}tj�|��}|�||��t|d��5}|�|���|�����ddd��n#1swxYwYt!|����	ddd��n#1swxYwYddd��dS#1swxYwYdS�NrYr0)rr\rQrRr rX�extractrTr�r7�getcwd�normpathrhr@�encoderir)rCrUrZr[�writtenfile�correctfiler&s       r'�test_extractzExtractTests.test_extractGs��
�Z�Z�	(�	(����!�!�!����#�.�.�
(�%�$3�
(�
(�L�E�5�"'�-�-��"6�"6�K�#%�'�,�,�r�y�{�{�E�"B�"B�K�"$�'�"2�"2�;�"?�"?�K��$�$�[�+�>�>�>��k�4�0�0�C�A��(�(�����������B�B�B�C�C�C�C�C�C�C�C�C�C�C����C�C�C�C��;�'�'�'�'�
(�
(�
(�
(�
(�
(�
(�
(�
(�
(�
(�
(����
(�
(�
(�
(�	(�	(�	(�	(�	(�	(�	(�	(�	(�	(�	(�	(����	(�	(�	(�	(�	(�	(sY�/E�BE�;D	�E�D!
�!E�$D!
�%E�9E�E		�	E�E		�
E�E!�$E!c���|���tjtd��5}tD�]\}}|�||��}tj�||��}tj�	|��}|�
tj�||��||f��t|d��5}|�
|���|�����ddd��n#1swxYwYt!|����	ddd��n#1swxYwYt!t��dSr^)r\rQrRr rXr_rTr�r7rarq�samefiler@rhrbrir)rC�targetrUrZr[rcrdr&s        r'�_test_extract_with_targetz&ExtractTests._test_extract_with_targetZs���������
�_�W�c�
*�
*�
	$�e� /�
$�
$���u�#�m�m�E�6�:�:��!�g�l�l�6�5�9�9�� �g�.�.�{�;�;������� 0� 0��k� J� J�[�Z`�La�b�b�b��+�t�,�,�?���$�$�U�\�\�^�^�Q�V�V�X�X�>�>�>�?�?�?�?�?�?�?�?�?�?�?����?�?�?�?��{�#�#�#�#�
$�
	$�
	$�
	$�
	$�
	$�
	$�
	$�
	$�
	$�
	$�
	$����
	$�
	$�
	$�
	$�	�w�����s6�B)E�;D�E�D#�#E�&D#�'E�E�Ec�~�t��5}|�|��ddd��dS#1swxYwYdSr)rri�rC�extdirs  r'�test_extract_with_targetz%ExtractTests.test_extract_with_targetms���
�Z�Z�	3�6��*�*�6�2�2�2�	3�	3�	3�	3�	3�	3�	3�	3�	3�	3�	3�	3����	3�	3�	3�	3�	3�	3��2�6�6c��t��5}|�tj|����ddd��dS#1swxYwYdSr)rrir�r�rks  r'�!test_extract_with_target_pathlikez.ExtractTests.test_extract_with_target_pathlikeqs���
�Z�Z�	A�6��*�*�7�<��+?�+?�@�@�@�	A�	A�	A�	A�	A�	A�	A�	A�	A�	A�	A�	A����	A�	A�	A�	A�	A�	A��(A�A�Ac	�h�t��5|���tjtd��5}|���tD]�\}}tj�	tj
��|��}t|d��5}|�|�
��|�����ddd��n#1swxYwYt|����	ddd��n#1swxYwYddd��dS#1swxYwYdSr^)rr\rQrRr �
extractallrXrTr�r7r`r@rhrbrir)rCrUrZr[�outfiler&s      r'�test_extract_allzExtractTests.test_extract_allus���
�Z�Z�
	$�
	$����!�!�!����#�.�.�
$�%�� � �"�"�"�$3�$�$�L�E�5� �g�l�l�2�9�;�;��>�>�G��g�t�,�,�C���(�(�����������B�B�B�C�C�C�C�C�C�C�C�C�C�C����C�C�C�C��7�O�O�O�O�
$�
$�
$�
$�
$�
$�
$�
$�
$�
$�
$�
$����
$�
$�
$�
$�
	$�
	$�
	$�
	$�
	$�
	$�
	$�
	$�
	$�
	$�
	$�
	$����
	$�
	$�
	$�
	$�
	$�
	$sY�/D'�A"D� ;C'	�D�'C+
�+D�.C+
�/D�D'�D	�D'�D	�D'�'D+�.D+c�"�|���tjtd��5}|�|��t
D]�\}}tj�||��}t|d��5}|�
|���|�����ddd��n#1swxYwYt|����	ddd��n#1swxYwYtt��dSr^)r\rQrRr rsrXrTr�r7r@rhrbrir)rCrhrUrZr[rtr&s       r'�_test_extract_all_with_targetz*ExtractTests._test_extract_all_with_target�sa��������
�_�W�c�
*�
*�	 �e����V�$�$�$� /�
 �
 ���u��'�,�,�v�u�5�5���'�4�(�(�?�A��$�$�U�\�\�^�^�Q�V�V�X�X�>�>�>�?�?�?�?�?�?�?�?�?�?�?����?�?�?�?��w�����

 �	 �	 �	 �	 �	 �	 �	 �	 �	 �	 �	 ����	 �	 �	 �	 �	�w�����s6�AC0�;C�<C0�C�C0�C�C0�0C4�7C4c�~�t��5}|�|��ddd��dS#1swxYwYdSr)rrwrks  r'�test_extract_all_with_targetz)ExtractTests.test_extract_all_with_target�s���
�Z�Z�	7�6��.�.�v�6�6�6�	7�	7�	7�	7�	7�	7�	7�	7�	7�	7�	7�	7����	7�	7�	7�	7�	7�	7rnc��t��5}|�tj|����ddd��dS#1swxYwYdSr)rrwr�r�rks  r'�%test_extract_all_with_target_pathlikez2ExtractTests.test_extract_all_with_target_pathlike�s���
�Z�Z�	E�6��.�.�w�|�F�/C�/C�D�D�D�	E�	E�	E�	E�	E�	E�	E�	E�	E�	E�	E�	E����	E�	E�	E�	E�	E�	Erqc��|�tj�|����t	|d��5}|�|���|��ddd��dS#1swxYwYdS)Nr0)rqrTr��isfiler@rhri)rCrfr�r&s    r'�
check_filezExtractTests.check_file�s����������x�0�0�1�1�1�
�(�D�
!�
!�	0�Q����Q�V�V�X�X�w�/�/�/�	0�	0�	0�	0�	0�	0�	0�	0�	0�	0�	0�	0����	0�	0�	0�	0�	0�	0s�)A9�9A=�A=c���tjj}|�|dd��d��|�|dd��d��|�|dd��d��dS)	Nz,,?,C:,foo,bar/z�,z_,C_,foo,bar/zza\b,c<d>e|f"g?h*iza\b,c_d_e_f_g_h_i�../../foo../../ba..rr�	foo/ba..r)rQrR�_sanitize_windows_namerh)rC�sans  r'�test_sanitize_windows_namez'ExtractTests.test_sanitize_windows_name�s}���o�4�������0�#�6�6�8I�J�J�J������1�3�7�7�9M�N�N�N������3�S�9�9�<�H�H�H�H�Hr3c�8�gd�}|�|��dS)N))z
../foo/bar�foo/bar)z
foo/../barr�)z
foo/../../barr�)z
foo/bar/..r�)z./../foo/barr�)z/foo/barr�)z/foo/../barr�)z/foo/../../barr���_test_extract_hackers_arcnames)rC�common_hacknamess  r'�*test_extract_hackers_arcnames_common_casesz7ExtractTests.test_extract_hackers_arcnames_common_cases�s1��	
�	
�	
��	
�+�+�,<�=�=�=�=�=r3�\zRequires \ as path separator.c�:�	gd�}|�|��dS)N))z
..\foo\barr�)z..\/foo\/barr�)zfoo/\..\/barr�)zfoo\/../\barr�)z	C:foo/barr�)z
C:/foo/barr�)zC://foo/barr�)z
C:\foo\barr�)z//conky/mountpoint/foo/barr�)z\\conky\mountpoint\foo\barr�)z///conky/mountpoint/foo/bar�conky/mountpoint/foo/bar)z\\\conky\mountpoint\foo\barr�)z//conky//mountpoint/foo/barr�)z\\conky\\mountpoint\foo\barr�)z//?/C:/foo/barr�)z\\?\C:\foo\barr�)zC:/../C:/foo/barz
C_/foo/bar)za:b\c<d>e|f"g?h*izb/c_d_e_f_g_h_i)r�r�r�)rC�windows_hacknamess  r'�*test_extract_hackers_arcnames_windows_onlyz7ExtractTests.test_extract_hackers_arcnames_windows_only�s4��L�
�
�
��*	
�+�+�,=�>�>�>�>�>r3rzRequires / as path separator.c�8�gd�}|�|��dS)N))z	//foo/barr�)r�zfoo../ba..r)�
foo/..\barr�r�)rC�posix_hacknamess  r'�(test_extract_hackers_arcnames_posix_onlyz5ExtractTests.test_extract_hackers_arcnames_posix_only�s/��
�
�
��
	
�+�+�O�<�<�<�<�<r3c���|D�]i\}}d|���z}tjtdtj��5}tj��}||_d|_|�||��ddd��n#1swxYwY|�	tjd��}tj�
ddd��}tjj
|g|�d���R�}tjtd��5}|�||��}	|�|	|d	|�d
|	�d|�����ddd��n#1swxYwY|�||��t%d��tjtd��5}|�|��ddd��n#1swxYwY|�||��t%d��tjj
tj��g|�d���R�}tjtd��5}|�|��}	|�|	|d
|z���ddd��n#1swxYwY|�||��t%|�d��d��tjtd��5}|���ddd��n#1swxYwY|�||��t%|�d��d��t+t����kdS)N�foobarrKrrrh�subdir�subsubrYzextract z: z != )�msgz
extract %rr)rbrQrRr r��ZipInforfrrS�replacerTrr�r7rpr_rhr~rrsr`r)
rC�	hacknames�arcname�	fixednamer�rUr �
targetpathrdrcs
          r'r�z+ExtractTests._test_extract_hackers_arcnames�sW��"+�(	�(	��G�Y��'�.�.�"2�"2�2�G����#�w�/A�B�B�
/�e���)�)��!(���&1��#����u�g�.�.�.�
/�
/�
/�
/�
/�
/�
/�
/�
/�
/�
/����
/�
/�
/�
/��o�o�b�f�c�2�2�G�����h��(�C�C�J��'�,�z�I�I�O�O�C�4H�4H�I�I�I�K����#�.�.�
F�%�#�m�m�G�Z�@�@��� � ��k�k�")�'�'�;�;�;���&E�!�F�F�F�
F�
F�
F�
F�
F�
F�
F�
F�
F�
F�
F����
F�
F�
F�
F�

�O�O�K��1�1�1��8�������#�.�.�
-�%�� � ��,�,�,�
-�
-�
-�
-�
-�
-�
-�
-�
-�
-�
-����
-�
-�
-�
-��O�O�K��1�1�1��8�����'�,�r�y�{�{�J�Y�_�_�S�5I�5I�J�J�J�K����#�.�.�
=�%�#�m�m�G�4�4��� � ��k�%1�G�%;�!�=�=�=�
=�
=�
=�
=�
=�
=�
=�
=�
=�
=�
=����
=�
=�
=�
=�
�O�O�K��1�1�1��9�?�?�3�'�'��*�+�+�+����#�.�.�
#�%�� � �"�"�"�
#�
#�
#�
#�
#�
#�
#�
#�
#�
#�
#����
#�
#�
#�
#��O�O�K��1�1�1��9�?�?�3�'�'��*�+�+�+��7�O�O�O�O�Q(	�(	sZ�8B	�	B
	�B
	�8E�E!	�$E!	�'G	�	G
	�G
	�1J�J	�J	�.L�L	�L	N)rr
rr\rerirmrprurwryr{r~r�r��unittest�skipIfrTr�rr�r�r�rdr3r'rVrV@sJ������-�-�-�
(�(�(�&���&3�3�3�A�A�A�$�$�$����7�7�7�E�E�E�0�0�0�
I�I�I�>�>�>��X�_�R�W�[�D�(�*J�K�K�?�?�L�K�?�2�X�_�R�W�[�C�'�)I�J�J�=�=�K�J�=�)�)�)�)�)r3rVc�>�eZdZd�Zd�Zd�Zd�Zd�Ze��d���Z	d�Z
d�Zd	�Zd
�Z
d�Zd�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z!d�Z"d �Z#d!�Z$d"�Z%d#�Z&d$�Z'd%�Z(d&�Z)e*��d'���Z+d(�Z,d)S)*�
OtherTestsc�V�tjtdtj��5}|�dd��|�t��5|�dd��ddd��n#1swxYwY|�|���dgdz��ddd��n#1swxYwYtjtd��5}|�	��}d}|D]F}|�
|��5}||���z
}ddd��n#1swxYwY�G|�|dd	h��d}|D]}||�|��z
}�|�|dd	h��ddd��dS#1swxYwYdS)
NrKrr��barr�rYr3r�sbarfoo)
rQrRr r�rSr6r7rhrurvr@riro)rCrUr�r8r�r�s      r'�test_open_via_zip_infoz!OtherTests.test_open_via_zip_infos���
�_�W�c�7�+=�
>�
>�	=�%��N�N�6�5�)�)�)��!�!�+�.�.�
.�
.����v�u�-�-�-�
.�
.�
.�
.�
.�
.�
.�
.�
.�
.�
.����
.�
.�
.�
.����U�^�^�-�-��x�!�|�<�<�<�		=�	=�	=�	=�	=�	=�	=�	=�	=�	=�	=����	=�	=�	=�	=��_�W�c�
*�
*�
	8�e��N�N�$�$�E��D��
+�
+���Z�Z��%�%�+���G�L�L�N�N�*�D�+�+�+�+�+�+�+�+�+�+�+����+�+�+�+���M�M�$��I� 6�7�7�7��D��
)�
)����
�
�4�(�(�(����M�M�$��I� 6�7�7�7�
	8�
	8�
	8�
	8�
	8�
	8�
	8�
	8�
	8�
	8�
	8�
	8����
	8�
	8�
	8�
	8�
	8�
	8sl�1B=�A:�.B=�:A>	�>B=�A>	�/B=�=C�C�"0F�D6�*F�6D:�:F�=D:�>AF�F"�%F"c��tjtd��5}dD]F}tj|��}|xjtjzc_|�||���G	ddd��dS#1swxYwYdS)NrK�abcdefghijklmnop)rQrRr r��	flag_bits�_MASK_USE_DATA_DESCRIPTORrS)rC�orig_zipr8r s    r'�-test_writestr_extended_local_header_issue1202z8OtherTests.test_writestr_extended_local_header_issue1202s���
�_�W�c�
*�
*�	/�h�*�
/�
/�����-�-�����7�#D�D����!�!�%��.�.�.�.�
/�	/�	/�	/�	/�	/�	/�	/�	/�	/�	/�	/�	/����	/�	/�	/�	/�	/�	/s�A
A3�3A7�:A7c���	tjtd��5}tD]6\}}|�||��|�|jd���7	ddd��n#1swxYwY|�|jd��tjtd��5}|�|jd��ddd��n#1swxYwY|�|jd��dS)NrKzzipfp is not open�zipfp is not closedrY)rQrRr rXrS�assertIsNotNonerD�assertIsNonerYs    r'�
test_closezOtherTests.test_closes���F�
�_�W�c�
*�
*�	D�e� /�
D�
D���u����u�e�,�,�,��$�$�U�X�/B�C�C�C�C�
D�	D�	D�	D�	D�	D�	D�	D�	D�	D�	D�	D����	D�	D�	D�	D�	
���%�(�$9�:�:�:�
�_�W�c�
*�
*�	@�e�� � ���+>�?�?�?�	@�	@�	@�	@�	@�	@�	@�	@�	@�	@�	@����	@�	@�	@�	@����%�(�$9�:�:�:�:�:s#�?A(�(A,�/A,�(C�C�Cc��	tjtd��5}tD]\}}|�||���	ddd��n#1swxYwY	tjtd��5}tj���#1swxYwYdS#tj$r|�|jd��YdSwxYw)NrKrYr�)rQrRr rXrSr�r�rD)rCrUrZr[�zipfp2s     r'�test_close_on_exceptionz"OtherTests.test_close_on_exception(s>��	�
�_�W�c�
*�
*�	-�e� /�
-�
-���u����u�e�,�,�,�,�
-�	-�	-�	-�	-�	-�	-�	-�	-�	-�	-�	-����	-�	-�	-�	-�	@����#�.�.�
+�&��(�*�*�*�
+�
+�
+�
+����
+�
+�
+�
+�
+�
+���!�	@�	@�	@����f�i�)>�?�?�?�?�?�?�	@���sA�$A
�
A�A�B�3B�B�B�B�B�*C�Cc�|�d}|�ttjt	j|��d��dS)NsdPKx!p�@xPKxx!p�@�xPK/rY)r��NotImplementedErrorrQrRr#r$�rCr8s  r'�test_unsupported_versionz#OtherTests.test_unsupported_version5sD��Y��	
���-�w���*�T�*�*�C�	1�	1�	1�	1�	1r3c��td��}tj|��5}|���D])}|�|������*	ddd��dS#1swxYwYdS)Nzzip_cp437_header.zip)rrQrRrur@rH)rCr�rUrs    r'�test_read_unicode_filenamesz&OtherTests.test_read_unicode_filenames@s����/�0�0��
�_�U�
#�
#�	)�u����(�(�
)�
)���
�
�4� � �&�&�(�(�(�(�
)�	)�	)�	)�	)�	)�	)�	)�	)�	)�	)�	)�	)����	)�	)�	)�	)�	)�	)s�?A1�1A5�8A5c�0�tjtd��5}|�dd��|�dd��|�|���djt��ddd��n#1swxYwYtjtd��5}|�|j	djd��|�|j	djd��ddd��dS#1swxYwYdS)NrK�foo.txtzTest for unicode filenameuö.txtrrYr_)
rQrRrrSr�rvrfrtrh�filelist�rCr�s  r'�test_write_unicode_filenamesz'OtherTests.test_write_unicode_filenamesHs���
�_�V�S�
)�
)�	B�R��K�K�	�#>�?�?�?��K�K�
�$?�@�@�@��!�!�"�+�+�-�-��"2�";�S�A�A�A�	B�	B�	B�	B�	B�	B�	B�	B�	B�	B�	B����	B�	B�	B�	B�
�_�V�S�
)�
)�	B�R����R�[��^�4�i�@�@�@����R�[��^�4�j�A�A�A�	B�	B�	B�	B�	B�	B�	B�	B�	B�	B�	B�	B����	B�	B�	B�	B�	B�	Bs%�A%B�B�B�1A
D�D�Dc���tjtd��5}|�dd��|�|�d��d��ddd��dS#1swxYwYdS)NrKuприкладssample)rQrRr rSrhrir)s  r'�'test_read_after_write_unicode_filenamesz2OtherTests.test_read_after_write_unicode_filenamesRs���
�_�W�c�
*�
*�	F�e��N�N�+�Y�7�7�7����U�Z�Z�(8�9�9�9�E�E�E�	F�	F�	F�	F�	F�	F�	F�	F�	F�	F�	F�	F����	F�	F�	F�	F�	F�	Fs�AA(�(A,�/A,c��	tt��d}d}tjtdtj��5}|�||��ddd��n#1swxYwY|�t��5tjtdtj��ddd��n#1swxYwYtjtd��5}|�|�	��|g��|�|�
|��|��ddd��dS#1swxYwYdS)N�testfile.txt�#hello, world. this is some content.�xrY)rr rQrRr�rSr��FileExistsErrorrhruri)rCrfr�rUs    r'�test_exclusive_create_zip_filez)OtherTests.test_exclusive_create_zip_fileWs���4��w����!��8��
�_�W�c�7�+=�
>�
>�	.�%��N�N�8�W�-�-�-�	.�	.�	.�	.�	.�	.�	.�	.�	.�	.�	.����	.�	.�	.�	.�
�
�
��
/�
/�	>�	>��O�G�S�'�*<�=�=�=�	>�	>�	>�	>�	>�	>�	>�	>�	>�	>�	>����	>�	>�	>�	>�
�_�W�c�
*�
*�	<�e����U�^�^�-�-��z�:�:�:����U�Z�Z��1�1�7�;�;�;�	<�	<�	<�	<�	<�	<�	<�	<�	<�	<�	<�	<����	<�	<�	<�	<�	<�	<s6�A"�"A&�)A&�&B9�9B=�B=�AD>�>E�Ec��tj�t��rtjt��d}d}	tjtd��5}|�||��ddd��n#1swxYwYn%#t$r|�	d��YnwxYw|�
tj�t����tjtd��5}|�|�|��|��ddd��dS#1swxYwYdS)Nr�r�r,z1Could not append data to a non-existent zip file.rY)
rTr��existsrrrQrRrSr�failrqrhri)rCrfr�r�s    r'�(test_create_non_existent_file_for_appendz3OtherTests.test_create_non_existent_file_for_appendds���
�7�>�>�&�!�!�	��I�f����!��8��	K�����-�-�
/�����H�g�.�.�.�
/�
/�
/�
/�
/�
/�
/�
/�
/�
/�
/����
/�
/�
/�
/����	K�	K�	K��I�I�I�J�J�J�J�J�	K����	
�������v�.�.�/�/�/�
�_�V�S�
)�
)�	9�R����R�W�W�X�.�.��8�8�8�	9�	9�	9�	9�	9�	9�	9�	9�	9�	9�	9�	9����	9�	9�	9�	9�	9�	9sH�B�B�4B�B�B�B�B�B.�-B.�*D9�9D=�D=c���ttdd���5}|�d��ddd��n#1swxYwY	tjt��}dS#tj$rYdSwxYw)NrKr:r;�this is not a legal zip file
)r@rrArQrRr�)rCrDr�s   r'�test_close_erroneous_filez$OtherTests.test_close_erroneous_filevs����&�#��
0�
0�
0�	7�B��H�H�5�6�6�6�	7�	7�	7�	7�	7�	7�	7�	7�	7�	7�	7����	7�	7�	7�	7�	����(�(�B�B�B���!�	�	�	��D�D�	���s�:�>�>�A!�!A4�3A4c�$�	ttdd���5}|�d��ddd��n#1swxYwY|�t	jt����|�t	jt
jt������ttd��5}|�t	j|����ddd��n#1swxYwYtj	��}|�d��|�t	j|����|�
dd��|�t	j|����dS)NrKr:r;r�r0sthis is not a legal zip file
r)r@rrAr!rQ�
is_zipfiler�r�r#r$r1rBs  r'�test_is_zip_erroneous_filez%OtherTests.test_is_zip_erroneous_file�s���I�
�&�#��
0�
0�
0�	7�B��H�H�5�6�6�6�	7�	7�	7�	7�	7�	7�	7�	7�	7�	7�	7����	7�	7�	7�	7�����+�F�3�3�4�4�4�����+�G�L��,@�,@�A�A�B�B�B�
�&�$�
�
�	5�2����W�/��3�3�4�4�4�	5�	5�	5�	5�	5�	5�	5�	5�	5�	5�	5����	5�	5�	5�	5��Z�\�\��
���2�3�3�3�����+�B�/�/�0�0�0�
����1�
�
�
�����+�B�/�/�0�0�0�0�0s�;�?�?�(C9�9C=�C=c��	tj��}tj|d���5}|�dd��ddd��n#1swxYwY|���}t
t|����D]I}tj|d|���}|�tj	tj|���JdS)NrKrOr��O, for a Muse of Fire!)
r#r$rQrRrSrlr4rnr�r�)rCrDr�r��Ns     r'�test_damaged_zipfilezOtherTests.test_damaged_zipfile�s��Q�
�Z�\�\��
�_�R�c�
*�
*�
*�	@�d��M�M�)�%>�?�?�?�	@�	@�	@�	@�	@�	@�	@�	@�	@�	@�	@����	@�	@�	@�	@��k�k�m�m���s�;�'�'�(�(�	G�	G�A���K����O�,�,�B����g�0�'�/�2�F�F�F�F�	G�	Gs�A�A�Ac��	tjtd���5}|�dd��ddd��n#1swxYwY|�tjt����t
td��5}|�tj|����|�dd��|���}ddd��n#1swxYwYtj
��}|�|��|�tj|����|�dd��|�tj|����dS)NrKrOr�r�r0r)rQrRrrSrqr�r@r1rir#r$rA)rCr�rD�zip_contentss    r'�test_is_zip_valid_filez!OtherTests.test_is_zip_valid_file�s���E�
�_�V�#�
.�
.�
.�	@�$��M�M�)�%>�?�?�?�	@�	@�	@�	@�	@�	@�	@�	@�	@�	@�	@����	@�	@�	@�	@�	
����*�6�2�2�3�3�3�
�&�$�
�
�	%�2��O�O�G�.�r�2�2�3�3�3��G�G�A�q�M�M�M��7�7�9�9�L�	%�	%�	%�	%�	%�	%�	%�	%�	%�	%�	%����	%�	%�	%�	%�
�Z�\�\��
�����������*�2�.�.�/�/�/�
����1�
�
�
�����*�2�.�.�/�/�/�/�/s$�A�A�A�AC*�*C.�1C.c�\�|�ttjt��dSr)r�rrQrRrrs r'�%test_non_existent_file_raises_OSErrorz0OtherTests.test_non_existent_file_raises_OSError�s$��	
���'�7�?�F�;�;�;�;�;r3c��ttdd���}|���|�tjtjt��ttdd���5}|�d��ddd��n#1swxYwY|�tjtjt��dS)NrKr:r;z
short file)r@rrHr�rQr�rRrA)rCr&rDs   r'�!test_empty_file_raises_BadZipFilez,OtherTests.test_empty_file_raises_BadZipFile�s������w�/�/�/��	���	�	�	����'�,�g�o�v�F�F�F�
�&�#��
0�
0�
0�	#�B��H�H�\�"�"�"�	#�	#�	#�	#�	#�	#�	#�	#�	#�	#�	#����	#�	#�	#�	#����'�,�g�o�v�F�F�F�F�Fs�3B�B�Bc���td��}dD][}tjd|��|dd�<tj|��}|�tjtj|���\dS)N�PK)r_r�r�rY�)	�	bytearrayrbr�r#r$r�rQr�rR)rC�buffer�dirsizer&s    r'�8test_negative_central_directory_offset_raises_BadZipFilezCOtherTests.test_negative_central_directory_offset_raises_BadZipFile�sw���3�4�4��"�	F�	F�G�"�K��g�6�6�F�2�b�5�M��
�6�"�"�A����g�0�'�/�1�E�E�E�E�	F�	Fr3c��	tj��}tj|d���5}|�dd��ddd��n#1swxYwY|�t|jd��|�t|jd��|�t|j	��|�t|jdd��ttdd���5}|�d	��ddd��n#1swxYwY|�t|jt��dS)
NrKrOr��O, for a Muse of Fire!z	bogus.txtrGr:r;zzipfile test data)r#r$rQrRrSr�rIrir@ryrrA)rCr8r�r&s    r'�!test_closed_zip_raises_ValueErrorz,OtherTests.test_closed_zip_raises_ValueError�s���M��z�|�|��
�_�T��
,�
,�
,�	?���M�M�)�%=�>�>�>�	?�	?�	?�	?�	?�	?�	?�	?�	?�	?�	?����	?�	?�	?�	?�	
���*�d�i��;�;�;����*�d�i��;�;�;����*�d�l�3�3�3����*�d�m�[�'�J�J�J�
�&�#��
0�
0�
0�	)�A�
�G�G�'�(�(�(�	)�	)�	)�	)�	)�	)�	)�	)�	)�	)�	)����	)�	)�	)�	)����*�d�j�&�9�9�9�9�9s#�A�A�A�4D�D�Dc�`�	|�ttjtd��dS)Nr�)r�rIrQrRrrs r'�test_bad_constructor_modez$OtherTests.test_bad_constructor_mode�s'��L����*�g�o�v�s�C�C�C�C�Cr3c��	tjtd���5}|�dd��ddd��n#1swxYwYtjtd���5}|�d��|�t|jdd��|�t|jdd��|�t|jdd��ddd��dS#1swxYwYdS)	NrKrOr�r�rYr��U�rU)rQrRrrSrir�rIr@�rCr�s  r'�test_bad_open_modezOtherTests.test_bad_open_mode�sr��E�
�_�V�#�
.�
.�
.�	?�$��M�M�)�%=�>�>�>�	?�	?�	?�	?�	?�	?�	?�	?�	?�	?�	?����	?�	?�	?�	?��_�V�#�
.�
.�
.�	F�$��I�I�i� � � ����j�$�)�Y��D�D�D����j�$�)�Y��D�D�D����j�$�)�Y��E�E�E�
	F�	F�	F�	F�	F�	F�	F�	F�	F�	F�	F�	F����	F�	F�	F�	F�	F�	Fs$�A�A�A�&A<C/�/C3�6C3c���	tjtd���5}|�dd��|�d��5}tt��D]+}|�|�d��d���,|�|���d��ddd��n#1swxYwYddd��dS#1swxYwYdS)NrKrOr�r�rr3r�)	rQrRrrSr@r4r5rhri)rCr�r&r1s    r'�
test_read0zOtherTests.test_read0�sr��	4�
�_�V�#�
.�
.�
.�	F�$��M�M�)�%=�>�>�>����9�%�%�
F���~�.�.�5�5�A��$�$�Q�V�V�A�Y�Y��4�4�4�4�� � ������+D�E�E�E�	
F�
F�
F�
F�
F�
F�
F�
F�
F�
F�
F����
F�
F�
F�
F�	F�	F�	F�	F�	F�	F�	F�	F�	F�	F�	F�	F����	F�	F�	F�	F�	F�	Fs6�,C�	A)B>�2C�>C	�C�C	�C�C�Cc��	tjtd���5}|�t|jdd��ddd��dS#1swxYwYdS)NrKrOr�rY)rQrRrr��KeyErrorr@r�s  r'�test_open_non_existent_itemz&OtherTests.test_open_non_existent_item	s���	7�
�_�V�#�
.�
.�
.�	C�$����h��	�9�c�B�B�B�	C�	C�	C�	C�	C�	C�	C�	C�	C�	C�	C�	C����	C�	C�	C�	C�	C�	Cs�#A
�
A�Ac�b�	|�ttjtdd��dS)NrKr�)r�r�rQrRrrs r'�test_bad_compression_modez$OtherTests.test_bad_compression_modes,��	����-�w����R�P�P�P�P�Pr3c���d}tjtj|��d��5}|�t
|jd��ddd��dS#1swxYwYdS)NsfPK.�C�@xPK..�C�@�xPK/!rYr�)rQrRr#r$r�r�r@)rCr8r�s   r'�test_unsupported_compressionz'OtherTests.test_unsupported_compressions���6���_�R�Z��-�-�s�
3�
3�	C�t����1�4�9�c�B�B�B�	C�	C�	C�	C�	C�	C�	C�	C�	C�	C�	C�	C����	C�	C�	C�	C�	C�	Cs�"A�A� Ac���	tjtd���5}|�dd��|�|���dg��ddd��dS#1swxYwYdS)NrKrOzfoo.txtqqqr�r�)rQrRrrSrhrur�s  r'�test_null_byte_in_filenamez%OtherTests.test_null_byte_in_filenames���	�
�_�V�#�
.�
.�
.�	;�$��M�M�*�,E�F�F�F����T�]�]�_�_�y�k�:�:�:�	;�	;�	;�	;�	;�	;�	;�	;�	;�	;�	;�	;����	;�	;�	;�	;�	;�	;s�AA*�*A.�1A.c��	|�tjd��|�tjd��|�tjd��|�tjd��dS)N��.�8r�)rhrQ�sizeEndCentDir�sizeCentralDir�sizeEndCentDir64�sizeEndCentDir64Locatorrs r'�test_struct_sizeszOtherTests.test_struct_sizes&so��O�����/��4�4�4�����/��4�4�4�����1�2�6�6�6�����8�"�=�=�=�=�=r3c�0
�	tjtd���5}|�|jd��|�dd��ddd��n#1swxYwYtjtd���5}|�|jd��ddd��n#1swxYwYd}tjtd���5}||_|�dd��ddd��n#1swxYwYtjtd���5}|�|j|��ddd��n#1swxYwYd�d	�td
��D����}|�d��}tjtd���5}||_|�dd��ddd��n#1swxYwYtjtd���5}|�|j|��ddd��n#1swxYwYtjtd���5}|�	t��5|dz|_ddd��n#1swxYwY|�dd��ddd��n#1swxYwYtjtd���5}|�|j|��ddd��n#1swxYwYtjtd���5}d
|_|�dd��ddd��n#1swxYwYtjtd���5}d|_ddd��n#1swxYwYtjtd���5}|�|jd��ddd��n#1swxYwYtjtd���5}d|_|�dd��ddd��n#1swxYwYtj�
t��}tjtd���5}d|_ddd��n#1swxYwY|�|tj�
t��k��tjtd���5}|�|jd��ddd��dS#1swxYwYdS)NrKrOr3r�r�rYs9Bravely taking to his feet, he beat a very brave retreat.�c�$�g|]
}d|dzdzz��S)r�r�r�rdr/s  r'r2z,OtherTests.test_comments.<locals>.<listcomp>As%��K�K�K�1�D�A�q�D�2�I�.�K�K�Kr3�r-soopssoriginal commentr,san updated commentsoriginal comment that's longersshorter comment)rQrRrrhrArSr7r4rbr6r7rTr��getsizerq)rCr��zipfrrA�comment2�original_zip_sizes      r'�
test_commentszOtherTests.test_comments-s��F��_�V�#�
.�
.�
.�	?�$����T�\�3�/�/�/��M�M�)�%=�>�>�>�	?�	?�	?�	?�	?�	?�	?�	?�	?�	?�	?����	?�	?�	?�	?��_�V�#�
.�
.�
.�	1�%����U�]�C�0�0�0�	1�	1�	1�	1�	1�	1�	1�	1�	1�	1�	1����	1�	1�	1�	1�O��
�_�V�#�
.�
.�
.�	?�$�"�D�L��M�M�)�%=�>�>�>�	?�	?�	?�	?�	?�	?�	?�	?�	?�	?�	?����	?�	?�	?�	?��_�V�#�
.�
.�
.�	4�%����T�\�7�3�3�3�	4�	4�	4�	4�	4�	4�	4�	4�	4�	4�	4����	4�	4�	4�	4��7�7�K�K��k�8J�8J�K�K�K�L�L���?�?�7�+�+��
�_�V�#�
.�
.�
.�	?�$�#�D�L��M�M�)�%=�>�>�>�	?�	?�	?�	?�	?�	?�	?�	?�	?�	?�	?����	?�	?�	?�	?��_�V�#�
.�
.�
.�	6�%����U�]�H�5�5�5�	6�	6�	6�	6�	6�	6�	6�	6�	6�	6�	6����	6�	6�	6�	6��_�V�#�
.�
.�
.�	?�$��!�!�+�.�.�
2�
2�'�'�1���
2�
2�
2�
2�
2�
2�
2�
2�
2�
2�
2����
2�
2�
2�
2��M�M�)�%=�>�>�>�	?�	?�	?�	?�	?�	?�	?�	?�	?�	?�	?����	?�	?�	?�	?��_�V�#�
.�
.�
.�	6�%����U�]�H�5�5�5�	6�	6�	6�	6�	6�	6�	6�	6�	6�	6�	6����	6�	6�	6�	6��_�V��
-�
-�
-�	?��.�D�L��M�M�)�%=�>�>�>�	?�	?�	?�	?�	?�	?�	?�	?�	?�	?�	?����	?�	?�	?�	?��_�V��
-�
-�
-�	1��0�D�L�	1�	1�	1�	1�	1�	1�	1�	1�	1�	1�	1����	1�	1�	1�	1�
�_�V��
-�
-�
-�	B�����T�\�+@�A�A�A�	B�	B�	B�	B�	B�	B�	B�	B�	B�	B�	B����	B�	B�	B�	B�
�_�V��
-�
-�
-�	?��<�D�L��M�M�)�%=�>�>�>�	?�	?�	?�	?�	?�	?�	?�	?�	?�	?�	?����	?�	?�	?�	?��G�O�O�F�3�3��
�_�V��
-�
-�
-�	.��-�D�L�	.�	.�	.�	.�	.�	.�	.�	.�	.�	.�	.����	.�	.�	.�	.����)�B�G�O�O�F�,C�,C�C�D�D�D�
�_�V��
-�
-�
-�	?�����T�\�+=�>�>�>�	?�	?�	?�	?�	?�	?�	?�	?�	?�	?�	?�	?����	?�	?�	?�	?�	?�	?s�2A�A�"A�B)�)B-�0B-�C;�;C?�C?�!E	�	E
�E
�0G�G�!G�H(�(H,�/H,�J-�)J�4J-�J	�J-�J	�J-�-J1�4J1�K;�;K?�K?�!M�M�M�1N�N	�N	�+O�O�O�9P#�#P'�*P'�-R�R�R�"T�T�Tc� �tjtdtj��5}|�dd��|�t��5d|_ddd��n#1swxYwYddd��dS#1swxYwYdS)NrKr�r�zthis is an error)rQrRrr�rSr��	TypeErrorrAr�s  r'�test_unicode_commentzOtherTests.test_unicode_commentgs���
�_�V�S�'�*<�
=�
=�	2���M�M�)�%=�>�>�>��"�"�9�-�-�
2�
2�1���
2�
2�
2�
2�
2�
2�
2�
2�
2�
2�
2����
2�
2�
2�
2�	2�	2�	2�	2�	2�	2�	2�	2�	2�	2�	2�	2����	2�	2�	2�	2�	2�	2s5�1B�A+�B�+A/	�/B�2A/	�3B�B�
Bc�^�tjtdtj��5}|�|j��d|_ddd��n#1swxYwYtjtd��5}|�|jd��ddd��dS#1swxYwYdS)Nr,r@rY)rQrRrr�r!r�rArhr�s  r'�$test_change_comment_in_empty_archivez/OtherTests.test_change_comment_in_empty_archivems)��
�_�V�S�'�*<�
=�
=�	0�����T�]�+�+�+�/�D�L�	0�	0�	0�	0�	0�	0�	0�	0�	0�	0�	0����	0�	0�	0�	0��_�V�S�
)�
)�	A�T����T�\�+?�@�@�@�	A�	A�	A�	A�	A�	A�	A�	A�	A�	A�	A�	A����	A�	A�	A�	A�	A�	As#�"A�A�A�9B"�"B&�)B&c��tjtdtj��5}|�dd��ddd��n#1swxYwYtjtdtj��5}|�|j��d|_ddd��n#1swxYwYtjtd��5}|�|jd��ddd��dS#1swxYwYdS)NrKr�r�r,r@rY)	rQrRrr�rSrqr�rArhr�s  r'�'test_change_comment_in_nonempty_archivez2OtherTests.test_change_comment_in_nonempty_archivets���
�_�V�S�'�*<�
=�
=�	?���M�M�)�%=�>�>�>�	?�	?�	?�	?�	?�	?�	?�	?�	?�	?�	?����	?�	?�	?�	?�
�_�V�S�'�*<�
=�
=�	0���O�O�D�M�*�*�*�/�D�L�	0�	0�	0�	0�	0�	0�	0�	0�	0�	0�	0����	0�	0�	0�	0��_�V�S�
)�
)�	A�T����T�\�+?�@�@�@�	A�	A�	A�	A�	A�	A�	A�	A�	A�	A�	A�	A����	A�	A�	A�	A�	A�	As5�A	�	A
�A
�9"B'�'B+�.B+�C5�5C9�<C9c���tjtd���}|���	tjtd���}n*#tj$r|�d��YnwxYwtjtd���}|���	tjtd���}dS#|�d��YdSxYw)NrKrOrYz+Unable to create empty ZIP file in 'w' moder,z+Unable to create empty ZIP file in 'a' mode)rQrRrrHr�r�r�s  r'�test_empty_zipfilezOtherTests.test_empty_zipfile}s�����v�C�0�0�0���
�
����	E��?�6��4�4�4�D�D���!�	E�	E�	E��I�I�C�D�D�D�D�D�	E������v�C�0�0�0���
�
����	E��?�6��4�4�4�D�D�D��	E��I�I�C�D�D�D�D�D�D���s�A
�
$A4�3A4�'C�Cc��ttdd���}|���|�tjtjtd��dS)NrKr:r;rY)r@rrHr�rQr�rRr�s  r'�test_open_empty_filezOtherTests.test_open_empty_file�sJ��
���w�/�/�/��	���	�	�	����'�,�g�o�v�s�K�K�K�K�Kr3c�T�|�ttjdd��dS)N�	seventies)i�r_r_rrr)r�rIrQr�rs r'�test_create_zipinfo_before_1980z*OtherTests.test_create_zipinfo_before_1980�s5�����*�!�/�;�8M�	O�	O�	O�	O�	Or3c�x�	tjd���}|�t|��d��dS)N�emptyrez&<ZipInfo filename='empty' file_size=0>)rQr�rhr��rC�zis  r'�test_create_empty_zipinfo_reprz)OtherTests.test_create_empty_zipinfo_repr�s:��K�
�_�g�
.�
.�
.������b���#K�L�L�L�L�Lr3c���	tj��}|�|jd��|�|jd��|�|jd��|�|jtj��|�|jd��|�|j	d��|�
|jd��|�|jtj
��|�|jtj
��|�|jd��|�|jd��|�|jd��|�|jd��|�|jd��|�|jd��|�|jd��dS)N�NoNamerSr3)rr�r)rQr�rh�
orig_filenamerfrVr�r�rAr�ro�
create_system�create_version�DEFAULT_VERSION�extract_version�reservedr��volume�
internal_attrrrwr�rs  r'�,test_create_empty_zipinfo_default_attributesz7OtherTests.test_create_empty_zipinfo_default_attributes�s���5�
�_�
�
������)�8�4�4�4������h�/�/�/������'<�=�=�=�����)�7�+=�>�>�>������S�)�)�)������3�'�'�'��
�
�b�&��/�/�/�����*�G�,C�D�D�D�����+�W�-D�E�E�E������a�(�(�(������q�)�)�)������A�&�&�&�����)�1�-�-�-�����)�1�-�-�-�	
�����q�)�)�)�����)�1�-�-�-�-�-r3c���	d}tjtj|��d��5}|�|�����ddd��dS#1swxYwYdS)NsnPK���@����abcAPK���@������abcPK3%rY)rQrRr#r$r�ry�rCr�r�s   r'�#test_zipfile_with_short_extra_fieldz.OtherTests.test_zipfile_with_short_extra_field�s���L�
B�	��_�R�Z��0�0�#�
6�
6�	.�$����d�l�l�n�n�-�-�-�	.�	.�	.�	.�	.�	.�	.�	.�	.�	.�	.�	.����	.�	.�	.�	.�	.�	.s�(A � A$�'A$c��d}d}d}tjtdtj��5}|�dd���5}|�|��ddd��n#1swxYwY|�dd���5}|�t��5|�dd���ddd��n#1swxYwY|�t��5|�dd	���ddd��n#1swxYwY|�t��5|�d
d��ddd��n#1swxYwY|�t��5|�td��ddd��n#1swxYwY|�t��5|�
��ddd��n#1swxYwY|�|��ddd��n#1swxYwY|�d
d���5}|�|��ddd��n#1swxYwYddd��n#1swxYwYtjtd	��5}|�|�d��|��|�|�d��|��|�|�d
��|��|�|�
��gd���ddd��dS#1swxYwYdS)Ns"It's fun to charter an accountant!s And sail the wide accountant seas#To find, explore the funds offshorerKr�rOr��handlerYrt�abcderZ�baz)r�r�r/)rQrRr r�r@rAr�rIrSrrHrhriru)rC�msg1�msg2�msg3r��w2�w1s       r'�test_open_conflicting_handlesz(OtherTests.test_open_conflicting_handles�sb��4��2��5��
�_�W�c�7�+=�
>�
>�	�$����5�s��+�+�
�r��������
�
�
�
�
�
�
�
�
�
�
����
�
�
�
����5�s��+�+�
�r��&�&�z�2�2�2�2��I�I�h�S�I�1�1�1�2�2�2�2�2�2�2�2�2�2�2����2�2�2�2��&�&�z�2�2�/�/��I�I�e�#�I�.�.�.�/�/�/�/�/�/�/�/�/�/�/����/�/�/�/��&�&�z�2�2�2�2��M�M�%��1�1�1�2�2�2�2�2�2�2�2�2�2�2����2�2�2�2��&�&�z�2�2�1�1��J�J�x��0�0�0�1�1�1�1�1�1�1�1�1�1�1����1�1�1�1��&�&�z�2�2�!�!��J�J�L�L�L�!�!�!�!�!�!�!�!�!�!�!����!�!�!�!��������
�
�
�
�
�
�
�
�
�
�
����
�
�
�
����5�s��+�+�
�r��������
�
�
�
�
�
�
�
�
�
�
����
�
�
�
�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�$�_�W�c�
*�
*�	E�d����T�Y�Y�u�-�-�t�4�4�4����T�Y�Y�u�-�-�t�4�4�4����T�Y�Y�u�-�-�t�4�4�4����T�]�]�_�_�.C�.C�.C�D�D�D�		E�	E�	E�	E�	E�	E�	E�	E�	E�	E�	E�	E����	E�	E�	E�	E�	E�	EsD�I2�A&�I2�&A*	�*I2�-A*	�.I2�H�#C�;H�C�H�C�H�,D�H�D�H�D�H�5E�H�E�H�E� H�=F%�H�%F)�)H�,F)�-H�
G+�H�+G/�/H�2G/�3H�I2�H	�I2�H	�I2�9I�I2�I	�I2�"I	�#I2�2I6�9I6�B&M
�
M�Mc	�	�d}|�d��}tjtd��5}|�d|��ddd��n#1swxYwYtjtd��5}|�dd��5}|�|tj��|�	|�
��|��|�|tj��|�	|�
��d��|�|tj��|�	|�
��|��|�	|�d��|||dz���|�dtj
��|�	|�
��t|����|�dtj��|�	|�
��d��ddd��n#1swxYwYddd��n#1swxYwYtj��}tj|d���5}|�d|��ddd��n#1swxYwYtj|d���5}|�dd��5}|�|tj��|�	|�
��|��|�|tj��|�	|�
��d��|�|tj��|�	|�
��|��|�	|�d��|||dz���|�dtj
��|�	|�
��t|����|�dtj��|�	|�
��d��ddd��n#1swxYwYddd��dS#1swxYwYdS)	NsWhere's Bruce?sBrucerKr�rYrr[rO)�findrQrRrrSr@r1rT�SEEK_SETrhr��SEEK_CURri�SEEK_ENDrnr#r$)rC�txt�blocr�rDr8s      r'�test_seek_tellzOtherTests.test_seek_tell�s0�����x�x��!�!��
�_�V�S�
)�
)�	*�T��M�M�)�S�)�)�)�	*�	*�	*�	*�	*�	*�	*�	*�	*�	*�	*����	*�	*�	*�	*�
�_�V�S�
)�
)�	/�T����9�c�*�*�
/�b�����b�k�*�*�*�� � ������D�1�1�1������r�{�+�+�+�� � ������A�.�.�.�����b�k�*�*�*�� � ������D�1�1�1�� � �������S��d�1�f��-=�>�>�>�����2�;�'�'�'�� � ������C��H�H�5�5�5�����2�;�'�'�'�� � ������A�.�.�.�
/�
/�
/�
/�
/�
/�
/�
/�
/�
/�
/����
/�
/�
/�
/�	/�	/�	/�	/�	/�	/�	/�	/�	/�	/�	/����	/�	/�	/�	/��z�|�|��
�_�T��
,�
,�
,�	*���M�M�)�S�)�)�)�	*�	*�	*�	*�	*�	*�	*�	*�	*�	*�	*����	*�	*�	*�	*�
�_�T��
,�
,�
,�	/�����9�c�*�*�
/�b�����b�k�*�*�*�� � ������D�1�1�1������r�{�+�+�+�� � ������A�.�.�.�����b�k�*�*�*�� � ������D�1�1�1�� � �������S��d�1�f��-=�>�>�>�����2�;�'�'�'�� � ������C��H�H�5�5�5�����2�;�'�'�'�� � ������A�.�.�.�
/�
/�
/�
/�
/�
/�
/�
/�
/�
/�
/����
/�
/�
/�
/�	/�	/�	/�	/�	/�	/�	/�	/�	/�	/�	/�	/����	/�	/�	/�	/�	/�	/s��A�A�A�:I�F+I�<I�I	�I�I	�I�I#�&I#�J6�6J:�=J:�R=�.F+R%�R=�%R)	�)R=�,R)	�-R=�=S�Sc���d}tj|��}tj|dtj���5}|�dd��ddd��n#1swxYwYt
jdd��5tj|��5}|�t|j
d��ddd��n#1swxYwYddd��dS#1swxYwYdS)Nr�rK)rIr��azzipfile.bz2)r#r$rQrRrsrS�mock�patchr�rNr_)rCr8�zip_filer�s    r'�)test_decompress_without_3rd_party_libraryz4OtherTests.test_decompress_without_3rd_party_librarys���d���:�d�#�#��
�_�X�s��8I�
J�
J�
J�	'�b��K�K���&�&�&�	'�	'�	'�	'�	'�	'�	'�	'�	'�	'�	'����	'�	'�	'�	'�
�Z�
�t�
,�
,�	E�	E����*�*�
E�b��!�!�,��
�G�D�D�D�
E�
E�
E�
E�
E�
E�
E�
E�
E�
E�
E����
E�
E�
E�
E�	E�	E�	E�	E�	E�	E�	E�	E�	E�	E�	E�	E����	E�	E�	E�	E�	E�	EsG�A�A�"A�;C�"B>�2C�>C	�C�C	�C�C�Cc�V�tt��tt��dSrrrs r'rzOtherTests.tearDownrr3N)-rr
rr�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
r
rrrrrrr(r+r5r=r
rCrrdr3r'r�r�s�������8�8�8�(/�/�/�
;�
;�
;�@�@�@�	1�	1�	1��]�_�_�)�)��_�)�B�B�B�F�F�F�
<�<�<�9�9�9�$
�
�
�1�1�1�$G�G�G�0�0�0�&<�<�<�G�G�G�	F�	F�	F�:�:�:�$D�D�D�F�F�F�
F�
F�
F�C�C�C�Q�Q�Q�
	C�	C�	C�;�;�;�>�>�>�8?�8?�8?�t2�2�2�A�A�A�A�A�A�E�E�E�"L�L�L�O�O�O�M�M�M�
.�.�.�,
.�
.�
.�E�E�E�:$/�$/�$/�L�\�^�^�E�E��^�E�����r3r�c��eZdZd�Zd�ZdS)�AbstractBadCrcTestsc���	|j}tjtj|��d���5}|�d|�����ddd��dS#1swxYwYdS)NrYrO�afile)�zip_with_bad_crcrQrRr#r$rhryr*s   r'�test_testzip_with_bad_crcz-AbstractBadCrcTests.test_testzip_with_bad_crcs���L��'��
�_�R�Z��0�0�s�
;�
;�
;�	6�t����W�d�l�l�n�n�5�5�5�	6�	6�	6�	6�	6�	6�	6�	6�	6�	6�	6�	6����	6�	6�	6�	6�	6�	6s�)A'�'A+�.A+c��	|j}tjtj|��d���5}|�tj|jd��ddd��n#1swxYwYtjtj|��d���5}|�dd��5}|�tj|j��ddd��n#1swxYwYddd��n#1swxYwYtjtj|��d���5}|�dd��5}d|_	|�tj��5|�d��r	|�d���ddd��n#1swxYwYddd��n#1swxYwYddd��dS#1swxYwYdS)NrYrOrHr�)
rIrQrRr#r$r�r�rir@�
MIN_READ_SIZE)rCr�r��corrupt_files    r'�test_read_with_bad_crcz*AbstractBadCrcTests.test_read_with_bad_crcsO��T��'���_�R�Z��0�0�s�
;�
;�
;�	F�t����g�0�$�)�W�E�E�E�	F�	F�	F�	F�	F�	F�	F�	F�	F�	F�	F����	F�	F�	F�	F��_�R�Z��0�0�s�
;�
;�
;�	I�t����7�C�(�(�
I�L��!�!�'�"4�l�6G�H�H�H�
I�
I�
I�
I�
I�
I�
I�
I�
I�
I�
I����
I�
I�
I�
I�	I�	I�	I�	I�	I�	I�	I�	I�	I�	I�	I����	I�	I�	I�	I�
�_�R�Z��0�0�s�
;�
;�
;�	�t����7�C�(�(�
�L�-.��*��&�&�w�'9�:�:���&�+�+�A�.�.���'�+�+�A�.�.��������������������
�
�
�
�
�
�
�
�
�
�
����
�
�
�
�	�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	�	s��'A$�$A(�+A(�C7�.&C �C7� C$	�$C7�'C$	�(C7�7C;�>C;�*G�'F7�(,F �F7� F$�$F7�'F$�(F7�+G�7F;	�;G�>F;	�?G�G�GN)rr
rrJrNrdr3r'rFrFs2������6�6�6�����r3rFc� �eZdZejZdZdS)�StoredBadCrcTestssxPK ��;:r��afilehello,AworldPK ��;:r���afilePK3/N)rr
rrQr�rIrIrdr3r'rPrP5s"�������$�K�	���r3rPc� �eZdZejZdZdS)�DeflateBadCrcTestss|PKn}=FAKEnafile�H���W(�/�Iɠ=PKn}=FAKEn�afilePK33N)rr
rrQrlrIrIrdr3r'rRrRAs"�������&�K�	6���r3rRc� �eZdZejZdZdS)�Bzip2BadCrcTestss�PKnu=FAKE8nafileBZh91AY&SYԨ��@D��  �P�!����u5:���"�(HjTe?�PKnu=FAKE8n ���afilePK3[N)rr
rrQrsrIrIrdr3r'rTrTNs"�������#�K�
	���r3rTc� �eZdZejZdZdS)�LzmaBadCrcTestss�PKnu=FAKEnafile	]4I���:3`	q!.8PKnu=FAKEn ���afilePK3>N)rr
rrQrxrIrIrdr3r'rVrV^s"�������"�K�	%���r3rVc�j�eZdZ	dZdZdZdZd�Zd�Zd�Z	d�Z
e��d	���Zd
�Z
d�ZdS)
�DecryptionTestss�PKn�i.#y�?&test.txt��gly|�-�=�y�r�Z}Lg���|�䋺�)���lPKn�i.#y�?& ��test.txtPK6Ls�PK	�}38xu��zeroUT	֋�Gڋ�GUx���<M�a�X�Y&�{oEם���PKxu��PK	�}38xu��
��zeroUT֋�GUxPK?[szipfile.py encryption testsc��ttd��5}|�|j��ddd��n#1swxYwYt	jtd��|_ttd��5}|�|j��ddd��n#1swxYwYt	jtd��|_	dS)Nr>rY)
r@rrAr8rQrRr�r �data2�zip2rBs  r'rEzDecryptionTests.setUp�s��
�&�$�
�
�	 �2��H�H�T�Y����	 �	 �	 �	 �	 �	 �	 �	 �	 �	 �	 ����	 �	 �	 �	 ��?�6�3�/�/���
�'�4�
 �
 �	!�B��H�H�T�Z� � � �	!�	!�	!�	!�	!�	!�	!�	!�	!�	!�	!����	!�	!�	!�	!��O�G�S�1�1��	�	�	s!�=�A�A�<B#�#B'�*B'c���|j���tjt��|j���tjt��dSr)r�rHrTrrr[r rs r'rzDecryptionTests.tearDown�sL���������
�	�&�����	������
�	�'�����r3c��|�t|jjd��|�t|jjd��dS)N�test.txt�zero)r�rNr�rir[rs r'�test_no_passwordz DecryptionTests.test_no_password�sB��	
���,���
�z�B�B�B����,��	���?�?�?�?�?r3c��|j�d��|�t|jjd��|j�d��|�t|jjd��dS)Nsperlr^r_)r��setpasswordr�rNrir[rs r'�test_bad_passwordz!DecryptionTests.test_bad_password�sl������W�%�%�%����,���
�z�B�B�B��	���g�&�&�&����,��	���?�?�?�?�?r3c�:�|j�d��|�|j�d��|j��|j�d��|�|j�d��|j��dS)N�pythonr^s12345r_)r�rbrhri�plainr[�plain2rs r'�test_good_passwordz"DecryptionTests.test_good_password�s�������Y�'�'�'��������z�2�2�D�J�?�?�?��	���h�'�'�'���������/�/���=�=�=�=�=r3c�0�d}|�t|��5|j�d��ddd��n#1swxYwY|�t|��5|j�dd��ddd��n#1swxYwY|�t|��5|j�dd���ddd��n#1swxYwY|�t|��5|j�dd���ddd��n#1swxYwY|�t|��5d|j_|j�d��ddd��dS#1swxYwYdS)Nzpwd: expected bytes, got str�unicoder^�python)�pwd)�assertRaisesRegexrr�rbrir@r_rl)rC�expected_msgs  r'�test_unicode_passwordz%DecryptionTests.test_unicode_password�s���5��
�
#�
#�I�|�
<�
<�	,�	,��H� � ��+�+�+�	,�	,�	,�	,�	,�	,�	,�	,�	,�	,�	,����	,�	,�	,�	,��
#�
#�I�|�
<�
<�	0�	0��H�M�M�*�h�/�/�/�	0�	0�	0�	0�	0�	0�	0�	0�	0�	0�	0����	0�	0�	0�	0��
#�
#�I�|�
<�
<�	4�	4��H�M�M�*�(�M�3�3�3�	4�	4�	4�	4�	4�	4�	4�	4�	4�	4�	4����	4�	4�	4�	4��
#�
#�I�|�
<�
<�	7�	7��H���Z�X��6�6�6�	7�	7�	7�	7�	7�	7�	7�	7�	7�	7�	7����	7�	7�	7�	7��
#�
#�I�|�
<�
<�	&�	&�#�D�H�L��H�M�M�*�%�%�%�	&�	&�	&�	&�	&�	&�	&�	&�	&�	&�	&�	&����	&�	&�	&�	&�	&�	&sY�A�A	�A	�+B�B�B�9C"�"C&�)C&�D1�1D5�8D5�'F�F�Fc��|j�d��|j}d}|�|��}t	|��}|j�dd��5}|�|tj��|�	|�
��|��|�|tj��|�	|�
��d��|�|tj��|�	|�
��|��|�	|�|��||||z���|j
}d|_
d|_d|_|�dtj��|�	|�
��d��|�|tj��|�	|�|��||||z���||_
|�dtj��|�	|�
��t	|����|�dtj��|�	|�
��d��|���ddd��dS#1swxYwYdS)Nres
encryptionr^rYrr_r3)r�rbrfr7rnr@r1rTr8rhr�r9rirL�_readbuffer�_offsetr:)rCr;�	test_wordr<�bloc_lenrD�
old_read_sizes       r'r=zDecryptionTests.test_seek_tell�s�������Y�'�'�'��j��!�	��x�x�	�"�"���y�>�>��
�X�]�]�:�s�
+�
+�	�r��G�G�D�"�+�&�&�&����R�W�W�Y�Y��-�-�-��G�G�T�E�2�;�'�'�'����R�W�W�Y�Y��*�*�*��G�G�D�"�+�&�&�&����R�W�W�Y�Y��-�-�-����R�W�W�X�.�.��D��h��4F�0G�H�H�H�
�,�M� �B�� �B�N��B�J��G�G�A�r�{�#�#�#����R�W�W�Y�Y��*�*�*��G�G�D�"�+�&�&�&����R�W�W�X�.�.��D��h��4F�0G�H�H�H�,�B���G�G�A�r�{�#�#�#����R�W�W�Y�Y��C���1�1�1��G�G�A�r�{�#�#�#����R�W�W�Y�Y��*�*�*�
�G�G�I�I�I�;	�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	�	s�#I>K.�.K2�5K2N)rr
rr8rZrfrgrErr`rcr	rhror=rdr3r'rXrXms��������
	)�	�	:�
�
*�E�
�F�2�2�2����@�@�@�@�@�@��]�_�_�>�>��_�>�&�&�&�&#�#�#�#�#r3rXc�Z�eZdZed���Zd�Zd�Zd�Zd�Zd�Z	d�Z
d�Zd	�Zd
�Z
dS)�"AbstractTestsWithRandomBinaryFilesc��tdd��dztdd��z}d�d�t|��D����|_dS)Nr��@r�r_r3c	3�zK�|]6}tjdt��tdd��z��V��7dS)z<fi���rN)rbr�rrr/s  r'r~z@AbstractTestsWithRandomBinaryFiles.setUpClass.<locals>.<genexpr>�sU����7�7� !�#�K��f�h�h�w�u�d�7K�7K�.K�L�L�7�7�7�7�7�7r3)rr7r4r8)r:�	datacounts  r'r;z-AbstractTestsWithRandomBinaryFiles.setUpClass�s`���B��O�O�D�(�7�1�d�+;�+;�;�	��8�8�7�7�%*�9�%5�%5�7�7�7�7�7����r3c��ttd��5}|�|j��ddd��dS#1swxYwYdSr=r?rBs  r'rEz(AbstractTestsWithRandomBinaryFiles.setUp�rFrGc�V�tt��tt��dSrrrs r'rz+AbstractTestsWithRandomBinaryFiles.tearDown�rr3c���tj|d|��5}|�td��|�tt��ddd��dS#1swxYwYdS)NrKrL)rQrRrArr�s    r'rWz4AbstractTestsWithRandomBinaryFiles.make_test_archive�s���
�_�Q��[�
1�
1�	(�U��K�K���/�/�/��K�K���'�'�'�	(�	(�	(�	(�	(�	(�	(�	(�	(�	(�	(�	(����	(�	(�	(�	(�	(�	(s�<A � A$�'A$c��|�||��tj|d|��5}|�t��}|�t
|��t
|j����|�||j��|�|�d��|j��ddd��dS#1swxYwYdS)NrYrL)rWrQrRrirrhrnr8)rCr&rIrU�testdatas     r'r�z+AbstractTestsWithRandomBinaryFiles.zip_test�s�����q�+�.�.�.��_�Q��[�
1�
1�	D�U��z�z�&�)�)�H����S��]�]�C��	�N�N�;�;�;����X�t�y�1�1�1����U�Z�Z��7�7���C�C�C�		D�	D�	D�	D�	D�	D�	D�	D�	D�	D�	D�	D����	D�	D�	D�	D�	D�	Ds�BC�C�Cc�`�t|��D]}|�||j���dSrr�r�s  r'�	test_readz,AbstractTestsWithRandomBinaryFiles.test_read	r�r3c��|�||��tj|d|��5}g}|�t��5}	|�d��}|sn|�|���.	ddd��n#1swxYwYg}|�d��5}	|�d��}|sn|�|���.	ddd��n#1swxYwYd�|��}	|�t|	��t|j
����|�|	|j
��d�|��}
|�t|
��t|j
����|�|
|j
��ddd��dS#1swxYwYdSr�)rWrQrRr@rrir�r7rhrnr8)rCr&rIrUr�r�r�r�r��	testdata1�	testdata2s           r'r�z0AbstractTestsWithRandomBinaryFiles.zip_open_test	sy�����q�+�.�.�.��_�Q��[�
1�
1�	3�U��H����F�#�#�
/�x�/� (�
�
�c� 2� 2�I�$����O�O�I�.�.�.�	/��	
/�
/�
/�
/�
/�
/�
/�
/�
/�
/�
/����
/�
/�
/�
/��H����N�+�+�
/�x�/� (�
�
�c� 2� 2�I�$����O�O�I�.�.�.�	/��	
/�
/�
/�
/�
/�
/�
/�
/�
/�
/�
/����
/�
/�
/�
/�����*�*�I����S��^�^�S���^�^�<�<�<����Y��	�2�2�2�����*�*�I����S��^�^�S���^�^�<�<�<����Y��	�2�2�2�/	3�	3�	3�	3�	3�	3�	3�	3�	3�	3�	3�	3����	3�	3�	3�	3�	3�	3sZ�G�
0B�;G�B	�G�B	�G�)0C&�G�&C*	�*G�-C*	�.C
G�G�Gc�`�t|��D]}|�||j���dSrr�r�s  r'r�z,AbstractTestsWithRandomBinaryFiles.test_open"	r�r3c�>�|�||��tj|d|��5}g}|�t��5}	|�t
dd����}|sn|�|���<	ddd��n#1swxYwYd�|��}|�	t|��t|j����|�	||j��ddd��dS#1swxYwYdSr�)rWrQrRr@rrirr�r7rhrnr8)rCr&rIrUr�r�r�r�s        r'r�z7AbstractTestsWithRandomBinaryFiles.zip_random_open_test&	s������q�+�.�.�.��_�Q��[�
1�
1�	2�U��H����F�#�#�
/�x�/� (�
�
�g�a��.>�.>� ?� ?�I�$����O�O�I�.�.�.�	/��	
/�
/�
/�
/�
/�
/�
/�
/�
/�
/�
/����
/�
/�
/�
/��x�x��)�)�H����S��]�]�C��	�N�N�;�;�;����X�t�y�1�1�1�	2�	2�	2�	2�	2�	2�	2�	2�	2�	2�	2�	2����	2�	2�	2�	2�	2�	2s6�D�
>B�	D�B	�D�B	�A(D�D�Dc�`�t|��D]}|�||j���dSrr�r�s  r'r�z3AbstractTestsWithRandomBinaryFiles.test_random_open7	r�r3N)rr
rrr;rErrWr�r�r�r�r�r�rdr3r'rwrw�s��������7�7��[�7�
 � � �
���(�(�(�D�D�D�/�/�/�3�3�3�:4�4�4�2�2�2�";�;�;�;�;r3rwc��eZdZejZdS)� StoredTestsWithRandomBinaryFilesNr�rdr3r'r�r�<	s�������$�K�K�Kr3r�c��eZdZejZdS)�!DeflateTestsWithRandomBinaryFilesNr�rdr3r'r�r�@	r�r3r�c��eZdZejZdS)�Bzip2TestsWithRandomBinaryFilesNrrrdr3r'r�r�E	rtr3r�c��eZdZejZdS)�LzmaTestsWithRandomBinaryFilesNrwrdr3r'r�r�J	ryr3r�c�&�eZdZd�Zd�Zd�Zd�ZdS)�Tellablec�"�||_d|_dS�Nr)rD�offsetrBs  r'�__init__zTellable.__init__R	s���������r3c�Z�|j�|��}|xj|z
c_|Sr)rDrAr�)rCr8�ns   r'rAzTellable.writeV	s*���G�M�M�$�������q�����r3c��|jSr)r�rs r'r�z
Tellable.tell[	s
���{�r3c�8�|j���dSr�rD�flushrs r'r�zTellable.flush^	�����
�
�����r3N)rr
rr�rAr�r�rdr3r'r�r�Q	sP������������
�������r3r�c� �eZdZd�Zd�Zd�ZdS)�
Unseekablec��||_dSr)rDrBs  r'r�zUnseekable.__init__b	s
������r3c�6�|j�|��Sr)rDrAr�s  r'rAzUnseekable.writee	s���w�}�}�T�"�"�"r3c�8�|j���dSrr�rs r'r�zUnseekable.flushh	r�r3N)rr
rr�rAr�rdr3r'r�r�a	sA���������#�#�#�����r3r�c� �eZdZd�Zd�Zd�ZdS)�UnseekableTestsc	���d�ttfD�]�}|�|���5tj��}|�d��tj|��}tj||��dtj	��5}|�
dd��|�
dd��ddd��n#1swxYwY|�|���dd	�d
��tj|d���5}|�
d��5}|�|���d��ddd��n#1swxYwY|�
d��5}|�|���d��ddd��n#1swxYwYddd��n#1swxYwYddd��n#1swxYwY���dS)
Nc��|Srrd�r&s r'r/z/UnseekableTests.test_writestr.<locals>.<lambda>m	���!�r3��wrapper�abcrK�ones�111�twos�222r[�abcPKrYrO)r�r��subTestr#r$rA�BufferedWriterrQrRr�rSrhrlr@ri)rCr�r&�bfrUr��zopens       r'�
test_writestrzUnseekableTests.test_writestrl	s���#��h�
�:�
	?�
	?�G����g��.�.�
?�
?��J�L�L����������&�q�)�)���_�W�W�R�[�[�#�w�7I�J�J�3�e��N�N�6�6�2�2�2��N�N�6�6�2�2�2�3�3�3�3�3�3�3�3�3�3�3����3�3�3�3�� � ������b�q�b�!1�8�<�<�<��_�Q�S�1�1�1�?�T����6�*�*�?�e��(�(������v�>�>�>�?�?�?�?�?�?�?�?�?�?�?����?�?�?�?����6�*�*�?�e��(�(������v�>�>�>�?�?�?�?�?�?�?�?�?�?�?����?�?�?�?�?�?�?�?�?�?�?�?�?�?�?����?�?�?�?�
?�
?�
?�
?�
?�
?�
?�
?�
?�
?�
?����
?�
?�
?�
?��
	?�
	?s��A&G(�-C	�=G(�	C
�
G(�C
�A	G(�G�0)E%	�G�%E)
�)G�,E)
�-G�)F:	�.G�:F>
�>G�F>
�G�G(�G�G(�G�G(�(G,	�/G,	c	�J�d�ttfD�]�}|�|���5tj��}|�d��tj|��}tj||��dtj	��5}|�
tt��ttd��5}|�d��ddd��n#1swxYwY|�td��ttd��5}|�d��ddd��n#1swxYwY|�td	��ddd��n#1swxYwY|�|���dd
�d��tj|d�
��5}|�
d��5}|�|���d��ddd��n#1swxYwY|�
d	��5}|�|���d��ddd��n#1swxYwYddd��n#1swxYwYddd��n#1swxYwY���dS)Nc��|Srrdr�s r'r/z,UnseekableTests.test_write.<locals>.<lambda>}	r�r3r�r�rKr>r�r�r�r�r[r�rYrO)r�r�r�r#r$rAr�rQrRr��
addCleanuprrr@rhrlri)rCr�r&r�rU�f2r�r�s        r'�
test_writezUnseekableTests.test_write|	s���#��h�
�:�	?�	?�G����g��.�.�
?�
?��J�L�L����������&�q�)�)���_�W�W�R�[�[�#�w�7I�J�J�0�e��O�O�F�F�3�3�3��f�d�+�+�)�r�����(�(�(�)�)�)�)�)�)�)�)�)�)�)����)�)�)�)��K�K���/�/�/��f�d�+�+�)�r�����(�(�(�)�)�)�)�)�)�)�)�)�)�)����)�)�)�)��K�K���/�/�/�0�0�0�0�0�0�0�0�0�0�0����0�0�0�0�� � ������b�q�b�!1�8�<�<�<��_�Q�S�1�1�1�?�T����6�*�*�?�e��(�(������v�>�>�>�?�?�?�?�?�?�?�?�?�?�?����?�?�?�?����6�*�*�?�e��(�(������v�>�>�>�?�?�?�?�?�?�?�?�?�?�?����?�?�?�?�?�?�?�?�?�?�?�?�?�?�?����?�?�?�?�
?�
?�
?�
?�
?�
?�
?�
?�
?�
?�
?����
?�
?�
?�
?��	?�	?s��A&J�6E7�C(	�E7�(C,
�,E7�/C,
�03E7�#E	�9E7�E	
�	E7�E	
�
E7�+J�7E;�;J�>E;�?A	J�I?�)H	�I?�H
�I?�H
�I?�3)I(	�I?�(I,
�,I?�/I,
�0I?�3J�?J�J�J�J�J	�J	c	���d�ttfD�]�}|�|���5tj��}|�d��tj|��}tj||��dtj	��5}|�
dd��5}|�d��ddd��n#1swxYwY|�
dd��5}|�d��ddd��n#1swxYwYddd��n#1swxYwY|�|���dd	�d
��tj|��5}|�|�
d��d��|�|�
d��d��ddd��n#1swxYwYddd��n#1swxYwY���dS)Nc��|Srrdr�s r'r/z1UnseekableTests.test_open_write.<locals>.<lambda>�	r�r3r�r�rKr�r�r�r�r[r�)r�r�r�r#r$rAr�rQrRr�r@rhrlri)rCr�r&r�r�r�s      r'�test_open_writezUnseekableTests.test_open_write�	s
��#��h�
�:�
	@�
	@�G����g��.�.�
@�
@��J�L�L����������&�q�)�)���_�W�W�R�[�[�#�w�7I�J�J�,�d����6�3�/�/�,�5����F�+�+�+�,�,�,�,�,�,�,�,�,�,�,����,�,�,�,����6�3�/�/�,�5����F�+�+�+�,�,�,�,�,�,�,�,�,�,�,����,�,�,�,�,�,�,�,�,�,�,�,�,�,�,����,�,�,�,�
� � ������b�q�b�!1�8�<�<�<��_�Q�'�'�@�4��$�$�T�Y�Y�v�%6�%6��?�?�?��$�$�T�Y�Y�v�%6�%6��?�?�?�@�@�@�@�@�@�@�@�@�@�@����@�@�@�@�
@�
@�
@�
@�
@�
@�
@�
@�
@�
@�
@����
@�
@�
@�
@��
	@�
	@s��A&G(�D#�'C		�=D#�	C

�
D#�C

�D#�*D	�D#�D
�D#�D
�D#�G(�#D'�'G(�*D'�+AG(�2AG�G(�G�G(�G�G(�(G,	�/G,	N)rr
rr�r�r�rdr3r'r�r�k	sF������?�?�?� ?�?�?�*@�@�@�@�@r3r�c�`�eZdZed���Zd�Zd�Zd�Zd�Zd�Z	d�Z
d�Zd	�Zd
�Z
d�ZdS)
�TestsWithMultipleOpensc�b�dtd��z|_dtd��z|_dS)Nr��'r�)r�data1rZr9s r'r;z!TestsWithMultipleOpens.setUpClass�	s.���Y�u�-�-�-��	��Y�u�-�-�-��	�	�	r3c���tj|dtj��5}|�d|j��|�d|j��ddd��dS#1swxYwYdS)NrKr�r�)rQrRrlrSr�rZ)rCr&rUs   r'rWz(TestsWithMultipleOpens.make_test_archive�	s���
�_�Q��W�%9�
:�
:�	/�e��N�N�6�4�:�.�.�.��N�N�6�4�:�.�.�.�	/�	/�	/�	/�	/�	/�	/�	/�	/�	/�	/�	/����	/�	/�	/�	/�	/�	/s�7A%�%A)�,A)c	�z�t|��D�])}|�|��tj|d���5}|�d��5}|�d��5}|�d��}|�d��}||���z
}||���z
}ddd��n#1swxYwYddd��n#1swxYwY|�||��|�||j��ddd��n#1swxYwY��+dS)NrYrOr���)r(rWrQrRr@rirhr��rCr&r��zopen1�zopen2r�rZs       r'�test_same_filez%TestsWithMultipleOpens.test_same_file�	s����4���		4�		4�A��"�"�1�%�%�%�����-�-�-�
4���Y�Y�v�&�&�+�&�$�)�)�F�2C�2C�+�v�"�K�K��,�,�E�"�K�K��,�,�E��V�[�[�]�]�*�E��V�[�[�]�]�*�E�	+�+�+�+�+�+�+�+�+�+�+����+�+�+�+�+�+�+�+�+�+�+�+�+�+�+����+�+�+�+�
� � ���.�.�.�� � ���
�3�3�3�
4�
4�
4�
4�
4�
4�
4�
4�
4�
4�
4����
4�
4�
4�
4��		4�		4sZ�D.�C&�*AC	�C&�C
�C&�C
�C&�D.�&C*�*D.�-C*�.4D.�.D2	�5D2	c	��t|��D�].}|�|��tj|d���5}|�d��5}|�d��5}|�d��}|�d��}||���z
}||���z
}ddd��n#1swxYwYddd��n#1swxYwY|�||j��|�||j��ddd��n#1swxYwY��0dS)NrYrOr�r�r��	r(rWrQrRr@rirhr�rZr�s       r'�test_different_filez*TestsWithMultipleOpens.test_different_file�	s����4���		4�		4�A��"�"�1�%�%�%�����-�-�-�
4���Y�Y�v�&�&�+�&�$�)�)�F�2C�2C�+�v�"�K�K��,�,�E�"�K�K��,�,�E��V�[�[�]�]�*�E��V�[�[�]�]�*�E�	+�+�+�+�+�+�+�+�+�+�+����+�+�+�+�+�+�+�+�+�+�+�+�+�+�+����+�+�+�+�
� � ���
�3�3�3�� � ���
�3�3�3�
4�
4�
4�
4�
4�
4�
4�
4�
4�
4�
4����
4�
4�
4�
4��		4�		4sZ�D3�C&�*AC	�C&�C
�C&�C
�C&�D3�&C*�*D3�-C*�.9D3�3D7	�:D7	c	��t|��D�].}|�|��tj|d���5}|�d��5}|�d��}|�d��5}|�d��}||���z
}||���z
}ddd��n#1swxYwYddd��n#1swxYwY|�||j��|�||j��ddd��n#1swxYwY��0dS)NrYrOr�r�r�r�)rCr&r�r�r�r�rZs       r'�test_interleavedz'TestsWithMultipleOpens.test_interleaved�	s����4���
	4�
	4�A��"�"�1�%�%�%�����-�-�-�
4���Y�Y�v�&�&�/�&�"�K�K��,�,�E����6�*�*�/�f� &���C� 0� 0��������.��������.��/�/�/�/�/�/�/�/�/�/�/����/�/�/�/�/�/�/�/�/�/�/�/�/�/�/����/�/�/�/�� � ���
�3�3�3�� � ���
�3�3�3�
4�
4�
4�
4�
4�
4�
4�
4�
4�
4�
4����
4�
4�
4�
4��
	4�
	4sZ�D3�+C&�?AC	�C&�C
�C&�C
�C&�D3�&C*�*D3�-C*�.9D3�3D7	�:D7	c���t|��D�]N}|�|��tj��5}t	j|d��5}|�|�d����}|�|�d����}ddd��n#1swxYwY|�d��}|�d��}||���z
}||���z
}ddd��n#1swxYwY|�	||j
��|�	||j����PdS)NrYr�r�r�)r(rW�
contextlib�	ExitStackrQrR�
enter_contextr@rirhr�rZ)rCr&�stackr�r�r�r�rZs        r'�test_read_after_closez,TestsWithMultipleOpens.test_read_after_close�	s����4���	0�	0�A��"�"�1�%�%�%��%�'�'�
'�5��_�Q��,�,�D��"�0�0����6�1B�1B�C�C�F�"�0�0����6�1B�1B�C�C�F�D�D�D�D�D�D�D�D�D�D�D����D�D�D�D����C�(�(�����C�(�(��������&��������&��
'�
'�
'�
'�
'�
'�
'�
'�
'�
'�
'����
'�
'�
'�
'�
���U�D�J�/�/�/����U�D�J�/�/�/�/�	0�	0s7�D�AB.�"D�.B2�2D�5B2�6AD�D!	�$D!	c���t|��D�]c}tj|dtj��5}|�d|j��|�d|j��|�d��5}|�d��}ddd��n#1swxYwYddd��n#1swxYwY|�	||jdd���tj|d��5}|�d��}|�d��}ddd��n#1swxYwY|�	||j��|�	||j����edS)NrKr�r�r�rY)
r(rQrRrlrSr�rZr@rirh�rCr&r�r�r�rZs      r'�test_read_after_writez,TestsWithMultipleOpens.test_read_after_write�	s	���4���	0�	0�A����C��)=�>�>�
-�$��
�
�f�d�j�1�1�1��
�
�f�d�j�1�1�1��Y�Y�v�&�&�-�&�"�K�K��,�,�E�-�-�-�-�-�-�-�-�-�-�-����-�-�-�-�
-�
-�
-�
-�
-�
-�
-�
-�
-�
-�
-����
-�
-�
-�
-�

���U�D�J�t��t�$4�5�5�5����C�(�(�
*�D��	�	�&�)�)���	�	�&�)�)��
*�
*�
*�
*�
*�
*�
*�
*�
*�
*�
*����
*�
*�
*�
*�
���U�D�J�/�/�/����U�D�J�/�/�/�/�	0�	0sH�AB8�?B!�B8�!B%�%B8�(B%�)B8�8B<	�?B<	�;+D2�2D6	�9D6	c��t|��D�]@}tj|dtj��5}|�d|j��|�d��5}|�d��|�d|j��ddd��n#1swxYwYddd��n#1swxYwYtj|d��5}|�d��}|�d��}ddd��n#1swxYwY|�	||j��|�	||j����BdS)NrKr�r�r�rY)
r(rQrRrlrSr�r@rirZrhr�s      r'�test_write_after_readz,TestsWithMultipleOpens.test_write_after_read�	s����4���
	0�
	0�A����C��)=�>�>�
6�$��
�
�f�d�j�1�1�1��Y�Y�v�&�&�6�&��K�K��$�$�$��M�M�&�$�*�5�5�5�6�6�6�6�6�6�6�6�6�6�6����6�6�6�6�
6�
6�
6�
6�
6�
6�
6�
6�
6�
6�
6����
6�
6�
6�
6�
���C�(�(�
*�D��	�	�&�)�)���	�	�&�)�)��
*�
*�
*�
*�
*�
*�
*�
*�
*�
*�
*����
*�
*�
*�
*�
���U�D�J�/�/�/����U�D�J�/�/�/�/�
	0�
	0sG�1B8�$1B!�B8�!B%�%B8�(B%�)B8�8B<	�?B<	�+D�D	�D	c��t��}|�t��tjtd���5}td��D]E}|�d��|�d��5}	ddd��n#1swxYwY�F	ddd��n#1swxYwY|�|t����dS)NrYrOr�r�)	rrWr rQrRr4rir@rh)rC�
startcountr�r�r�s     r'�test_many_opensz&TestsWithMultipleOpens.test_many_opens
s>���Z�Z�
����w�'�'�'�
�_�W�3�
/�
/�
/�	�4��3�Z�Z�
�
���	�	�&�!�!�!��Y�Y�v�&�&��&���������������������
�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�
	
����X�Z�Z�0�0�0�0�0s6�<B'�B�B'�B�B'�B�B'�'B+�.B+c�j�tjtdtj��5}|�d|j��ddd��n#1swxYwYtjtdtj��5}|�dd��5}|�d��}|�dd��5}|�|j	��ddd��n#1swxYwY||���z
}ddd��n#1swxYwYddd��n#1swxYwY|�
||j��tjt��5}|�
|�d��|j	��ddd��dS#1swxYwYdS)NrKr�r,rYr�r�)rQrRr rlrSr�r@rirArZrh)rCr��r1r�r4s     r'�test_write_while_readingz/TestsWithMultipleOpens.test_write_while_reading
s���
�_�W�c�7�+?�
@�
@�	.�D��M�M�&�$�*�-�-�-�	.�	.�	.�	.�	.�	.�	.�	.�	.�	.�	.����	.�	.�	.�	.�
�_�W�c�7�+?�
@�
@�	#�D����6�3�'�'�
#�2���������Y�Y�v�s�+�+�)�r��H�H�T�Z�(�(�(�)�)�)�)�)�)�)�)�)�)�)����)�)�)�)�������"��	
#�
#�
#�
#�
#�
#�
#�
#�
#�
#�
#����
#�
#�
#�
#�	#�	#�	#�	#�	#�	#�	#�	#�	#�	#�	#����	#�	#�	#�	#�	
�����
�+�+�+�
�_�W�
%�
%�	<�����T�Y�Y�v�.�.��
�;�;�;�	<�	<�	<�	<�	<�	<�	<�	<�	<�	<�	<�	<����	<�	<�	<�	<�	<�	<s}�A�A�A�>D-�,D�C(�D�(C,�,D�/C,�0D�
D-�D	�D-�D	�D-�-D1�4D1�,/F(�(F,�/F,c�.�tt��dSrr�rs r'rzTestsWithMultipleOpens.tearDown
r�r3N)rr
rrr;rWr�r�r�r�r�r�r�r�rrdr3r'r�r��	s��������.�.��[�.�/�/�/�4�4�4�4�4�4�
4�
4�
4�0�0�0�0�0�0�0�0�0�
1�
1�
1�<�<�<�����r3r�c�>�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	S)
�TestWithDirectoryc�8�tjt��dSr)rTrGr rs r'rEzTestWithDirectory.setUp!
s��
�������r3c
��tjtd����5}|�t��ddd��n#1swxYwY|�tj�tj�	td������|�tj�tj�	tdd������|�tj�
tj�	tddd������dS)N�
zipdir.zipr,�br�)rQrRrrsr rqrTr��isdirr7r�r�s  r'�test_extract_dirz"TestWithDirectory.test_extract_dir$
s��
�_�X�l�3�3�
4�
4�	%���O�O�G�$�$�$�	%�	%�	%�	%�	%�	%�	%�	%�	%�	%�	%����	%�	%�	%�	%������
�
�b�g�l�l�7�C�&@�&@�A�A�B�B�B������
�
�b�g�l�l�7�C��&E�&E�F�F�G�G�G��������r�w�|�|�G�S�#�s�'K�'K�L�L�M�M�M�M�Ms�A	�	A
�A
c��tjtj�td����|���dS�Nr,)rTrGr�r7r r�rs r'�
test_bug_6050zTestWithDirectory.test_bug_6050+
s:��
������g�s�+�+�,�,�,��������r3c	��tj�td��}tj|��tj|��jdz}tjtd��5}|�
|��|jd}|�|j
�d����|�|j|dzdz��|�
|d��|jd}|�|j
d	��|�|j|dzdz��ddd��n#1swxYwYtjtd
��5}|jd}|�|j
�d����|�|j|dzdz��|jd}|�|j
d	��|�|j|dzdz��tj�td��}tj|��|�|��|�tj�tj�|d������|�t'tj|����d��ddd��dS#1swxYwYdS)
Nr�rrKrz/x/r��yr_zy/rYrhr�)rTr�r7r rGr`�st_moderQrRrrAr�rqrfrrhrrsr�rn�listdir)rC�dirpathrPr�r rhs      r'�test_write_dirz TestWithDirectory.test_write_dir0
s���'�,�,�w��,�,��
�������w�w���'�&�0��
�_�V�S�
)�
)�	G�T��J�J�w�����M�!�$�E��O�O�E�N�3�3�E�:�:�;�;�;����U�0�4�2�:��2E�F�F�F��J�J�w��$�$�$��M�!�$�E��O�O�E�N�D�1�1�1����U�0�4�2�:��2E�F�F�F�	G�	G�	G�	G�	G�	G�	G�	G�	G�	G�	G����	G�	G�	G�	G��_�V�S�
)�
)�	9�T��M�!�$�E��O�O�E�N�3�3�E�:�:�;�;�;����U�0�4�2�:��2E�F�F�F��M�!�$�E��O�O�E�N�D�1�1�1����U�0�4�2�:��2E�F�F�F��W�\�\�'�8�4�4�F��H�V�����O�O�F�#�#�#��O�O�B�G�M�M�"�'�,�,�v�s�*C�*C�D�D�E�E�E����S���F�!3�!3�4�4�a�8�8�8�	9�	9�	9�	9�	9�	9�	9�	9�	9�	9�	9�	9����	9�	9�	9�	9�	9�	9s&�0CE�E�E�1E8K6�6K:�=K:c	�(�tjtj�td����tjtd��5}|�dd��|j	d}|�
|jd��|�
|jd��ddd��n#1swxYwYtjtd��5}|j	d}|�
|j�d����|�
|jd��tj�td��}tj|��|�|��|�
tj�tj�|d������|�
tj|��dg��ddd��dS#1swxYwYdS)	Nr�rKzx/r3ri�ArYrh)rTrGr�r7r rQrRrrSr�rhrfrrqrrsr�r�)rCr�r rhs    r'�test_writestr_dirz#TestWithDirectory.test_writestr_dirJ
s.��
������g�s�+�+�,�,�,�
�_�V�S�
)�
)�	J�T��M�M�$��$�$�$��M�!�$�E����U�^�T�2�2�2����U�0�2H�I�I�I�		J�	J�	J�	J�	J�	J�	J�	J�	J�	J�	J����	J�	J�	J�	J�
�_�V�S�
)�
)�	8�T��M�!�$�E��O�O�E�N�3�3�D�9�9�:�:�:����U�0�2H�I�I�I��W�\�\�'�8�4�4�F��H�V�����O�O�F�#�#�#��O�O�B�G�M�M�"�'�,�,�v�s�*C�*C�D�D�E�E�E����R�Z��/�/�#��7�7�7�	8�	8�	8�	8�	8�	8�	8�	8�	8�	8�	8�	8����	8�	8�	8�	8�	8�	8s&�AB8�8B<�?B<�DH�H�Hc��tjtd��5}|�d��|jd}|�|jd��|�|jd��|�d��|jd}|�|jd��|�|jd��|�dd	�
��|jd}|�|jd��|�|jd��tjd
��}d|_d|_	d|_
d|_|�|��|jd}|�|jd
��|�|j|j��tj
�td��}tj|��|�|��|�t#tj|����hd���ddd��dS#1swxYwYdS)NrKrzr�
directory/i�A�directory2/r_�
directory3i�rOr�zdirectory3/zdirectory4/r�rh>rz�
directory2r��
directory4)rQrRrrGr�rhrfrr��CRCrwr�rTr�r7r rs�setr�)rCr�r �	old_zinfo�	new_zinforhs      r'�
test_mkdirzTestWithDirectory.test_mkdir[
s_��
�_�V�S�
)�
)�	o�R��H�H�[�!�!�!��K��N�E����U�^�\�:�:�:����U�0�2H�I�I�I��H�H�]�#�#�#��K��N�E����U�^�]�;�;�;����U�0�2H�I�I�I��H�H�\��H�.�.�.��K��N�E����U�^�]�;�;�;����U�0�2H�I�I�I���
�6�6�I�&<�I�#��I�M�"#�I��&'�I�#��H�H�Y������A��I����Y�/��?�?�?����Y�4�i�6M�N�N�N��W�\�\�'�8�4�4�F��H�V�����M�M�&�!�!�!����S���F�!3�!3�4�4�6m�6m�6m�n�n�n�;	o�	o�	o�	o�	o�	o�	o�	o�	o�	o�	o�	o����	o�	o�	o�	o�	o�	os�HI�I	�I	c�z�tjtd��5}|�tjd��d��|jd}|�|jd��tj	�
td��}tj|��tj
|��j}|�|d���|jd}|�|jd��|�|j|d	zd	z��tj	�
td
��}tj|��|�|��|�t%tj|����ddh��ddd��dS#1swxYwYdS)NrKr�rrr�r�)r�r_r�rhrz)rQrRrrSr�r�rhrfrTr�r7r rGr`r�rArrsr�r�)rCr�r rzrPrhs      r'� test_create_directory_with_writez2TestWithDirectory.test_create_directory_with_write{
s���
�_�V�S�
)�
)�	S�R��K�K����5�5�r�:�:�:��K��N�E����U�^�\�:�:�:�����W�l�;�;�I��H�Y�����7�9�%�%�-�D��H�H�Y�
�H�6�6�6��K��N�E����U�^�]�;�;�;����U�0�4�2�:��2E�F�F�F��W�\�\�'�8�4�4�F��H�V�����M�M�&�!�!�!����S���F�!3�!3�4�4�{�L�6Q�R�R�R�%	S�	S�	S�	S�	S�	S�	S�	S�	S�	S�	S�	S����	S�	S�	S�	S�	S�	Ss�FF0�0F4�7F4c��tt��tj�t
��rt
t
��dSdSr)rr rTr�r�rrrs r'rzTestWithDirectory.tearDown�
s<���w����
�7�>�>�&�!�!�	��6�N�N�N�N�N�	�	r3N)rr
rrEr�r�r�r�r�rrrdr3r'r�r� 
s����������N�N�N� � � �
9�9�9�48�8�8�"o�o�o�@S�S�S�*����r3r�c�,�eZdZd�Zd�Zd�Zd�Zd�ZdS)�ZipInfoTestsc�p�tj�t��}|�tj|j��d��|�|�	����|�|j
tj�
t����dS�Nztest_zipfile.py)rQr��	from_filerrh�	posixpathr!rfr!�is_dirrwrTr�rrs  r'�test_from_filezZipInfoTests.test_from_file�
s���
�_�
&�
&�x�
0�
0������+�B�K�8�8�:K�L�L�L���������%�%�%������r�w���x�'@�'@�A�A�A�A�Ar3c��tj�tjt
����}|�tj|j	��d��|�
|�����|�|jtj�t
����dSr)rQr�rr�r�rrhrr!rfr!rrwrTr�rrs  r'�test_from_file_pathlikez$ZipInfoTests.test_from_file_pathlike�
s���
�_�
&�
&�w�|�H�'=�'=�
>�
>������+�B�K�8�8�:K�L�L�L���������%�%�%������r�w���x�'@�'@�A�A�A�A�Ar3c��tj�tjt
��d��}|�tj|j	��d��|�
|�����|�|jtj
�t
����dS)Nr%)rQr�rrT�fsencoderrhrr!rfr!rrwr�rrs  r'�test_from_file_bytesz!ZipInfoTests.test_from_file_bytes�
s���
�_�
&�
&�r�{�8�'<�'<�f�
E�
E������+�B�K�8�8�&�A�A�A���������%�%�%������r�w���x�'@�'@�A�A�A�A�Ar3c���ttd��5}tj�|���d��}|�tj|j	��d��|�
|�����|�|jtj�t����ddd��dS#1swxYwYdS)Nr0r%)r@rrQr�r�filenorhrr!rfr!rrwrTr�r)rCr&rs   r'�test_from_file_filenoz"ZipInfoTests.test_from_file_fileno�
s
��
�(�D�
!�
!�	F�Q���*�*�1�8�8�:�:�v�>�>�B����Y�/���<�<�f�E�E�E����R�Y�Y�[�[�)�)�)����R�\�2�7�?�?�8�+D�+D�E�E�E�		F�	F�	F�	F�	F�	F�	F�	F�	F�	F�	F�	F����	F�	F�	F�	F�	F�	Fs�CC'�'C+�.C+c���tj�tj�t����}t
j�|d��}|�|j	d��|�
|�����|�|jt
j
��|�|jd��dS)N�stdlib_testsz
stdlib_tests/r)rTr�r�abspathrrQr�rrhrfrqrr�r�rw)rCr�rs   r'�
test_from_dirzZipInfoTests.test_from_dir�
s����'�/�/�"�'�/�/�(�";�";�<�<��
�_�
&�
&�w��
?�
?�������o�6�6�6�����	�	���$�$�$�����)�7�+=�>�>�>������q�)�)�)�)�)r3N)rr
rr	rrrrrdr3r'rr�
sk������B�B�B�B�B�B�B�B�B�F�F�F�*�*�*�*�*r3rc�X�eZdZd�Zd�Zd�Zd�Zd�Ze��d���Z	d�Z
dS)	�CommandLineTestc��tjddg|�Ri|��\}}}|�tj���d��S)N�-mrQr)r�assert_python_okr�rT�lineseprb)rC�argsrT�rc�out�errs      r'�
zipfilecmdzCommandLineTest.zipfilecmd�
s_��$�5�d�I�@��@�@�@�8>�@�@���C���{�{�2�:�,�,�.�.��6�6�6r3c�(�tjddg|�R�S)NrrQ)r�assert_python_failure)rCrs  r'�zipfilecmd_failurez"CommandLineTest.zipfilecmd_failure�
s���2�4��J�T�J�J�J�Jr3c��|���\}}}|�|d��|�d|�����|�d|�����|�d|�����|�dd��\}}}|�|d��|�|���d��dS)Nr3susageserrorsrequired�-lr)r#rhror��assertNotEqual�strip)rCrrrs    r'�test_bad_usezCommandLineTest.test_bad_use�
s����.�.�0�0���C������c�"�"�"��
�
�h��	�	���,�,�,��
�
�h��	�	���,�,�,��
�
�k�3�9�9�;�;�/�/�/��.�.�t�R�8�8���C������c�"�"�"����C�I�I�K�K��-�-�-�-�-r3c�(�td��}dD]@}|�||��}|�|���d���Atd��}|�d|��\}}}|�|d��dS)Nr�)�-tz--testsDone testingztesttar.tarr*r3)rr rh�rstripr#)rC�zip_name�optrrrs      r'�test_test_commandz!CommandLineTest.test_test_command�
s����L�)�)��!�	<�	<�C��/�/�#�x�0�0�C����S�Z�Z�\�\�?�;�;�;�;��M�*�*���.�.�t�X�>�>���C������c�"�"�"�"�"r3c��td��}tj��}tj|d��5}|�|��ddd��n#1swxYwY|����dd��}dD]0}|�||d���}|�	||���1dS)Nr�rYr-�backslashreplace)r%z--listzascii:backslashreplace)�PYTHONIOENCODING)
rr#rjrQrRrkrlrbr rh)rCr,r#�tf�expectedr-rs       r'�test_list_commandz!CommandLineTest.test_list_command�
s����L�)�)���K�M�M��
�_�X�s�
+�
+�	�r��K�K��N�N�N�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	��:�:�<�<�&�&�w�0B�C�C��!�	,�	,�C��/�/�#�x�3K�"�M�M�C����S�(�+�+�+�+�	,�	,s�A�A�!Ac�~�|�tt��ttdd���5}|�d��ddd��n#1swxYwYtjt��|�tt��tt
j	�
td��dd���5}|�d��ddd��n#1swxYwYttg}ttdztdzg}d	D�]}	|j|tg|�R�}|�
|d
��tjt��5}|�
|���|��|�
|�|d��d��|�
|�|d
��d��ddd��n#1swxYwYtt����#tt��wxYwdS)NrKr:r;ztest 1�file.txtztest 2rz	/file.txt)�-cz--creater3rstest 1r�stest 2)r�rrr@rArTrG�	TESTFNDIRrr�r7r r rhrQrRruri)rCr&�filesrur-rr�s       r'�test_create_commandz#CommandLineTest.test_create_command�
s��������'�'�'�
�&�#��
0�
0�
0�	�A�
�G�G�H����	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�
����������	�*�*�*�
�"�'�,�,�y�*�5�5�s�W�
M�
M�
M�	�QR�
�G�G�H����	�	�	�	�	�	�	�	�	�	�	����	�	�	�	���#���I��O�Y��-D�E��#�		 �		 �C�
 �%�d�o�c�7�;�U�;�;�;��� � ��c�*�*�*��_�W�-�-�F���$�$�R�[�[�]�]�H�=�=�=��$�$�R�W�W�X�a�[�%9�%9�9�E�E�E��$�$�R�W�W�X�a�[�%9�%9�9�E�E�E�F�F�F�F�F�F�F�F�F�F�F����F�F�F�F�
�w�������w��������		 �		 sU�A�A�!A�C5�5C9�<C9�.AH$�1BH�8H$�H	�H$�H	�H$�$H:c��td��}dD�]�}t��5}|�|||��}|�|d��t	j|��5}|���D�]"}tj�	||j
�dtj����}|�
��r3|�tj�|������|�tj�|����t#|d��5}|�|���|�|����ddd��n#1swxYwY��$	ddd��n#1swxYwYddd��n#1swxYwY���dS)Nr�)�-ez	--extractr3rr0)rrr rhrQrRrvrTr�r7rfr�rrrqr�r}r@ri)	rCr,r-rlrr�rr�r&s	         r'�test_extract_commandz$CommandLineTest.test_extract_command�
st���L�)�)��$�
	H�
	H�C����
H�v��o�o�c�8�V�<�<��� � ��c�*�*�*��_�X�.�.�	H�"� �k�k�m�m�H�H��!�w�|�|�F�$&�K�$7�$7��R�V�$D�$D� F� F���9�9�;�;�H� �O�O�B�G�M�M�$�,?�,?�@�@�@�@� �O�O�B�G�N�N�4�,@�,@�A�A�A�!%�d�D�!1�!1�H�Q� $� 0� 0������2�7�7�2�;�;� G� G� G�H�H�H�H�H�H�H�H�H�H�H����H�H�H�H��H�	H�	H�	H�	H�	H�	H�	H�	H�	H�	H�	H����	H�	H�	H�	H�
H�
H�
H�
H�
H�
H�
H�
H�
H�
H�
H����
H�
H�
H�
H��
	H�
	Hs[�AG�%C$F+�	<F�F+�F�F+�F�F+�G�+F/�/G�2F/�3G�G	�	G	N)rr
rr r#r(r.r4r	r:r=rdr3r'rr�
s�������7�7�7�
K�K�K�.�.�.�#�#�#�	,�	,�	,��]�_�_� � ��_� �*H�H�H�H�Hr3rc��eZdZ	d�Zd�Zd�Zd�Zeje	j
d��ejejdej
��d��e��d�������Zeje	j
d��ejejdej
��d��e��d	�������Zd
S)�TestExecutablePrependedZipc�^�tdd���|_tdd���|_dS)N�exe_with_zip�ziptestdata)r��exe_with_z64)r�exe_zip�	exe_zip64rs r'rEz TestExecutablePrependedZip.setUps.����}�E�E�E���!�.��G�G�G����r3c�<�|�tj|��d|����tj|��5}|���D]-}|�|��}|�d|���.	ddd��dS#1swxYwYdS)Nzis_zipfile failed on sFAVORITE_NUMBER)rqrQr�rRruriro)rCrrUr�r8s     r'�_test_zip_worksz*TestExecutablePrependedZip._test_zip_workss�������*�4�0�0�6��6�6�	8�	8�	8��_�T�
"�
"�	8�e��^�^�%�%�
8�
8���z�z�!�}�}���
�
�0�$�7�7�7�7�
8�	8�	8�	8�	8�	8�	8�	8�	8�	8�	8�	8�	8����	8�	8�	8�	8�	8�	8s�AB�B�Bc�:�|�|j��dSr)rGrDrs r'� test_read_zip_with_exe_prependedz;TestExecutablePrependedZip.test_read_zip_with_exe_prependeds�����T�\�*�*�*�*�*r3c�:�|�|j��dSr)rGrErs r'�"test_read_zip64_with_exe_prependedz=TestExecutablePrependedZip.test_read_zip64_with_exe_prependeds�����T�^�,�,�,�,�,r3zsys.executable required.z	/bin/bashz#Test relies on #!/bin/bash working.c�|�tj|jtjg��}|�d|��dS�Nsnumber in executable: 5)�
subprocess�check_outputrD�sys�
executablero�rC�outputs  r'�test_execute_zip2z,TestExecutablePrependedZip.test_execute_zip2 s8��
�(�$�,���)G�H�H���
�
�0�&�9�9�9�9�9r3c�|�tj|jtjg��}|�d|��dSrM)rNrOrErPrQrorRs  r'�test_execute_zip64z-TestExecutablePrependedZip.test_execute_zip64(s8��
�(�$�.�#�.�)I�J�J���
�
�0�&�9�9�9�9�9r3N)rr
rrErGrIrKr��
skipUnlessrPrQrTr	�X_OKrrTrVrdr3r'r?r?	sF������J�H�H�H�8�8�8�+�+�+�-�-�-��X����)C�D�D��X�����;���8�8�>�@�@�����:�:���@�@�E�D�:��X����)C�D�D��X�����;���8�8�>�@�@�����:�:���@�@�E�D�:�:�:r3r?c�(�eZdZGd�d��ZdS)�jaracoc�(�eZdZGd�d��ZdS)�jaraco.itertoolsc� �eZdZd�Zd�Zd�ZdS)�jaraco.itertools.Counterc�<�d|_t|��|_dSr�)r
�iter�
_orig_iter)rCr1s  r'r�z!jaraco.itertools.Counter.__init__9s����
�"&�q�'�'����r3c��|Srrdrs r'�__iter__z!jaraco.itertools.Counter.__iter__=s���r3c�N�t|j��}|xjdz
c_|Sr)�nextrar
)rC�results  r'�__next__z!jaraco.itertools.Counter.__next__@s%���d�o�.�.���
�
�a��
�
��
r3N)rr
rr�rcrgrdr3r'�Counterr^8sA������
*�
*�
*�
�
�
�
�
�
�
�
r3rhN)rr
rrhrdr3r'r�r\7s<������	�	�	�	�	�	�	�	�	�	r3r�N)rr
rr�rdr3r'rZrZ6s<���������������r3rZc��	tj�|�����D]}|�|d���|S)Nr3)rQ�CompleteDirs�
_implied_dirsrurS)r�rs  r'�add_dirsrlFsM����$�2�2�2�;�;�=�=�A�A����
���D�#�����
�Ir3c�B�	tj��}tj|d��}|�dd��|�dd��|�dd��|�dd	��|�d
d��d|_|S)
NrKr�scontent of azb/c.txtscontent of cz	b/d/e.txtscontent of ezb/f.txtscontent of fz	g/h/i.txtscontent of izalpharep.zip)r#r$rQrRrSrf)r8r�s  r'�build_alpharep_fixturernPs����0�:�<�<�D�	���s�	#�	#�B��K�K���)�)�)��K�K�	�?�+�+�+��K�K��_�-�-�-��K�K�	�?�+�+�+��K�K��_�-�-�-� �B�K�
�Ir3c�H��	tj����fd���}|S)Nc�P��|���D]}�||����dS)N)�alpharep)�zipfile_alpharep)rCrq�meths  �r'r�zpass_alpharep.<locals>.wrapperzs@����-�-�/�/�	*�	*�H��D���)�)�)�)�)�	*�	*r3)�	functools�wraps)rsr�s` r'�
pass_alphareprvts?����
�_�T���*�*�*�*���*��Nr3c��eZdZd�Zd�Zd�Zed���Zed���Zed���Z	ed���Z
ed���Zd	�Zd
�Z
ed���Zd�Zed
���Zed���Zed���Zed���Zed���Zed���Zed���Zed���Zed���Zed���Zed���ZdZd�Zd�Zd�Zed���Zed���Z ed���Z!ed���Z"ed ���Z#ed!���Z$ed"���Z%ed#���Z&ed$���Z'ed%���Z(d&S)'�TestPathc�t�tj��|_|�|jj��dSr)r�r��fixturesr�rHrs r'rEzTestPath.setUp�s/��"�,�.�.��
�����
�+�,�,�,�,�,r3c#�K�|���5t��V�ddd��n#1swxYwY|���5tt����V�ddd��dS#1swxYwYdSr)r�rnrlrs r'rrzTestPath.zipfile_alpharep�s����
�\�\�^�^�	+�	+�(�*�*�*�*�*�	+�	+�	+�	+�	+�	+�	+�	+�	+�	+�	+����	+�	+�	+�	+�
�\�\�^�^�	5�	5��1�3�3�4�4�4�4�4�	5�	5�	5�	5�	5�	5�	5�	5�	5�	5�	5�	5����	5�	5�	5�	5�	5�	5s�4�8�8�A>�>B�Bc�h�tj|j�t	������}|j}|���||jz}|�d��5}|�	|�
����ddd��n#1swxYwY|Sr=)r�r�rzr�rrDrHrfr@rArl)rCrq�tmpdirr�r��strms      r'�zipfile_ondiskzTestPath.zipfile_ondisk�s�����d�m�9�9�(�*�*�E�E�F�F�������������)�)��
�Y�Y�t�_�_�	*���J�J�v���(�(�)�)�)�	*�	*�	*�	*�	*�	*�	*�	*�	*�	*�	*����	*�	*�	*�	*��s�3(B'�'B+�.B+c��tj|��}|���\}}}|���\}}}|���\}	|���\}
|
���\}dSr�rQr��iterdir)rCrq�rootr,r��gr�r&rr��hr1s            r'�test_iterdir_and_typeszTestPath.test_iterdir_and_types�sj���|�H�%�%���,�,�.�.���1�a��)�)�+�+���1�a��y�y�{�{����y�y�{�{����y�y�{�{����r3c�.�tj|��}dSr�rQr��rCrqr�s   r'�test_is_file_missingzTestPath.test_is_file_missing�����|�H�%�%���r3c���tj|��}|���\}}}|�t��5|���ddd��dS#1swxYwYdSr)rQr�r�r�rI�rCrqr�r,r�r�s      r'�test_iterdir_on_filezTestPath.test_iterdir_on_file�s����|�H�%�%���,�,�.�.���1�a�
�
�
�z�
*�
*�	�	�
�I�I�K�K�K�	�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	�	s�A)�)A-�0A-c�.�tj|��}dSrr�r�s   r'�test_subdir_is_dirzTestPath.test_subdir_is_dir�r�r3c���tj|��}|���\}}}|�d���5}|���}ddd��dS#1swxYwYdS)Nr:r;)rQr�r�r@ri)rCrqr�r,r�r�r~r8s        r'r�zTestPath.test_open�s����|�H�%�%���,�,�.�.���1�a�
�V�V�W�V�
%�
%�	���9�9�;�;�D�	�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	�	s�A%�%A)�,A)c���	tjtjtj��d�����}|�d���d��5}|�d��ddd��n#1swxYwY|�d���dd���5}|�d	��ddd��dS#1swxYwYdS)
NrKrOzfile.binr>sbinary contentsr6r:r;z	text file)rQr�rRr#r$�joinpathr@rA)rCr�r~s   r'r�zTestPath.test_open_write�sJ��	��\�'�/�"�*�,�,�S�A�A�A�
B�
B��
�[�[��
$�
$�
)�
)�$�
/�
/�	+�4��J�J�)�*�*�*�	+�	+�	+�	+�	+�	+�	+�	+�	+�	+�	+����	+�	+�	+�	+�
�[�[��
$�
$�
)�
)�#��
)�
@�
@�	$�D��J�J�{�#�#�#�	$�	$�	$�	$�	$�	$�	$�	$�	$�	$�	$�	$����	$�	$�	$�	$�	$�	$s$�#B�B	�B	�:C�C!�$C!c��	tjtt������}|�t
��5|�d�����ddd��dS#1swxYwYdS�Nr�)rQr�rlrnr��IsADirectoryErrorr�r@r�s  r'�test_open_extant_directoryz#TestPath.test_open_extant_directory����	��\�(�#9�#;�#;�<�<�
=�
=��
�
�
�0�
1�
1�	$�	$��K�K����!�!�#�#�#�	$�	$�	$�	$�	$�	$�	$�	$�	$�	$�	$�	$����	$�	$�	$�	$�	$�	$��	(A>�>B�Bc��tj|��}|�t��5|�d���dd���ddd��n#1swxYwY|�t��5|�d���dd��ddd��dS#1swxYwYdS)Nr�r0r:r;)rQr�r�rIr�r@r�s   r'�test_open_binary_invalid_argsz&TestPath.test_open_binary_invalid_args�sJ���|�H�%�%��
�
�
�z�
*�
*�	@�	@��M�M�'�"�"�'�'��w�'�?�?�?�	@�	@�	@�	@�	@�	@�	@�	@�	@�	@�	@����	@�	@�	@�	@�
�
�
�z�
*�
*�	7�	7��M�M�'�"�"�'�'��g�6�6�6�	7�	7�	7�	7�	7�	7�	7�	7�	7�	7�	7�	7����	7�	7�	7�	7�	7�	7s#�+A&�&A*�-A*�*C�C�	Cc��	tjtt������}|�t
��5|�d�����ddd��dS#1swxYwYdS)N�z)rQr�rlrnr��FileNotFoundErrorr�r@r�s  r'�test_open_missing_directoryz$TestPath.test_open_missing_directory�r�r�c�^�tj|��}|���\}}}dSrr�r�s      r'r�zTestPath.test_read�s(���|�H�%�%���,�,�.�.���1�a�a�ar3c���tj|��}|�d��}|�d���d���d��}dS�Nr�r�r�e.txt�rQr�r��rCrqr�r,r�s     r'�
test_joinpathzTestPath.test_joinpath�sS���|�H�%�%���M�M�'�"�"���M�M�#���'�'��,�,�5�5�g�>�>���r3c�\�tj|��}|�ddd��}dS)Nr�rr�r�)rCrqr�r�s    r'�test_joinpath_multiplezTestPath.test_joinpath_multiple�s*���|�H�%�%���M�M�#�s�G�,�,���r3c�N�tj|��}|dz}|dzdzdz}dSr�r�r�s     r'�test_traverse_truedivzTestPath.test_traverse_truediv�s1���|�H�%�%���7�N���3�J���w�&���r3c�L�	tdddd���}t|��dS)Nzzipfile.Path(alpharep) / 'a'z(test)�evalT)�sourcerfrP�dont_inherit)�compiler�)rCrq�codes   r'�test_traverse_simpledivz TestPath.test_traverse_simpledivs:��	��1����	
�
�
��	
�T�
�
�
�
�
r3c��	|�|��}tjt|����}t	j|��dSr)rr�r�rtrQ)rCrqr�pathlikes    r'�test_pathlike_constructionz#TestPath.test_pathlike_constructionsI��	��,�,�X�6�6���<��N� 3� 3�4�4����X�����r3c�\�tj|��}|tjd��zdSr�)rQr�r�r�s   r'�test_traverse_pathlikezTestPath.test_traverse_pathlikes,���|�H�%�%���w�|�C� � � � � � r3c�.�tj|��}dSrr�r�s   r'�test_parentzTestPath.test_parentr�r3c�.�tj|��}dSrr�r�s   r'�test_dir_parentzTestPath.test_dir_parent#r�r3c�.�tj|��}dSrr�r�s   r'�test_missing_dir_parentz TestPath.test_missing_dir_parent)r�r3c���	tj|��}|���\}}}|�dd��|�dd��|dz���\}dS)Nr�r�zbar/baz.txtr/r�)rQr�r�rS)rCrqr�r,r�r�r/s       r'�test_mutabilityzTestPath.test_mutability.st��	��|�H�%�%���,�,�.�.���1�a����)�U�+�+�+����-��/�/�/���,�'�'�)�)����r3i c���	tj��}tj|d��}t	t
t
|j����D]}|�||���d|_	|S)NrKrY)
r#r$rQrR�maprtr4�HUGE_ZIPFILE_NUM_ENTRIESrSrP)rCr~r��entrys    r'�huge_zipfilezTestPath.huge_zipfile?sh��O��z�|�|��
�_�T�3�
'�
'����e�D�$A�B�B�C�C�	&�	&�E��K�K��u�%�%�%�%�����	r3c���	tj|�����}tj�|�����}|D]}|�d���dS)N�suffix)rQr�r�rZr�rhr�r�)rCr��entriesr�s    r'�test_joinpath_constant_timez$TestPath.test_joinpath_constant_timeHsp��	��|�D�-�-�/�/�0�0���"�*�*�4�<�<�>�>�:�:���	%�	%�E��N�N�8�$�$�$�$�	%�	%r3c�v�d�td��D��}tj�|��dS)Nc�l�g|]1}d�tjt|��z����2S)r)r7�string�ascii_lowercasert)r0r�s  r'r2z:TestPath.test_implied_dirs_performance.<locals>.<listcomp>Us2��P�P�P�a�����/�#�a�&�&�8�9�9�P�P�Pr3r�)r4rQrjrkr�s  r'�test_implied_dirs_performancez&TestPath.test_implied_dirs_performanceTs8��P�P�5��<�<�P�P�P����*�*�4�0�0�0�0�0r3c��|�|��}tj|��5}td��D]+}tj|d���d����,	ddd��dS#1swxYwYdS)Nr�r�r:r;)rrQrRr4r��	read_text)rCrqrZ�reps    r'�test_read_does_not_closez!TestPath.test_read_does_not_closeXs����&�&�x�0�0��
�_�X�
&�
&�	H�$��Q�x�x�
H�
H����T�7�+�+�5�5�w�5�G�G�G�G�
H�	H�	H�	H�	H�	H�	H�	H�	H�	H�	H�	H�	H����	H�	H�	H�	H�	H�	Hs�<A4�4A8�;A8c�L�Gd�dtj��}||��}dS)Nc��eZdZdS)�(TestPath.test_subclass.<locals>.SubclassN)rr
rrdr3r'�Subclassr�as�������Dr3r�r�)rCrqr�r�s    r'�
test_subclasszTestPath.test_subclass_sC��	�	�	�	�	�w�|�	�	�	��x��!�!���r3c�.�tj|��}dSrr�r�s   r'�
test_filenamezTestPath.test_filenamegr�r3c�0�	tj|��}dSrr�r�s   r'�test_root_namezTestPath.test_root_namels��	��|�H�%�%���r3c�T�	tj|��}|dz}|dzdz}|dz}dS�Nr�r��filename.tar.gzrr��rCrqr�r�r�rs      r'�test_suffixzTestPath.test_suffixtsC��	�
�|�H�%�%��
�7�N��
�3�J�*�*��
�3�J���r3c�^�	tj|��}|dz}|dzdz}|dz}|dz}dS)Nr�r�r�rz.hgrcr�)rCrqr�r�r�rr�s       r'�
test_suffixeszTestPath.test_suffixes�sN��	�
�|�H�%�%��
�7�N��
�3�J�*�*��
�3�J��
�7�N���r3c�T�	tj|��}|dz}|dzdz}|dz}dSr�r�r�s      r'�	test_stemzTestPath.test_stem�sC��	��|�H�%�%��
�7�N��
�3�J�*�*��
�3�J���r3c�F�tj|��}d|j_dS)Nzfoo/bar.zip)rQr�r�rfr�s   r'�test_root_parentzTestPath.test_root_parent�s!���|�H�%�%��*��	���r3c�,�	d|_tj|��}|�t��5|jddd��n#1swxYwY|�t��5|jddd��n#1swxYwY|dz}dSr�)rfrQr�r�rr�parent)rCrqr��subs    r'�test_root_unnamedzTestPath.test_root_unnamed�s��	�!����|�H�%�%��
�
�
�y�
)�
)�	�	��I�I�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�
�
�
�y�
)�
)�	�	��K�K�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	��S�j���s#�A�A�A�0B�B�Bc��tdtjfi��}|���D]%}||���d��j}�&dS)N�	PathChildzsome dir)�typerQr�rrr�r�)rCrqr:rZs    r'�test_inheritancezTestPath.test_inheritance�s\���;�����4�4���-�-�/�/�	)�	)�H��3�x�=�=�)�)�*�5�5�<�D�D�	)�	)r3N))rr
rrErrrrvr�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�rdr3r'rxrx�s�������-�-�-�5�5�5�����
�
��]�
��:�:��]�:�����]���&�&��]�&��&�&��]�&�	$�	$�	$�$�$�$��7�7��]�7�$�$�$��1�1��]�1��?�?��]�?��?�?��]�?�
�?�?��]�?��
�
��]�
�����]���!�!��]�!��4�4��]�4�
�-�-��]�-�
�7�7��]�7��8�8��]�8� '�����	>�	>�	>�1�1�1��H�H��]�H��0�0��]�0��=�=��]�=��A�A��]�A�����]��$� � ��]� �*����]�� �2�2��]�2�����]��"�)�)��]�)�)�)r3rxc���eZdZgd�Zd�d��d�d��d�d��gZd�Zd	�Zd
�Zd�Z	d�Z
d
�Zd�Zd�Z
d�Zd�ZdS)�EncodedMetadataTests)u一u二u三zThis is pure ASCII.
r-u%これは現代的日本語です。
r:u"これは古い日本語です。
�	shift_jisc��|�tt��ddg|jdd�z}t	jtd���5}t
||j��D]&\}}|�||tj	���'	ddd��n#1swxYwYttd��5}|���}ddd��n#1swxYwYt
|j|dd���D]A\}}|�|�
d��|�
d����}�Bttd	��5}|�|��ddd��dS#1swxYwYdS)
N�n1�n2r�rKrOr0r-r�r>)r�rr�
file_namesrQrRr��file_contentrSr�r@rir�rbrA)rC�placeholdersr2�tempr�r8rs       r'rEzEncodedMetadataTests.setUp�s$�������'�'�'��d�|�d�o�a�b�b�&9�9��
�_�V�#�
.�
.�
.�	?�"�!$�\�4�3D�!E�!E�
?�
?�
��g����D�'�7�+=�>�>�>�>�
?�	?�	?�	?�	?�	?�	?�	?�	?�	?�	?�	?����	?�	?�	?�	?��&�$�
�
�	�2��7�7�9�9�D�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	��d�o�|�B�Q�B�/?�@�@�	:�	:�J�D�$��<�<����G� 4� 4� $���K� 8� 8�:�:�D�D�
�&�$�
�
�	�2��H�H�T�N�N�N�	�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	�	s6�=B�B�!B�:C�C�"C�E=�=F�Fc�\�|���}|�t|��t|����|���}d�|D��}|�t|��t|����t	||��D]�\}}|�|��}|�|j|��|�|jt|����|�|�	|��|����dS)Nc��g|]	}|j��
Srdre)r0rs  r'r2z3EncodedMetadataTests._test_read.<locals>.<listcomp>�s��-�-�-����-�-�-r3)
rurh�sortedrvr�rxrfrwrnri)	rCrU�expected_namesr�r�r�rr�r�s	         r'�
_test_readzEncodedMetadataTests._test_read�s����� � ����������~�(>�(>�?�?�?���� � ��-�-�u�-�-�-����������~�(>�(>�?�?�?�!��1A�B�B�	8�	8�M�D�'��=�=��&�&�D����T�]�D�1�1�1����T�^�S��\�\�:�:�:����U�Z�Z��-�-�w�7�7�7�7�		8�	8r3c��tjtdd���5}|�||j|j��ddd��dS#1swxYwYdS)NrYr���metadata_encoding)rQrRrr�r�r�r)s  r'� test_read_with_metadata_encodingz5EncodedMetadataTests.test_read_with_metadata_encoding�s���
�_�V�S�K�
H�
H�
H�	G�E��O�O�E�4�?�D�4E�F�F�F�	G�	G�	G�	G�	G�	G�	G�	G�	G�	G�	G�	G����	G�	G�	G�	G�	G�	Gs�"A�A�Ac��d�|jdd�D��|jdd�z}tjtd��5}|�|||j��ddd��dS#1swxYwYdS)Nc�^�g|]*}|�d���d����+S�r��cp437�rbr��r0rs  r'r2zLEncodedMetadataTests.test_read_without_metadata_encoding.<locals>.<listcomp>
�B��;�;�;�"��+�+�k�2�2�9�9�'�B�B�;�;�;r3r�rY�r�rQrRrr�r��rCr�rUs   r'�#test_read_without_metadata_encodingz8EncodedMetadataTests.test_read_without_metadata_encoding
s���;�;�&*�o�b�q�b�&9�;�;�;�=A�_�Q�R�R�=P�Q��
�_�V�S�
)�
)�	F�U��O�O�E�>�4�3D�E�E�E�	F�	F�	F�	F�	F�	F�	F�	F�	F�	F�	F�	F����	F�	F�	F�	F�	F�	Fs�A.�.A2�5A2c��d�|jdd�D��|jdd�z}tjtdd���5}|�|||j��ddd��dS#1swxYwYdS)Nc�^�g|]*}|�d���d����+S)r��koi8-urrs  r'r2zSEncodedMetadataTests.test_read_with_incorrect_metadata_encoding.<locals>.<listcomp>
sB��;�;�;�"��+�+�k�2�2�9�9�(�C�C�;�;�;r3r�rYrr�rrs   r'�*test_read_with_incorrect_metadata_encodingz?EncodedMetadataTests.test_read_with_incorrect_metadata_encoding

s���;�;�&*�o�b�q�b�&9�;�;�;�=A�_�Q�R�R�=P�Q��
�_�V�S�H�
E�
E�
E�	F���O�O�E�>�4�3D�E�E�E�	F�	F�	F�	F�	F�	F�	F�	F�	F�	F�	F�	F����	F�	F�	F�	F�	F�	Fs�A0�0A4�7A4c�@�|�t��5tjtdd���ddd��n#1swxYwY|�t��5tjtdd���ddd��dS#1swxYwYdS)NrYr-r�r:)r��UnicodeDecodeErrorrQrRrrs r'�+test_read_with_unsuitable_metadata_encodingz@EncodedMetadataTests.test_read_with_unsuitable_metadata_encoding
s:���
�
�1�
2�
2�	D�	D��O�F�C�7�C�C�C�C�	D�	D�	D�	D�	D�	D�	D�	D�	D�	D�	D����	D�	D�	D�	D�
�
�
�1�
2�
2�	D�	D��O�F�C�7�C�C�C�C�	D�	D�	D�	D�	D�	D�	D�	D�	D�	D�	D�	D����	D�	D�	D�	D�	D�	Ds#�A�A�A�)B�B�Bc�(�d}d�|jdd�D��|jdd�z}|�|��g|j�d�R}tjt
d��5}|�|d��|�t|�	����t|����ddd��n#1swxYwYtjt
d��5}|�
|||��ddd��n#1swxYwYtjt
dd�	��5}|�t|�	����t|����tt||����D]�\}\}}|�
|��}|�|j|��|�|jt!|����|dkrM|�tj��5|�|��ddd��n#1swxYwY��|�|�|��|����	ddd��dS#1swxYwYdS)
Nu四c�^�g|]*}|�d���d����+Srrrs  r'r2z?EncodedMetadataTests.test_read_after_append.<locals>.<listcomp>
rr3r�s
newcontentr,�
newcontentrYr�r�)r�r�r�rQrRrrSrhr�rur��	enumerater�rxrfrwrnr�r�ri)	rC�newnamer�r�rUr1rr�r�s	         r'�test_read_after_appendz+EncodedMetadataTests.test_read_after_append
s�����;�;�&*�o�b�q�b�&9�;�;�;�=A�_�Q�R�R�=P�Q�����g�&�&�&�>�T�.�>�
�>�>��
�_�V�S�
)�
)�	O�U��N�N�7�L�1�1�1����V�E�N�N�$4�$4�5�5�v�n�7M�7M�N�N�N�	O�	O�	O�	O�	O�	O�	O�	O�	O�	O�	O����	O�	O�	O�	O��_�V�S�
)�
)�	E�U��O�O�E�>�3C�D�D�D�	E�	E�	E�	E�	E�	E�	E�	E�	E�	E�	E����	E�	E�	E�	E��_�V�S�K�
H�
H�
H�
	@�E����V�E�N�N�$4�$4�5�5�v�n�7M�7M�N�N�N�&/��N�DT�0U�0U�&V�&V�
@�
@�"��?�D�'��}�}�T�*�*��� � ����5�5�5�� � ����W���>�>�>��q�5�@��*�*�7�+=�>�>�)�)��
�
�4�(�(�(�)�)�)�)�)�)�)�)�)�)�)����)�)�)�)���$�$�U�Z�Z��%5�%5�w�?�?�?�?�
@�
	@�
	@�
	@�
	@�
	@�
	@�
	@�
	@�
	@�
	@�
	@�
	@����
	@�
	@�
	@�
	@�
	@�
	@s\�'AC�C�C�1D�D�D�<C%J�!I�7J�I�J�
I�.J�J�Jc��tj}dD]C}|�td��5|d|d���ddd��n#1swxYwY�DdS)N)rKr�r,z^metadata_encoding is onlyznonesuch.zipr�r�)rQrRrmrI)rC�ZFrPs   r'�!test_write_with_metadata_encodingz6EncodedMetadataTests.test_write_with_metadata_encoding3
s���
�_��#�	H�	H�D��'�'�
�(D�F�F�
H�
H���>�4�;�G�G�G�G�
H�
H�
H�
H�
H�
H�
H�
H�
H�
H�
H����
H�
H�
H�
H��	H�	Hs�A�A	�A	c�.�d}gd�}t��5}t��5}|�ttj|��ddd��n#1swxYwYddd��n#1swxYwY|�|���d��|�||�����t��5}t	jddtg��ddd��n#1swxYwY|���}t��5}t	jddtg��ddd��n#1swxYwY|���}|j
D]}|�||���dS)Nz/Non-conforming encodings not supported with -c.)�--metadata-encoding=shift_jisr7�nonesuchrrrr*r%)rr
r��
SystemExitrQ�mainrhrlrorr�)rC�errmsgr�stdout�stderr�listingrs       r'�test_cli_with_metadata_encodingz4EncodedMetadataTests.test_cli_with_metadata_encoding:
s���B��N�N�N��
�
�
�	B�&� �"�"�
B�f��!�!�*�g�l�D�A�A�A�
B�
B�
B�
B�
B�
B�
B�
B�
B�
B�
B����
B�
B�
B�
B�	B�	B�	B�	B�	B�	B�	B�	B�	B�	B�	B����	B�	B�	B�	B�	
������*�*�B�/�/�/��
�
�f�f�o�o�/�/�0�0�0�
�
�
�	J�&��L�9�4��H�I�I�I�	J�	J�	J�	J�	J�	J�	J�	J�	J�	J�	J����	J�	J�	J�	J��/�/�#�#��
�
�
�	J�&��L�9�4��H�I�I�I�	J�	J�	J�	J�	J�	J�	J�	J�	J�	J�	J����	J�	J�	J�	J��/�/�#�#���O�	)�	)�D��M�M�$��(�(�(�(�	)�	)sX�A.�'A�A.�A	�A.�A	�A.�.A2�5A2�D�D�D�-E�E�Ec��tjt��|�tt��|jD]m}	tjtj�t|�����;#t$rY�Gt$r|�d|����Y�jwxYwtj
ddttg��tjt��}|jD]}|�||���dS)Nzcannot encode file name rr<)rTrGr r�rr�r`r�r7r�UnicodeEncodeErrorr_rQrrr�ro)rCr|r"rs    r'�'test_cli_with_metadata_encoding_extractz<EncodedMetadataTests.test_cli_with_metadata_encoding_extractM
s��
�����������(�(�(��/�	A�	A�B�
A�������W�b�1�1�2�2�2�2���
�
�
���%�
A�
A�
A��
�
�?��?�?�@�@�@�@�@�
A����	��5�t�V�W�M�N�N�N��*�W�%�%���O�	)�	)�D��M�M�$��(�(�(�(�	)�	)s�7A<�<
B,�!B,�+B,N)rr
rr�rbr�rEr�r�r	r
rrrr#r&rdr3r'r�r��s������/�/�/�J��&�&�w�/�/�T�[�[�\c�d�d�N�U�U�Va�b�b��L����(8�8�8�"G�G�G�
F�F�F�F�F�F�D�D�D�@�@�@�4H�H�H�)�)�)�&)�)�)�)�)r3r��__main__)^r�r��importlib.utilrr#r�rTr�rr�rbrNrPrrr��
unittest.mockr@rQrt�tempfilerrrr�test.supportrrr	r
rrr
r�test.support.os_helperrrrrrrr r8r5�
DATAFILES_DIRrXr(r*�TestCaserrhrqrvr{r�r�r�r�r�r�r�r�rrrVr�rFrPrRrTrVrXrwr�r�r�r�r�r�r�r�r�rrr?�tuple�consumerZrlrnrvrxr�rrrdr3r'�<module>r1sA��������������	�	�	�	�����	�	�	�	���������
�
�
�
�
�
�
�
�����
�
�
�
�����������������������#�"�"�"�"�"�-�-�-�-�-�-�-�-�-�-�&�&�&�&�&�&�����������������������������������
�3�,���S�L�	���#�
�T�T�T��
#�#�#�Q�Q�Q�Q�Q�Q�Q�Q�hJ�J�J�J�J� ;� (� 1�J�J�J�D����
H�
H�
H�
H�
H�!<�!)�!2�
H�
H���
H�����$�$�$�$�$�:�'�0�$�$���$�����#�#�#�#�#�9�&�/�#�#���#�
O�O�O�O�O�O�O�O�dCG�CG�CG�CG�CG�"?�"*�"3�CG�CG�CG�L����'�'�'�'�'�#@�#+�#4�'�'���'�����$�$�$�$�$�!>�!)�!2�$�$���$�����#�#�#�#�#� =� (� 1�#�#���#�
 D� D� D� D� D� D� D� D�D%�%�%�%�%�+�X�->�%�%�%�����'�'�'�'�'�,�h�.?�'�'���'�����$�$�$�$�$�*�H�,=�$�$���$�����#�#�#�#�#�)�8�+<�#�#���#�~�~�~�~�~�X�&�~�~�~�B}�}�}�}�}�8�$�}�}�}�@S�S�S�S�S��"�S�S�S�l��������>
�
�
�
�
�+�X�->�
�
�
�����
7�
7�
7�
7�
7�,�h�.?�
7�
7���
7�����
�
�
�
�
�*�H�,=�
�
���
�����&�&�&�&�&�)�8�+<�&�&���&�q�q�q�q�q�h�'�q�q�q�hX;�X;�X;�X;�X;�X;�X;�X;�v%�%�%�%�%�'I�'/�'8�%�%�%�����'�'�'�'�'�(J�(0�(9�'�'���'�����$�$�$�$�$�&H�&.�&7�$�$���$�����#�#�#�#�#�%G�%-�%6�#�#���#��������� ��������4@�4@�4@�4@�4@�h�'�4@�4@�4@�n����z�z�z�z�z�X�.�z�z���z�zs�s�s�s�s��)�s�s�s�l *� *� *� *� *�8�$� *� *� *�FMH�MH�MH�MH�MH�h�'�MH�MH�MH�`%:�%:�%:�%:�%:��!2�%:�%:�%:�R��
�
�
�
�
�
�
�
� ���!�!�!�H���J)�J)�J)�J)�J)�x� �J)�J)�J)�Z
N)�N)�N)�N)�N)�8�,�N)�N)�N)�b�z����H�M�O�O�O�O�O��r3