Current File : //usr/local/apps/python3/lib/python3.11/test/__pycache__/test_zipfile.cpython-311.opt-2.pyc
�

�Ke�+��Z	�ddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
mZddlZddlZddlmZddlZddlZddlmZddlmZmZmZddlmZddlmZmZmZmZm Z m!Z!m"Z"ddl#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)e$dzZ*e$d	zZ+d
Z,dZ-gd�Z.d
�Z/Gd�d��Z0Gd�de0ej1��Z2e��Gd�de0ej1����Z3e��Gd�de0ej1����Z4e��Gd�de0ej1����Z5Gd�d��Z6Gd�de6ej1��Z7e��Gd�de6ej1����Z8e��Gd�de6ej1����Z9e��Gd �d!e6ej1����Z:Gd"�d#��Z;Gd$�d%e;ej1��Z<e��Gd&�d'e;ej1����Z=e��Gd(�d)e;ej1����Z>e��Gd*�d+e;ej1����Z?Gd,�d-ej1��Z@Gd.�d/ej1��ZAGd0�d1ej1��ZBGd2�d3��ZCGd4�d5eCej1��ZDe��Gd6�d7eCej1����ZEe��Gd8�d9eCej1����ZFe��Gd:�d;eCej1����ZGGd<�d=ej1��ZHGd>�d?��ZIGd@�dAeIej1��ZJe��GdB�dCeIej1����ZKe��GdD�dEeIej1����ZLe��GdF�dGeIej1����ZMGdH�dI��ZNGdJ�dK��ZOGdL�dMej1��ZPe��GdN�dOej1����ZQGdP�dQej1��ZRGdR�dSej1��ZSGdT�dUej1��ZTGdV�dWej1��ZUeVZWGdX�dY��ZXdZ�ZYd[�ZZd\�Z[Gd]�d^ej1��Z\Gd_�d`ej1��Z]Gda�dbej1��Z^e_dckrej`��dSdS)d�N)�assert_python_ok)�
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  �;/usr/local/apps/python3/lib/python3.11/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>8sH��8�8�8���H� �&�(�(�m�,�-4�6�6�8�8�8�r4)�range�FIXEDTEST_SIZE�line_gen�join�data��clss r(�
setUpClassz&AbstractTestsWithSourceFile.setUpClass6sE��8�8�!&�~�!6�!6�8�8�8����8�8�C�L�)�)����r4c��ttd��5}|�|j��ddd��dS#1swxYwYdS�N�wb��openr�writer9��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�ZipFilerBr�writestrr9rAr7)rDr'rJrK�kwargs�zipfp�lines       r(�make_test_archivez-AbstractTestsWithSourceFile.make_test_archiveBsX��!,�}�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�rrMrN)�file��	File Namer�Modified�Size��%Y-%m-%d�%H:%M:%S�rOc��g|]	}|j��
S���filenamer0s  r(r3z8AbstractTestsWithSourceFile.zip_test.<locals>.<listcomp>q���/�/�/�A�Q�Z�/�/�/r4)rXrRrS�assertEqual�readrr9r$�StringIO�printdir�getvalue�
splitlines�len�assertIn�split�
assertTrue�time�strptime�str�namelist�infolist�	file_size�getinforg�testzip)rDr'rJrKrVrE�	directory�lines�fn�date�time_�size�names�infosr2�nm�infos                 r(�zip_testz$AbstractTestsWithSourceFile.zip_testMs������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�rJ�rDr's  r(�
test_basicz&AbstractTestsWithSourceFile.test_basic��;���4���	/�	/�A��M�M�!�T�-�.�.�.�.�	/�	/r4c���|�||��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�NrZT�rMr4)
rXrRrSrArrj�appendrir8r9)	rDr'rJrV�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�rJr�s  r(�	test_openz%AbstractTestsWithSourceFile.test_open��=���4���	4�	4�A����q�$�"2�3�3�3�3�	4�	4r4c��tjt��}|�||j��tj|d|j��5}|�|jt��ddd��dS#1swxYwYdS�NrZ)
�pathlib�Pathr!r�rJrRrS�assertIsInstancergru)rD�pathrVs   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�NrZTr`�r4)rXrRrSrArrjrr�rir8r9)rDr'rJrVr�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�rJr�s  r(�test_random_openz,AbstractTestsWithSourceFile.test_random_open��=���4���	;�	;�A��%�%�a��)9�:�:�:�:�	;�	;r4c��|�||��tj|d��5}|�t��5}g}	|�d��}|sn|�|���.	ddd��n#1swxYwYddd��n#1swxYwY|�d�|��|j	��dS)NrZT���r4)
rXrRrSrAr�read1r�rir8r9�rDr'rJrV�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�rJr�s  r(�
test_read1z&AbstractTestsWithSourceFile.test_read1�s=���4���	5�	5�A�����4�#3�4�4�4�4�	5�	5r4c��|�||��tj|d��5}|�t��5}g}	|�d��}|�t|��d��|sn|�|���Q	ddd��n#1swxYwYddd��n#1swxYwY|�	d�
|��|j��dS)NrZT�
r4)rXrRrSrArr��assertLessEqualror�rir8r9r�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�rJr�s  r(�
test_read1_10z)AbstractTestsWithSourceFile.test_read1_10��=���4���	8�	8�A��"�"�1�d�&6�7�7�7�7�	8�	8r4c��|�||��tj|d��5}|�t��5}d}	|���}|sn#||z
}|�d��}|sn||z
}�:ddd��n#1swxYwYddd��n#1swxYwY|�||j��dS)NrZr4T�d)	rXrRrSrAr�readlinerjrir9)rDr'rJrVr�r9rjs       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�rJr�s  r(�test_readline_readz.AbstractTestsWithSourceFile.test_readline_read�s=���4���	=�	=�A��'�'��4�+;�<�<�<�<�	=�	=r4c�\�|�||��tj|d��5}|�t��5}|jD],}|���}|�||���-	ddd��n#1swxYwYddd��dS#1swxYwYdSr�)rXrRrSrArr7r�ri)rDr'rJrVr�rW�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�rJr�s  r(�
test_readlinez)AbstractTestsWithSourceFile.test_readliner�r4c�~�|�||��tj|d��5}|�t��5}|���}ddd��n#1swxYwYt
|j|��D]\}}|�||���	ddd��dS#1swxYwYdSr�)	rXrRrSrAr�	readlines�zipr7ri)rDr'rJrVr��ziplinesrW�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�rJr�s  r(�test_readlinesz*AbstractTestsWithSourceFile.test_readlines�=���4���	9�	9�A��#�#�A�t�'7�8�8�8�8�	9�	9r4c�V�|�||��tj|d��5}|�t��5}t|j|��D]\}}|�||���	ddd��n#1swxYwYddd��dS#1swxYwYdSr�)rXrRrSrArr�r7ri)rDr'rJrVr�rWr�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�rJr�s  r(�test_iterlinesz*AbstractTestsWithSourceFile.test_iterlines!r�r4c��	tjtd|j��5}|�dd��ddd��n#1swxYwYtjtd|j��5}|�d��5}|�|�d��d��|�|�d��d��ddd��n#1swxYwYddd��dS#1swxYwYdS)NrLrN�12rZr`�1�2)rRrSr!rJrTrArirj)rDrV�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)NrL�b.txt�hello world��
compress_type)rRrSr!rTrJryrir�)rDrVr�s   r(�test_writestr_compressionz5AbstractTestsWithSourceFile.test_writestr_compression1sa������-�-��
���w�
�T�=M��N�N�N��}�}�W�%�%������+�T�-=�>�>�>�>�>r4c���tjtdd���}|�dd|j���|�dd|jd�	��|�d��}|�|j|j��|�|jd��|�d��}|�|j|j��|�|jd��dS)
NrLr`�rK�a.txtr�r�r��)r�rK)	rRrSr!rTrJryrir��_compresslevel)rDrV�a_info�b_infos    r(�test_writestr_compresslevelz7AbstractTestsWithSourceFile.test_writestr_compresslevel7s�������A�>�>�>��
���w�
�T�=M��N�N�N�
���w�
�T�=M�%&�	�	(�	(�	(����w�'�'������-�t�/?�@�@�@�����.��2�2�2����w�'�'������-�t�/?�@�@�@�����.��2�2�2�2�2r4c��dD]�}|dz}t|��}tjtj��d|j��5}|�d|��|�dd��5}|�|��}|�	t|��|��ddd��n#1swxYwYddd��n#1swxYwY��dS)N)r`i�iii@r`rL�foorZ)rrRrSr$r%rJrTrArjriro)rD�	test_sizerx�junk�zipfrE�bufs       r(�test_read_return_sizez1AbstractTestsWithSourceFile.test_read_return_sizeGsJ��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)NrLrPrNr��r�)r$r%rRrSrTr9rJ�tellrmrA�truncate�assertRaises�EOFErrorrjr�)rDrEr��
end_offset�zipfiledatar�s      r(�test_truncated_zipfilez2AbstractTestsWithSourceFile.test_truncated_zipfileSs#��
�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.namerLzmode='w'rZzfilename=%rzfile=%rzmode='r'z	filemode=z
file_size=zcompress_type=zcompress_size=zname=%rz[closed])
r)rRrSrJrBr�reprrp�
isinstancerury�
ZIP_STOREDrA)rD�fnamer'rVrZr�s      r(�	test_reprz%AbstractTestsWithSourceFile.test_reprqs�����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�9��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�?�?�?�?�	@�	@r4c��	tjtdd���5}|�td��|�tdd���|�d��}|�d��}|�|jd��|�|jd��ddd��dS#1swxYwYdS)NrLr`r��
compress_1�
compress_9r�)rRrSr!rBrryrir�)rDrV�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�superrB)rDr9�	__class__�count�stops  ���r(rBzIAbstractTestsWithSourceFile.test_writing_errors.<locals>.BrokenFile.write�s<����$���}�}�%�
��Q�J�E����
�
�d�#�#�#�#�#r4)�__name__�
__module__�__qualname__rB�
__classcell__)r
rrs@��r(�
BrokenFiler�sC��������
$�
$�
$�
$�
$�
$�
$�
$�
$�
$�
$r4rrTrL�file1sdata1�file2sdata2r`)r$r%rRrSrJrArBrrmrirvrj)rDr�testfilerVr'rrs     @@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!�rDs r(�tearDownz$AbstractTestsWithSourceFile.tearDown�����v�����w�����r4r )$r
rr�classmethodr<rFrXr�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�rrrrer4r(r+r+5s
�������*�*��[�*� � � �
	"�	"�	"�	"�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����r4r+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)NrZrN��rO)rXrRrSryri�
external_attr)rDr'rJrV�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#rRr�r�s  r(�test_writestr_permissionsz3StoredTestsWithSourceFile.test_writestr_permissions�sA���4���	F�	F�A��.�.�q�'�2D�E�E�E�E�	F�	Fr4c��tjtdtj��5}|�t
d��ddd��n#1swxYwYtjtdtj��5}|�|���dg��ddd��dS#1swxYwYdS)NrL�	/absoluterZ�absolute�rRrSr!r�rBrrirv�rDrVs  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)NrL�arN)
rRrSr!r�rBrrTr9rirvr*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-�rbrZ)rAr!rBrRrSr�r�seekrorirvrjr9r$r%)rDr9r'rVr��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)NrLr0r?)r$r%rRrSr�rBrrmrAr!rirvrjr9�rDr3rVr�r9r'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)NrLsI am not a ZipFile!i@Br?r-rNr1)r$r%rRrSr�rBrrmrAr!rirvrTr9rjror6s      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)NrLr-�utf-8��encodingz
rZ)rRrSr!r�rBrrAr��rDrVr'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)NrL�this is a commentr-r;r<zabcdef
rZ)
rRrSr!r��commentrBrrAr�rir>s   r(�)test_ignores_stuff_appended_past_commentszCStoredTestsWithSourceFile.test_ignores_stuff_appended_past_comments2s���
�_�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)NrLr1)rRrSr!rBrrArirjr>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.txtrLrP�bogusrZr)
rRrSr!rTrA�closer��
ValueErrorrjr2r��readable�seekable)rDr�rV�fids    r(�test_io_on_closed_zipextfilez6StoredTestsWithSourceFile.test_io_on_closed_zipextfileDs�����
�_�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)NrLrPrGrHrZ)	rRrSr!rTr�rJrBrrAr*s  r(�test_write_to_readonlyz0StoredTestsWithSourceFile.test_write_to_readonlyRs���	 �
�_�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)rrrLF��strict_timestamps�i�r`r`rrr)�os�utimerrRrSr!r�rJrBryri�	date_time)rDrVr!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=rLFrR)i;����;r])rs�	localtime�
OverflowError�skipTestrUrVr�stat�st_mtime_nsrRrSr!r��struct�errorrBryrirW)rD�ts�mtime_nsrVr!s     r(�test_add_file_after_2107z2StoredTestsWithSourceFile.test_add_file_after_2107jsN��
��	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�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
rrrRr�rJr�r#r%r+r.r4r7r9r?rCrErNrPrXrgrer4r(rr�s�������$�K���@�@�@�F�F�F�=�=�=�D�D�D�<�<�<�.<�<�<�?�?�?�,:�:�:�B�B�B�?�?�?�<�<�<�-�-�-�	E�	E�	E�J�J�J�J�Jr4rc�"�eZdZejZd�ZdS)�DeflateTestsWithSourceFilec���	tjtd��5}|�tdtj��|�tdtj��|�d��}|�d��}|�|j	tj��|�|j	tj��ddd��dS#1swxYwYdS)NrL�storeme�	deflateme)
rRrSr!rBrr��ZIP_DEFLATEDryrir�)rDrV�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
rrrRrmrJrprer4r(riri�s2�������&�K�	H�	H�	H�	H�	Hr4ric��eZdZejZdS)�Bzip2TestsWithSourceFileN�r
rrrR�	ZIP_BZIP2rJrer4r(rrrr���������#�K�K�Kr4rrc��eZdZejZdS)�LzmaTestsWithSourceFileN�r
rrrR�ZIP_LZMArJrer4r(rwrw���������"�K�K�Kr4rwc�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/r0s  r(�	<genexpr>z;AbstractTestZip64InSmallFiles.setUpClass.<locals>.<genexpr>�sF����7�7���4�q�8�'�B�B�7�7�7�7�7�7r4r�
)r5r6r8r9)r;r7s  r(r<z(AbstractTestZip64InSmallFiles.setUpClass�sA��7�7�"�1�n�5�5�7�7�7���:�:�h�'�'����r4c�
�tj|_tj|_dt_dt_ttd��5}|�|j��ddd��dS#1swxYwYdS)Nrr�r?)	rR�ZIP64_LIMIT�_limit�ZIP_FILECOUNT_LIMIT�_filecount_limitrArrBr9rCs  r(rFz#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)NrLT��
allowZip64rMrNrZrcr]rr^r_r`rarb�c��g|]	}|j��
Srerfr0s  r(r3z:AbstractTestZip64InSmallFiles.zip_test.<locals>.<listcomp>�rhr4)rRrSrBrrTr9rirjr$rkrlrmrnrorprqrrrsrtrurvrwrxryrgrz)rDr'rJrVrEr{r|r}r~rr�r�r�r2r�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���dSr r�r�s  r(r�z(AbstractTestZip64InSmallFiles.test_basic�r�r4c���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)NrLTr�r���foo%08d�%dr��9rZr.)
rRrSrrJ�debugr5rTrirorvrIrj�decode)rDr��numfilesr2�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�
���
�
�
�
�
r4c��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)NrLFr�r�r�r�r�r�r�r4r-Tr�rZr.)rRrSrrJr�r5rTrirorvr��LargeZipFilerIrjr�)rDr�r�r2�	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�rRr�r�r�rrr!rs r(rz&AbstractTestZip64InSmallFiles.tearDown1s1��"�k���&*�&;��#��v�����w�����r4N)r
rrrr<rFr�r�r�r�rrer4r(r|r|�s��������(�(��[�(�
 � � �7�7�7�r/�/�/����&%�%�%�N����r4r|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�NrLFr�rM)rRrSr�r�rBr�rDr'rJrVs    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�)rRrSr�r�rTr9r�s    r(�large_file_exception_test2z6StoredTestZip64InSmallFiles.large_file_exception_test2As���
�_�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�rRr�r�r�s  r(�test_large_file_exceptionz5StoredTestZip64InSmallFiles.test_large_file_exceptionFsZ���4���	C�	C�A��*�*�1�g�.@�A�A�A��+�+�A�w�/A�B�B�B�B�	C�	Cr4c��tjtdtjd���5}|�t
d��ddd��n#1swxYwYtjtdtj��5}|�|���dg��ddd��dS#1swxYwYdS)NrLTr�r'rZr(r)r*s  r(r+z2StoredTestZip64InSmallFiles.test_absolute_arcnamesKs(��
�_�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)NrLTr�rNrZr-�strfile2)rRrSr!rTr9ry�extrari)rDrVr!r�s    r(�test_appendz'StoredTestZip64InSmallFiles.test_appendSs&���_�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����<L�<HH�Qr`z<Q�:�2z<Hrcstest.txt�test1234sPK!�%��sPK--!�%��s
�sPK,--ss
sPKlssPK:2s)r�rc�packro)rD�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_fieldsrx�
compress_size�
header_offset�local_extra�
central_extra�central_dir_size�offset_to_central_dir�local_extra_length�central_extra_lengthrgr��filename_length�zip64_contentss                        r(�make_zip64_filez+StoredTestZip64InSmallFiles.make_zip64_fileasg��
	��� ����!���	��	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�r4c�	�	|�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�rR�
BadZipFilerSr$r%rpru�	exception�lower)rD�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`re)r5ro�	itertools�combinations�updaterRrSr$r%r�rwrirxr�r�rj)rD�expected_file_size�expected_compress_size�expected_header_offset�expected_content�paramsrZ�comborU�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
rrrRr�rJr�r�r�r+r�r�r�r�rer4r(r�r�8s��������$�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�Gr4r�c��eZdZejZdS)�DeflateTestZip64InSmallFilesN�r
rrrRrmrJrer4r(r�r�>��������&�K�K�Kr4r�c��eZdZejZdS)�Bzip2TestZip64InSmallFilesNrsrer4r(r�r�Crur4r�c��eZdZejZdS)�LzmaTestZip64InSmallFilesNrxrer4r(r�r�Hrzr4r�c�&�eZdZd�Zd�Zd�Zd�ZdS)�AbstractWriterTestsc�.�tt��dSr �rr!rs r(rzAbstractWriterTests.tearDownP����w�����r4c���d}tjtd|j��5}|�dd��}|�|��|���|�|j��|���|�|j��|�	|�
d��|��ddd��dS#1swxYwYdS)N�contentrLr&)rRrSr!rJrArBrIrrr#rirj�rDr9r�rLs    r(�test_close_after_closez*AbstractWriterTests.test_close_after_closeSs����
�_�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�rLr&r4)
rRrSr!rJrArBrIrrr#r�rJrirjr�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�rcr\rLr9)
�arrayro�itemsizerRrSr$r%rJrArirBryrx)rD�q�LENGTHr�r9s     r(�test_issue44439z#AbstractWriterTests.test_issue44439hse���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
rrrr�r�r�rer4r(r�r�NsU���������	6�	6�	6�6�6�6�D�D�D�D�Dr4r�c��eZdZejZdS)�StoredWriterTestsN�r
rrrRr�rJrer4r(r�r�ps�������$�K�K�Kr4r�c��eZdZejZdS)�DeflateWriterTestsNr�rer4r(r�r�ss�������&�K�K�Kr4r�c��eZdZejZdS)�Bzip2WriterTestsNrsrer4r(rrws�������#�K�K�Kr4rc��eZdZejZdS)�LzmaWriterTestsNrxrer4r(rr{s�������"�K�K�Kr4rc�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�)rp)rD�namervs   r(�assertCompiledInzPyZipFileTests.assertCompiledIn�s7���#�:�X�%�%��M�M�$��*�h�/�/�/�/�/�&�%r4c���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)
rU�access�W_OK�supports_effective_idsr`r�r8rA�O_WRONLY�O_CREATrI�	Exceptionr)rDr�rg�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)NrL�.pyc�__pycache__r��testpackage�/)rrUr��dirname�__file__rrR�	PyZipFile�endswithrq�sep�altsep�extend�	importlib�util�source_from_cache�writepy�basename�assertNotInrvr)rD�trVr}�
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)NrrLzemail/__init__.pyzemail/mime/text.py)�emailrUr�rrrrrRrr"rvr)rDr*�
packagedirr%rVr�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)NrrL�SyntaxErrorc��dS)NFre)�whatevers r(�<lambda>zCPyZipFileTests.test_write_filtered_python_package.<locals>.<lambda>�s��e�r4��
filterfuncc�h�tj�|���d��S)N�bad)rUr�r#�
startswith)r�s r(�filterzAPyZipFileTests.test_write_filtered_python_package.<locals>.filter�s)���7�+�+�D�1�1�<�<�U�C�C�C�Cr4)r&rUr�rrrrrRrr
r"rmrr�assertWarns�UserWarning�print)rDr&r+r%rV�	reportSIO�	reportStrr7s        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`rrL)�optimizezemail/__init__zemail/mime/text)r*rUr�rrrrrRrr"rvrp)rDr*r+�optlevel�extr%rVr�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.pyrLr;r<�
print(42)
�mod2.py�print(42 * 42)
zmod2.txtzbla bla bla
�rU�mkdirr!rAr�r8rBrrRrr"rvrr$r�rDrEr%rVr�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)
NrDrLr;r<rErFrGc�.�|�d��S)NrF)r)r}s r(r1zEPyZipFileTests.test_write_python_directory_filtered.<locals>.<lambda>s��68�k�k�)�6L�6L�2L�r4r2rHrJs     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)NrLr;r<z!most definitely not a python file)
rrRrrArrBr��RuntimeErrorr"r)rDr%rVr'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)NrDrLr;r<zBad syntax in python file
r.zmod1.pyc)rUrIr!rAr�r8rBrrRrr
r"rprmrvr$r)rDrEr%rV�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)NrDrLr;r<rE)rUrIr!rAr�r8rBrrRrr"r�r�rvrrrJs     r(�test_write_pathlikez"PyZipFileTests.test_write_pathlike3s���
������		��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
rrrrr(r,r=rBrKrNrQrTrVrer4r(rr�s�������0�0�0����8�8�8�<?�?�?�<�<�<�<
:�
:�
:����.���(������,����r4rc��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)NrL)rRrSr!r��SMALL_TEST_DATArT�rDrV�fpath�fdatas    r(�make_test_filezExtractTests.make_test_fileCs���
�_�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�NrZr1)rr^rRrSr!rZ�extractrUr�r8�getcwd�normpathrirA�encoderjr)rDrVr\r]�writtenfile�correctfiler's       r(�test_extractzExtractTests.test_extractHs��
�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^rRrSr!rZrarUr�r8rcrr�samefilerArirdrjr)rD�targetrVr\r]rerfr's        r(�_test_extract_with_targetz&ExtractTests._test_extract_with_target[s���������
�_�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 )rrk�rD�extdirs  r(�test_extract_with_targetz%ExtractTests.test_extract_with_targetns���
�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 )rrkr�r�rms  r(�!test_extract_with_target_pathlikez.ExtractTests.test_extract_with_target_pathlikers���
�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^rRrSr!�
extractallrZrUr�r8rbrArirdrjr)rDrVr\r]�outfiler's      r(�test_extract_allzExtractTests.test_extract_allvs���
�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^rRrSr!rurZrUr�r8rArirdrjr)rDrjrVr\r]rvr'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 )rryrms  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�	7rpc��t��5}|�tj|����ddd��dS#1swxYwYdSr )rryr�r�rms  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�	Ersc��|�tj�|����t	|d��5}|�|���|��ddd��dS#1swxYwYdS)Nr1)rrrUr��isfilerArirj)rDrgr�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)rRrS�_sanitize_windows_nameri)rD�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�Hr4c�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)rD�common_hacknamess  r(�*test_extract_hackers_arcnames_common_casesz7ExtractTests.test_extract_hackers_arcnames_common_cases�s1��	
�	
�	
��	
�+�+�,<�=�=�=�=�=r4�\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�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�)rD�windows_hacknamess  r(�*test_extract_hackers_arcnames_windows_onlyz7ExtractTests.test_extract_hackers_arcnames_windows_only�s4��L�
�
�
��*	
�+�+�,=�>�>�>�>�>r4rzRequires / as path separator.c�8�gd�}|�|��dS)N))z	//foo/barr�)r�zfoo../ba..r)�
foo/..\barr�r�)rD�posix_hacknamess  r(�(test_extract_hackers_arcnames_posix_onlyz5ExtractTests.test_extract_hackers_arcnames_posix_only�s/��
�
�
��
	
�+�+�O�<�<�<�<�<r4c���|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�foobarrLrrrj�subdir�subsubrZzextract z: z != )�msgz
extract %rr)rdrRrSr!r��ZipInforgr rT�replacerUrr�r8rqrarir�rrurbr)
rD�	hacknames�arcname�	fixednamer�rVr!�
targetpathrfres
          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
