Sindbad~EG File Manager

Current Path : /usr/local/lib/python3.11/test/__pycache__/
Upload File :
Current File : //usr/local/lib/python3.11/test/__pycache__/test_zipfile.cpython-311.pyc

�

SԚg*r���	�ddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
mZddlZddlZddlmZddlZddlZddlmZddlmZmZmZddlmZddlmZddlmZmZm Z m!Z!m"Z"m#Z#m$Z$ddl%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,e&d	zZ-e&d
zZ.dZ/dZ0gd
�Z1d�Z2Gd�d��Z3Gd�de3ej4��Z5e��Gd�de3ej4����Z6e ��Gd�de3ej4����Z7e!��Gd�de3ej4����Z8Gd�d��Z9Gd�de9ej4��Z:e��Gd�de9ej4����Z;e ��Gd�d e9ej4����Z<e!��Gd!�d"e9ej4����Z=Gd#�d$��Z>Gd%�d&e>ej4��Z?e��Gd'�d(e>ej4����Z@e ��Gd)�d*e>ej4����ZAe!��Gd+�d,e>ej4����ZBGd-�d.ej4��ZCGd/�d0ej4��ZDGd1�d2ejEej4��ZEGd3�d4ej4��ZFGd5�d6��ZGGd7�d8eGej4��ZHe��Gd9�d:eGej4����ZIe ��Gd;�d<eGej4����ZJe!��Gd=�d>eGej4����ZKGd?�d@ej4��ZLGdA�dB��ZMGdC�dDeMej4��ZNe��GdE�dFeMej4����ZOe ��GdG�dHeMej4����ZPe!��GdI�dJeMej4����ZQGdK�dL��ZRGdM�dN��ZSGdO�dPej4��ZTe��GdQ�dRej4����ZUGdS�dTej4��ZVGdU�dVej4��ZWGdW�dXej4��ZXGdY�dZej4��ZYeZZ[Gd[�d\��Z\d]�Z]d^�Z^d_�Z_Gd`�daej4��Z`Gdb�dceja��ZbGdd�deej4��ZcGdf�dgej4��Zdeedhkrejf��dSdS)i�N)�assert_python_ok)�
TemporaryFile)�randint�random�	randbytes)�archiver_tests)�
script_helper)�findfile�
requires_zlib�requires_bz2�
requires_lzma�captured_stdout�captured_stderr�requires_subprocess)�TESTFN�unlink�rmtree�temp_dir�temp_cwd�fd_count�FakePath�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/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#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>9sH��8�8�8���H� �&�(�(�m�,�-4�6�6�8�8�8�r6)�range�FIXEDTEST_SIZE�line_gen�join�data��clss r*�
setUpClassz&AbstractTestsWithSourceFile.setUpClass7sE��8�8�!&�~�!6�!6�8�8�8����8�8�C�L�)�)����r6c��ttd��5}|�|j��ddd��dS#1swxYwYdS�N�wb��openr�writer;��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�ZipFilerDr�writestrr;rCr9)rFr)rLrM�kwargs�zipfp�lines       r*�make_test_archivez-AbstractTestsWithSourceFile.make_test_archiveCsX��!,�}�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�rrOrP)�file��	File Namer�Modified�Size��%Y-%m-%d�%H:%M:%S�rQc��g|]	}|j��
S���filenamer2s  r*r5z8AbstractTestsWithSourceFile.zip_test.<locals>.<listcomp>r���/�/�/�A�Q�Z�/�/�/r6)rZrTrU�assertEqual�readrr;r&�StringIO�printdir�getvalue�
splitlines�len�assertIn�split�
assertTrue�time�strptime�str�namelist�infolist�	file_size�getinfori�testzip)rFr)rLrMrXrG�	directory�lines�fn�date�time_�size�names�infosr4�nm�infos                 r*�zip_testz$AbstractTestsWithSourceFile.zip_testNs������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�rL�rFr)s  r*�
test_basicz&AbstractTestsWithSourceFile.test_basic��;���4���	/�	/�A��M�M�!�T�-�.�.�.�.�	/�	/r6c���|�||��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�Nr\T�rOr6)
rZrTrUrCrrl�appendrkr:r;)	rFr)rLrX�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�rLr�s  r*�	test_openz%AbstractTestsWithSourceFile.test_open��=���4���	4�	4�A����q�$�"2�3�3�3�3�	4�	4r6c��tt��}|�||j��t	j|d|j��5}|�|jt��ddd��dS#1swxYwYdS�Nr\)	rr#r�rLrTrU�assertIsInstancerirw)rF�pathrXs   r*�test_open_with_pathlikez3AbstractTestsWithSourceFile.test_open_with_pathlike�s����� � �����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�!A9�9A=�A=c���|�||��tj|d|��5}g}|�t��5}	|�t
dd����}|sn|�|���<	ddd��n#1swxYwY|�d�	|��|j
��ddd��dS#1swxYwYdS�Nr\Trb�r6)rZrTrUrCrrlrr�rkr:r;)rFr)rLrXr�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�rLr�s  r*�test_random_openz,AbstractTestsWithSourceFile.test_random_open��=���4���	;�	;�A��%�%�a��)9�:�:�:�:�	;�	;r6c��|�||��tj|d��5}|�t��5}g}	|�d��}|sn|�|���.	ddd��n#1swxYwYddd��n#1swxYwY|�d�|��|j	��dS)Nr\T���r6)
rZrTrUrCr�read1r�rkr:r;�rFr)rLrX�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�rLr�s  r*�
test_read1z&AbstractTestsWithSourceFile.test_read1�s=���4���	5�	5�A�����4�#3�4�4�4�4�	5�	5r6c��|�||��tj|d��5}|�t��5}g}	|�d��}|�t|��d��|sn|�|���Q	ddd��n#1swxYwYddd��n#1swxYwY|�	d�
|��|j��dS)Nr\T�
r6)rZrTrUrCrr��assertLessEqualrqr�rkr:r;r�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�rLr�s  r*�
test_read1_10z)AbstractTestsWithSourceFile.test_read1_10��=���4���	8�	8�A��"�"�1�d�&6�7�7�7�7�	8�	8r6c��|�||��tj|d��5}|�t��5}d}	|���}|sn#||z
}|�d��}|sn||z
}�:ddd��n#1swxYwYddd��n#1swxYwY|�||j��dS)Nr\r6T�d)	rZrTrUrCr�readlinerlrkr;)rFr)rLrXr�r;rls       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�rLr�s  r*�test_readline_readz.AbstractTestsWithSourceFile.test_readline_read�s=���4���	=�	=�A��'�'��4�+;�<�<�<�<�	=�	=r6c�\�|�||��tj|d��5}|�t��5}|jD],}|���}|�||���-	ddd��n#1swxYwYddd��dS#1swxYwYdSr�)rZrTrUrCrr9r�rk)rFr)rLrXr�rY�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�rLr�s  r*�
test_readlinez)AbstractTestsWithSourceFile.test_readliner�r6c�~�|�||��tj|d��5}|�t��5}|���}ddd��n#1swxYwYt
|j|��D]\}}|�||���	ddd��dS#1swxYwYdSr�)	rZrTrUrCr�	readlines�zipr9rk)rFr)rLrXr��ziplinesrY�ziplines        r*�zip_readlines_testz.AbstractTestsWithSourceFile.zip_readlines_tests?�����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�rLr�s  r*�test_readlinesz*AbstractTestsWithSourceFile.test_readlines�=���4���	9�	9�A��#�#�A�t�'7�8�8�8�8�	9�	9r6c�V�|�||��tj|d��5}|�t��5}t|j|��D]\}}|�||���	ddd��n#1swxYwYddd��dS#1swxYwYdSr�)rZrTrUrCrr�r9rk)rFr)rLrXr�rYr�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�rLr�s  r*�test_iterlinesz*AbstractTestsWithSourceFile.test_iterlines"r�r6c��tjtd|j��5}|�dd��ddd��n#1swxYwYtjtd|j��5}|�d��5}|�|�d��d��|�|�d��d��ddd��n#1swxYwYddd��dS#1swxYwYdS)	z>Check for cases where compressed data is larger than original.rNrP�12Nr\rb�1�2)rTrUr#rLrVrCrkrl)rFrX�openobjs   r*�test_low_compressionz0AbstractTestsWithSourceFile.test_low_compression&s����_�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�/C<�AC$�C<�$C(	�(C<�+C(	�,C<�<D�Dc���tjtd��}|�dd|j���|�d��}|�|j|j��dS)NrN�b.txt�hello world��
compress_type)rTrUr#rVrLr{rkr�)rFrXr�s   r*�test_writestr_compressionz5AbstractTestsWithSourceFile.test_writestr_compression2sa������-�-��
���w�
�T�=M��N�N�N��}�}�W�%�%������+�T�-=�>�>�>�>�>r6c���tjtdd���}|�dd|j���|�dd|jd�	��|�d��}|�|j|j��|�|jd��|�d��}|�|j|j��|�|jd��dS)
NrNrb�rM�a.txtr�r�r��)r�rM)	rTrUr#rVrLr{rkr��_compresslevel)rFrX�a_info�b_infos    r*�test_writestr_compresslevelz7AbstractTestsWithSourceFile.test_writestr_compresslevel8s�������A�>�>�>��
���w�
�T�=M��N�N�N�
���w�
�T�=M�%&�	�	(�	(�	(����w�'�'������-�t�/?�@�@�@�����.��2�2�2����w�'�'������-�t�/?�@�@�@�����.��2�2�2�2�2r6c��dD]�}|dz}t|��}tjtj��d|j��5}|�d|��|�dd��5}|�|��}|�	t|��|��ddd��n#1swxYwYddd��n#1swxYwY��dS)N)rbi�iii@rbrN�foor\)rrTrUr&r'rLrVrCrlrkrq)rF�	test_sizerz�junk�zipfrG�bufs       r*�test_read_return_sizez1AbstractTestsWithSourceFile.test_read_return_sizeHsJ��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)NrNrRrPr��r�)r&r'rTrUrVr;rL�tellrorC�truncate�assertRaises�EOFErrorrlr�)rFrGr��
end_offset�zipfiledatar�s      r*�test_truncated_zipfilez2AbstractTestsWithSourceFile.test_truncated_zipfileTs#��
�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.namerNzmode='w'r\zfilename=%rzfile=%rzmode='r'z	filemode=z
file_size=zcompress_type=zcompress_size=zname=%rz[closed])
r+rTrUrLrDr�reprrr�
isinstancerwr{�
ZIP_STOREDrC)rF�fnamer)rXr\r�s      r*�	test_reprz%AbstractTestsWithSourceFile.test_reprrs�����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�?�?�?�?�	@�	@r6c��tjtdd���5}|�td��|�tdd���|�d��}|�d��}|�|jd��|�|jd��ddd��dS#1swxYwYdS)zTCheck that files within a Zip archive can have different
        compression levels.rNrbr��
compress_1�
compress_9r�N)rTrUr#rDrr{rkr�)rFrX�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�Nrb)�OSError�superrD)rFr;�	__class__�count�stops  ���r*rDzIAbstractTestsWithSourceFile.test_writing_errors.<locals>.BrokenFile.write�s<����$���}�}�%�
��Q�J�E����
�
�d�#�#�#�#�#r6)�__name__�
__module__�__qualname__rD�
__classcell__)r
rrs@��r*�
BrokenFiler�sC��������
$�
$�
$�
$�
$�
$�
$�
$�
$�
$�
$r6rrTrN�file1sdata1�file2sdata2rb)r&r'rTrUrLrCrDrrorkrxrl)rFr�testfilerXr)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��d}tjtd���5}|�|d��ddd��n#1swxYwYtjtd���5}|�|��5}|�|j|��|�tj	|j
��|�|jd��|�|�
��d��|�|���d��|�|���d��|�|jd��ddd��n#1swxYwY|�|jd��|�|j|��|�|jd��|�tj	|j
��|�t"|j
��|�|���d��|�t"|j��ddd��dS#1swxYwYdS)N�somefile.txtrNrR�bogusr\TF)rTrUr#rVrCrk�namer�r&�UnsupportedOperation�filenorS�assertIs�readable�writable�seekabler%�
ValueError�rFr�rX�fids    r*�test_zipextfile_attrsz1AbstractTestsWithSourceFile.test_zipextfile_attrs�s�����
�_�W�3�
/�
/�
/�	+�5��N�N�5�'�*�*�*�	+�	+�	+�	+�	+�	+�	+�	+�	+�	+�	+����	+�	+�	+�	+��_�W�3�
/�
/�
/�	8�5����E�"�"�
1�c�� � ���5�1�1�1��!�!�"�"9�3�:�F�F�F�� � ���3�/�/�/��
�
�c�l�l�n�n�d�3�3�3��
�
�c�l�l�n�n�e�4�4�4��
�
�c�l�l�n�n�d�3�3�3��
�
�c�j�%�0�0�0�
1�
1�
1�
1�
1�
1�
1�
1�
1�
1�
1����
1�
1�
1�
1�
�M�M�#�*�d�+�+�+����S�X�u�-�-�-����S�X�s�+�+�+����b�5�s�z�B�B�B����j�#�,�7�7�7��M�M�#�,�,�.�.�%�0�0�0����j�#�,�7�7�7�	8�	8�	8�	8�	8�	8�	8�	8�	8�	8�	8�	8����	8�	8�	8�	8�	8�	8sI�A�A�A�'I.�=C/E8�,I.�8E<	�<I.�?E<	�C!I.�.I2�5I2c�V�tt��tt��dSr"�rrr#�rFs r*�tearDownz$AbstractTestsWithSourceFile.tearDown�����v�����w�����r6r")%r
rr�classmethodr>rHrZr�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�rrr#r'rgr6r*r-r-6s�������*�*��[�*� � � �
	"�	"�	"�	"�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�>@�@�@�	:�	:�	:�"<�"<�"<�H8�8�8�,����r6r-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)Nr\rP��rQ)rZrTrUr{rk�
external_attr)rFr)rLrX�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+r1rTr�r�s  r*�test_writestr_permissionsz3StoredTestsWithSourceFile.test_writestr_permissions�sA���4���	F�	F�A��.�.�q�'�2D�E�E�E�E�	F�	Fr6c��tjtdtj��5}|�t
d��ddd��n#1swxYwYtjtdtj��5}|�|���dg��ddd��dS#1swxYwYdS)NrN�	/absoluter\�absolute�rTrUr#r�rDrrkrx�rFrXs  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)z&Test appending to an existing zipfile.rNN�arP)
rTrUr#r�rDrrVr;rkrxr8s  r*�test_append_to_zip_filez1StoredTestsWithSourceFile.test_append_to_zip_file�sG��
�_�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�"Cc�d�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)z9Test appending to an existing file that is 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!I am not a ZipFile!rANr;�rbr\)rCr#rDrTrUr�r�seekrqrkrxrlr;r&r')rFr;r)rXr��bios      r*�test_append_to_non_zip_filez5StoredTestsWithSourceFile.test_append_to_non_zip_files���)��
�'�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�78E4�/A"E�E4�E!	�!E4�$E!	�%E4�4E8�;E8�AG+�+G/�2G/�
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)NrNr>rA)r&r'rTrUr�rDrrorCr#rkrxrlr;�rFrArXr�r;r)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)NrNsI am not a ZipFile!i@BrAr;rPr?)r&r'rTrUr�rDrrorCr#rkrxrVr;rlrqrDs      r*�$test_append_to_concatenated_zip_filez>StoredTestsWithSourceFile.test_append_to_concatenated_zip_file*s���
�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)NrNr;�utf-8��encodingz
r\)rTrUr#r�rDrrCr��rFrXr)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)NrN�this is a commentr;rIrJzabcdef
r\)
rTrUr#r��commentrDrrCr�rkrLs   r*�)test_ignores_stuff_appended_past_commentszCStoredTestsWithSourceFile.test_ignores_stuff_appended_past_commentsHs���
�_�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�z�tjtd��5}|�t��ttd��5}|�|�t��|�����ddd��n#1swxYwYddd��dS#1swxYwYdS)z`Check that calling ZipFile.write without arcname specified
        produces the expected result.rNr?N)rTrUr#rDrrCrkrlrLs   r*�test_write_default_namez1StoredTestsWithSourceFile.test_write_default_nameRs���_�W�c�
*�
*�	?�e��K�K������f�d�#�#�
?�q�� � ����F�!3�!3�Q�V�V�X�X�>�>�>�
?�
?�
?�
?�
?�
?�
?�
?�
?�
?�
?����
?�
?�
?�
?�	?�	?�	?�	?�	?�	?�	?�	?�	?�	?�	?�	?����	?�	?�	?�	?�	?�	?s6�0B0�AB�B0�B	�B0�B	� B0�0B4�7B4c��d}tjtd|j���5}|�|d��ddd��n#1swxYwYtjtd���5}|�|��5}|���|�|jd��|�	t|j��|�	t|jd��|�	t|j
��ddd��n#1swxYwYddd��dS#1swxYwYdS)	NrrN�rSrLrr\rRTr)rTrUr#rLrVrC�closerr%r�r rlr@r�r!s    r*�test_io_on_closed_zipextfilez6StoredTestsWithSourceFile.test_io_on_closed_zipextfileZs�����
�_�W�3�D�<L�
M�
M�
M�	+�QV��N�N�5�'�*�*�*�	+�	+�	+�	+�	+�	+�	+�	+�	+�	+�	+����	+�	+�	+�	+��_�W�3�
/�
/�
/�	8�5����E�"�"�
8�c��	�	�����
�
�c�j�$�/�/�/��!�!�*�c�h�7�7�7��!�!�*�c�h��:�:�:��!�!�*�c�h�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�-D8�BD �D8� D$	�$D8�'D$	�(D8�8D<�?D<c�N�tjtd���5}|�dd��ddd��n#1swxYwYtjtd���5}|�t
|jt��ddd��n#1swxYwYtjtd���5}|�t
��5|�td���ddd��n#1swxYwYddd��dS#1swxYwYdS)z[Check that trying to call write() on a readonly ZipFile object
        raises a ValueError.rNrRrrNr\)	rTrUr#rVr�r rDrrCr8s  r*�test_write_to_readonlyz0StoredTestsWithSourceFile.test_write_to_readonlygs����_�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��
�,�,�,�
-�
-�
-�
-�
-�
-�
-�
-�
-�
-�
-����
-�
-�
-�
-�	-�	-�	-�	-�	-�	-�	-�	-�	-�	-�	-�	-����	-�	-�	-�	-�	-�	-sW�?�A�A�%'B�B�B�>D�D�6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)rrrNF��strict_timestamps�i�rbrbrrr)�os�utimerrTrUr#r�r rDr{rk�	date_time)rFrXr/s   r*�test_add_file_before_1980z3StoredTestsWithSourceFile.test_add_file_before_1980ts[��
���� � � �
�_�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=rNFr[)i;����;rf)ru�	localtime�
OverflowError�skipTestr^r_r�stat�st_mtime_nsrTrUr#r��struct�errorrDr{rkr`)rF�ts�mtime_nsrXr/s     r*�test_add_file_after_2107z2StoredTestsWithSourceFile.test_add_file_after_2107sN��
��	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
rrrTr�rLr�r1r3r9r<rBrErGrMrQrSrWrYrarprgr6r*r+r+�s�������$�K���@�@�@�F�F�F�=�=�=�D�D�D�<�<�<�.<�<�<�?�?�?�,:�:�:�B�B�B�?�?�?�8�8�8�-�-�-�	E�	E�	E�J�J�J�J�Jr6r+c�"�eZdZejZd�ZdS)�DeflateTestsWithSourceFilec���tjtd��5}|�tdtj��|�tdtj��|�d��}|�d��}|�|j	tj��|�|j	tj��ddd��dS#1swxYwYdS)zUCheck that files within a Zip archive can have different
        compression options.rN�storeme�	deflatemeN)
rTrUr#rDrr��ZIP_DEFLATEDr{rkr�)rFrX�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-�0C-N)r
rrrTrvrLryrgr6r*rrrr�s2�������&�K�	H�	H�	H�	H�	Hr6rrc��eZdZejZdS)�Bzip2TestsWithSourceFileN�r
rrrT�	ZIP_BZIP2rLrgr6r*r{r{���������#�K�K�Kr6r{c��eZdZejZdS)�LzmaTestsWithSourceFileN�r
rrrT�ZIP_LZMArLrgr6r*r�r����������"�K�K�Kr6r�c�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.r0N)r1r2s  r*�	<genexpr>z;AbstractTestZip64InSmallFiles.setUpClass.<locals>.<genexpr>�sF����7�7���4�q�8�'�B�B�7�7�7�7�7�7r6r�
)r7r8r:r;)r=r9s  r*r>z(AbstractTestZip64InSmallFiles.setUpClass�sA��7�7�"�1�n�5�5�7�7�7���:�:�h�'�'����r6c�
�tj|_tj|_dt_dt_ttd��5}|�|j��ddd��dS#1swxYwYdS)Nrr�rA)	rT�ZIP64_LIMIT�_limit�ZIP_FILECOUNT_LIMIT�_filecount_limitrCrrDr;rEs  r*rHz#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)NrNT��
allowZip64rOrPr\rer_rr`rarbrcrd�c��g|]	}|j��
Srgrhr2s  r*r5z:AbstractTestZip64InSmallFiles.zip_test.<locals>.<listcomp>�rjr6)rTrUrDrrVr;rkrlr&rmrnrorprqrrrsrtrurvrwrxryrzr{rir|)rFr)rLrXrGr}r~rr�r�r�r�r�r4r�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_basicr�r6c���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)NrNTr�r���foo%08d�%dr��9r\r0)
rTrUrrL�debugr7rVrkrqrxrVrl�decode)rFr��numfilesr4�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�
���
�
�
�
�
r6c��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)NrNFr�r�r�r�r�r�r�r6r;Tr�r\r0)rTrUrrLr�r7rVrkrqrxr��LargeZipFilerVrlr�)rFr�r�r4�	numfiles2r�r�s       r*�test_too_many_files_appendz8AbstractTestZip64InSmallFiles.test_too_many_files_appends�����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�rTr�r�r�rrr#r&s r*r'z&AbstractTestZip64InSmallFiles.tearDownFs1��"�k���&*�&;��#��v�����w�����r6N)r
rrr)r>rHr�r�r�r�r'rgr6r*r�r��s��������(�(��[�(�
 � � �7�7�7�r/�/�/����&%�%�%�N����r6r�c�l�eZdZejZd�Zd�Zd�Zd�Z	d�Z
			dd�Zd�Zd	�Z
d
�Zd�Zd�Zd
�ZdS)�StoredTestZip64InSmallFilesc��tj|d|d���5}|�tj|jt
d��ddd��dS#1swxYwYdS�NrNFr�rO)rTrUr�r�rDr�rFr)rLrXs    r*�large_file_exception_testz5StoredTestZip64InSmallFiles.large_file_exception_testQs���
�_�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�)rTrUr�r�rVr;r�s    r*�large_file_exception_test2z6StoredTestZip64InSmallFiles.large_file_exception_test2Vs���
�_�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�rTr�r�r�s  r*�test_large_file_exceptionz5StoredTestZip64InSmallFiles.test_large_file_exception[sZ���4���	C�	C�A��*�*�1�g�.@�A�A�A��+�+�A�w�/A�B�B�B�B�	C�	Cr6c��tjtdtjd���5}|�t
d��ddd��n#1swxYwYtjtdtj��5}|�|���dg��ddd��dS#1swxYwYdS)NrNTr�r5r\r6r7r8s  r*r9z2StoredTestZip64InSmallFiles.test_absolute_arcnames`s(��
�_�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)NrNTr�rPr\r;�strfile2)rTrUr#rVr;r{�extrark)rFrXr/r�s    r*�test_appendz'StoredTestZip64InSmallFiles.test_appendhs&���_�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)z�Generate bytes sequence for a zip with (incomplete) zip64 data.

        The actual values (not the zip 64 0xffffffff values) stored in the file
        are:
        file_size: 8
        compress_size: 8
        header_offset: 0
        �r����<L�<HH�Qrbz<Q�:�2z<Hrestest.txt�test1234sPK!�%��sPK--!�%��s
�sPK,--ss
sPKlssPK:2s)r�rl�packrq)rF�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_fieldsrz�
compress_size�
header_offset�local_extra�
central_extra�central_dir_size�offset_to_central_dir�local_extra_length�central_extra_lengthrir��filename_length�zip64_contentss                        r*�make_zip64_filez+StoredTestZip64InSmallFiles.make_zip64_filevsb���� ����!���	��	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�r6c�	�|�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|�d	t|j	���
����|�d
ddd���}|�tj��5}tjtj|����ddd��n#1swxYwY|�d	t|j	���
����|�ddd
d���}|�tj��5}tjtj|����ddd��n#1swxYwY|�d	t|j	���
����|�d
d
d�
��}|�tj��5}tjtj|����ddd��n#1swxYwY|�d	t|j	���
����dS)a
Missing zip64 extra records raises an exception.

        There are 4 fields that the zip64 format handles (the disk number is
        not used in this module and so is ignored here). According to the zip
        spec:
              The order of the fields in the zip64 extended
              information record is fixed, but the fields MUST
              only appear if the corresponding Local or Central
              directory record field is set to 0xFFFF or 0xFFFFFFFF.

        If the zip64 extra content doesn't contain enough entries for the
        number of fields marked with 0xFFFF or 0xFFFFFFFF, we raise an error.
        This test mismatches the length of the zip64 extra field and the number
        of fields set to indicate the presence of zip64 data.
        T)r�Nz	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�rT�
BadZipFilerUr&r'rrrw�	exception�lower)rF�missing_file_size_extra�e�missing_compress_size_extra�missing_header_offset_extras     r*�test_bad_zip64_extraz0StoredTestZip64InSmallFiles.test_bad_zip64_extra�sR��$#'�"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-�0A-�%'D�D�D�'G�G	�G	�'I6�6I:�=I:�3'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�rbrg)r7rq�	itertools�combinations�updaterTrUr&r'r�ryrkrzr�r�rl)rF�expected_file_size�expected_compress_size�expected_header_offset�expected_content�paramsr\�comborW�c�zfr/s            r*� test_generated_valid_zip64_extraz<StoredTestZip64InSmallFiles.test_generated_valid_zip64_extra7s�����!"��!"��&��
"&�$�?�?�%)�$�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�Ec�"�tj��}tj|dd���5}|�ddd���5}|�d��ddd��n#1swxYwYddd��n#1swxYwY|���}tjd|dd	���\}}}}}	}
}}}
}}}}}}|�	|d
��|�
|tj��|�	|d��|�	|d��|�	|	d��|�	|
d��|�	|d��|�	|d
��|�	|
d��|�	|d��|�	|d��|�	|d��|�	|d��|�	|d��tjtj|����}|���}|�	t|��d��|�
|djtj��dS)zGTest that forcing zip64 extensions correctly notes this in the zip filerNT�rSr��text.txt�rS�force_zip64�_Nz<4sBBHH8xIIHH8shhQQx4s�?�PKrr�r�r�rb��PK)r&r'rTrUrCrDrorl�unpackrk�assertGreaterEqual�
ZIP64_VERSIONryrq�extract_version)rFr;r��zir��header�versr^�flags�comp�csize�usize�fn_len�ex_total_lenri�ex_id�ex_len�ex_usize�ex_csize�cd_sig�z�zinfoss                      r*�test_force_zip64z,StoredTestZip64InSmallFiles.test_force_zip64Rs���*�z�|�|��
�_�T���
=�
=�
=�	������#�4��@�@�
�B��������
�
�
�
�
�
�
�
�
�
�
����
�
�
�
�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	��-�-�/�/��
�M�2�G�C�R�C�L�A�A�	
��D�"�e�T�5�%���(�E�6�8�X�v�	
�����/�/�/�����g�&;�<�<�<�����Q���������"�"�"�����q�!�!�!�����
�+�+�+�����
�+�+�+������#�#�#�����r�*�*�*������"�"�"������$�$�$�����1�%�%�%�����1�%�%�%������/�/�/��O�B�J�w�/�/�0�0������������V���a�(�(�(�����q�	� 9�7�;P�Q�Q�Q�Q�Qs5�A=�A&�A=�&A*	�*A=�-A*	�.A=�=B�Bc���d�}|�t|tj����|�t|t	tj������dS)zjTest that creating a zip with/without seeking will raise a RuntimeError if zip64 was required but not usedc��tj|dd���5}|�ddd���5}|�dtjdzz��ddd��n#1swxYwYddd��dS#1swxYwYdS)	NrNTr�r�Fr�r�rb)rTrUrCrDr�)rGr�r�s   r*�make_zipzRStoredTestZip64InSmallFiles.test_unseekable_zip_unknown_filesize.<locals>.make_zip�s�����#�$�?�?�?�
?�2��W�W�Z�c�u�W�E�E�?���H�H�T�W�%8�1�%<�=�>�>�>�?�?�?�?�?�?�?�?�?�?�?����?�?�?�?�
?�
?�
?�
?�
?�
?�
?�
?�
?�
?�
?�
?����
?�
?�
?�
?�
?�
?s4�A;�&A#�A;�#A'	�'A;�*A'	�+A;�;A?�A?N)r��RuntimeErrorr&r'�
Unseekable�rFrs  r*�$test_unseekable_zip_unknown_filesizez@StoredTestZip64InSmallFiles.test_unseekable_zip_unknown_filesize�s]��	?�	?�	?�
	
���,��"�*�,�,�?�?�?����,��*�R�Z�\�\�2J�2J�K�K�K�K�Kr6c���d�}|�tj|tj����|�tj|ttj������dS)z^Test that trying to add a large file to a zip that doesn't allow zip64 extensions fails on addc���tj|dd���5}tjd��}tjdz|_|�|d���ddd��dS#1swxYwYdS)NrNFr�r�rbrR)rTrU�ZipInfor�rzrC)rGr�r�s   r*rzRStoredTestZip64InSmallFiles.test_zip64_required_not_allowed_fail.<locals>.make_zip�s������#�%�@�@�@�
(�B���z�2�2��!(�!4�q�!8�������3��'�'�'�	
(�
(�
(�
(�
(�
(�
(�
(�
(�
(�
(�
(����
(�
(�
(�
(�
(�
(s�AA%�%A)�,A)N)r�rTr�r&r'r
rs  r*�$test_zip64_required_not_allowed_failz@StoredTestZip64InSmallFiles.test_zip64_required_not_allowed_fail�sc��	(�	(�	(�	
���'�.��"�*�,�,�G�G�G����'�.��*�R�Z�\�\�:R�:R�S�S�S�S�Sr6c���tjdz��fd�}|tj�������}tjd����|dd�z���\}}}}}}}	}
}}}
}}}}|�|d��|�	|tj
��|�|d��|�|d��|�|d��|�|d��|�|	d��|�|
d	��|�|d
��|�|
d��|�|d��|�|���|�|���|�|d��|ttj������j���}tjd
����|dd�z���\}}}}}}}	}
}}}
}}}}}}}|�|d��|�	|tj
��|�|d��|�d�|��d��|�|d��|�|d��|�|	d��|�|
d	��|�|d
��|�|
d��|�|d��|�|d��|�|d��|�|d��|�|���|�|���|�|d��dS)zhTest that creating a zip without seeking will use zip64 extensions if the file size is provided up-frontrbc�,��tj|dd���5}tjd��}�|_|�|dd���5}|�d�z��ddd��n#1swxYwYddd��n#1swxYwY|S)NrNTr�r�Fr�r�)rTrUrrzrCrD)rGr�r�r�rzs    �r*rzPStoredTestZip64InSmallFiles.test_unseekable_zip_known_filesize.<locals>.make_zip�s
������#�$�?�?�?�
/�2���z�2�2��!*����W�W�T���W�?�?�/�2��H�H�T�I�-�.�.�.�/�/�/�/�/�/�/�/�/�/�/����/�/�/�/�	
/�
/�
/�
/�
/�
/�
/�
/�
/�
/�
/����
/�
/�
/�
/��Is5�4B	�
A2�&B	�2A6	�6B	�9A6	�:B	�	B
�B
z<4sBBHH8xIIHH8shhQQ{}x4sN�>r�rr�r�r�r�r�z<4sBBHH8xIIHH8shhQQ{}x4s4xQQ4s�Vz{:b}�1000sPK)
rTr�r&r'rorlr��formatrkr�r�r
rG)rFr�
seekable_datar�r�r^r�r�r�r�r�rrirrrrr�unseekable_data�	dd_header�dd_usize�dd_csizerzs                      @r*�"test_unseekable_zip_known_filesizez>StoredTestZip64InSmallFiles.test_unseekable_zip_known_filesize�s���� �'�!�+�	�	�	�	�	�	�!������.�.�7�7�9�9�
�

�M�4�;�;�I�F�F�
�Ve�WY�\e�We�Ve�Hf�g�g�		
��D�"�e�T�5�%���(�E�6�8�X��	
�����/�/�/�����g�&;�<�<�<�����Q���������"�"�"�����q�!�!�!�����
�+�+�+�����
�+�+�+������#�#�#�����r�*�*�*������"�"�"������$�$�$�����9�-�-�-�����9�-�-�-������/�/�/�#�(�:�b�j�l�l�#;�#;�<�<�?�H�H�J�J��

�M�:�A�A�)�L�L�o�^m�_a�dm�_m�^m�Nn�o�o�		
��D�"�e�T�5�%���(�E�6�8�X��x��6�	
�����/�/�/�����g�&;�<�<�<�����Q����������u�-�-�v�6�6�6�����q�!�!�!�����
�+�+�+�����
�+�+�+������#�#�#�����r�*�*�*������"�"�"������$�$�$�����1�%�%�%�����1�%�%�%�����L�1�1�1�����9�-�-�-�����9�-�-�-������/�/�/�/�/r6N)FFFFFF)r
rrrTr�rLr�r�r�r9r�r�r�r�rrrrrgr6r*r�r�Ms�������$�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�64R�4R�4R�l	L�	L�	L�
T�
T�
T�J0�J0�J0�J0�J0r6r�c��eZdZejZdS)�DeflateTestZip64InSmallFilesN�r
rrrTrvrLrgr6r*r!r!���������&�K�K�Kr6r!c��eZdZejZdS)�Bzip2TestZip64InSmallFilesNr|rgr6r*r%r%�r~r6r%c��eZdZejZdS)�LzmaTestZip64InSmallFilesNr�rgr6r*r'r'�r�r6r'c�,�eZdZd�Zd�Zd�Zd�Zd�ZdS)�AbstractWriterTestsc�.�tt��dSr"�rr#r&s r*r'zAbstractWriterTests.tearDown�����w�����r6c���d}tjtd|j��5}|�dd��}|�|��|���|�|j��|���|�|j��|�	|�
d��|��ddd��dS#1swxYwYdS)N�contentrNr()rTrUr#rLrCrDrVrtr%rkrl�rFr;r�rNs    r*�test_close_after_closez*AbstractWriterTests.test_close_after_closes����
�_�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.rNr(r6)
rTrUr#rLrCrDrVrtr%r�r rkrlr/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�)rbr�r�rer^rNr;)
�arrayrq�itemsizerTrUr&r'rLrCrkrDr{rz)rF�q�LENGTHr�r;s     r*�test_issue44439z#AbstractWriterTests.test_issue44439se���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�5C2c��d}tjtd|j���5}|�|d��5}|�tj|j��|�	|�
��d��|�	|���d��|�	|���d��|�	|j
d��ddd��n#1swxYwY|�	|j
d��|�tj|j��|�	|�
��d��|�	|���d��|�	|���d��ddd��dS#1swxYwYdS)NrrNrUFT)rTrUr#rLrCr�r&rrrrrrr%r!s    r*�test_zipwritefile_attrsz+AbstractWriterTests.test_zipwritefile_attrss�����
�_�W�3�D�<L�
M�
M�
M�	1�QV����E�3�'�'�
1�3��!�!�"�"9�3�:�F�F�F��
�
�c�l�l�n�n�e�4�4�4��
�
�c�l�l�n�n�d�3�3�3��
�
�c�l�l�n�n�e�4�4�4��
�
�c�j�%�0�0�0�
1�
1�
1�
1�
1�
1�
1�
1�
1�
1�
1����
1�
1�
1�
1�
�M�M�#�*�d�+�+�+����b�5�s�z�B�B�B��M�M�#�,�,�.�.�%�0�0�0��M�M�#�,�,�.�.�$�/�/�/��M�M�#�,�,�.�.�%�0�0�0�	1�	1�	1�	1�	1�	1�	1�	1�	1�	1�	1�	1����	1�	1�	1�	1�	1�	1s6�G�B9D�4G�D	�G�D	�B;G�G�GN)r
rrr'r0r2r8r:rgr6r*r)r)�sb���������	6�	6�	6�6�6�6�D�D�D�
1�
1�
1�
1�
1r6r)c��eZdZejZdS)�StoredWriterTestsN�r
rrrTr�rLrgr6r*r<r<-s�������$�K�K�Kr6r<c��eZdZejZdS)�DeflateWriterTestsNr"rgr6r*r?r?0s�������&�K�K�Kr6r?c��eZdZejZdS)�Bzip2WriterTestsNr|rgr6r*rArA4s�������#�K�K�Kr6rAc��eZdZejZdS)�LzmaWriterTestsNr�rgr6r*rCrC8s�������"�K�K�Kr6rCc�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�)rr)rFrrxs   r*�assertCompiledInzPyZipFileTests.assertCompiledIn>s7���#�:�X�%�%��M�M�$��*�h�/�/�/�/�/�&�%r6c���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)
r^�access�W_OK�supports_effective_idsrir�r:rC�O_WRONLY�O_CREATrV�	Exceptionr)rFr�ri�fds    r*�requiresWriteAccessz"PyZipFileTests.requiresWriteAccessBs����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)NrN�.pyc�__pycache__r��testpackage�/)rRr^r��dirname�__file__rrT�	PyZipFile�endswithrs�sep�altsep�extend�	importlib�util�source_from_cache�writepy�basename�assertNotInrxrH)rF�trXr�
path_split�bns      r*�test_write_pyfilez PyZipFileTests.test_write_pyfileOs<��� � ������!:�!:�;�;�;�
�_�_�	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)NrrNzemail/__init__.pyzemail/mime/text.py)�emailr^r�rXrYrRrrTrZrbrxrH)rFrj�
packagedirrerXr�s      r*�test_write_python_packagez(PyZipFileTests.test_write_python_packagemsT�������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)NrrN�SyntaxErrorc��dS)NFrg)�whatevers r*�<lambda>zCPyZipFileTests.test_write_filtered_python_package.<locals>.<lambda>�s��e�r6��
filterfuncc�h�tj�|���d��S)N�bad)r^r�rc�
startswith)r�s r*�filterzAPyZipFileTests.test_write_filtered_python_package.<locals>.filter�s)���7�+�+�D�1�1�<�<�U�C�C�C�Cr6)r(r^r�rXrYrRrrTrZrrbrort�assertWarns�UserWarning�print)rFr(rkrerX�	reportSIO�	reportStrrws        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)	NrTrbrTrN)�optimizezemail/__init__zemail/mime/text)rjr^r�rXrYrRrrTrZrbrxrr)rFrjrk�optlevel�extrerXr�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.pyrNrIrJ�
print(42)
�mod2.py�print(42 * 42)
zmod2.txtzbla bla bla
�r^�mkdirr#rCr�r:rDrrTrZrbrxrHrdr�rFrGrerXr�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)
Nr�rNrIrJr�r�r�c�.�|�d��S)Nr�)r[)rs r*rqzEPyZipFileTests.test_write_python_directory_filtered.<locals>.<lambda>�s��68�k�k�)�6L�6L�2L�r6rrr�r�s     r*�$test_write_python_directory_filteredz3PyZipFileTests.test_write_python_directory_filtered�sw��
������	��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)NrNrIrJz!most definitely not a python file)
rrTrZrCrrDr�rrbr)rFrerXr)s    r*�test_write_non_pyfilez$PyZipFileTests.test_write_non_pyfile�sp��
�_�_�	��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)Nr�rNrIrJzBad syntax in python file
rnzmod1.pyc)r^r�r#rCr�r:rDrrTrZrrbrrrorxrdr)rFrGrerX�sr�s      r*�test_write_pyfile_bad_syntaxz+PyZipFileTests.test_write_pyfile_bad_syntax�sn��
������	��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}|�
ttj�td������|���}|�
d|��ddd��n#1swxYwYddd��n#1swxYwYtt��dS#tt��wxYw)Nr�rNrIrJr�)r^r�r#rCr�r:rDrrTrZrbrrxrHrr�s     r*�test_write_pathlikez"PyZipFileTests.test_write_pathlike�s���
������		��b�g�l�l�7�I�6�6��g�N�N�N�
(�RT�����'�'�'�
(�
(�
(�
(�
(�
(�
(�
(�
(�
(�
(����
(�
(�
(�
(����
8�A�w�'8��C�'@�'@�
8�E��
�
�h�r�w�|�|�G�Y�'G�'G�H�H�I�I�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�5E�A2�&E�2A6�6E�9A6�:E�D4�!A0D�D4�D!	�!D4�$D!	�%D4�(E�4D8�8E�;D8�<E�E+N)r
rrrHrRrhrlr}r�r�r�r�r�r�rgr6r*rErE=s�������0�0�0����8�8�8�<?�?�?�<�<�<�<
:�
:�
:����.���(������,����r6rEc��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)NrN)rTrUr#r��SMALL_TEST_DATArV�rFrX�fpath�fdatas    r*�make_test_filezExtractTests.make_test_files���
�_�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�Nr\r?)rr�rTrUr#r��extractr^r�r:�getcwd�normpathrkrC�encoderlr)rFrXr�r��writtenfile�correctfiler)s       r*�test_extractzExtractTests.test_extracts��
�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�rTrUr#r�r�r^r�r:r�rt�samefilerCrkr�rlr)rF�targetrXr�r�r�r�r)s        r*�_test_extract_with_targetz&ExtractTests._test_extract_with_targets���������
�_�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")rr��rF�extdirs  r*�test_extract_with_targetz%ExtractTests.test_extract_with_target+s���
�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}|�t|����ddd��dS#1swxYwYdSr")rr�rr�s  r*�!test_extract_with_target_pathlikez.ExtractTests.test_extract_with_target_pathlike/s���
�Z�Z�	=�6��*�*�8�F�+;�+;�<�<�<�	=�	=�	=�	=�	=�	=�	=�	=�	=�	=�	=�	=����	=�	=�	=�	=�	=�	=��#?�A�Ac	�h�t��5|���tjtd��5}|���tD]�\}}tj�	tj
��|��}t|d��5}|�|�
��|�����ddd��n#1swxYwYt|����	ddd��n#1swxYwYddd��dS#1swxYwYdSr�)rr�rTrUr#�
extractallr�r^r�r:r�rCrkr�rlr)rFrXr�r��outfiler)s      r*�test_extract_allzExtractTests.test_extract_all3s���
�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�rTrUr#r�r�r^r�r:rCrkr�rlr)rFr�rXr�r�r�r)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")rr�r�s  r*�test_extract_all_with_targetz)ExtractTests.test_extract_all_with_targetNs���
�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�	7r�c��t��5}|�t|����ddd��dS#1swxYwYdSr")rr�rr�s  r*�%test_extract_all_with_target_pathlikez2ExtractTests.test_extract_all_with_target_pathlikeRs���
�Z�Z�	A�6��.�.�x��/?�/?�@�@�@�	A�	A�	A�	A�	A�	A�	A�	A�	A�	A�	A�	A����	A�	A�	A�	A�	A�	Ar�c��|�tj�|����t	|d��5}|�|���|��ddd��dS#1swxYwYdS)Nr?)rtr^r��isfilerCrkrl)rFrir�r)s    r*�
check_filezExtractTests.check_fileVs����������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..rrW�	foo/ba..r)rTrU�_sanitize_windows_namerk)rF�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�Hr6c�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)rF�common_hacknamess  r*�*test_extract_hackers_arcnames_common_casesz7ExtractTests.test_extract_hackers_arcnames_common_casesbs1��	
�	
�	
��	
�+�+�,<�=�=�=�=�=r6�\zRequires \ as path separator.c�8�gd�}|�|��dS)z>Test combination of path fixing and windows name sanitization.))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�Nr�)rF�windows_hacknamess  r*�*test_extract_hackers_arcnames_windows_onlyz7ExtractTests.test_extract_hackers_arcnames_windows_onlyos1��
�
�
��*	
�+�+�,=�>�>�>�>�>r6rWzRequires / as path separator.c�8�gd�}|�|��dS)N))z	//foo/barr�)r�zfoo../ba..r)�
foo/..\barr�r�)rF�posix_hacknamess  r*�(test_extract_hackers_arcnames_posix_onlyz5ExtractTests.test_extract_hackers_arcnames_posix_only�s/��
�
�
��
	
�+�+�O�<�<�<�<�<r6c���|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�foobarrNr-rWr��subdir�subsubr\zextract z: z != )�msgz
extract %rr)r�rTrUr#r�rrir.rV�replacer^r\r�r:rsr�rkr�rr�r�r)
rF�	hacknames�arcname�	fixednamer�rXr/�
targetpathr�r�s
          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�r�r�r�r�r�r�r�r�r�r�r��unittest�skipIfr^r�r\r�r�r�rgr6r*r�r��sG������-�-�-�
(�(�(�&���&3�3�3�=�=�=�$�$�$����7�7�7�A�A�A�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�=�)�)�)�)�)r6r�c�4�eZdZeZed���Zd�Zd�ZdS)�OverwriteTestsc��tdzx}|_|�t|��t	j|d��5}|�dd��ddd��n#1swxYwYtdzx}|_|�t|��t	j|d��5}|�d��ddd��n#1swxYwYtdzx}|_	|�t|��t	j|d��5}|�dd��ddd��dS#1swxYwYdS)Nz-with-file.ziprNr(�
newcontentz
-with-dir.zipz-with-implicit-dir.zipz	test/file)
r�ar_with_file�addClassCleanuprrTrUrV�ar_with_dirr��ar_with_implicit_dir)r=�prXs   r*r>zOverwriteTests.setUpClass�s���%�(8�8�8��C�����F�A�&�&�&�
�_�Q��
$�
$�	2���N�N�6�=�1�1�1�	2�	2�	2�	2�	2�	2�	2�	2�	2�	2�	2����	2�	2�	2�	2�%��6�6��C�O����F�A�&�&�&�
�_�Q��
$�
$�	 ���K�K�����	 �	 �	 �	 �	 �	 �	 �	 �	 �	 �	 ����	 �	 �	 �	 �(.�0H�'H�H��C�$����F�A�&�&�&�
�_�Q��
$�
$�	7���N�N�;�
�6�6�6�	7�	7�	7�	7�	7�	7�	7�	7�	7�	7�	7�	7����	7�	7�	7�	7�	7�	7s6�A%�%A)�,A)�1C�C�C�E�E�
Ec�,�tj|d��Sr�)rTrU)rFr�s  r*rCzOverwriteTests.open�s����t�S�)�)�)r6c�:�|�|j��dSr")r��testdir)rF�ars  r*r�zOverwriteTests.extractall�s��
�
�
�d�l�#�#�#�#�#r6N)	r
rrrr�r)r>rCr�rgr6r*r�r��sP�������G��7�7��[�7� *�*�*�$�$�$�$�$r6r�c��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+e��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)
NrNrr��barr�r\r6r�sbarfoo)
rTrUr#r�rVrxryrkrxryrCrlrr)rFrXr�r;r�r�s      r*�test_open_via_zip_infoz!OtherTests.test_open_via_zip_info�s���
�_�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)NrN�abcdefghijklmnop)rTrUr#r�	flag_bits�_MASK_USE_DATA_DESCRIPTORrV)rF�orig_zipr;r/s    r*�-test_writestr_extended_local_header_issue1202z8OtherTests.test_writestr_extended_local_header_issue1202�s���
�_�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)z8Check that the zipfile is closed after the 'with' block.rNzzipfp is not openN�zipfp is not closedr\)rTrUr#r�rV�assertIsNotNonerG�assertIsNoner�s    r*�
test_closezOtherTests.test_close�s���
�_�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)zWCheck that the zipfile is closed if an exception is raised in the
        'with' block.rNNr\r�)rTrUr#r�rVr�r�rG)rFrXr�r��zipfp2s     r*�test_close_on_exceptionz"OtherTests.test_close_on_exceptions;���_�W�c�
*�
*�	-�e� /�
-�
-���u����u�e�,�,�,�,�
-�	-�	-�	-�	-�	-�	-�	-�	-�	-�	-�	-����	-�	-�	-�	-�	@����#�.�.�
+�&��(�*�*�*�
+�
+�
+�
+����
+�
+�
+�
+�
+�
+���!�	@�	@�	@����f�i�)>�?�?�?�?�?�?�	@���sA�$A�A�A�B�2B�B
�
B�
B
�B�*C�Cc�|�d}|�ttjt	j|��d��dS)NsdPKx!p�@xPKxx!p�@�xPK/r\)r��NotImplementedErrorrTrUr&r'�rFr;s  r*�test_unsupported_versionz#OtherTests.test_unsupported_versionsD��Y��	
���-�w���*�T�*�*�C�	1�	1�	1�	1�	1r6c��td��}tj|��5}|���D])}|�|������*	ddd��dS#1swxYwYdS)Nzzip_cp437_header.zip)r
rTrUrxrCrV)rFr�rXrs    r*�test_read_unicode_filenamesz&OtherTests.test_read_unicode_filenamess����/�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)NrN�foo.txtzTest for unicode filenameuö.txtrr\rb)
rTrUrrVr�ryrirwrk�filelist�rFr�s  r*�test_write_unicode_filenamesz'OtherTests.test_write_unicode_filenames!s���
�_�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)NrNuприкладssample)rTrUr#rVrkrlr8s  r*�'test_read_after_write_unicode_filenamesz2OtherTests.test_read_after_write_unicode_filenames+s���
�_�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)z&Test exclusive creating a new zipfile.�testfile.txt�#hello, world. this is some content.�xNr\)rr#rTrUr�rVr��FileExistsErrorrkrxrl)rFrir�rXs    r*�test_exclusive_create_zip_filez)OtherTests.test_exclusive_create_zip_file0s����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%�&B8�8B<�?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)Nrrr;z1Could not append data to a non-existent zip file.r\)
r^r��existsrrrTrUrVr�failrtrkrl)rFrir�r�s    r*�(test_create_non_existent_file_for_appendz3OtherTests.test_create_non_existent_file_for_append=s���
�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)NrNrIrJ�this is not a legal zip file
)rCrrDrTrUr�)rFrGr�s   r*�test_close_erroneous_filez$OtherTests.test_close_erroneous_fileOs����&�#��
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
t������ttd��5}|�t	j|����ddd��n#1swxYwYtj��}|�d��|�t	j|����|�	dd��|�t	j|����dS)	z;Check that is_zipfile() correctly identifies non-zip files.rNrIrJrNr?sthis is not a legal zip file
r)
rCrrDr$rT�
is_zipfilerr&r'r@rEs  r*�test_is_zip_erroneous_filez%OtherTests.test_is_zip_erroneous_file^s����&�#��
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�����+�H�V�,<�,<�=�=�>�>�>�
�&�$�
�
�	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�:�>�>�?(C3�3C7�:C7c��tj��}tj|d���5}|�dd��ddd��n#1swxYwY|���}t
t|����D]I}tj|d|���}|�tj	tj|���JdS)zCCheck that zipfiles with missing bytes at the end raise BadZipFile.rNrRr	�O, for a Muse of Fire!N)
r&r'rTrUrVror7rqr�r�)rFrGr�r��Ns     r*�test_damaged_zipfilezOtherTests.test_damaged_zipfileps���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)z7Check that is_zipfile() correctly identifies zip files.rNrRr	r Nr?r)rTrUrrVrtrrCr@rlr&r'rD)rFr�rG�zip_contentss    r*�test_is_zip_valid_filez!OtherTests.test_is_zip_valid_file~s����_�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�AC)�)C-�0C-c�\�|�ttjt��dSr")r�rrTrUrr&s r*�%test_non_existent_file_raises_OSErrorz0OtherTests.test_non_existent_file_raises_OSError�s$��	
���'�7�?�F�;�;�;�;�;r6c��ttdd���}|���|�tjtjt��ttdd���5}|�d��ddd��n#1swxYwY|�tjtjt��dS)NrNrIrJz
short file)rCrrVr�rTr�rUrD)rFr)rGs   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)rbr�r�rcr�)	�	bytearrayrlr�r&r'r�rTr�rU)rF�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�	Fr6c��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)z?Verify that testzip() doesn't swallow inappropriate exceptions.rNrRr	�O, for a Muse of Fire!Nz	bogus.txtrrIrJzzipfile test data)r&r'rTrUrVr�r rlrCr|rrD)rFr;r�r)s    r*�!test_closed_zip_raises_ValueErrorz,OtherTests.test_closed_zip_raises_ValueError�s����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�3D�D�Dc�^�|�ttjtd��dS)z>Check that bad modes passed to ZipFile constructor are caught.r6N)r�r rTrUrr&s r*�test_bad_constructor_modez$OtherTests.test_bad_constructor_mode�s$�����*�g�o�v�s�C�C�C�C�Cr6c��tjtd���5}|�dd��ddd��n#1swxYwYtjtd���5}|�d��|�t|jdd��|�t|jdd��|�t|jdd	��ddd��dS#1swxYwYdS)
z7Check that bad modes passed to ZipFile.open are caught.rNrRr	r1Nr\r6�U�rU)rTrUrrVrlr�r rC�rFr�s  r*�test_bad_open_modezOtherTests.test_bad_open_mode�so��
�_�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<C.�.C2�5C2c���tjtd���5}|�dd��|�d��5}tt��D]+}|�|�d��d���,|�|���d��ddd��n#1swxYwYddd��dS#1swxYwYdS)	zsCheck that calling read(0) on a ZipExtFile object returns an empty
        string and doesn't advance file pointer.rNrRr	r1rr6r N)	rTrUrrVrCr7r8rkrl)rFr�r)r4s    r*�
test_read0zOtherTests.test_read0�so���_�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=�1C�=C	�C�C	�C�C�Cc��tjtd���5}|�t|jdd��ddd��dS#1swxYwYdS)zqCheck that attempting to call open() for an item that doesn't
        exist in the archive raises a RuntimeError.rNrRr	r\N)rTrUrr��KeyErrorrCr8s  r*�test_open_non_existent_itemz&OtherTests.test_open_non_existent_item�s����_�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�`�|�ttjtdd��dS)zMCheck that bad compression methods passed to ZipFile.open are
        caught.rNr�N)r�rrTrUrr&s r*�test_bad_compression_modez$OtherTests.test_bad_compression_mode�s)��	
���-�w����R�P�P�P�P�Pr6c���d}tjtj|��d��5}|�t
|jd��ddd��dS#1swxYwYdS)NsfPK.�C�@xPK..�C�@�xPK/!r\r)rTrUr&r'r�rrC)rFr;r�s   r*�test_unsupported_compressionz'OtherTests.test_unsupported_compression�s���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)zLCheck that a filename containing a null byte is properly
        terminated.rNrRzfoo.txtqqqr r	N)rTrUrrVrkrxr8s  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-�0A-c��|�tjd��|�tjd��|�tjd��|�tjd��dS)zACheck that ZIP internal structure sizes are calculated correctly.��.�8r�N)rkrT�sizeEndCentDir�sizeCentralDir�sizeEndCentDir64�sizeEndCentDir64Locatorr&s r*�test_struct_sizeszOtherTests.test_struct_sizes�sl������/��4�4�4�����/��4�4�4�����1�2�6�6�6�����8�"�=�=�=�=�=r6c�.
�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)z8Check that comments on the archive are handled properly.rNrRr6r	r1Nr\s9Bravely taking to his feet, he beat a very brave retreat.�c�$�g|]
}d|dzdzz��S)r�r�r�rgr2s  r*r5z,OtherTests.test_comments.<locals>.<listcomp>s%��K�K�K�1�D�A�q�D�2�I�.�K�K�Kr6�r0soopssoriginal commentr;san updated commentsoriginal comment that's longersshorter comment)rTrUrrkrPrVr:r7r�rxryr^r��getsizert)rFr��zipfrrP�comment2�original_zip_sizes      r*�
test_commentszOtherTests.test_commentss���_�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,�/B,�C:�:C>�C>� E�E�E�/G�G� G�?H'�'H+�.H+�
J,�(I?�3J,�?J	�J,�J	�J,�,J0�3J0�K:�:K>�K>� M
�
M�M�0N�N�N�*O�O�O�8P"�"P&�)P&�,R�R�R�!T
�
T�Tc� �tjtdtj��5}|�dd��|�t��5d|_ddd��n#1swxYwYddd��dS#1swxYwYdS)NrNr	r1zthis is an error)rTrUrr�rVr��	TypeErrorrPr8s  r*�test_unicode_commentzOtherTests.test_unicode_comment@s���
�_�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;rOr\)rTrUrr�r$r
rPrkr8s  r*�$test_change_comment_in_empty_archivez/OtherTests.test_change_comment_in_empty_archiveFs)��
�_�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)NrNr	r1r;rOr\)	rTrUrr�rVrtr
rPrkr8s  r*�'test_change_comment_in_nonempty_archivez2OtherTests.test_change_comment_in_nonempty_archiveMs���
�_�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)NrNrRr\z+Unable to create empty ZIP file in 'w' moder;z+Unable to create empty ZIP file in 'a' mode)rTrUrrVr�rr8s  r*�test_empty_zipfilezOtherTests.test_empty_zipfileVs�����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)NrNrIrJr\)rCrrVr�rTr�rUr�s  r*�test_open_empty_filezOtherTests.test_open_empty_filegsJ��
���w�/�/�/��	���	�	�	����'�,�g�o�v�s�K�K�K�K�Kr6c�T�|�ttjdd��dS)N�	seventies)i�rbrbrrr)r�r rTrr&s r*�test_create_zipinfo_before_1980z*OtherTests.test_create_zipinfo_before_1980os5�����*�!�/�;�8M�	O�	O�	O�	O�	Or6c�v�tjd���}|�t|��d��dS)z=Before bpo-26185, repr() on empty ZipInfo object was failing.�emptyrhz&<ZipInfo filename='empty' file_size=0>N)rTrrkr��rFr�s  r*�test_create_empty_zipinfo_reprz)OtherTests.test_create_empty_zipinfo_reprss7��
�_�g�
.�
.�
.������b���#K�L�L�L�L�Lr6c���tj��}|�|jd��|�|jd��|�|jd��|�|jtj��|�|jd��|�|j	d��|�
|jd��|�|jtj
��|�|jtj
��|�|jd��|�|jd��|�|jd��|�|jd��|�|jd��|�|jd��|�|jd��dS)z'Ensure all required attributes are set.�NoNamer]r6)rr�rN)rTrrk�
orig_filenamerir`r�r�rPr�rr�
create_system�create_version�DEFAULT_VERSIONr��reservedr��volume�
internal_attrr.rzr�rgs  r*�,test_create_empty_zipinfo_default_attributesz7OtherTests.test_create_empty_zipinfo_default_attributesxs���
�_�
�
������)�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�-�-�-�-�-r6c���d}tjtj|��d��5}|�|�����ddd��dS#1swxYwYdS)z>If an extra field in the header is less than 4 bytes, skip it.snPK���@����abcAPK���@������abcPK3%r\N)rTrUr&r'r�r|�rFr�r�s   r*�#test_zipfile_with_short_extra_fieldz.OtherTests.test_zipfile_with_short_extra_field�s���
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 offshorerNr�rRr��handler\rw�abcder]�baz)r�r�ry)rTrUr#r�rCrDr�r rVrYrVrkrlrx)rF�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?sBrucerNr	r\rr^rR)�findrTrUrrVrCr@r^�SEEK_SETrkr��SEEK_CURrl�SEEK_ENDrqr&r')rF�txt�blocr�rGr;s      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+rN)rLr��azzipfile.bz2)r&r'rTrUr}rV�mock�patchr�rr�)rFr;�zip_filer�s    r*�)test_decompress_without_3rd_party_libraryz4OtherTests.test_decompress_without_3rd_party_library�s���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�|�d}tjtj|��d��5}|�|���ddg��|�d��}|�|jd��|�|jd��|�|j	d��|�d��}|�|jd��|�|jd��|�|j	d��|�t|�d����d��|�tj
d��5|�d��ddd��n#1swxYwYddd��dS#1swxYwYdS)	Ns�PK�lH�8�	a��0�K\d`PK�lH�8�	aPK�lH�8�	bPK^/r\r;�brr��	zFile name.*differ)rTrUr&r'rkrxr{r�r�rzrqrl�assertRaisesRegexr��rFr;r�r�s    r*�test_full_overlapzOtherTests.test_full_overlap�s	��

�	
��_�R�Z��-�-�s�
3�
3�	�t����T�]�]�_�_�s�C�j�9�9�9����c�"�"�B����R�-�q�1�1�1����R�-�r�2�2�2����R�\�4�0�0�0����c�"�"�B����R�-�q�1�1�1����R�-�r�2�2�2����R�\�4�0�0�0����S����3���0�0�$�7�7�7��'�'��(:�<O�P�P�
�
��	�	�#����
�
�
�
�
�
�
�
�
�
�
����
�
�
�
�	�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	�	s6�E
F1�7F�
F1�F	�F1� F	�!F1�1F5�8F5c�|�d}tjtj|��d��5}|�|���ddg��|�d��}|�|jd��|�|jd��|�|j	d��|�d��}|�|jd��|�|jd	��|�|j	d
��|�
tjd��5|�d��ddd��n#1swxYwY|�t|�d����d
��ddd��dS#1swxYwYdS)Ns�PK�lHY�84(a�PK�lH�8�	b��0�K\d`PK�lHY�84(aPK�lH�8�	$bPK^Sr\r;r�r�4i(�$r�r�zOverlapped entries)rTrUr&r'rkrxr{r�r�rzr�r�rlrqr�s    r*�test_quoted_overlapzOtherTests.test_quoted_overlap	s	��
)�	
��_�R�Z��-�-�s�
3�
3�	8�t����T�]�]�_�_�s�C�j�9�9�9����c�"�"�B����R�-�q�1�1�1����R�-�r�2�2�2����R�\�4�0�0�0����c�"�"�B����R�-�r�2�2�2����R�-�r�2�2�2����R�\�4�0�0�0��'�'��(:�<P�Q�Q�
�
��	�	�#����
�
�
�
�
�
�
�
�
�
�
����
�
�
�
����S����3���0�0�$�7�7�7�	8�	8�	8�	8�	8�	8�	8�	8�	8�	8�	8�	8����	8�	8�	8�	8�	8�	8s6�DF1�E#�F1�#E'	�'F1�*E'	�+9F1�1F5�8F5c�V�tt��tt��dSr"r%r&s r*r'zOtherTests.tearDown&	r(r6N)/r
rrr�r�r�rrrrrrrrrrr"r%r'r)r/r2r4r9r;r>r@rBrDrMrVrYr[r]r_rardrhrrrurr�rr�r�r�r'rgr6r*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��]�_�_����_��8�]�_�_�8�8��_�8�<����r6r�c��eZdZd�Zd�ZdS)�AbstractBadCrcTestsc���|j}tjtj|��d���5}|�d|�����ddd��dS#1swxYwYdS)z>Tests that files with bad CRCs return their name from testzip.r\rR�afileN)�zip_with_bad_crcrTrUr&r'rkr|rts   r*�test_testzip_with_bad_crcz-AbstractBadCrcTests.test_testzip_with_bad_crc,	s����'��
�_�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)zFTests that files with bad CRCs raise a BadZipFile exception when read.r\rRr�Nr�)
r�rTrUr&r'r�r�rlrC�
MIN_READ_SIZE)rFr�r��corrupt_files    r*�test_read_with_bad_crcz*AbstractBadCrcTests.test_read_with_bad_crc4	sL���'���_�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'�C6�-&C�C6�C#	�#C6�&C#	�'C6�6C:�=C:�)G�'F6�',F�F6�F#�#F6�&F#�'F6�*G�6F:	�:G�=F:	�>G�G�GN)r
rrr�r�rgr6r*r�r�+	s2������6�6�6�����r6r�c� �eZdZejZdZdS)�StoredBadCrcTestssxPK ��;:r��afilehello,AworldPK ��;:r���afilePK3/N)r
rrrTr�rLr�rgr6r*r�r�J	s"�������$�K�	���r6r�c� �eZdZejZdZdS)�DeflateBadCrcTestss|PKn}=FAKEnafile�H���W(�/�Iɠ=PKn}=FAKEn�afilePK33N)r
rrrTrvrLr�rgr6r*r�r�V	s"�������&�K�	6���r6r�c� �eZdZejZdZdS)�Bzip2BadCrcTestss�PKnu=FAKE8nafileBZh91AY&SYԨ��@D��  �P�!����u5:���"�(HjTe?�PKnu=FAKE8n ���afilePK3[N)r
rrrTr}rLr�rgr6r*r�r�c	s"�������#�K�
	���r6r�c� �eZdZejZdZdS)�LzmaBadCrcTestss�PKnu=FAKEnafile	]4I���:3`	q!.8PKnu=FAKEn ���afilePK3>N)r
rrrTr�rLr�rgr6r*r�r�s	s"�������"�K�	%���r6r�c�l�eZdZdZdZdZdZdZd�Zd�Z	d�Z
d	�Ze��d
���Z
d�Zd�Zd
S)�DecryptionTestsz�Check that ZIP decryption works. Since the library does not
    support encryption at the moment, we use a pre-generated encrypted
    ZIP file.s�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)NrAr\)
rCrrDr;rTrUr�r#�data2�zip2rEs  r*rHzDecryptionTests.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�rVr^rrr�r#r&s r*r'zDecryptionTests.tearDown�	sL���������
�	�&�����	������
�	�'�����r6c��|�t|jjd��|�t|jjd��dS)N�test.txt�zero)r�rr�rlr�r&s r*�test_no_passwordz DecryptionTests.test_no_password�	sB��	
���,���
�z�B�B�B����,��	���?�?�?�?�?r6c��|j�d��|�t|jjd��|j�d��|�t|jjd��dS)Nsperlr�r�)r��setpasswordr�rrlr�r&s r*�test_bad_passwordz!DecryptionTests.test_bad_password�	sl������W�%�%�%����,���
�z�B�B�B��	���g�&�&�&����,��	���?�?�?�?�?r6c�:�|j�d��|�|j�d��|j��|j�d��|�|j�d��|j��dS)N�pythonr�s12345r�)r�r�rkrl�plainr��plain2r&s r*�test_good_passwordz"DecryptionTests.test_good_password�	s�������Y�'�'�'��������z�2�2�D�J�?�?�?��	���h�'�'�'���������/�/���=�=�=�=�=r6c�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)r�rXr�r�rlrCr�r�)rF�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)Nr�s
encryptionr�r\rrbr6)r�r�r�r�rqrCr@r^r�rkr�r�rlr��_readbuffer�_offsetr�)rFr��	test_wordr��bloc_lenrG�
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
rr�__doc__r;r�r�r�rHr'r�r�rr�r�r�rgr6r*r�r��	s���������
	)�	�	:�
�
*�E�
�F�2�2�2����@�@�@�@�@�@��]�_�_�>�>��_�>�&�&�&�&#�#�#�#�#r6r�c�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�rbr6c	3�zK�|]6}tjdt��tdd��z��V��7dS)z<fi���rN)rlr�rrr2s  r*r�z@AbstractTestsWithRandomBinaryFiles.setUpClass.<locals>.<genexpr>�	sU����7�7� !�#�K��f�h�h�w�u�d�7K�7K�.K�L�L�7�7�7�7�7�7r6)rr:r7r;)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����r6c��ttd��5}|�|j��ddd��dS#1swxYwYdSr@rBrEs  r*rHz(AbstractTestsWithRandomBinaryFiles.setUp�	rIrJc�V�tt��tt��dSr"r%r&s r*r'z+AbstractTestsWithRandomBinaryFiles.tearDown
r(r6c���tj|d|��5}|�td��|�tt��ddd��dS#1swxYwYdS)NrNrO)rTrUrDrr�s    r*rZz4AbstractTestsWithRandomBinaryFiles.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)Nr\rO)rZrTrUrlrrkrqr;)rFr)rLrX�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�r6c��|�||��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�)rZrTrUrCrrlr�r:rkrqr;)rFr)rLrXr�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_open7
r�r6c�>�|�||��tj|d|��5}g}|�t��5}	|�t
dd����}|sn|�|���<	ddd��n#1swxYwYd�|��}|�	t|��t|j����|�	||j��ddd��dS#1swxYwYdSr�)rZrTrUrCrrlrr�r:rkrqr;)rFr)rLrXr�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_openL
r�r6N)r
rrr)r>rHr'rZr�r�r�r�r�r�rgr6r*r�r��	s��������7�7��[�7�
 � � �
���(�(�(�D�D�D�/�/�/�3�3�3�:4�4�4�2�2�2�";�;�;�;�;r6r�c��eZdZejZdS)� StoredTestsWithRandomBinaryFilesNr=rgr6r*r�r�Q
s�������$�K�K�Kr6r�c��eZdZejZdS)�!DeflateTestsWithRandomBinaryFilesNr"rgr6r*r�r�U
r#r6r�c��eZdZejZdS)�Bzip2TestsWithRandomBinaryFilesNr|rgr6r*r�r�Z
r~r6r�c��eZdZejZdS)�LzmaTestsWithRandomBinaryFilesNr�rgr6r*r�r�_
r�r6r�c�&�eZdZd�Zd�Zd�Zd�ZdS)�Tellablec�"�||_d|_dS�Nr)rG�offsetrEs  r*�__init__zTellable.__init__g
s���������r6c�Z�|j�|��}|xj|z
c_|Sr")rGrDr�)rFr;�ns   r*rDzTellable.writek
s*���G�M�M�$�������q�����r6c��|jSr")r�r&s r*r�z
Tellable.tellp
s
���{�r6c�8�|j���dSr"�rG�flushr&s r*r�zTellable.flushs
�����
�
�����r6N)r
rrr�rDr�r�rgr6r*r�r�f
sP������������
�������r6r�c� �eZdZd�Zd�Zd�ZdS)r
c��||_dSr")rGrEs  r*r�zUnseekable.__init__w
s
������r6c�6�|j�|��Sr")rGrDrs  r*rDzUnseekable.writez
s���w�}�}�T�"�"�"r6c�8�|j���dSr"r�r&s r*r�zUnseekable.flush}
r�r6N)r
rrr�rDr�rgr6r*r
r
v
sA���������#�#�#�����r6r
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"rg�r)s r*rqz/UnseekableTests.test_writestr.<locals>.<lambda>�
���!�r6��wrapper�abcrN�ones�111�twos�222r^�abcPKr\rR)r�r
�subTestr&r'rD�BufferedWriterrTrUr�rVrkrorCrl)rFr�r)�bfrXr��zopens       r*�
test_writestrzUnseekableTests.test_writestr�
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"rgr�s r*rqz,UnseekableTests.test_write.<locals>.<lambda>�
r�r6r�r�rNrArr�rrr^rr\rR)r�r
rr&r'rDrrTrUr��
addCleanuprrrCrkrorl)rFr�r)rrX�f2r�rs        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"rgr�s r*rqz1UnseekableTests.test_open_write.<locals>.<lambda>�
r�r6r�r�rNr�rrrr^r)r�r
rr&r'rDrrTrUr�rCrkrorl)rFr�r)rr�rs      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
rrrr
rrgr6r*r�r��
sF������?�?�?� ?�?�?�*@�@�@�@�@r6r�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�-�-�-��	�	�	r6c���tj|dtj��5}|�d|j��|�d|j��ddd��dS#1swxYwYdS)NrNr�r)rTrUrvrVrr�)rFr)rXs   r*rZz(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)Nr\rRr���)r+rZrTrUrCrlrkr�rFr)r��zopen1�zopen2rr�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)Nr\rRr�rr�	r+rZrTrUrCrlrkrr�rs       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)Nr\rRr�rrr)rFr)r�rrrr�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)Nr\r�rr)r+rZ�
contextlib�	ExitStackrTrU�
enter_contextrCrlrkrr�)rFr)�stackr�rrrr�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)NrNr�rrr\)
r+rTrUrvrVrr�rCrlrk�rFr)r�rrr�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)NrNr�rrr\)
r+rTrUrvrVrrCrlr�rkr)s      r*�test_write_after_readz,TestsWithMultipleOpens.test_write_after_reads����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)Nr\rRr�r�)	rrZr#rTrUr7rlrCrk)rF�
startcountr�rrs     r*�test_many_opensz&TestsWithMultipleOpens.test_many_openss>���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)NrNr�r;r\rr)rTrUr#rvrVrrCrlrDr�rk)rFr��r1rr~s     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+r&s r*r'zTestsWithMultipleOpens.tearDown1r,r6N)r
rrr)r>rZrrr!r'r*r,r/r2r'rgr6r*rr�
s��������.�.��[�.�/�/�/�4�4�4�4�4�4�
4�
4�
4�0�0�0�0�0�0�0�0�0�
1�
1�
1�<�<�<�����r6rc�D�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
S)�TestWithDirectoryc�8�tjt��dSr")r^r�r#r&s r*rHzTestWithDirectory.setUp6s��
�������r6c
��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;r�r�)rTrUr
r�r#rtr^r��isdirr:rr8s  r*�test_extract_dirz"TestWithDirectory.test_extract_dir9s��
�_�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;)r^r�r�r:r#r:r&s r*�
test_bug_6050zTestWithDirectory.test_bug_6050@s:��
������g�s�+�+�,�,�,��������r6c
���td��}tj|��5}|�t��ddd��n#1swxYwYt
jdk�r�|�t
j�	t
j�
td������|�t
j�	t
j�
tdd������|�t
j�t
j�
tddd������|�t
j�	t
j�
td������|�t
j�	t
j�
tdd������dS|�t
j�t
j�
td������|�t
j�t
j�
td	������|�t
j�
t
j�
td������|�t
j�
t
j�
td������dS)
Nzzipdir_backslash.zip�ntr;r�r�rr�za\b\czd\e\)r
rTrUr�r#r^rrtr�r9r:r�r$r)rF�zfnamer�s   r*�test_extract_dir_backslashz,TestWithDirectory.test_extract_dir_backslashEsW���0�1�1��
�_�V�
$�
$�	%���O�O�G�$�$�$�	%�	%�	%�	%�	%�	%�	%�	%�	%�	%�	%����	%�	%�	%�	%�
�7�d�?�?��O�O�B�G�M�M�"�'�,�,�w��*D�*D�E�E�F�F�F��O�O�B�G�M�M�"�'�,�,�w��S�*I�*I�J�J�K�K�K��O�O�B�G�N�N�2�7�<�<���c�3�+O�+O�P�P�Q�Q�Q��O�O�B�G�M�M�"�'�,�,�w��*D�*D�E�E�F�F�F��O�O�B�G�M�M�"�'�,�,�w��S�*I�*I�J�J�K�K�K�K�K��O�O�B�G�N�N�2�7�<�<���+K�+K�L�L�M�M�M��O�O�B�G�N�N�2�7�<�<���+J�+J�K�K�L�L�L����R�W�^�^�B�G�L�L��#�,F�,F�G�G�H�H�H����R�W�^�^�B�G�L�L��#�,F�,F�G�G�H�H�H�H�Hs�A�A�Ac	��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)
NrrQrNrz/x/r��yrbzy/r\r�r�)r^r�r:r#r�rj�st_moderTrUrrDr
rtrir[rkr.r�r9rq�listdir)rF�dirpathrSr�r/r�s      r*�test_write_dirz TestWithDirectory.test_write_dirUs���'�,�,�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)	NrrNzx/r6ri�Ar\r�)r^r�r�r:r#rTrUrrVr
rkrir.rtr[r�r9rE)rFr�r/r�s    r*�test_writestr_dirz#TestWithDirectory.test_writestr_diros.��
������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)NrNr}r�
directory/i�A�directory2/rb�
directory3i�rRr�zdirectory3/zdirectory4/r�r�>r}�
directory2rM�
directory4)rTrUrr�r
rkrir.r�CRCrzr�r^r�r:r#r��setrE)rFr�r/�	old_zinfo�	new_zinfor�s      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��tjtd��5}|�tjd��d��|jd}|�|jd��tj	�
td��}tj|��tj
|��jdz}|�|d���|jd	}|�|jd��|�|j|d
zd
z��tj	�
td��}tj|��|�|��|�t%tj|����ddh��ddd��dS#1swxYwYdS)
NrNrKrOrrNrQrL)r�rbr�r�r})rTrUrrVrr
rkrir^r�r:r#r�rjrDrDr.r�rQrE)rFr�r/r}rSr�s      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�%�%�-��6�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�FF3�3F7�:F7c��tt��tj�t
��rt
t
��dSdSr")rr#r^r�rrrr&s r*r'zTestWithDirectory.tearDown�s<���w����
�7�>�>�&�!�!�	��6�N�N�N�N�N�	�	r6N)r
rrrHr:r=rArGrIrTrVr'rgr6r*r5r55s����������N�N�N� � � �
I�I�I� 9�9�9�48�8�8�"o�o�o�@S�S�S�*����r6r5c�,�eZdZd�Zd�Zd�Zd�Zd�ZdS)�ZipInfoTestsc�p�tj�t��}|�tj|j��d��|�|�	����|�|j
tj�
t����dS�Nztest_zipfile.py)rTr�	from_filerYrk�	posixpathrcrir$�is_dirrzr^r�rRrgs  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�Ar6c��tj�tt����}|�t
j|j��d��|�	|�
����|�|jtj
�t����dSr[)rTrr\rrYrkr]rcrir$r^rzr^r�rRrgs  r*�test_from_file_pathlikez$ZipInfoTests.test_from_file_pathlike�s���
�_�
&�
&�x��'9�'9�
:�
:������+�B�K�8�8�:K�L�L�L���������%�%�%������r�w���x�'@�'@�A�A�A�A�Ar6c��tj�tjt
��d��}|�tj|j	��d��|�
|�����|�|jtj
�t
����dS)Nr()rTrr\r^�fsencoderYrkr]rcrir$r^rzr�rRrgs  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�Ar6c���ttd��5}tj�|���d��}|�tj|j	��d��|�
|�����|�|jtj�t����ddd��dS#1swxYwYdS)Nr?r()rCrYrTrr\rrkr]rcrir$r^rzr^r�rR)rFr)r�s   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)r^r�rX�abspathrYrTrr\rkrirtr^r�r�rz)rFrFr�s   r*�
test_from_dirzZipInfoTests.test_from_dir�s����'�/�/�"�'�/�/�(�";�";�<�<��
�_�
&�
&�w��
?�
?�������o�6�6�6�����	�	���$�$�$�����)�7�+=�>�>�>������q�)�)�)�)�)r6N)r
rrr_rardrfrjrgr6r*rYrY�sk������B�B�B�B�B�B�B�B�B�F�F�F�*�*�*�*�*r6rYc�X�eZdZd�Zd�Zd�Zd�Zd�Ze��d���Z	d�Z
dS)	�CommandLineTestc��tjddg|�Ri|��\}}}|�tj���d��S)N�-mrTr�)r	rr�r^�linesepr�)rF�argsrW�rc�out�errs      r*�
zipfilecmdzCommandLineTest.zipfilecmd�s_��$�5�d�I�@��@�@�@�8>�@�@���C���{�{�2�:�,�,�.�.��6�6�6r6c�(�tjddg|�R�S)NrnrT)r	�assert_python_failure)rFrps  r*�zipfilecmd_failurez"CommandLineTest.zipfilecmd_failure�s���2�4��J�T�J�J�J�Jr6c��|���\}}}|�|d��|�d|�����|�d|�����|�d|�����|�dd��\}}}|�|d��|�|���d��dS)Nr6susageserrorsrequired�-lrO)rwrkrrr��assertNotEqual�strip)rFrqrrrss    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��-�-�-�-�-r6c�(�td��}dD]@}|�||��}|�|���d���Atd��}|�d|��\}}}|�|d��dS)Nr8)�-tz--testsDone testingztesttar.tarr~r6)r
rtrk�rstriprw)rF�zip_name�optrrrqrss      r*�test_test_commandz!CommandLineTest.test_test_command�s����L�)�)��!�	<�	<�C��/�/�#�x�0�0�C����S�Z�Z�\�\�?�;�;�;�;��M�*�*���.�.�t�X�>�>���C������c�"�"�"�"�"r6c��td��}tj��}tj|d��5}|�|��ddd��n#1swxYwY|����dd��}dD]0}|�||d���}|�	||���1dS)Nr8r\r0�backslashreplace)ryz--listzascii:backslashreplace)�PYTHONIOENCODING)
r
r&rmrTrUrnror�rtrk)rFr�re�tf�expectedr�rrs       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)NrNrIrJztest 1�file.txtztest 2rWz	/file.txt)�-cz--creater6rstest 1r�stest 2)rrrrCrDr^r��	TESTFNDIRrr�r:rtr#rkrTrUrxrl)rFr)�filesrxr�rrr�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)Nr8)�-ez	--extractr6rWr?)r
rrtrkrTrUryr^r�r:rir�r\r^rtr9r�rCrl)	rFr�r�r�rrr�r�r�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
rrrtrwr|r�r�rr�r�rgr6r*rlrl�s�������7�7�7�
K�K�K�.�.�.�#�#�#�	,�	,�	,��]�_�_� � ��_� �*H�H�H�H�Hr6rlc��eZdZdZd�Zd�Zd�Zd�Zej	e
jd��ej	ej
dej��d��e��d	�������Zej	e
jd��ej	ej
dej��d��e��d
�������ZdS)�TestExecutablePrependedZipz@Test our ability to open zip files with an executable prepended.c�^�tdd���|_tdd���|_dS)N�exe_with_zip�ziptestdata)r��exe_with_z64)r
�exe_zip�	exe_zip64r&s r*rHz TestExecutablePrependedZip.setUp1s.����}�E�E�E���!�.��G�G�G����r6c�<�|�tj|��d|����tj|��5}|���D]-}|�|��}|�d|���.	ddd��dS#1swxYwYdS)Nzis_zipfile failed on sFAVORITE_NUMBER)rtrTrrUrxrlrr)rFrrXr�r;s     r*�_test_zip_worksz*TestExecutablePrependedZip._test_zip_works5s�������*�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")r�r�r&s r*� test_read_zip_with_exe_prependedz;TestExecutablePrependedZip.test_read_zip_with_exe_prepended?s�����T�\�*�*�*�*�*r6c�:�|�|j��dSr")r�r�r&s r*�"test_read_zip64_with_exe_prependedz=TestExecutablePrependedZip.test_read_zip64_with_exe_prependedBs�����T�^�,�,�,�,�,r6zsys.executable required.z	/bin/bashz#Test relies on #!/bin/bash working.c�|�tj|jtjg��}|�d|��dS�Nsnumber in executable: 5)�
subprocess�check_outputr��sys�
executablerr�rF�outputs  r*�test_execute_zip2z,TestExecutablePrependedZip.test_execute_zip2Es8��
�(�$�,���)G�H�H���
�
�0�&�9�9�9�9�9r6c�|�tj|jtjg��}|�d|��dSr�)r�r�r�r�r�rrr�s  r*�test_execute_zip64z-TestExecutablePrependedZip.test_execute_zip64Ms8��
�(�$�.�#�.�)I�J�J���
�
�0�&�9�9�9�9�9r6N)r
rrr�rHr�r�r�r��
skipUnlessr�r�r^rK�X_OKrr�r�rgr6r*r�r�.sI������J�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�:�:�:r6r�c�(�eZdZGd�d��ZdS)�jaracoc�(�eZdZGd�d��ZdS)�jaraco.itertoolsc� �eZdZd�Zd�Zd�ZdS)�jaraco.itertools.Counterc�<�d|_t|��|_dSr�)r�iter�
_orig_iter)rFr4s  r*r�z!jaraco.itertools.Counter.__init__^s����
�"&�q�'�'����r6c��|Sr"rgr&s r*�__iter__z!jaraco.itertools.Counter.__iter__bs���r6c�N�t|j��}|xjdz
c_|Sr)�nextr�r)rF�results  r*�__next__z!jaraco.itertools.Counter.__next__es%���d�o�.�.���
�
�a��
�
��
r6N)r
rrr�r�r�rgr6r*�Counterr�]sA������
*�
*�
*�
�
�
�
�
�
�
�
r6r�N)r
rrr�rgr6r*r�r�\s<������	�	�	�	�	�	�	�	�	�	r6r�N)r
rrr�rgr6r*r�r�[s<���������������r6r�c��tj�|�����D]}|�|d���|S)z}
    Given a writable zip file zf, inject directory entries for
    any directories implied by the presence of children.
    r6)rT�CompleteDirs�
_implied_dirsrxrV)r�rs  r*�add_dirsr�ksH��
�$�2�2�2�;�;�=�=�A�A����
���D�#�����
�Ir6c�@�tj��}tj|d��}|�dd��|�dd��|�dd��|�dd	��|�d
d��d|_|S)
u:
    Create a zip file with this structure:

    .
    ├── a.txt
    ├── b
    │   ├── c.txt
    │   ├── d
    │   │   └── e.txt
    │   └── f.txt
    └── g
        └── h
            └── i.txt

    This fixture has the following key characteristics:

    - a file at the root (a)
    - a file two levels deep (b/d/e)
    - multiple files in a directory (b/c, b/f)
    - a directory containing only a directory (g/h)

    "alpha" because it uses alphabet
    "rep" because it's a representative example
    rNr��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 i�alpharep.zip)r&r'rTrUrVri)r;r�s  r*�build_alpharep_fixturer�us���2�:�<�<�D�	���s�	#�	#�B��K�K���)�)�)��K�K�	�?�+�+�+��K�K��_�-�-�-��K�K�	�?�+�+�+��K�K��_�-�-�-� �B�K�
�Ir6c�F��tj����fd���}|S)zZ
    Given a method, wrap it in a for loop that invokes method
    with each subtest.
    c�P��|���D]}�||����dS)N)�alpharep)�zipfile_alpharep)rFr��meths  �r*r�zpass_alpharep.<locals>.wrapper�s@����-�-�/�/�	*�	*�H��D���)�)�)�)�)�	*�	*r6)�	functools�wraps)r�r�s` r*�
pass_alpharepr��s:����_�T���*�*�*�*���*��Nr6c���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,ed*���Z-d+�Z.d,�Z/d-�Z0d.S)/�TestPathc�t�tj��|_|�|jj��dSr")r#r$�fixturesrrVr&s r*rHzTestPath.setUp�s/��"�,�.�.��
�����
�+�,�,�,�,�,r6c#�K�|���5t��V�ddd��n#1swxYwY|���5tt����V�ddd��dS#1swxYwYdSr")rr�r�r&s r*r�zTestPath.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@)�pathlib�Pathr�r%rrGrVrirCrDro)rFr��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�n�tj|��}|���sJ�|���\}}}|���sJ�|���sJ�|���sJ�|���\}}}|���r|���sJ�|���\}	|	���sJ�|���\}
|
���\}|���sJ�dSr")rTr�r^�iterdir�is_file)rFr��rootr;r��gr�r)rr��hr4s            r*�test_iterdir_and_typeszTestPath.test_iterdir_and_types�s����|�H�%�%���{�{�}�}���}��,�,�.�.���1�a��y�y�{�{���{��x�x�z�z���z��x�x�z�z���z��)�)�+�+���1�a��y�y�{�{�*�q�y�y�{�{�*�*�*��y�y�{�{����y�y�{�{���{��y�y�{�{����y�y�{�{����y�y�{�{���{��r6c��tj|��}|�d�����rJ�dS)Nzmissing.txt)rTr��joinpathr��rFr�r�s   r*�test_is_file_missingzTestPath.test_is_file_missing�s;���|�H�%�%���=�=��/�/�7�7�9�9�9�9�9�9�9r6c���tj|��}|���\}}}|�t��5|���ddd��dS#1swxYwYdSr")rTr�r�r�r �rFr�r�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|��}|dz���sJ�|dz���sJ�|dz���sJ�|dz���sJ�dS)Nr��b/r�zg/)rTr�r^r�s   r*�test_subdir_is_dirzTestPath.test_subdir_is_dir�s����|�H�%�%���s�
�"�"�$�$�$�$�$��t��#�#�%�%�%�%�%��s�
�"�"�$�$�$�$�$��t��#�#�%�%�%�%�%�%�%r6c��tj|��}|���\}}}|�d���5}|���}ddd��n#1swxYwY|�|d��|�dd��5}|���}ddd��n#1swxYwY|�|d��dS)NrIrJ�content of ar\)rTr�r�rCrlrk)rFr�r�r;r�r�r�r;s        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)	NrNzpath/16.txtzThis was utf-16zutf-16ztest_open_utf16.zipz16.txtr\rJ)
r&r'rTrUrVr�rir�r�r�rCrlrk)rF�in_memory_filer�r�r��u16r�r;s        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)NrNzpath/bad-utf8.binsinvalid utf-8: ��.z"test_read_text_encoding_errors.zipzbad-utf8.binrI�ignore)�errorszinvalid utf-8: .r\�surrogateescapeuinvalid utf-8: ��.rKrJ�strict)rKr�)r&r'rTrUrVrir�r�r��	read_textrkrCrlr�rXr��UnicodeDecodeError)rFr�r�r�r�r�r;r)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	��d
S)z8EncodingWarning must blame the read_text and open calls.aimport 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_encodingr�r�rs^<string>:8: EncodingWarning:rbs^<string>:9: EncodingWarning:N)rrsrprkrq�assertRegex)rF�code�proc�warningss    r*�test_encoding_warningszTestPath.test_encoding_warnings
s���
�� ��&=�t�T�J�J���8�&�&�(�(������X����4�8�4�4�4�����!��&G�H�H�H�����!��&G�H�H�H�H�Hr6c���tjtjtj��d�����}|�d���d��5}|�d��ddd��n#1swxYwY|�d���dd�	��5}|�d
��ddd��dS#1swxYwYdS)zo
        If the zipfile is open for write, it should be possible to
        write bytes or text to it.
        rNrRzfile.binrAsbinary contentsNr�rIrJz	text file)rTr�rUr&r'r�rCrD)rFr�r�s   r*rzTestPath.test_open_write%