rrr^rgrkrorrrwryr{r}r�r�r��unittest�skipIfrUr�rr�r�r�rer4r(rXrXAsJ������-�-�-�
(�(�(�&���&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�=�)�)�)�)�)r4rXc�>�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)
NrLrr��barr�rZr4r�sbarfoo)
rRrSr!r�rTr8r9rirvrwrArjrp)rDrVr�r9r�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)NrL�abcdefghijklmnop)rRrSr!r��	flag_bits�_MASK_USE_DATA_DESCRIPTORrT)rD�orig_zipr9r!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)NrLzzipfp is not open�zipfp is not closedrZ)rRrSr!rZrT�assertIsNotNonerE�assertIsNoner[s    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)NrLrZr�)rRrSr!rZrTr�r�rE)rDrVr\r]�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/rZ)r��NotImplementedErrorrRrSr$r%�rDr9s  r(�test_unsupported_versionz#OtherTests.test_unsupported_version6sD��Y��	
���-�w���*�T�*�*�C�	1�	1�	1�	1�	1r4c��td��}tj|��5}|���D])}|�|������*	ddd��dS#1swxYwYdS)Nzzip_cp437_header.zip)r	rRrSrvrArI)rDr�rVrs    r(�test_read_unicode_filenamesz&OtherTests.test_read_unicode_filenamesAs����/�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)NrL�foo.txtzTest for unicode filenameuö.txtrrZr`)
rRrSrrTr�rwrgruri�filelist�rDr�s  r(�test_write_unicode_filenamesz'OtherTests.test_write_unicode_filenamesIs���
�_�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)NrLuприкладssample)rRrSr!rTrirjr*s  r(�'test_read_after_write_unicode_filenamesz2OtherTests.test_read_after_write_unicode_filenamesSs���
�_�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.�xrZ)rr!rRrSr�rTr��FileExistsErrorrirvrj)rDrgr�rVs    r(�test_exclusive_create_zip_filez)OtherTests.test_exclusive_create_zip_fileXs���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.rZ)
rUr��existsrrrRrSrTr�failrrrirj)rDrgr�r�s    r(�(test_create_non_existent_file_for_appendz3OtherTests.test_create_non_existent_file_for_appendes���
�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)NrLr;r<�this is not a legal zip file
)rArrBrRrSr�)rDrEr�s   r(�test_close_erroneous_filez$OtherTests.test_close_erroneous_filews����&�#��
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)NrLr;r<r�r1sthis is not a legal zip file
r)rArrBr"rR�
is_zipfiler�r�r$r%r2rCs  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)NrLrPr��O, for a Muse of Fire!)
r$r%rRrSrTrmr5ror�r�)rDrEr�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)NrLrPr�r�r1r)rRrSrrTrrr�rAr2rjr$r%rB)rDr�rE�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�rrRrSrrs r(�%test_non_existent_file_raises_OSErrorz0OtherTests.test_non_existent_file_raises_OSError�s$��	
���'�7�?�F�;�;�;�;�;r4c��ttdd���}|���|�tjtjt��ttdd���5}|�d��ddd��n#1swxYwY|�tjtjt��dS)NrLr;r<z
short file)rArrIr�rRr�rSrB)rDr'rEs   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�rZ�)	�	bytearrayrcr�r$r%r�rRr�rS)rD�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�	Fr4c��	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)
NrLrPr��O, for a Muse of Fire!z	bogus.txtrHr;r<zzipfile test data)r$r%rRrSrTr�rJrjrArzrrB)rDr9r�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�rJrRrSrrs r(�test_bad_constructor_modez$OtherTests.test_bad_constructor_mode�s'��L����*�g�o�v�s�C�C�C�C�Cr4c��	tjtd���5}|�dd��ddd��n#1swxYwYtjtd���5}|�d��|�t|jdd��|�t|jdd��|�t|jdd��ddd��dS#1swxYwYdS)	NrLrPr�r�rZr��U�rU)rRrSrrTrjr�rJrA�rDr�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)NrLrPr�r�rr4r�)	rRrSrrTrAr5r6rirj)rDr�r'r2s    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)NrLrPr�rZ)rRrSrr��KeyErrorrAr�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)NrLr�)r�r�rRrSrrs r(�test_bad_compression_modez$OtherTests.test_bad_compression_modes,��	����-�w����R�P�P�P�P�Pr4c���d}tjtj|��d��5}|�t
|jd��ddd��dS#1swxYwYdS)NsfPK.�C�@xPK..�C�@�xPK/!rZr�)rRrSr$r%r�r�rA)rDr9r�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)NrLrPzfoo.txtqqqr�r�)rRrSrrTrirvr�s  r(�test_null_byte_in_filenamez%OtherTests.test_null_byte_in_filename s���	�
�_�V�#�
.�
.�
.�	;�$��M�M�*�,E�F�F�F����T�]�]�_�_�y�k�:�:�:�	;�	;�	;�	;�	;�	;�	;�	;�	;�	;�	;�	;����	;�	;�	;�	;�	;�	;s�AA*�*A.�1A.c��	|�tjd��|�tjd��|�tjd��|�tjd��dS)N��.�8r�)rirR�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�"�=�=�=�=�=r4c�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)NrLrPr4r�r�rZs9Bravely taking to his feet, he beat a very brave retreat.�c�$�g|]
}d|dzdzz��S)r�r�r�rer0s  r(r3z,OtherTests.test_comments.<locals>.<listcomp>Bs%��K�K�K�1�D�A�q�D�2�I�.�K�K�Kr4�r.soopssoriginal commentr-san updated commentsoriginal comment that's longersshorter comment)rRrSrrirBrTr8r5rdr8r9rUr��getsizerr)rDr��zipfrrB�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)NrLr�r�zthis is an error)rRrSrr�rTr��	TypeErrorrBr�s  r(�test_unicode_commentzOtherTests.test_unicode_commenths���
�_�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-rArZ)rRrSrr�r"r�rBrir�s  r(�$test_change_comment_in_empty_archivez/OtherTests.test_change_comment_in_empty_archivens)��
�_�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)NrLr�r�r-rArZ)	rRrSrr�rTrrr�rBrir�s  r(�'test_change_comment_in_nonempty_archivez2OtherTests.test_change_comment_in_nonempty_archiveus���
�_�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)NrLrPrZz+Unable to create empty ZIP file in 'w' moder-z+Unable to create empty ZIP file in 'a' mode)rRrSrrIr�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)NrLr;r<rZ)rArrIr�rRr�rSr�s  r(�test_open_empty_filezOtherTests.test_open_empty_file�sJ��
���w�/�/�/��	���	�	�	����'�,�g�o�v�s�K�K�K�K�Kr4c�T�|�ttjdd��dS)N�	seventies)i�r`r`rrr)r�rJrRr�rs r(�test_create_zipinfo_before_1980z*OtherTests.test_create_zipinfo_before_1980�s5�����*�!�/�;�8M�	O�	O�	O�	O�	Or4c�x�	tjd���}|�t|��d��dS)N�emptyrfz&<ZipInfo filename='empty' file_size=0>)rRr�rir��rD�zis  r(�test_create_empty_zipinfo_reprz)OtherTests.test_create_empty_zipinfo_repr�s:��K�
�_�g�
.�
.�
.������b���#K�L�L�L�L�Lr4c���	tj��}|�|jd��|�|jd��|�|jd��|�|jtj��|�|jd��|�|j	d��|�
|jd��|�|jtj
��|�|jtj
��|�|jd��|�|jd��|�|jd��|�|jd��|�|jd��|�|jd��|�|jd��dS)N�NoNamerTr4)rr�r)rRr�ri�
orig_filenamergrWr�r�rBr�rp�
create_system�create_version�DEFAULT_VERSION�extract_version�reservedr��volume�
internal_attrr rxr�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�-�-�-�-�-r4c���	d}tjtj|��d��5}|�|�����ddd��dS#1swxYwYdS)NsnPK���@����abcAPK���@������abcPK3%rZ)rRrSr$r%r�rz�rDr�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 offshorerLr�rPr��handlerZru�abcder[�baz)r�r�r1)rRrSr!r�rArBr�rJrTrrIrirjrv)rD�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?sBrucerLr�rZrr\rP)�findrRrSrrTrAr2rU�SEEK_SETrir��SEEK_CURrj�SEEK_ENDror$r%)rD�txt�blocr�rEr9s      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�rL)rJr��azzipfile.bz2)r$r%rRrSrtrT�mock�patchr�rPra)rDr9�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��dSr rrs r(rzOtherTests.tearDownrr4N)-r
rrr�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rrrrrrrr*r-r7r?rrErrer4r(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�����r4r�c��eZdZd�Zd�ZdS)�AbstractBadCrcTestsc���	|j}tjtj|��d���5}|�d|�����ddd��dS#1swxYwYdS)NrZrP�afile)�zip_with_bad_crcrRrSr$r%rirzr,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)NrZrPrJr�)
rKrRrSr$r%r�r�rjrA�
MIN_READ_SIZE)rDr�r��corrupt_files    r(�test_read_with_bad_crcz*AbstractBadCrcTests.test_read_with_bad_crc sO��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
rrrLrPrer4r(rHrHs2������6�6�6�����r4rHc� �eZdZejZdZdS)�StoredBadCrcTestssxPK ��;:r��afilehello,AworldPK ��;:r���afilePK3/N)r
rrrRr�rJrKrer4r(rRrR6s"�������$�K�	���r4rRc� �eZdZejZdZdS)�DeflateBadCrcTestss|PKn}=FAKEnafile�H���W(�/�Iɠ=PKn}=FAKEn�afilePK33N)r
rrrRrmrJrKrer4r(rTrTBs"�������&�K�	6���r4rTc� �eZdZejZdZdS)�Bzip2BadCrcTestss�PKnu=FAKE8nafileBZh91AY&SYԨ��@D��  �P�!����u5:���"�(HjTe?�PKnu=FAKE8n ���afilePK3[N)r
rrrRrtrJrKrer4r(rVrVOs"�������#�K�
	���r4rVc� �eZdZejZdZdS)�LzmaBadCrcTestss�PKnu=FAKEnafile	]4I���:3`	q!.8PKnu=FAKEn ���afilePK3>N)r
rrrRryrJrKrer4r(rXrX_s"�������"�K�	%���r4rXc�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?rZ)
rArrBr9rRrSr�r!�data2�zip2rCs  r(rFzDecryptionTests.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�rIrUrrr]r!rs r(rzDecryptionTests.tearDown�sL���������
�	�&�����	������
�	�'�����r4c��|�t|jjd��|�t|jjd��dS)N�test.txt�zero)r�rPr�rjr]rs r(�test_no_passwordz DecryptionTests.test_no_password�sB��	
���,���
�z�B�B�B����,��	���?�?�?�?�?r4c��|j�d��|�t|jjd��|j�d��|�t|jjd��dS)Nsperlr`ra)r��setpasswordr�rPrjr]rs r(�test_bad_passwordz!DecryptionTests.test_bad_password�sl������W�%�%�%����,���
�z�B�B�B��	���g�&�&�&����,��	���?�?�?�?�?r4c�:�|j�d��|�|j�d��|j��|j�d��|�|j�d��|j��dS)N�pythonr`s12345ra)r�rdrirj�plainr]�plain2rs r(�test_good_passwordz"DecryptionTests.test_good_password�s�������Y�'�'�'��������z�2�2�D�J�?�?�?��	���h�'�'�'���������/�/���=�=�=�=�=r4c�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)�assertRaisesRegexrr�rdrjrArarn)rD�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)Nrgs
encryptionr`rZrr`r4)r�rdrhr9rorAr2rUr:rir�r;rjrN�_readbuffer�_offsetr<)rDr=�	test_wordr>�bloc_lenrE�
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
rrr9r\rhrirFrrbrer
rjrqr?rer4r(rZrZns��������
	)�	�	:�
�
*�E�
�F�2�2�2����@�@�@�@�@�@��]�_�_�>�>��_�>�&�&�&�&#�#�#�#�#r4rZc�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`r4c	3�zK�|]6}tjdt��tdd��z��V��7dS)z<fi���rN)rcr�rrr0s  r(rz@AbstractTestsWithRandomBinaryFiles.setUpClass.<locals>.<genexpr>�sU����7�7� !�#�K��f�h�h�w�u�d�7K�7K�.K�L�L�7�7�7�7�7�7r4)rr8r5r9)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����r4c��ttd��5}|�|j��ddd��dS#1swxYwYdSr>r@rCs  r(rFz(AbstractTestsWithRandomBinaryFiles.setUp�rGrHc�V�tt��tt��dSr rrs r(rz+AbstractTestsWithRandomBinaryFiles.tearDown�rr4c���tj|d|��5}|�td��|�tt��ddd��dS#1swxYwYdS)NrLrM)rRrSrBrr�s    r(rXz4AbstractTestsWithRandomBinaryFiles.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)NrZrM)rXrRrSrjrriror9)rDr'rJrV�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���dSr r�r�s  r(�	test_readz,AbstractTestsWithRandomBinaryFiles.test_read	r�r4c��|�||��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�)rXrRrSrArrjr�r8riror9)rDr'rJrVr�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���dSr r�r�s  r(r�z,AbstractTestsWithRandomBinaryFiles.test_open#	r�r4c�>�|�||��tj|d|��5}g}|�t��5}	|�t
dd����}|sn|�|���<	ddd��n#1swxYwYd�|��}|�	t|��t|j����|�	||j��ddd��dS#1swxYwYdSr�)rXrRrSrArrjrr�r8riror9)rDr'rJrVr�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���dSr r�r�s  r(r�z3AbstractTestsWithRandomBinaryFiles.test_random_open8	r�r4N)r
rrrr<rFrrXr�r�r�r�r�r�rer4r(ryry�s��������7�7��[�7�
 � � �
���(�(�(�D�D�D�/�/�/�3�3�3�:4�4�4�2�2�2�";�;�;�;�;r4ryc��eZdZejZdS)� StoredTestsWithRandomBinaryFilesNr�rer4r(r�r�=	s�������$�K�K�Kr4r�c��eZdZejZdS)�!DeflateTestsWithRandomBinaryFilesNr�rer4r(r�r�A	r�r4r�c��eZdZejZdS)�Bzip2TestsWithRandomBinaryFilesNrsrer4r(r�r�F	rur4r�c��eZdZejZdS)�LzmaTestsWithRandomBinaryFilesNrxrer4r(r�r�K	rzr4r�c�&�eZdZd�Zd�Zd�Zd�ZdS)�Tellablec�"�||_d|_dS�Nr)rE�offsetrCs  r(�__init__zTellable.__init__S	s���������r4c�Z�|j�|��}|xj|z
c_|Sr )rErBr�)rDr9�ns   r(rBzTellable.writeW	s*���G�M�M�$�������q�����r4c��|jSr )r�rs r(r�z
Tellable.tell\	s
���{�r4c�8�|j���dSr �rE�flushrs r(r�zTellable.flush_	�����
�
�����r4N)r
rrr�rBr�r�rer4r(r�r�R	sP������������
�������r4r�c� �eZdZd�Zd�Zd�ZdS)�
Unseekablec��||_dSr )rErCs  r(r�zUnseekable.__init__c	s
������r4c�6�|j�|��Sr )rErBr�s  r(rBzUnseekable.writef	s���w�}�}�T�"�"�"r4c�8�|j���dSr r�rs r(r�zUnseekable.flushi	r�r4N)r
rrr�rBr�rer4r(r�r�b	sA���������#�#�#�����r4r�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��|Sr re�r's r(r1z/UnseekableTests.test_writestr.<locals>.<lambda>n	���!�r4��wrapper�abcrL�ones�111�twos�222r\�abcPKrZrP)r�r��subTestr$r%rB�BufferedWriterrRrSr�rTrirmrArj)rDr�r'�bfrVr��zopens       r(�
test_writestrzUnseekableTests.test_writestrm	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��|Sr rer�s r(r1z,UnseekableTests.test_write.<locals>.<lambda>~	r�r4r�r�rLr?r�r�r�r�r\r�rZrP)r�r�r�r$r%rBr�rRrSr��
addCleanuprrrArirmrj)rDr�r'r�rV�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��|Sr rer�s r(r1z1UnseekableTests.test_open_write.<locals>.<lambda>�	r�r4r�r�rLr�r�r�r�r\r�)r�r�r�r$r%rBr�rRrSr�rArirmrj)rDr�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
rrr�r�r�rer4r(r�r�l	sF������?�?�?� ?�?�?�*@�@�@�@�@r4r�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�data1r\r:s r(r<z!TestsWithMultipleOpens.setUpClass�	s.���Y�u�-�-�-��	��Y�u�-�-�-��	�	�	r4c���tj|dtj��5}|�d|j��|�d|j��ddd��dS#1swxYwYdS)NrLr�r�)rRrSrmrTr�r\)rDr'rVs   r(rXz(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)NrZrPr���)r)rXrRrSrArjrir��rDr'r��zopen1�zopen2r�r\s       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)NrZrPr�r�r��	r)rXrRrSrArjrir�r\r�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)NrZrPr�r�r�r�)rDr'r�r�r�r�r\s       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)NrZr�r�r�)r)rX�
contextlib�	ExitStackrRrS�
enter_contextrArjrir�r\)rDr'�stackr�r�r�r�r\s        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)NrLr�r�r�rZ)
r)rRrSrmrTr�r\rArjri�rDr'r�r�r�r\s      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)NrLr�r�r�rZ)
r)rRrSrmrTr�rArjr\rir�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)NrZrPr�r�)	rrXr!rRrSr5rjrAri)rD�
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)NrLr�r-rZr�r�)rRrSr!rmrTr�rArjrBr\ri)rDr��r1r�r6s     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��dSr r�rs r(rzTestsWithMultipleOpens.tearDown
r�r4N)r
rrrr<rXr�r�r�r�r�r�r�r�rrer4r(r�r��	s��������.�.��[�.�/�/�/�4�4�4�4�4�4�
4�
4�
4�0�0�0�0�0�0�0�0�0�
1�
1�
1�<�<�<�����r4r�c�>�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	S)
�TestWithDirectoryc�8�tjt��dSr )rUrIr!rs r(rFzTestWithDirectory.setUp"
s��
�������r4c
��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�)rRrSr	rur!rrrUr��isdirr8r�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-)rUrIr�r8r!r�rs r(�
test_bug_6050zTestWithDirectory.test_bug_6050,
s:��
������g�s�+�+�,�,�,��������r4c	��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�rrLrz/x/r��yr`zy/rZrjr�)rUr�r8r!rIra�st_moderRrSrrBr�rrrgrrir rur�ro�listdir)rD�dirpathrQr�r!rjs      r(�test_write_dirz TestWithDirectory.test_write_dir1
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�rLzx/r4ri�ArZrj)rUrIr�r8r!rRrSrrTr�rirgr rrrrur�r�)rDr�r!rjs    r(�test_writestr_dirz#TestWithDirectory.test_writestr_dirK
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)NrLr{r�
directory/i�A�directory2/r`�
directory3i�rPr�zdirectory3/zdirectory4/r�rj>r{�
directory2r��
directory4)rRrSrrIr�rirgr r��CRCrxr�rUr�r8r!ru�setr�)rDr�r!�	old_zinfo�	new_zinforjs      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)NrLr�rrr�r�)r�r`r�rjr{)rRrSrrTr�r�rirgrUr�r8r!rIrar�rBr rur�r�)rDr�r!r{rQrjs      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!rUr�r�rrrs r(rzTestWithDirectory.tearDown�
s<���w����
�7�>�>�&�!�!�	��6�N�N�N�N�N�	�	r4N)r
rrrFr�r�r�r�rrrrer4r(r�r�!
s����������N�N�N� � � �
9�9�9�48�8�8�"o�o�o�@S�S�S�*����r4r�c�,�eZdZd�Zd�Zd�Zd�Zd�ZdS)�ZipInfoTestsc�p�tj�t��}|�tj|j��d��|�|�	����|�|j
tj�
t����dS�Nztest_zipfile.py)rRr��	from_filerri�	posixpathr#rgr"�is_dirrxrUr�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�Ar4c��tj�tjt
����}|�tj|j	��d��|�
|�����|�|jtj�t
����dSr)rRr�rr�r�rrir	r#rgr"r
rxrUr�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�Ar4c��tj�tjt
��d��}|�tj|j	��d��|�
|�����|�|jtj
�t
����dS)Nr&)rRr�rrU�fsencoderrir	r#rgr"r
rxr�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�Ar4c���ttd��5}tj�|���d��}|�tj|j	��d��|�
|�����|�|jtj�t����ddd��dS#1swxYwYdS)Nr1r&)rArrRr�r�filenorir	r#rgr"r
rxrUr�r)rDr'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)rUr�r�abspathrrRr�rrirgrrr
r�r�rx)rDr�rs   r(�
test_from_dirzZipInfoTests.test_from_dir�
s����'�/�/�"�'�/�/�(�";�";�<�<��
�_�
&�
&�w��
?�
?�������o�6�6�6�����	�	���$�$�$�����)�7�+=�>�>�>������q�)�)�)�)�)r4N)r
rrrr
rrrrer4r(rr�
sk������B�B�B�B�B�B�B�B�B�F�F�F�*�*�*�*�*r4rc�X�eZdZd�Zd�Zd�Zd�Zd�Ze��d���Z	d�Z
dS)	�CommandLineTestc��tjddg|�Ri|��\}}}|�tj���d��S)N�-mrRr�)rrr�rU�lineseprd)rD�argsrU�rc�out�errs      r(�
zipfilecmdzCommandLineTest.zipfilecmd�
s_��$�5�d�I�@��@�@�@�8>�@�@���C���{�{�2�:�,�,�.�.��6�6�6r4c�(�tjddg|�R�S)NrrR)r�assert_python_failure)rDrs  r(�zipfilecmd_failurez"CommandLineTest.zipfilecmd_failure�
s���2�4��J�T�J�J�J�Jr4c��|���\}}}|�|d��|�d|�����|�d|�����|�d|�����|�dd��\}}}|�|d��|�|���d��dS)Nr4susageserrorsrequired�-lr)r$rirpr��assertNotEqual�strip)rDrrr s    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��-�-�-�-�-r4c�(�td��}dD]@}|�||��}|�|���d���Atd��}|�d|��\}}}|�|d��dS)Nr�)�-tz--testsDone testingztesttar.tarr+r4)r	r!ri�rstripr$)rD�zip_name�optrrr s      r(�test_test_commandz!CommandLineTest.test_test_command�
s����L�)�)��!�	<�	<�C��/�/�#�x�0�0�C����S�Z�Z�\�\�?�;�;�;�;��M�*�*���.�.�t�X�>�>���C������c�"�"�"�"�"r4c��td��}tj��}tj|d��5}|�|��ddd��n#1swxYwY|����dd��}dD]0}|�||d���}|�	||���1dS)Nr�rZr.�backslashreplace)r&z--listzascii:backslashreplace)�PYTHONIOENCODING)
r	r$rkrRrSrlrmrdr!ri)rDr-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)NrLr;r<ztest 1�file.txtztest 2rz	/file.txt)�-cz--creater4rstest 1r�stest 2)r�rrrArBrUrI�	TESTFNDIRrr�r8r!r!rirRrSrvrj)rDr'�filesrvr.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	--extractr4rr1)r	rr!rirRrSrwrUr�r8rgr�rr
rrr�rrArj)	rDr-r.rnrr�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
rrr!r$r)r/r5r
r;r>rer4r(rr�
s�������7�7�7�
K�K�K�.�.�.�#�#�#�	,�	,�	,��]�_�_� � ��_� �*H�H�H�H�Hr4rc��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(rFz TestExecutablePrependedZip.setUp
s.����}�E�E�E���!�.��G�G�G����r4c�<�|�tj|��d|����tj|��5}|���D]-}|�|��}|�d|���.	ddd��dS#1swxYwYdS)Nzis_zipfile failed on sFAVORITE_NUMBER)rrrRr�rSrvrjrp)rDrrVr�r9s     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 )rHrErs r(� test_read_zip_with_exe_prependedz;TestExecutablePrependedZip.test_read_zip_with_exe_prependeds�����T�\�*�*�*�*�*r4c�:�|�|j��dSr )rHrFrs r(�"test_read_zip64_with_exe_prependedz=TestExecutablePrependedZip.test_read_zip64_with_exe_prependeds�����T�^�,�,�,�,�,r4zsys.executable required.z	/bin/bashz#Test relies on #!/bin/bash working.c�|�tj|jtjg��}|�d|��dS�Nsnumber in executable: 5)�
subprocess�check_outputrE�sys�
executablerp�rD�outputs  r(�test_execute_zip2z,TestExecutablePrependedZip.test_execute_zip2!s8��
�(�$�,���)G�H�H���
�
�0�&�9�9�9�9�9r4c�|�tj|jtjg��}|�d|��dSrN)rOrPrFrQrRrprSs  r(�test_execute_zip64z-TestExecutablePrependedZip.test_execute_zip64)s8��
�(�$�.�#�.�)I�J�J���
�
�0�&�9�9�9�9�9r4N)r
rrrFrHrJrLr��
skipUnlessrQrRrUr�X_OKrrUrWrer4r(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�:�:�:r4r@c�(�eZdZGd�d��ZdS)�jaracoc�(�eZdZGd�d��ZdS)�jaraco.itertoolsc� �eZdZd�Zd�Zd�ZdS)�jaraco.itertools.Counterc�<�d|_t|��|_dSr�)r�iter�
_orig_iter)rDr2s  r(r�z!jaraco.itertools.Counter.__init__:s����
�"&�q�'�'����r4c��|Sr rers r(�__iter__z!jaraco.itertools.Counter.__iter__>s���r4c�N�t|j��}|xjdz
c_|Sr)�nextrbr)rD�results  r(�__next__z!jaraco.itertools.Counter.__next__As%���d�o�.�.���
�
�a��
�
��
r4N)r
rrr�rdrhrer4r(�Counterr_9sA������
*�
*�
*�
�
�
�
�
�
�
�
r4riN)r
rrrirer4r(r�r]8s<������	�	�	�	�	�	�	�	�	�	r4r�N)r
rrr�rer4r(r[r[7s<���������������r4r[c��	tj�|�����D]}|�|d���|S)Nr4)rR�CompleteDirs�
_implied_dirsrvrT)r�rs  r(�add_dirsrmGsM����$�2�2�2�;�;�=�=�A�A����
���D�#�����
�Ir4c�B�	tj��}tj|d��}|�dd��|�dd��|�dd��|�dd	��|�d
d��d|_|S)
NrLr�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%rRrSrTrg)r9r�s  r(�build_alpharep_fixtureroQs����0�:�<�<�D�	���s�	#�	#�B��K�K���)�)�)��K�K�	�?�+�+�+��K�K��_�-�-�-��K�K�	�?�+�+�+��K�K��_�-�-�-� �B�K�
�Ir4c�H��	tj����fd���}|S)Nc�P��|���D]}�||����dS)N)�alpharep)�zipfile_alpharep)rDrr�meths  �r(r�zpass_alpharep.<locals>.wrapper{s@����-�-�/�/�	*�	*�H��D���)�)�)�)�)�	*�	*r4)�	functools�wraps)rtr�s` r(�
pass_alphareprwus?����
�_�T���*�*�*�*���*��Nr4c���eZdZd�Zd�Zd�Zed���Zed���Zed���Z	ed���Z
ed���Zd	�Zd
�Z
d�Zd�Zd
�Zed���Zd�Zed���Zed���Zed���Zed���Zed���Zed���Zed���Zed���Zed���Zed���Zed���ZdZd�Zd�Z d�Z!ed���Z"ed ���Z#ed!���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�rIrs r(rFzTestPath.setUp�s/��"�,�.�.��
�����
�+�,�,�,�,�,r4c#�K�|���5t��V�ddd��n#1swxYwY|���5tt����V�ddd��dS#1swxYwYdSr )r�rormrs r(rszTestPath.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�r{r�rrErIrgrArBrm)rDrr�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 )rRr��iterdir)rDrr�rootr-r��gr�r'rr��hr2s            r(�test_iterdir_and_typeszTestPath.test_iterdir_and_types�sj���|�H�%�%���,�,�.�.���1�a��)�)�+�+���1�a��y�y�{�{����y�y�{�{����y�y�{�{����r4c�.�tj|��}dSr �rRr��rDrrr�s   r(�test_is_file_missingzTestPath.test_is_file_missing�����|�H�%�%���r4c���tj|��}|���\}}}|�t��5|���ddd��dS#1swxYwYdSr )rRr�r�r�rJ�rDrrr�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|��}dSr r�r�s   r(�test_subdir_is_dirzTestPath.test_subdir_is_dir�r�r4c��tj|��}|���\}}}|�d���5}|���}ddd��n#1swxYwY|�|d��|�dd��5}|���}ddd��n#1swxYwY|�|d��dS)Nr;r<zcontent of arZ)rRr�r�rArjri)rDrrr�r-r�r�rr9s        r(r�zTestPath.test_open�s<���|�H�%�%���,�,�.�.���1�a�
�V�V�W�V�
%�
%�	���9�9�;�;�D�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�����~�.�.�.�
�V�V�C��
!�
!�	�T��9�9�;�;�D�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�����~�.�.�.�.�.s$�A$�$A(�+A(�B<�<C�Cc��tj��}tj|d��}|�dd�d����d|_tj|��}|���\}|�	d��}|�
dd��5}|���}ddd��n#1swxYwY|�|d��|�
d���5}|���}ddd��n#1swxYwY|�|d��dS)	NrLzpath/16.txtzThis was utf-16zutf-16ztest_open_utf16.zipz16.txtrZr<)
r$r%rRrSrTrdrgr�r��joinpathrArjri)rD�in_memory_filer�r�r��u16rr9s        r(�test_open_encoding_utf16z!TestPath.test_open_encoding_utf16�s��������
�_�^�S�
1�
1��
���M�#4�#;�#;�H�#E�#E�F�F�F�+����|�B�����,�,�.�.����m�m�H�%�%��
�X�X�c�8�
$�
$�	���9�9�;�;�D�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�����0�1�1�1�
�X�X�x�X�
(�
(�	�D��9�9�;�;�D�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�����0�1�1�1�1�1s$�.C�C�C�D'�'D+�.D+c��tj��}tj|d��}|�dd��d|_tj|��}|���\}|�d��}|�	dd���}|�
|d	��|�d
dd���5}|�
|���d��ddd��n#1swxYwY|�
td
��5|�	dd���}ddd��n#1swxYwY|�d
dd���5}|�t ��5|���ddd��n#1swxYwYddd��dS#1swxYwYdS)NrLzpath/bad-utf8.binsinvalid utf-8: ��.z"test_read_text_encoding_errors.zipzbad-utf8.binr;�ignore)�errorszinvalid utf-8: .rZ�surrogateescapeuinvalid utf-8: ��.r=r<�strict)r=r�)r$r%rRrSrTrgr�r�r��	read_textrirArjrorr��UnicodeDecodeError)rDr�r�r�r�r�r9r's        r(�test_open_encoding_errorsz"TestPath.test_open_encoding_errors�s��������
�_�^�S�
1�
1��
���'�)D�E�E�E�:����|�B�����,�,�.�.����m�m�N�+�+���}�}�W�X�}�6�6������1�2�2�2�
�X�X�c�7�+<�X�
=�
=�	G�����Q�V�V�X�X�'E�F�F�F�	G�	G�	G�	G�	G�	G�	G�	G�	G�	G�	G����	G�	G�	G�	G��
#�
#�I�z�
:�
:�	<�	<��=�=��7�=�;�;�D�	<�	<�	<�	<�	<�	<�	<�	<�	<�	<�	<����	<�	<�	<�	<��X�X�c�G�H�X�
=�
=�	���"�"�#5�6�6�
�
�������
�
�
�
�
�
�
�
�
�
�
����
�
�
�
�	�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	�	sZ�
)C?�?D�D�%E	�	E
�E
�,G�F(�G�(F,	�,G�/F,	�0G�G�Gc�$�	d}tddd|��}|j���}|�t	|��d|j��|�|dd��|�|dd	��dS)
Naimport io, zipfile
with zipfile.ZipFile(io.BytesIO(), "w") as zf:
    zf.filename = '<test_encoding_warnings in memory zip file>'
    zf.writestr("path/file.txt", b"Spanish Inquisition")
    root = zipfile.Path(zf)
    (path,) = root.iterdir()
    file_path = path.joinpath("file.txt")
    unused = file_path.read_text()  # should warn
    file_path.open("r").close()  # should warn
z-X�warn_default_encodingr8r�rs^<string>:8: EncodingWarning:r`s^<string>:9: EncodingWarning:)rr rnriro�assertRegex)rD�code�proc�warningss    r(�test_encoding_warningszTestPath.test_encoding_warnings�s���F�
�� ��&=�t�T�J�J���8�&�&�(�(������X����4�8�4�4�4�����!��&G�H�H�H�����!��&G�H�H�H�H�Hr4c���	tjtjtj��d�����}|�d���d��5}|�d��ddd��n#1swxYwY|�d���dd���5}|�d	��ddd��dS#1swxYwYdS)
NrLrPzfile.binr?sbinary contentsr7r;r<z	text file)rRr�rSr$r%r�rArB)rDr�rs   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�)rRr�rmror��IsADirectoryErrorr�rAr�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�r1r;r<)rRr�r�rJr�rAr�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)rRr�rmror��FileNotFoundErrorr�rAr�s  r(�test_open_missing_directoryz$TestPath.test_open_missing_directoryr�r�c��tj|��}|���\}}}|�d��dS)Nr;)rRr�r�r�r�s      r(r�zTestPath.test_read$s<���|�H�%�%���,�,�.�.���1�a�	���G�����r4c���tj|��}|�d��}|�d���d���d��}dS�Nr�r�r�e.txt�rRr�r��rDrrr�r-r�s     r(�
test_joinpathzTestPath.test_joinpath,sS���|�H�%�%���M�M�'�"�"���M�M�#���'�'��,�,�5�5�g�>�>���r4c�\�tj|��}|�ddd��}dS)Nr�rr�r�)rDrrr�r�s    r(�test_joinpath_multiplezTestPath.test_joinpath_multiple4s*���|�H�%�%���M�M�#�s�G�,�,���r4c�N�tj|��}|dz}|dzdzdz}dSr�r�r�s     r(�test_traverse_truedivzTestPath.test_traverse_truediv:s1���|�H�%�%���7�N���3�J���w�&���r4c�L�	tdddd���}t|��dS)Nzzipfile.Path(alpharep) / 'a'z(test)�evalT)�sourcergrQ�dont_inherit)�compiler�)rDrrr�s   r(�test_traverse_simpledivz TestPath.test_traverse_simpledivBs:��	��1����	
�
�
��	
�T�
�
�
�
�
r4c��	|�|��}tjt|����}t	j|��dSr )r�r�r�rurR)rDrrr��pathlikes    r(�test_pathlike_constructionz#TestPath.test_pathlike_constructionOsI��	��,�,�X�6�6���<��N� 3� 3�4�4����X�����r4c�\�tj|��}|tjd��zdSr�)rRr�r�r�s   r(�test_traverse_pathlikezTestPath.test_traverse_pathlikeXs,���|�H�%�%���w�|�C� � � � � � r4c�.�tj|��}dSr r�r�s   r(�test_parentzTestPath.test_parent]r�r4c�.�tj|��}dSr r�r�s   r(�test_dir_parentzTestPath.test_dir_parentcr�r4c�.�tj|��}dSr r�r�s   r(�test_missing_dir_parentz TestPath.test_missing_dir_parentir�r4c���	tj|��}|���\}}}|�dd��|�dd��|dz���\}dS)Nr�r�zbar/baz.txtr1r�)rRr�r�rT)rDrrr�r-r�r�r1s       r(�test_mutabilityzTestPath.test_mutabilitynst��	��|�H�%�%���,�,�.�.���1�a����)�U�+�+�+����-��/�/�/���,�'�'�)�)����r4i c���	tj��}tj|d��}t	t
t
|j����D]}|�||���d|_	|S)NrLrZ)
r$r%rRrS�maprur5�HUGE_ZIPFILE_NUM_ENTRIESrTrQ)rDrr��entrys    r(�huge_zipfilezTestPath.huge_zipfilesh��O��z�|�|��
�_�T�3�
'�
'����e�D�$A�B�B�C�C�	&�	&�E��K�K��u�%�%�%�%�����	r4c���	tj|�����}tj�|�����}|D]}|�d���dS)N�suffix)rRr�r�r[r�rir�r�)rDr��entriesr�s    r(�test_joinpath_constant_timez$TestPath.test_joinpath_constant_time�sp��	��|�D�-�-�/�/�0�0���"�*�*�4�<�<�>�>�:�:���	%�	%�E��N�N�8�$�$�$�$�	%�	%r4c�v�d�td��D��}tj�|��dS)Nc�l�g|]1}d�tjt|��z����2S)r)r8�string�ascii_lowercaseru)r1r�s  r(r3z:TestPath.test_implied_dirs_performance.<locals>.<listcomp>�s2��P�P�P�a�����/�#�a�&�&�8�9�9�P�P�Pr4r�)r5rRrkrlr�s  r(�test_implied_dirs_performancez&TestPath.test_implied_dirs_performance�s8��P�P�5��<�<�P�P�P����*�*�4�0�0�0�0�0r4c��|�|��}tj|��5}td��D]+}tj|d���d����,	ddd��dS#1swxYwYdS)Nr�r�r;r<)r�rRrSr5r�r�)rDrrr[�reps    r(�test_read_does_not_closez!TestPath.test_read_does_not_close�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
rrrer4r(�Subclassr��s�������Dr4r�r�)rDrrr�r�s    r(�
test_subclasszTestPath.test_subclass�sC��	�	�	�	�	�w�|�	�	�	��x��!�!���r4c�.�tj|��}dSr r�r�s   r(�
test_filenamezTestPath.test_filename�r�r4c�0�	tj|��}dSr r�r�s   r(�test_root_namezTestPath.test_root_name�s��	��|�H�%�%���r4c�T�	tj|��}|dz}|dzdz}|dz}dS�Nr�r��filename.tar.gzrr��rDrrr�r�r�rs      r(�test_suffixzTestPath.test_suffix�sC��	�
�|�H�%�%��
�7�N��
�3�J�*�*��
�3�J���r4c�^�	tj|��}|dz}|dzdz}|dz}|dz}dS)Nr�r�r�rz.hgrcr�)rDrrr�r�r�rr�s       r(�
test_suffixeszTestPath.test_suffixes�sN��	�
�|�H�%�%��
�7�N��
�3�J�*�*��
�3�J��
�7�N���r4c�T�	tj|��}|dz}|dzdz}|dz}dSr�r�r�s      r(�	test_stemzTestPath.test_stem�sC��	��|�H�%�%��
�7�N��
�3�J�*�*��
�3�J���r4c�F�tj|��}d|j_dS)Nzfoo/bar.zip)rRr�r�rgr�s   r(�test_root_parentzTestPath.test_root_parent�s!���|�H�%�%��*��	���r4c�,�	d|_tj|��}|�t��5|jddd��n#1swxYwY|�t��5|jddd��n#1swxYwY|dz}dSr�)rgrRr�r�rr�parent)rDrrr��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)�typerRr�rsr�r�)rDrrr;r[s    r(�test_inheritancezTestPath.test_inheritance
s\���;�����4�4���-�-�/�/�	)�	)�H��3�x�=�=�)�)�*�5�5�<�D�D�	)�	)r4c��	|�|��}tj|��}tj|��|�|j��dSr )r�rRrSr�rur�)rDrr�source_pathr�s    r(�#test_extract_orig_with_implied_dirsz,TestPath.test_extract_orig_with_implied_dirs
sV��	��)�)�(�3�3��
�_�[�
)�
)����R����
�
�
�k�(�)�)�)�)�)r4N)-r
rrrFrsr�rwr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrer4r(ryry�s�������-�-�-�5�5�5�����
�
��]�
��:�:��]�:�����]���&�&��]�&��/�/��]�/�
2�
2�
2����2I�I�I�&	$�	$�	$�$�$�$��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�����]��"�)�)��]�)��*�*��]�*�*�*r4ryc���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�rLrPr1r.rr?)r�rr�
file_namesrRrSr��file_contentrTr�rArjr�rdrB)rD�placeholdersr3�tempr�r9rs       r(rFzEncodedMetadataTests.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��
Srerf)r1rs  r(r3z3EncodedMetadataTests._test_read.<locals>.<listcomp>?
s��-�-�-����-�-�-r4)
rvri�sortedrwr�ryrgrxrorj)	rDrV�expected_namesr�r�r�rr�r�s	         r(�
_test_readzEncodedMetadataTests._test_read8
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�	8r4c��tjtdd���5}|�||j|j��ddd��dS#1swxYwYdS)NrZr��metadata_encoding)rRrSrrrrr*s  r(� test_read_with_metadata_encodingz5EncodedMetadataTests.test_read_with_metadata_encodingI
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�rdr��r1rs  r(r3zLEncodedMetadataTests.test_read_without_metadata_encoding.<locals>.<listcomp>P
�B��;�;�;�"��+�+�k�2�2�9�9�'�B�B�;�;�;r4r�rZ�rrRrSrrr�rDrrVs   r(�#test_read_without_metadata_encodingz8EncodedMetadataTests.test_read_without_metadata_encodingN
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(r3zSEncodedMetadataTests.test_read_with_incorrect_metadata_encoding.<locals>.<listcomp>W
sB��;�;�;�"��+�+�k�2�2�9�9�(�C�C�;�;�;r4r�rZr rrrs   r(�*test_read_with_incorrect_metadata_encodingz?EncodedMetadataTests.test_read_with_incorrect_metadata_encodingU
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)NrZr.rr;)r�r�rRrSrrs 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(r3z?EncodedMetadataTests.test_read_after_append.<locals>.<listcomp>f
rr4r�s
newcontentr-�
newcontentrZrr)rr�rrRrSrrTrir
rvr�	enumerater�ryrgrxror�r�rj)	rD�newnamerr�rVr2rr�r�s	         r(�test_read_after_appendz+EncodedMetadataTests.test_read_after_appendd
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�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)rLr�r-z^metadata_encoding is onlyznonesuch.ziprr)rRrSrorJ)rD�ZFrQs   r(�!test_write_with_metadata_encodingz6EncodedMetadataTests.test_write_with_metadata_encoding~
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_jisr8�nonesuchr/rr.r+r&)r
rr��
SystemExitrR�mainrirmrprr)rD�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 r.r=)rUrIr!r�rrrar�r8r�UnicodeEncodeErrorr`rRr1rr�rp)rDr}r5rs    r(�'test_cli_with_metadata_encoding_extractz<EncodedMetadataTests.test_cli_with_metadata_encoding_extract�
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
rrrrdrrFrrrr!r#r)r,r6r9rer4r(rr
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�)�)�)�&)�)�)�)�)r4rc�*�eZdZdZd�Zd�Zd�Zd�ZdS)�StripExtraTestsr`c�2�tjd��}|�|jd��}|�dd��}|�dd��}|�dtj||jf����|�|tj||jf����|�|dztj|dz|jf����|�||ztj||z|z|jf����|�||ztj||z|z|jf����|�||ztj||z|z|jf����dS)Nr�rr�r�r4�z�rc�Structr��ZIP64_EXTRArirR�_strip_extra�rDrSr-r�r�s     r(�test_no_datazStripExtraTests.test_no_data�
s}���M�%� � ��
�F�F�4�#�Q�'�'��
�F�F�1�a�L�L��
�F�F�1�a�L�L������g�2�1�t�7G�6I�J�J�K�K�K�����G�0��T�5E�4G�H�H�I�I�I����
�d�F�G�(��4��$�2B�1D�E�E�	G�	G�	G�	
����1��g�2�1�Q�3�q�5�4�;K�:M�N�N�O�O�O�����1��g�2�1�Q�3�q�5�4�;K�:M�N�N�O�O�O�����1��g�2�1�Q�3�q�5�4�;K�:M�N�N�O�O�O�O�Or4c�D�tjd��}|�|jd��dz}|�dd��dz}|�dd��dz}|�dtj||jf����|�|tj||jf����|�|d	ztj|d	z|jf����|�||ztj||z|z|jf����|�||ztj||z|z|jf����|�||ztj||z|z|jf����dS)
Nr�r`rAr��bbr�scccr4r=r>rBs     r(�test_with_datazStripExtraTests.test_with_data�
s����M�%� � ��
�F�F�4�#�Q�'�'�$�.��
�F�F�1�a�L�L�5� ��
�F�F�1�a�L�L�6�!������g�2�1�t�7G�6I�J�J�K�K�K�����G�0��T�5E�4G�H�H�I�I�I����
�d�F�G�(��4��$�2B�1D�E�E�	G�	G�	G�	
����1��g�2�1�Q�3�q�5�4�;K�:M�N�N�O�O�O�����1��g�2�1�Q�3�q�5�4�;K�:M�N�N�O�O�O�����1��g�2�1�Q�3�q�5�4�;K�:M�N�N�O�O�O�O�Or4c��tjd��}|�|jd��dz}|�dd��dz}|�dtj||z|jf����|�dtj||z|z|jf����|�dtj||zdz|jf����|�|dztj||z|zdz|jf����|�|tj||z|z|jf����|�|tj||z|z|jf����|�|tj||z|z|jf����dS)Nr�r`rAr�rEr4r=r>)rDrSr-r�s    r(�test_multipleszStripExtraTests.test_multiples�
s����M�%� � ��
�F�F�4�#�Q�'�'�$�.��
�F�F�1�a�L�L�5� ������g�2�1�Q�3��9I�8K�L�L�M�M�M�����g�2�1�Q�3�q�5�4�;K�:M�N�N�O�O�O�����'�&�q��s�4�x�$�2B�1D�E�E�	G�	G�	G����
�d�F�G�(��1��Q��t��d�6F�5H�I�I�	K�	K�	K�	
����G�0��1��Q���9I�8K�L�L�M�M�M�����G�0��1��Q���9I�8K�L�L�M�M�M�����G�0��1��Q���9I�8K�L�L�M�M�M�M�Mr4c�~�|�dtjd|jf����|�dtjd|jf����|�dtjd|jf����|�dtjd|jf����dS)Nr4r=szzszzz)rirRrAr@rs r(�test_too_shortzStripExtraTests.test_too_short�
s�������g�2�3��9I�8K�L�L�M�M�M�����w�3�D�4�;K�:M�N�N�O�O�O�����7�'���0@�/B�C�C�	E�	E�	E�����G�(��$�2B�1D�E�E�	G�	G�	G�	G�	Gr4N)r
rrr@rCrFrHrJrer4r(r;r;�
se������
�K�
P�
P�
P�
P�
P�
P�N�N�N� G�G�G�G�Gr4r;�__main__)ar�r��importlib.utilrr$r�rUr�r	r�rcrOrQ�test.support.script_helperrrsr��
unittest.mockrBrRru�tempfilerrrr�test.supportrr	r
rrr
rr�test.support.os_helperrrrrrrr!r9r6�
DATAFILES_DIRrZr)r+�TestCaserrirrrwr|r�r�r�r�r�r�r�rrrrXr�rHrRrTrVrXrZryr�r�r�r�r�r�r�r�r�rrr@�tuple�consumer[rmrorwryrr;r
r1rer4r(�<module>rVs���������������	�	�	�	�����	�	�	�	���������
�
�
�
�
�
�
�
�����
�
�
�
�7�7�7�7�7�7�����������������������#�"�"�"�"�"�-�-�-�-�-�-�-�-�-�-�&�&�&�&�&�&�����������������������������������
�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���T*�T*�T*�T*�T*�x� �T*�T*�T*�nN)�N)�N)�N)�N)�8�,�N)�N)�N)�b;G�;G�;G�;G�;G�h�'�;G�;G�;G�|�z����H�M�O�O�O�O�O��r4