sE��
�\�'�/�"�*�,�,�S�A�A�A�
B�
B��
�[�[��
$�
$�
)�
)�$�
/�
/�	+�4��J�J�)�*�*�*�	+�	+�	+�	+�	+�	+�	+�	+�	+�	+�	+����	+�	+�	+�	+�
�[�[��
$�
$�
)�
)�#��
)�
@�
@�	$�D��J�J�{�#�#�#�	$�	$�	$�	$�	$�	$�	$�	$�	$�	$�	$�	$����	$�	$�	$�	$�	$�	$s$�"B�B�B�9C�C �#C c��tjtt������}|�t
��5|�d�����ddd��dS#1swxYwYdS)zJ
        Attempting to open a directory raises IsADirectoryError.
        r�N)rTr�r�r�r��IsADirectoryErrorr�rCrs  r*�test_open_extant_directoryz#TestPath.test_open_extant_directory0
����\�(�#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�r?rIrJ)rTr�r�r r�rCr�s   r*�test_open_binary_invalid_argsz&TestPath.test_open_binary_invalid_args8
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)zR
        Attempting to open a missing directory raises FileNotFoundError.
        rN)rTr�r�r�r��FileNotFoundErrorr�rCrs  r*�test_open_missing_directoryz$TestPath.test_open_missing_directory@
rrc���tj|��}|���\}}}|�d���dksJ�|�d��|���dksJ�dS)NrIrJr�r�)rTr�r�r��
read_bytesr�s      r*r�zTestPath.test_readH
st���|�H�%�%���,�,�.�.���1�a��{�{�G�{�,�,��>�>�>�>�	���G�����|�|�~�~��0�0�0�0�0�0r6c�2�tj|��}|�d��}|���sJ�|�d���d���d��}|�d���dksJ�dS�Nr�r�r�e.txtrIrJ�content of e)rTr�r�r�r��rFr�r�r;r�s     r*�
test_joinpathzTestPath.test_joinpathP
s����|�H�%�%���M�M�'�"�"���y�y�{�{���{��M�M�#���'�'��,�,�5�5�g�>�>���{�{�G�{�,�,��>�>�>�>�>�>r6c��tj|��}|�ddd��}|�d���dksJ�dS)Nr�rr
rIrJr)rTr�r�r�)rFr�r�r�s    r*�test_joinpath_multiplezTestPath.test_joinpath_multipleX
sK���|�H�%�%���M�M�#�s�G�,�,���{�{�G�{�,�,��>�>�>�>�>�>r6c��tj|��}|dz}|���sJ�|dzdzdz}|�d���dksJ�dSr)rTr�r�r�rs     r*�test_traverse_truedivzTestPath.test_traverse_truediv^
se���|�H�%�%���7�N���y�y�{�{���{��3�J���w�&���{�{�G�{�,�,��>�>�>�>�>�>r6c�J�tdddd���}t|��dS)zI
        Disable the __future__.division when testing traversal.
        zzipfile.Path(alpharep) / 'a'z(test)�evalT)�sourcerirS�dont_inheritN)�compiler)rFr�r�s   r*�test_traverse_simpledivz TestPath.test_traverse_simpledivf
s5��
�1����	
�
�
��	
�T�
�
�
�
�
r6c��|�|��}tjt|����}t	j|��dS)zN
        zipfile.Path should be constructable from a path-like object
        N)r�r�r�rwrT)rFr�r��pathlikes    r*�test_pathlike_constructionz#TestPath.test_pathlike_constructions
sD��
�,�,�X�6�6���<��N� 3� 3�4�4����X�����r6c�\�tj|��}|tjd��zdSr<)rTr�r�r�s   r*�test_traverse_pathlikezTestPath.test_traverse_pathlike|
s,���|�H�%�%���w�|�C� � � � � � r6c��tj|��}|dzjjdksJ�|dzdzjjdksJ�dS)Nr;rOr�za/�rTr��parent�atr�s   r*�test_parentzTestPath.test_parent�
sR���|�H�%�%���s�
�"�%��+�+�+�+��s�
�S� �(�+�t�3�3�3�3�3�3r6c��tj|��}|dzjjdksJ�|dzjjdksJ�dS)Nr�rOr�r!r�s   r*�test_dir_parentzTestPath.test_dir_parent�
sM���|�H�%�%���s�
�"�%��+�+�+�+��t��#�&�"�,�,�,�,�,�,r6c�X�tj|��}|dzjjdksJ�dS)Nzmissing dir/rOr!r�s   r*�test_missing_dir_parentz TestPath.test_missing_dir_parent�
s3���|�H�%�%���~�%�-�0�B�6�6�6�6�6�6r6c��tj|��}|���\}}}|�dd��|�dd��t	d�|���D����sJ�|dz�d���dksJ�|dz���\}|�d���dksJ�d	S)
zk
        If the underlying zipfile is changed, the Path object should
        reflect that change.
        r	r�zbar/baz.txtryc3�,K�|]}|jdkV��dS)r	N)r)r3�childs  r*r�z+TestPath.test_mutability.<locals>.<genexpr>�
s)����G�G�u�5�:��*�G�G�G�G�G�Gr6rIrJr�N)rTr�r�rV�anyr�)rFr�r�r;r�r�rys       r*�test_mutabilityzTestPath.test_mutability�
s����|�H�%�%���,�,�.�.���1�a����)�U�+�+�+����-��/�/�/��G�G������G�G�G�G�G�G�G�G��y� �+�+�W�+�=�=��F�F�F�F���,�'�'�)�)����}�}�g�}�.�.�%�7�7�7�7�7�7r6i c���tj��}tj|d��}t	t
t
|j����D]}|�||���d|_	|S)zACreate a read-only zipfile with a huge number of entries entries.rNr\)
r&r'rTrU�maprwr7�HUGE_ZIPFILE_NUM_ENTRIESrVrS)rFr�r��entrys    r*�huge_zipfilezTestPath.huge_zipfile�
se���z�|�|��
�_�T�3�
'�
'����e�D�$A�B�B�C�C�	&�	&�E��K�K��u�%�%�%�%�����	r6c��tj|�����}tj�|�����}|D]}|�d���|j|j	ksJ�dS)zE
        Ensure joinpath on items in zipfile is linear time.
        �suffixN)
rTr�r2r�r�r�r�r�rr0)rFr��entriesr1s    r*�test_joinpath_constant_timez$TestPath.test_joinpath_constant_time�
s}���|�D�-�-�/�/�0�0���"�*�*�4�<�<�>�>�:�:���	%�	%�E��N�N�8�$�$�$�$��}�� =�=�=�=�=�=�=r6c�v�d�td��D��}tj�|��dS)Nc�l�g|]1}d�tjt|��z����2S)rW)r:�string�ascii_lowercaserw)r3r�s  r*r5z:TestPath.test_implied_dirs_performance.<locals>.<listcomp>�
s2��P�P�P�a�����/�#�a�&�&�8�9�9�P�P�Pr6r)r7rTr�r�rs  r*�test_implied_dirs_performancez&TestPath.test_implied_dirs_performance�
s8��P�P�5��<�<�P�P�P����*�*�4�0�0�0�0�0r6c��|�|��}tj|��5}td��D]+}tj|d���d����,	ddd��dS#1swxYwYdS)Nr�r�rIrJ)r�rTrUr7r�r�)rFr�r]�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�v�Gd�dtj��}||��}t|dz|��sJ�dS)Nc��eZdZdS)�(TestPath.test_subclass.<locals>.SubclassN)r
rrrgr6r*�SubclassrA�
s�������Dr6rBr�)rTr�r�)rFr�rBr�s    r*�
test_subclasszTestPath.test_subclass�
s_��	�	�	�	�	�w�|�	�	�	��x��!�!���$��*�h�/�/�/�/�/�/�/r6c�l�tj|��}|jtjd��ksJ�dS)Nr�)rTr�rir�r�s   r*�
test_filenamezTestPath.test_filename�
s4���|�H�%�%���}���^� <� <�<�<�<�<�<�<r6c�n�tj|��}|jdcxkr|jjksnJ�dS)zH
        The name of the root should be the name of the zipfile
        r�N)rTr�rrir�s   r*�test_root_namezTestPath.test_root_name�
sE��
�|�H�%�%���y�N�@�@�@�@�d�m�.@�@�@�@�@�@�@�@�@r6c���tj|��}|jdcxkr|jjksnJ�|dz}|jdksJ�|dzdz}|jdksJ�|dz}|jdksJ�d	S)
��
        The suffix of the root should be the suffix of the zipfile.
        The suffix of each nested file is the final component's last suffix, if any.
        Includes the leading period, just like pathlib.Path.
        �.zipr��.txtr��filename.tar.gz�.gzrrON)rTr�r4ri�rFr�r�r�r�rs      r*�test_suffixzTestPath.test_suffix�
s����|�H�%�%���{�f�<�<�<�<��
�(<�<�<�<�<�<�<��7�N���x�6�!�!�!�!��3�J�*�*���x�5� � � � ��3�J���x�2�~�~�~�~�~�~r6c��tj|��}|jdgcxkr|jjksnJ�|dz}|jdgksJ�|dzdz}|jddgksJ�|dz}|jgksJ�|d	z}|jgksJ�d
S)rIrJr�rKr�rLz.tarrMrz.hgrcN)rTr��suffixesri)rFr�r�r�r�rr�s       r*�
test_suffixeszTestPath.test_suffixes�
s����|�H�%�%���}���B�B�B�B�D�M�,B�B�B�B�B�B�B��7�N���z�f�X�%�%�%�%��3�J�*�*���z�f�e�_�,�,�,�,��3�J���z�R������7�N���z�R������r6c��d|_tj|��}|�d��jdksJ�|�d��jgksJ�dS)N�examplerO)rirTr�r�r4rQr�s   r*�test_suffix_no_filenamez TestPath.test_suffix_no_filenames_�� ����|�H�%�%���}�}�Y�'�'�.�"�4�4�4�4��}�}�Y�'�'�0�B�6�6�6�6�6�6r6c��tj|��}|jdcxkr|jjksnJ�|dz}|jdksJ�|dzdz}|jdksJ�|dz}|jdksJ�|dzjdksJ�d	S)
z>
        The final path component, without its suffix
        r�r�r�r�rLzfilename.tarrz
.gitignoreN)rTr��stemrirNs      r*�	test_stemzTestPath.test_stems���
�|�H�%�%���y�J�<�<�<�<�$�-�*<�<�<�<�<�<�<��7�N���v��}�}�}�}��3�J�*�*���v��'�'�'�'��3�J���v��}�}�}�}��|�#�)�\�9�9�9�9�9�9r6c���tj|��}|jtjd��ksJ�d|j_|jtjd��ksJ�dS)N�.zfoo/bar.zipr�)rTr�r"r�r�rir�s   r*�test_root_parentzTestPath.test_root_parents[���|�H�%�%���{�g�l�3�/�/�/�/�/�/�*��	���{�g�l�5�1�1�1�1�1�1�1�1r6c�V�d|_tj|��}|�t��5|jddd��n#1swxYwY|�t��5|jddd��n#1swxYwY|dz}|jdksJ�|jsJ�dS)zd
        It is an error to attempt to get the name
        or parent of an unnamed zipfile.
        Nr�)rirTr�r�rXrr")rFr�r��subs    r*�test_root_unnamedzTestPath.test_root_unnamed"s(��!����|�H�%�%��
�
�
�y�
)�
)�	�	��I�I�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�
�
�
�y�
)�
)�	�	��K�K�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	��S�j���x�3������z���z��s#�A
�
A�A�/B�B�
Bc���tdtjfi��}|���D]7}||���d��j}t
||��sJ��8dS)N�	PathChildzsome dir)�typerTr�r�r�r"r�)rFr�r=r]s    r*�test_inheritancezTestPath.test_inheritance4ss���;�����4�4���-�-�/�/�	)�	)�H��3�x�=�=�)�)�*�5�5�<�D��d�C�(�(�(�(�(�(�	)�	)r6c��|�|��}tj|��}tj|��|�|j��dS)zU
        A zip file wrapped in a Path should extract even with implied dirs.
        N)r�rTrUr�r�r")rFr��source_pathr�s    r*�#test_extract_orig_with_implied_dirsz,TestPath.test_extract_orig_with_implied_dirs;sQ��
�)�)�(�3�3��
�_�[�
)�
)����R����
�
�
�k�(�)�)�)�)�)r6c��tj��}tj|d��}|�dd��|�dd��|�dd��d|_tj|��}ttt|�
������dgksJ�|�d���d	�����dksJ�d
S)z�
        Path should handle malformed paths gracefully.

        Paths with leading slashes are not visible.

        Paths with dots are treated like regular files.
        rNz/one-slash.txtr.z//two-slash.txtz
../parent.txtrOz../z..z
parent.txtN)
r&r'rTrUrVrir��listr/rwr�r�r
)rFr;r�r�s    r*�test_malformed_pathszTestPath.test_malformed_pathsFs����z�|�|��
�_�T�3�
'�
'��
���$�j�1�1�1�
���%�z�2�2�2�
���O�Z�0�0�0�����|�B�����C��T�\�\�^�^�,�,�-�-�%��8�8�8�8��}�}�T�"�"�+�+�L�9�9�D�D�F�F�*�T�T�T�T�T�Tr6c���tj��}tj|d��}|�dd��|�dd��d|_tj|��}|���}t|��j	dksJ�t|��j	dksJ�|�
d�����dksJ�dS)z�
        Path segments with special characters are readable.

        On some platforms or file systems, characters like
        ``:`` and ``?`` are not allowed, but they are valid
        in the zip file.
        rNzpath?r.zV: NMS.flacsfLaC...rON)r&r'rTrUrVrir�r�r�rr�r
)rFr;r�r��contentss     r*�test_unsupported_nameszTestPath.test_unsupported_namesXs����z�|�|��
�_�T�3�
'�
'��
���G�Z�(�(�(�
���M�:�.�.�.�����|�B�����<�<�>�>���H�~�~�"�g�-�-�-�-��H�~�~�"�m�3�3�3�3��}�}�]�+�+�6�6�8�8�J�F�F�F�F�F�Fr6c�\�tj��}tj|d��}|�t
�d|��d��d|_tj|��}|�	��\}|�
��rJ�|jdksJ�dS)z@
        In a zip file, backslashes are not separators.
        rNzfoo\barr.rON)r&r'rTrUrV�DirtyZipInfo�for_namerir�r�r^r)rFr;r�r��firsts     r*�test_backslash_not_separatorz%TestPath.test_backslash_not_separatorks����z�|�|��
�_�T�3�
'�
'��
���L�)�)�*�b�9�9�:�F�F�F�����|�B�����<�<�>�>����<�<�>�>�!�!�!��z�Z�'�'�'�'�'�'r6N)1r
rrrHr�r�r�r�r�r�r�r�r�r�r�rrrrr�rrrrrrr$r&r(r-r0r2r6r;r>rCrErGrOrRrUrXr[r^rbrerhrkrprgr6r*r�r��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�����]��$� � ��]� �*�7�7��]�7��:�:��]�:�$�2�2��]�2�����]��"�)�)��]�)��*�*��]�*�U�U�U�$G�G�G�&(�(�(�(�(r6r�c�8��eZdZdZ�fd�Zed���Z�xZS)rmz#
    Bypass name sanitization.
    c�P��t��j|g|�Ri|��||_dSr")r	r�ri)rFrirprWr
s    �r*r�zDirtyZipInfo.__init__~s5���������3�D�3�3�3�F�3�3�3� ��
�
�
r6c��||tjtj����dd����}|j|_|j|_|j�d��rd|_|xjdzc_nd|_|S)zy
        Construct the same way that ZipFile.writestr does.

        TODO: extract this functionality and re-use
        N�)rir`rWi�Ar�r-)	rurgrLr�rM�compress_levelrir[r.)r=r�archiverFs    r*rnzDirtyZipInfo.for_name�s����s�D�D�N�4�9�;�;�,G�,G����,K�L�L�L��$�0���%�3����=�!�!�#�&�&�	-�!.�D�����$�&����!,�D���r6)r
rrr�r�r)rnr)r
s@r*rmrmys]���������!�!�!�!�!�����[�����r6rmc���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.
r0u%これは現代的日本語です。
rIu"これは古い日本語です。
�	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�rNrRr?r0ryrA)rrr�
file_namesrTrUr��file_contentrVr�rCrlr�r�rD)rF�placeholdersr��tempr�r;rs       r*rHzEncodedMetadataTests.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��
Srgrh)r3r�s  r*r5z3EncodedMetadataTests._test_read.<locals>.<listcomp>�s��-�-�-����-�-�-r6)
rxrk�sortedryr�r{rirzrqrl)	rFrX�expected_namesr�r�r�rr�r�s	         r*�
_test_readzEncodedMetadataTests._test_read�s����� � ����������~�(>�(>�?�?�?���� � ��-�-�u�-�-�-����������~�(>�(>�?�?�?�!��1A�B�B�	8�	8�M�D�'��=�=��&�&�D����T�]�D�1�1�1����T�^�S��\�\�:�:�:����U�Z�Z��-�-�w�7�7�7�7�		8�	8r6c��tjtdd���5}|�||j|j��ddd��dS#1swxYwYdS)Nr\ry��metadata_encoding)rTrUrr�r}r~r8s  r*� test_read_with_metadata_encodingz5EncodedMetadataTests.test_read_with_metadata_encoding�s���
�_�V�S�K�
H�
H�
H�	G�E��O�O�E�4�?�D�4E�F�F�F�	G�	G�	G�	G�	G�	G�	G�	G�	G�	G�	G�	G����	G�	G�	G�	G�	G�	Gs�"A�A�Ac��d�|jdd�D��|jdd�z}tjtd��5}|�|||j��ddd��dS#1swxYwYdS)Nc�^�g|]*}|�d���d����+S�ry�cp437�r�r��r3rs  r*r5zLEncodedMetadataTests.test_read_without_metadata_encoding.<locals>.<listcomp>��B��;�;�;�"��+�+�k�2�2�9�9�'�B�B�;�;�;r6r�r\�r}rTrUrr�r~�rFr�rXs   r*�#test_read_without_metadata_encodingz8EncodedMetadataTests.test_read_without_metadata_encoding�s���;�;�&*�o�b�q�b�&9�;�;�;�=A�_�Q�R�R�=P�Q��
�_�V�S�
)�
)�	F�U��O�O�E�>�4�3D�E�E�E�	F�	F�	F�	F�	F�	F�	F�	F�	F�	F�	F�	F����	F�	F�	F�	F�	F�	Fs�A.�.A2�5A2c��d�|jdd�D��|jdd�z}tjtdd���5}|�|||j��ddd��dS#1swxYwYdS)Nc�^�g|]*}|�d���d����+S)ry�koi8-ur�r�s  r*r5zSEncodedMetadataTests.test_read_with_incorrect_metadata_encoding.<locals>.<listcomp>�sB��;�;�;�"��+�+�k�2�2�9�9�(�C�C�;�;�;r6r�r\r�r�r�r�s   r*�*test_read_with_incorrect_metadata_encodingz?EncodedMetadataTests.test_read_with_incorrect_metadata_encoding�s���;�;�&*�o�b�q�b�&9�;�;�;�=A�_�Q�R�R�=P�Q��
�_�V�S�H�
E�
E�
E�	F���O�O�E�>�4�3D�E�E�E�	F�	F�	F�	F�	F�	F�	F�	F�	F�	F�	F�	F����	F�	F�	F�	F�	F�	Fs�A0�0A4�7A4c�@�|�t��5tjtdd���ddd��n#1swxYwY|�t��5tjtdd���ddd��dS#1swxYwYdS)Nr\r0r�rI)r�r�rTrUrr&s 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����+Sr�r�r�s  r*r5z?EncodedMetadataTests.test_read_after_append.<locals>.<listcomp>�r�r6r�r�r;�
newcontentr\ryr�)r}r�r~rTrUrrVrkr�rxr��	enumerater�r{rirzrqr�r�rl)	rF�newnamer�r�rXr4rr�r�s	         r*�test_read_after_appendz+EncodedMetadataTests.test_read_after_append�s�����;�;�&*�o�b�q�b�&9�;�;�;�=A�_�Q�R�R�=P�Q�����g�&�&�&�>�T�.�>�
�>�>��
�_�V�S�
)�
)�	O�U��N�N�7�L�1�1�1����V�E�N�N�$4�$4�5�5�v�n�7M�7M�N�N�N�	O�	O�	O�	O�	O�	O�	O�	O�	O�	O�	O����	O�	O�	O�	O��_�V�S�
)�
)�	E�U��O�O�E�>�3C�D�D�D�	E�	E�	E�	E�	E�	E�	E�	E�	E�	E�	E����	E�	E�	E�	E��_�V�S�K�
H�
H�
H�
	@�E����V�E�N�N�$4�$4�5�5�v�n�7M�7M�N�N�N�&/��N�DT�0U�0U�&V�&V�
@�
@�"��?�D�'��}�}�T�*�*��� � ����5�5�5�� � ����W���>�>�>��q�5�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)rNrr;z^metadata_encoding is onlyznonesuch.zipryr�)rTrUr�r )rF�ZFrSs   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_jisr��nonesuchr�rOr�r~ry)rrr��
SystemExitrT�mainrkrorrrr})rF�errmsgrp�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�)r^r�r#rrr}rjr�r:r�UnicodeEncodeErrorrirTr�rrErr)rFrr�rs    r*�'test_cli_with_metadata_encoding_extractz<EncodedMetadataTests.test_cli_with_metadata_encoding_extracts��
�����������(�(�(��/�	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
rrr}r�r~rHr�r�r�r�r�r�r�r�r�rgr6r*rxrx�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�)�)�)�&)�)�)�)�)r6rxc�*�eZdZdZd�Zd�Zd�Zd�ZdS)�StripExtraTestsrbc�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�r6�z�rl�Structr��ZIP64_EXTRArkrT�_strip_extra�rFr�r;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�Or6c�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�rbr�r��bbr�scccr6r�r�r�s     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�Or6c��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�rbr�r�r�r6r�r�)rFr�r;r�s    r*�test_multipleszStripExtraTests.test_multiplesJs����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�Mr6c�~�|�dtjd|jf����|�dtjd|jf����|�dtjd|jf����|�dtjd|jf����dS)Nr6r�szzszzz)rkrTr�r�r&s r*�test_too_shortzStripExtraTests.test_too_shortZs�������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�	Gr6N)r
rrr�r�r�r�r�rgr6r*r�r�%se������
�K�
P�
P�
P�
P�
P�
P�N�N�N� G�G�G�G�Gr6r��__main__)gr4r#�importlib.utilr_r&r�r^r�r]r9rlr�r��test.support.script_helperrrur��
unittest.mockr�rTr��tempfilerrrrr(r�test.supportr	r
rrr
rrr�test.support.os_helperrrrrrrrr#r�r8�
DATAFILES_DIRr�r+r-�TestCaser+rrr{r�r�r�r!r%r'r)r<r?rArCrEr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r
r�rr5rYrlr��tuple�consumer�r�r�r�r�rrmrxr�r
r�rgr6r*�<module>r�s���������������	�	�	�	�����	�	�	�	���������
�
�
�
�
�
�
�
�����
�
�
�
�7�7�7�7�7�7�����������������������#�"�"�"�"�"�-�-�-�-�-�-�-�-�-�-�������&�&�&�&�&�&�������������������������������������
�3�,���S�L�	���#�
�T�T�T��
#�#�#�f�f�f�f�f�f�f�f�R
~J�~J�~J�~J�~J� ;� (� 1�~J�~J�~J�B����
H�
H�
H�
H�
H�!<�!)�!2�
H�
H���
H�����$�$�$�$�$�:�'�0�$�$���$�����#�#�#�#�#�9�&�/�#�#���#�
O�O�O�O�O�O�O�O�d\0�\0�\0�\0�\0�"?�"*�"3�\0�\0�\0�~����'�'�'�'�'�#@�#+�#4�'�'���'�����$�$�$�$�$�!>�!)�!2�$�$���$�����#�#�#�#�#� =� (� 1�#�#���#�
/1�/1�/1�/1�/1�/1�/1�/1�b%�%�%�%�%�+�X�->�%�%�%�����'�'�'�'�'�,�h�.?�'�'���'�����$�$�$�$�$�*�H�,=�$�$���$�����#�#�#�#�#�)�8�+<�#�#���#�~�~�~�~�~�X�&�~�~�~�B}�}�}�}�}�8�$�}�}�}�@$�$�$�$�$�^�2�H�4E�$�$�$�6O	�O	�O	�O	�O	��"�O	�O	�O	�d��������>
�
�
�
�
�+�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�zC�C�C�C�C��)�C�C�C�L *� *� *� *� *�8�$� *� *� *�FMH�MH�MH�MH�MH�h�'�MH�MH�MH�`%:�%:�%:�%:�%:��!2�%:�%:�%:�R��
�
�
�
�
�
�
�
� ���!�!�!�H���O(�O(�O(�O(�O(�x� �O(�O(�O(�d�����7�?����6N)�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��r6

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists