HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //usr/local/lib/python3.10/test/__pycache__/test_zipfile.cpython-310.opt-2.pyc
o

�i��@s�ddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
mZddlZddlZddlmZddlZddlZddlmZddlmZmZmZddlmZddlmZmZmZmZm Z ddl!m"Z"m#Z#m$Z$m%Z%m&Z&e"dZ'e"d	Z(d
Z)dZ*gd�Z+d
d�Z,Gdd�d�Z-Gdd�de-ej.�Z/e�Gdd�de-ej.��Z0e�Gdd�de-ej.��Z1e�Gdd�de-ej.��Z2Gdd�d�Z3Gdd�de3ej.�Z4e�Gdd�de3ej.��Z5e�Gdd �d e3ej.��Z6e�Gd!d"�d"e3ej.��Z7Gd#d$�d$�Z8Gd%d&�d&e8ej.�Z9e�Gd'd(�d(e8ej.��Z:e�Gd)d*�d*e8ej.��Z;e�Gd+d,�d,e8ej.��Z<Gd-d.�d.ej.�Z=Gd/d0�d0ej.�Z>Gd1d2�d2ej.�Z?Gd3d4�d4�Z@Gd5d6�d6e@ej.�ZAe�Gd7d8�d8e@ej.��ZBe�Gd9d:�d:e@ej.��ZCe�Gd;d<�d<e@ej.��ZDGd=d>�d>ej.�ZEGd?d@�d@�ZFGdAdB�dBeFej.�ZGe�GdCdD�dDeFej.��ZHe�GdEdF�dFeFej.��ZIe�GdGdH�dHeFej.��ZJGdIdJ�dJ�ZKGdKdL�dL�ZLGdMdN�dNej.�ZMe�GdOdP�dPej.��ZNGdQdR�dRej.�ZOGdSdT�dTej.�ZPGdUdV�dVej.�ZQGdWdX�dXej.�ZReSZTGdYdZ�dZ�ZUd[d\�ZVd]d^�ZWd_d`�ZXGdadb�dbej.�ZYGdcdd�ddej.�ZZe[dek�rGe�\�dSdS)f�N)�assert_python_ok)�
TemporaryFile)�randint�random�	randbytes)�
script_helper)�findfile�
requires_zlib�requires_bz2�
requires_lzma�captured_stdout)�TESTFN�unlink�rmtree�temp_dir�temp_cwd�2�d��Zzipfile_datafiles))Z	_ziptest1Z
1q2w3e4r5t)zziptest2dir/_ziptest2Z
qawsedrftg)z!ziptest2dir/ziptest3dir/_ziptest3Z
azsxdcfvgb)z-ziptest2dir/ziptest3dir/ziptest4dir/_ziptest3Z
6y7u8i9o0pccs��tVt��}|V|�|j�Wd�n1swYt���}|V|�|j�Wd�dS1s9wYdS�N)�TESTFN2r�assertFalse�closed�io�BytesIO)�test�f�r�./usr/local/lib/python3.10/test/test_zipfile.py�	get_files(s��
"�rc@seZdZedd��Zdd�ZdBdd�ZdBdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�Zd4d5�Zd6d7�Zd8d9�Zd:d;�Z d<d=�Z!d>d?�Z"d@dA�Z#dS)C�AbstractTestsWithSourceFilecCs&dd�tt�D�|_d�|j�|_dS)NcSs g|]}td|t�fd��qS)z'Zipfile test line %d. random float: %f
�ascii)�bytesr��.0�irrr�
<listcomp>4s���z:AbstractTestsWithSourceFile.setUpClass.<locals>.<listcomp>�)�range�FIXEDTEST_SIZE�line_gen�join�data��clsrrr�
setUpClass2s�z&AbstractTestsWithSourceFile.setUpClasscC�<ttd��}|�|j�Wd�dS1swYdS�N�wb��openr
�writer,��self�fprrr�setUp9�"�z!AbstractTestsWithSourceFile.setUpNc	Cs�||d�}tj|dfi|���F}|�td�|�tt�|�d|j�|jddd��}|jD]}|�|�q.Wd�n1s@wYWd�dSWd�dS1sXwYdS)N)�compression�
compresslevel�w�another.name�strfile�written-open-w��mode)�zipfile�ZipFiler5r
�writestrr,r4r*)r7rr;r<�kwargs�zipfp�linerrr�make_test_archive>s

���"�z-AbstractTestsWithSourceFile.make_test_archivecCsB|�|||�t�|d|���}|�|�t�|j�|�|�d�|j�|�|�d�|j�t��}|j	|d�|�
�}|��}|�t|�d�|�
d|d�|�
d|d�|�
d	|d�|d
��\}}	}
}|�|d�|�t�|	d��|�t�|
d��|�|tt|j���|��}|�t|�d
�|�
t|�|�
d|�|�
d|�|�
d|�|��}
dd�|
D�}|�t|�d
�|�
t|�|�
d|�|�
d|�|�
d|�|
D]}|�|jt|j��q�tdddfD]}|�|�}|�|j|�|�|jt|j��q�|��Wd�dS1�swYdS)N�rr>r?)�file��	File Namer�Modified�Size��%Y-%m-%d�%H:%M:%S�r@cS�g|]}|j�qSr��filenamer#rrrr&m�z8AbstractTestsWithSourceFile.zip_test.<locals>.<listcomp>)rIrCrD�assertEqual�readr
r,r�StringIO�printdir�getvalue�
splitlines�len�assertIn�split�
assertTrue�time�strptime�str�namelist�infolist�	file_size�getinforV�testzip)r7rr;r<rGr8�	directory�lines�fn�date�time_�size�names�infosr%�nm�inforrr�zip_testIsN

$�z$AbstractTestsWithSourceFile.zip_testcC� t|�D]	}|�||j�qdSr�rrtr;�r7rrrr�
test_basic��z&AbstractTestsWithSourceFile.test_basicc		Cs|�||�t�|d|��i}g}|�t��}	|�d�}|sn|�|�qWd�n1s/wYg}|�d��}	|�d�}|sEn|�|�q=Wd�n1sUwY|�d�|�|j	�|�d�|�|j	�Wd�dS1sywYdS�NrJT�r>r')
rIrCrDr4r
rY�appendrXr+r,)	r7rr;rG�zipdata1�zipopen1�	read_data�zipdata2�zipopen2rrr�
zip_open_test�s2

��

��"�z)AbstractTestsWithSourceFile.zip_open_testcCrur�rr�r;rwrrr�	test_open�ryz%AbstractTestsWithSourceFile.test_opencCs\t�t�}|�||j�t�|d|j��}|�|jt	�Wd�dS1s'wYdS�NrJ)
�pathlib�Pathrr�r;rCrD�assertIsInstancerVrd)r7�pathrGrrr�test_open_with_pathlike�s

"�z3AbstractTestsWithSourceFile.test_open_with_pathlikec	Cs�|�||�t�|d|��<}g}|�t��}	|�tdd��}|s"n|�|�qWd�n1s2wY|�d�	|�|j
�Wd�dS1sLwYdS�NrJTrP�r')rIrCrDr4r
rYrr|rXr+r,)r7rr;rGr}r~rrrr�zip_random_open_test�s
��"�z0AbstractTestsWithSourceFile.zip_random_open_testcCrur�rr�r;rwrrr�test_random_open�ryz,AbstractTestsWithSourceFile.test_random_openc	Cs�|�||�t�|d��.}|�t��}g}	|�d�}|sn|�|�qWd�n1s.wYWd�n1s=wY|�d�|�|j	�dS)NrJT���r')
rIrCrDr4r
�read1r|rXr+r,�r7rr;rG�zipopen�zipdatarrrr�zip_read1_test�s"�

���	z*AbstractTestsWithSourceFile.zip_read1_testcCrur)rr�r;rwrrr�
test_read1�ryz&AbstractTestsWithSourceFile.test_read1c	Cs�|�||�t�|d��6}|�t��!}g}	|�d�}|�t|�d�|s&n|�|�qWd�n1s6wYWd�n1sEwY|�	d�
|�|j�dS)NrJT�
r')rIrCrDr4r
r�ZassertLessEqualr^r|rXr+r,r�rrr�zip_read1_10_test�s$�

���
z-AbstractTestsWithSourceFile.zip_read1_10_testcCrur)rr�r;rwrrr�
test_read1_10�ryz)AbstractTestsWithSourceFile.test_read1_10c	Cs�|�||�t�|d��8}|�t��#}d}	|��}|sn||7}|�d�}|s)n||7}qWd�n1s8wYWd�n1sGwY|�||j�dS)NrJr'T�d)	rIrCrDr4r
�readlinerYrXr,)r7rr;rGr�r,rYrrr�zip_readline_read_test�s*�
����z2AbstractTestsWithSourceFile.zip_readline_read_testcCrur)rr�r;rwrrr�test_readline_read�s�z.AbstractTestsWithSourceFile.test_readline_readc	Cs�|�||�t�|d��6}|�t��}|jD]}|��}|�||�qWd�n1s-wYWd�dSWd�dS1sEwYdSr�)rIrCrDr4r
r*r�rX)r7rr;rGr�rHZlinedatarrr�zip_readline_test�s
���"�z-AbstractTestsWithSourceFile.zip_readline_testcCrur)rr�r;rwrrr�
test_readlineryz)AbstractTestsWithSourceFile.test_readlinec	Cs�|�||�t�|d��3}|�t��}|��}Wd�n1s!wYt|j|�D]
\}}|�||�q,Wd�dS1sBwYdSr�)	rIrCrDr4r
�	readlines�zipr*rX)r7rr;rGr�ZziplinesrH�ziplinerrr�zip_readlines_tests
��"�z.AbstractTestsWithSourceFile.zip_readlines_testcCrur)rr�r;rwrrr�test_readlinesryz*AbstractTestsWithSourceFile.test_readlinesc	Cs�|�||�t�|d��7}|�t��}t|j|�D]
\}}|�||�qWd�n1s.wYWd�dSWd�dS1sFwYdSr�)rIrCrDr4r
r�r*rX)r7rr;rGr�rHr�rrr�zip_iterlines_tests���"�z.AbstractTestsWithSourceFile.zip_iterlines_testcCrur)rr�r;rwrrr�test_iterlinesryz*AbstractTestsWithSourceFile.test_iterlinesc	Cs�	t�td|j��}|�dd�Wd�n1swYt�td|j��8}|�d��}|�|�d�d�|�|�d�d�Wd�n1sJwYWd�dSWd�dS1sbwYdS)Nr=r?Z12rJrP�1�2)rCrDrr;rEr4rXrY)r7rGZopenobjrrr�test_low_compression!s���"�z0AbstractTestsWithSourceFile.test_low_compressioncCs<t�td�}|jdd|jd�|�d�}|�|j|j�dS)Nr=�b.txt�hello world��
compress_type)rCrDrrEr;rhrXr�)r7rGrsrrr�test_writestr_compression-s
z5AbstractTestsWithSourceFile.test_writestr_compressioncCs�tjtddd�}|jdd|jd�|jdd|jdd	�|�d�}|�|j|j�|�|jd�|�d�}|�|j|j�|�|jd�dS)
Nr=rP�r<�a.txtr�r�r��)r�r<)	rCrDrrEr;rhrXr��_compresslevel)r7rGZa_infoZb_inforrr�test_writestr_compresslevel3s�

z7AbstractTestsWithSourceFile.test_writestr_compresslevelc
Cs�dD]M}|d}t|�}t�t��d|j��1}|�d|�|�dd��}|�|�}|�	t
|�|�Wd�n1s;wYWd�n1sJwYqdS)N)rPi�iii@rPr=�foorJ)rrCrDrrr;rEr4rYrXr^)r7Z	test_sizergZjunk�zipfr8�bufrrr�test_read_return_sizeCs
�����z1AbstractTestsWithSourceFile.test_read_return_sizec
Cslt��}tj|dd��}|jd|j|jd�|��}Wd�n1s$wY|��}t�|�}t�|��=}|�	d��(}|�
|d�|�t��|�
�Wd�n1sYwYWd�n1shwYWd�n1swwYt�|�}t�|��D}|�	d��/}|�
|d�|�t��|�
d�r�	|�
d�s�Wd�n1s�wYWd�n1s�wYWd�n1s�wYt�|�}t�|��O}|�	d��0}|�
|d�|�t��|�d�r�	|�d�s�Wd�n	1�swYWd�n1�swYWd�dSWd�dS1�s/wYdS)Nr=rAr?r��r�)rrrCrDrEr,r;�tellr\r4�truncate�assertRaises�EOFErrorrYr�)r7r8r��
end_offset�zipfiledatar�rrr�test_truncated_zipfileOs\
�

�����


�������


���� ��$�z2AbstractTestsWithSourceFile.test_truncated_zipfilec
Cs�d}t|�D]�}t�|d|j��}|�t|�t|�}|�d|�Wd�n1s+wYt�|d���}t|�}t|t	�rI|�d||�n|�d||�|�d|�t|�
|��}|�d||�|�d|�|�d	|�|jtjkr�|�d
|�|�d|�|�|��&}t|�}|�d||�|�d|�|jtjkr�|�d
|�Wd�n1s�wY|�d
t|��Wd�n1s�wY|�d
t|��qdS)Nz	file.namer=zmode='w'rJzfilename=%rzfile=%rzmode='r'z	filemode=z
file_size=zcompress_type=zcompress_size=zname=%rz[closed])
rrCrDr;r5r
�reprr_�
isinstancerdrh�
ZIP_STOREDr4)r7�fnamerrGrJr�rrr�	test_reprms@�
����z%AbstractTestsWithSourceFile.test_reprcCs$t|�D]}|j||jdd�qdS)N�	r�rvrwrrr�test_compresslevel_basic���z4AbstractTestsWithSourceFile.test_compresslevel_basiccCs�	tjtddd��/}|�td�|jtddd�|�d�}|�d�}|�|jd�|�|jd�Wd�dS1s;wYdS)Nr=rPr�Z
compress_1Z
compress_9r�)rCrDrr5r
rhrXr�)r7rGZone_infoZ	nine_inforrr�test_per_file_compresslevel�s

"�z7AbstractTestsWithSourceFile.test_per_file_compresslevelc	s�G��fdd�dtj�}d�	|�}d�t�|d|j��b}|�dd��
}|�d�Wd�n1s3wYd�z9z|�dd��
}|�d	�Wd�n1sRwYWn
tye�d
7�YnwWd�Wd�nCWd�nd�wWd�n1s�wYt�t�|�����}|�	|�
�dg�|�	|�d�d�Wd�n1s�wYqt�t�|�����%}|�	|�
�ddg�|�	|�d�d�|�	|�d�d	�Wd�dS1s�wYdS)Ncs eZdZ���fdd�Z�ZS)zCAbstractTestsWithSourceFile.test_writing_errors.<locals>.BrokenFilecs,�dur��kr
t��d7�t��|�dS�NrP)�OSError�superr5�r7r,)�	__class__�count�stoprrr5�s
zIAbstractTestsWithSourceFile.test_writing_errors.<locals>.BrokenFile.write)�__name__�
__module__�__qualname__r5�
__classcell__r�r�r�)r�r�
BrokenFile�sr�rTr=Zfile1sdata1Zfile2sdata2rP)rrrCrDr;r4r5r�r\rXrerY)r7r�ZtestfilerGrrr�r�test_writing_errors�sD	������
��"�z/AbstractTestsWithSourceFile.test_writing_errorscC�tt�tt�dSr�rr
r�r7rrr�tearDown��z$AbstractTestsWithSourceFile.tearDownr)$r�r�r��classmethodr/r9rIrtrxr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrr 1sD


6

	%r c@s�eZdZejZdZdd�Zdd�Zdd�Z	dd	�Z
d
d�Zdd
�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�ZdS)�StoredTestsWithSourceFileNcCsn|�||�t�|d��!}|�d�}|�|jd�|�d�}|�|jd�Wd�dS1s0wYdS)NrJr?��r@)rIrCrDrhrX�
external_attr)r7rr;rG�zinfoZzinfo2rrr�zip_test_writestr_permissions�s

"�z7StoredTestsWithSourceFile.zip_test_writestr_permissionscCs t|�D]	}|�|tj�qdSr)rr�rCr�rwrrr�test_writestr_permissions�ryz3StoredTestsWithSourceFile.test_writestr_permissionscCs�t�tdtj��}|�td�Wd�n1swYt�tdtj��}|�|��dg�Wd�dS1s;wYdS)Nr=�	/absoluterJ�absolute�rCrDrr�r5r
rXre�r7rGrrr�test_absolute_arcnames�s�"�z0StoredTestsWithSourceFile.test_absolute_arcnamescCs�	t�tdtj��}|�tt�Wd�n1swYt�tdtj��}|�d|j�|�|�	�tdg�Wd�dS1sDwYdS)Nr=�ar?)
rCrDrr�r5r
rEr,rXrer�rrr�test_append_to_zip_file�s�"�z1StoredTestsWithSourceFile.test_append_to_zip_filec	Cs�	d}ttd��
}|�|�Wd�n1swYt�tdtj��}|�tt�Wd�n1s6wYttd��8}|�t|��t�|d��}|�	|�
�tg�|�	|�t�|j�Wd�n1slwYWd�n1s{wYttd��}|�	|�t|��|�|��}Wd�n1s�wYt
�|��9}t�|��}|�	|�
�tg�|�	|�t�|j�Wd�n1s�wYWd�dSWd�dS1s�wYdS)N�I am not a ZipFile!I am not a ZipFile!I am not a ZipFile!I am not a ZipFile!I am not a ZipFile!I am not a ZipFile!I am not a ZipFile!I am not a ZipFile!I am not a ZipFile!I am not a ZipFile!r2r��rbrJ)r4rr5rCrDr�r
�seekr^rXrerYr,rr)r7r,rrGr��biorrr�test_append_to_non_zip_file�s0�����
�P�z5StoredTestsWithSourceFile.test_append_to_non_zip_filec	Cst���*}t�|dtj��}|�tt�Wd�n1swY|��}Wd�n1s1wYd}tt	d��}|�|�|�|�Wd�n1sRwYt�t	��}|�
|��tg�|�
|�t�|j
�Wd�dS1s{wYdS)Nr=r�r2)rrrCrDr�r5r
r\r4rrXrerYr,�r7r�rGr�r,rrrr�test_read_concatenated_zip_files
�
�
�"�z9StoredTestsWithSourceFile.test_read_concatenated_zip_filec	Cs�t���*}t�|dtj��}|�tt�Wd�n1swY|��}Wd�n1s1wYdd}tt	d��}|�|�|�|�Wd�n1sTwYt�t	d��}|�
|��tg�|�d|j
�Wd�n1szwYtt	d��}|�
|�t|��|�|��}Wd�n1s�wYt�|��D}t�|��&}|�
|��tdg�|�
|�t�|j
�|�
|�d�|j
�Wd�n1s�wYWd�dSWd�dS1s�wYdS)Nr=sI am not a ZipFile!i@Br2r�r?r�)rrrCrDr�r5r
r\r4rrXrerEr,rYr^r�rrr�$test_append_to_concatenated_zip_files0
�
�
��
�P�z>StoredTestsWithSourceFile.test_append_to_concatenated_zip_filecCs�t�tdtj��}|�tt�Wd�n1swYttddd��
}|�d�Wd�n1s5wYt�td��}|�|tj�Wd�dS1sSwYdS)Nr=r��utf-8��encodingz
rJ)rCrDrr�r5r
r4r��r7rGrrrr�test_ignores_newline_at_end&s��"�z5StoredTestsWithSourceFile.test_ignores_newline_at_endcCs�t�tdtj��}d|_|�tt�Wd�n1swYttddd��
}|�d�Wd�n1s8wYt�td��}|�|tj�|�	|jd�Wd�dS1s]wYdS)Nr=�this is a commentr�r�r�zabcdef
rJ)
rCrDrr��commentr5r
r4r�rXr�rrr�)test_ignores_stuff_appended_past_comments.s��"�zCStoredTestsWithSourceFile.test_ignores_stuff_appended_past_commentsc	Cs�	t�td��6}|�t�ttd��}|�|�t�|���Wd�n1s(wYWd�dSWd�dS1s@wYdS)Nr=r�)rCrDrr5r
r4rXrYr�rrr�test_write_default_name8s
��"�z1StoredTestsWithSourceFile.test_write_default_namec	Cs�d}tjtdd��}|�|d�Wd�n1swYtjtdd��N}|�|��0}|��|�t|j�|�t|j	d�|�t|j
�|�t|j�|�t|j�Wd�n1s_wYWd�dSWd�dS1swwYdS)N�somefile.txtr=rA�bogusrJr)
rCrDrrEr4�closer��
ValueErrorrYr�r��readable�seekable)r7r�rGZfidrrr�test_io_on_closed_zipextfile@s ���"�z6StoredTestsWithSourceFile.test_io_on_closed_zipextfilec	Cs�	tjtdd��}|�dd�Wd�n1swYtjtdd��}|�t|jt�Wd�n1s8wYtjtdd��-}|�t��|jtdd�Wd�n1s\wYWd�dSWd�dS1stwYdS)Nr=rAr�r�rJ)	rCrDrrEr�r�r5r
r4r�rrr�test_write_to_readonlyNs����"�z0StoredTestsWithSourceFile.test_write_to_readonlycCs�t�td�t�td��}|�t|jt�Wd�n1swYtjtddd��}|�t�|�	t�}|�
|jd�Wd�dS1sIwYdS)N)rrr=F�Zstrict_timestamps�i�rPrPrrr)�os�utimer
rCrDrr�r�r5rhrX�	date_time)r7rGr�rrr�test_add_file_before_1980[s�

"�z3StoredTestsWithSourceFile.test_add_file_before_1980cCs$d}zt�|�Wnty|�d|�d��Ynwz
t�t||f�Wnty4|�d�Ynwt�t�j}|dkrG|�d|���t	�
td��}|�t
j|jt�Wd�n1sawYt	j
tddd	��}|�t�|�t�}|�|jd
�Wd�dS1s�wYdS)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=r=Fr)i;����;r)rb�	localtime�
OverflowError�skipTestrrr
�stat�st_mtime_nsrCrDrr��struct�errorr5rhrXr)r7�tsZmtime_nsrGr�rrr�test_add_file_after_2107fs,��	�

"�z2StoredTestsWithSourceFile.test_add_file_after_2107)r�r�r�rCr�r;r�r�r�r�r�r�r�r�r�r�r�rrrrrrrrr��s"
	

r�c@seZdZejZdd�ZdS)�DeflateTestsWithSourceFilecCs�	t�td��3}|�tdtj�|�tdtj�|�d�}|�d�}|�|j	tj�|�|j	tj�Wd�dS1s=wYdS)Nr=ZstoremeZ	deflateme)
rCrDrr5r
r��ZIP_DEFLATEDrhrXr�)r7rG�sinfoZdinforrr�test_per_file_compression�s

"�z4DeflateTestsWithSourceFile.test_per_file_compressionN)r�r�r�rCrr;rrrrrr�src@�eZdZejZdS)�Bzip2TestsWithSourceFileN�r�r�r�rC�	ZIP_BZIP2r;rrrrr��
rc@r)�LzmaTestsWithSourceFileN�r�r�r�rC�ZIP_LZMAr;rrrrr�rrc@sHeZdZedd��Zdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dS)�AbstractTestZip64InSmallFilescCs$dd�tdt�D�}d�|�|_dS)Ncss�|]
}td|d�VqdS)zTest of zipfile line %d.r!N)r"r#rrr�	<genexpr>�s��z;AbstractTestZip64InSmallFiles.setUpClass.<locals>.<genexpr>r�
)r(r)r+r,)r.r*rrrr/�s�z(AbstractTestZip64InSmallFiles.setUpClasscCsXtj|_tj|_dt_dt_ttd��}|�|j�Wd�dS1s%wYdS)Nrr�r2)	rC�ZIP64_LIMIT�_limit�ZIP_FILECOUNT_LIMIT�_filecount_limitr4r
r5r,r6rrrr9�s"�z#AbstractTestZip64InSmallFiles.setUpcCsptj|d|dd��}|�td�|�tt�|�d|j�Wd�n1s'wYt�|d|���}|�|�t�|j�|�|�d�|j�|�|�d�|j�t�	�}|�
|�|��}|��}|�t
|�d�|�d|d	�|�d
|d	�|�d|d	�|d��\}}}	}
|�|d�|�t�|d
��|�t�|	d��|�|
tt
|j���|��}|�t
|�d�|�t|�|�d|�|�d|�|��}dd�|D�}|�t
|�d�|�t|�|�d|�|�d|�|D]}
|�|
jt
|j��q�tddfD]}|�|�}|�|j|�|�|jt
|j���q|��Wd�dS1�s1wYdS)Nr=T�Z
allowZip64r>r?rJrSrMrrNrOrPrQrR�cSrTrrUr#rrrr&�rWz:AbstractTestZip64InSmallFiles.zip_test.<locals>.<listcomp>)rCrDr5r
rEr,rXrYrrZr[r\r]r^r_r`rarbrcrdrerfrgrhrVri)r7rr;rGr8rjrkrlrmrnrorprqr%rrrsrrrrt�sR�


$�z&AbstractTestZip64InSmallFiles.zip_testcCrurrvrwrrrrx�ryz(AbstractTestZip64InSmallFiles.test_basiccCs�tjtd|jdd�}d|_d}t|�D]}|�d|d|dd	�q|�t|�	��|�|�
�t�td
|j�}|�t|�	��|�t|�D]}|�d|��d�}|�|d|dd	�qH|�
�dS)Nr=Tr)r���foo%08d�%dr*�9rJr!)
rCrDr
r;�debugr(rErXr^rer�rY�decode)r7r��numfilesr%�zipf2�contentrrr�test_too_many_files�s�z1AbstractTestZip64InSmallFiles.test_too_many_filescCstjtd|jdd�}d|_d}t|�D]}|�d|d|dd	�q|�t|�	��|�|�
tj��|�d|d
�Wd�n1sGwY|�t|�	��|�|��tjtd|jdd�}d|_|�t|�	��|�|�
tj��|�d|d
�Wd�n1s�wY|�t|�	��|�|��tjtd|jdd�}d|_|�t|�	��|�d
}t||�D]}|�d|d|dd	�q�|�t|�	��|�|��t�td|j�}|�t|�	��|�t|�D]}|�
d|��d�}|�|d|dd	�q�|��dS)Nr=Fr)r�r�r,r-r*r.r'r�Tr+rJr!)rCrDr
r;r/r(rErXr^rer��LargeZipFiler�rYr0)r7r�r1r%Z	numfiles2r2r3rrr�test_too_many_files_appendsN�����z8AbstractTestZip64InSmallFiles.test_too_many_files_appendcCs$|jt_|jt_tt�tt�dSr)r&rCr%r(r'rr
rr�rrrr�-sz&AbstractTestZip64InSmallFiles.tearDownN)r�r�r�r�r/r9rtrxr4r6r�rrrrr"�s

9'r"c@sZeZdZejZdd�Zdd�Zdd�Zdd�Z	d	d
�Z
			ddd
�Zdd�Zdd�Z
dS)�StoredTestZip64InSmallFilescCsLtj|d|dd��}|�tj|jtd�Wd�dS1swYdS�Nr=Fr)r>)rCrDr�r5r5r
�r7rr;rGrrr�large_file_exception_test8s
�"�z5StoredTestZip64InSmallFiles.large_file_exception_testcCsNtj|d|dd��}|�tj|jd|j�Wd�dS1s wYdSr8)rCrDr�r5rEr,r9rrr�large_file_exception_test2=s

�"�z6StoredTestZip64InSmallFiles.large_file_exception_test2cCs.t|�D]}|�|tj�|�|tj�qdSr)rr:rCr�r;rwrrr�test_large_file_exceptionBs�z5StoredTestZip64InSmallFiles.test_large_file_exceptioncCs�tjtdtjdd��}|�td�Wd�n1swYt�tdtj��}|�|��dg�Wd�dS1s=wYdS)Nr=Tr)r�rJr�r�r�rrrr�Gs��"�z2StoredTestZip64InSmallFiles.test_absolute_arcnamescCs
tjtddd��}|�d|j�Wd�n1swYtjtddd��}|�d�}|j}Wd�n1s:wYtjtddd��}|�d|j�Wd�n1sYwYtjtddd��}|�d�}|�|j|�Wd�dS1s~wYdS)Nr=Tr)r?rJr�Zstrfile2)rCrDrrEr,rh�extrarX)r7rGr�r=rrr�test_appendOs�
��
"�z'StoredTestZip64InSmallFiles.test_appendFcCs�	d}d}g}	g}
|}|rd}|r|	�|�|
�|�t�d|�}|}|r3d}|r3|	�|�|
�|�t�d|�}|}
|rFd}
|rF|
�|�t�d|
�}
tjddt|	�ddt|	�g|	�R�}tjddt|
�ddt|
�g|
�R�}t�dd	dt|
��}t�dd
dt|	��}t�dddt|	��}t�dddt|
��}d
}d}t�dt|��}d|||||||d||||d|
||ddd||dddd}|S)N�r����<L�<HH�QrPz<Q�:�2z<HrSstest.txt�test1234sPK!�%��sPK--!�%��s
�sPK,--ss
sPKlssPK:2s)r|r�packr^)r7�file_size_64_set�file_size_extra�compress_size_64_set�compress_size_extra�header_offset_64_set�header_offset_extraZactual_sizeZactual_header_offsetZlocal_zip64_fieldsZcentral_zip64_fieldsrg�
compress_size�
header_offsetZlocal_extraZ
central_extraZcentral_dir_sizeZoffset_to_central_dirZlocal_extra_lengthZcentral_extra_lengthrVr3Zfilename_lengthZzip64_contentsrrr�make_zip64_file]s�





��
���������	�
���
���������������!z+StoredTestZip64InSmallFiles.make_zip64_filecCs�	|jdd�}|�tj��}t�t�|��Wd�n1s wY|�dt|j	��
��|jdddd�}|�tj��}t�t�|��Wd�n1sQwY|�dt|j	��
��|jdd�}|�tj��}t�t�|��Wd�n1s�wY|�dt|j	��
��|jdddddd�}|�tj��}t�t�|��Wd�n1s�wY|�dt|j	��
��|jd	dddd
�}|�tj��}t�t�|��Wd�n1s�wY|�dt|j	��
��|jddd	dd�}|�tj��}t�t�|��Wd�n	1�swY|�dt|j	��
��|jd	d	dd�}|�tj��}t�t�|��Wd�n	1�sJwY|�dt|j	��
��dS)
NT)rHz	file size)rHrIrJz
compress size)rJ)rHrIrJrKrLz
header offsetF)rHrJrKrL)rHrIrJrL)rHrJrL)rPr�rC�
BadZipFilerDrrr_rd�	exception�lower)r7Zmissing_file_size_extra�eZmissing_compress_size_extraZmissing_header_offset_extrarrr�test_bad_zip64_extra�s���������������z0StoredTestZip64InSmallFiles.test_bad_zip64_extrac
Cs�d}d}d}d}ddd�ddd�ddd�f}tdt|�d�D]Y}t�||�D]P}i}|D]}	|�|	�q-t�t�|j	d	i|�����,}
|
�
�d}|�|j|�|�|j
|�|�|j|�|�|
�|�|�Wd�n1srwYq'qdS)
Nr?rrFT)rHrI)rJrK)rLrMrPr)r(r^�	itertools�combinations�updaterCrDrrrPrfrXrgrNrOrY)r7Zexpected_file_sizeZexpected_compress_sizeZexpected_header_offsetZexpected_content�paramsrJZcomborF�c�zfr�rrr� test_generated_valid_zip64_extras.�����z<StoredTestZip64InSmallFiles.test_generated_valid_zip64_extraN)FFFFFF)r�r�r�rCr�r;r:r;r<r�r>rPrUr\rrrrr74s
�c^r7c@r)�DeflateTestZip64InSmallFilesN�r�r�r�rCrr;rrrrr]:rr]c@r)�Bzip2TestZip64InSmallFilesNrrrrrr_?rr_c@r)�LzmaTestZip64InSmallFilesNr rrrrr`Drr`c@�,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�AbstractWriterTestscC�tt�dSr�rrr�rrrr�L�zAbstractWriterTests.tearDowncCs�d}t�td|j��1}|�dd�}|�|�|��|�|j�|��|�|j�|�	|�
d�|�Wd�dS1s>wYdS)N�contentr=r)rCrDrr;r4r5r�rarrXrY�r7r,r�r=rrr�test_close_after_closeOs
"�z*AbstractWriterTests.test_close_after_closecCs�d}t�td|j��/}|�dd�}|�|�|��|�|j�|�	t
|jd�|�|�d�|�Wd�dS1s<wYdS)Nrfr=rr')
rCrDrr;r4r5r�rarr�r�rXrYrgrrr�test_write_after_closeZs
"�z*AbstractWriterTests.test_write_after_closec	Cs�t�dgd��}t|�|j}t�t��d|j��2}|�dd��}|�	|�
|�|�Wd�n1s4wY|�	|�d�j|�Wd�dS1sNwYdS)NrC)rPr�r*rSrLr=r,)
�arrayr^�itemsizerCrDrrr;r4rXr5rhrg)r7�qZLENGTHr�r,rrr�test_issue44439ds�"�z#AbstractWriterTests.test_issue44439N)r�r�r�r�rhrirmrrrrrbJs

rbc@r)�StoredWriterTestsN�r�r�r�rCr�r;rrrrrnls
rnc@r)�DeflateWriterTestsNr^rrrrrpo�
rpc@r)�Bzip2WriterTestsNrrrrrrrsrqrrc@r)�LzmaWriterTestsNr rrrrrswrqrsc@sdeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dS)�PyZipFileTestscCs$|d|vr|�|d|�dSdS)N�orZ)r_)r7�namererrr�assertCompiledIn}r�zPyZipFileTests.assertCompiledIncCs~tj|tjtjtjvd�s|�d�tj�|d�}zt�|tjtj	B�}t�
|�Wnty8|�d�Ynwt|�dS)N)Z
effective_idsz/requires write access to the installed locationztest_zipfile.try)
r�access�W_OK�supports_effective_idsrr�r+r4�O_WRONLY�O_CREATr��	Exceptionr)r7r�rV�fdrrr�requiresWriteAccess�s

�
�z"PyZipFileTests.requiresWriteAccessc	Cs�|�tj�t��t��e}t�|d��O}t}|�d�r@|�	tj
�}tjdur/|�|�	tj��d|vr:t
j�|�}n|dd�}|�|�tj�|�}|�||���|�||���Wd�n1sewYWd�n1stwYt��T}t�|d��5}t}|�d�r�|dd�}|�|d�ddtj�|�f}|�||���|�||���Wd�n1s�wYWd�dSWd�dS1s�wYdS)Nr=�.pyc�__pycache__r�Ztestpackagez%s/%s)rrr��dirname�__file__rrC�	PyZipFile�endswithr`�sep�altsep�extend�	importlib�util�source_from_cache�writepy�basename�assertNotInrerw)r7�trGrlZ
path_splitZbnrrr�test_write_pyfile�s4


��
P�z PyZipFileTests.test_write_pyfilec	Cs�ddl}tj�|j�}|�|�t��<}t�|d��}|�	|�|�
�}|�d|�|�d|�Wd�n1s:wYWd�dSWd�dS1sRwYdS)Nrr=zemail/__init__.pyzemail/mime/text.py)�emailrr�r�r�rrrCr�r�rerw)r7r��
packagedirr�rGrprrr�test_write_python_package�s

P�z(PyZipFileTests.test_write_python_packagecCs�ddl}tj�|j�}|�|�t���}t�|d���}t	��
}|�
|�Wd�n1s.wY|��}|�d|v�t	��}|j
|dd�d�Wd�n1sUwY|��}|�d|v�dd�}t	��$}|�
t��|j
||d�Wd�n1s�wYWd�n1s�wY|��}|r�t|�|�d|v�Wd�n1s�wYWd�dSWd�dS1s�wYdS)	Nrr=�SyntaxErrorcSsdS)NFr)Zwhateverrrr�<lambda>��zCPyZipFileTests.test_write_filtered_python_package.<locals>.<lambda>�Z
filterfunccSstj�|��d�S)NZbad)rr�r��
startswith)r�rrr�filter��zAPyZipFileTests.test_write_filtered_python_package.<locals>.filter)rrr�r�r�rrrCr�rr�r\ra�assertWarns�UserWarning�print)r7rr�r�rGZ	reportSIOZ	reportStrr�rrr�"test_write_filtered_python_package�s2
����P�z1PyZipFileTests.test_write_filtered_python_packagec	Cs�ddl}tj�|j�}|�|�d}d}t��B}tj|d|d��!}|�	|�|�
�}|�d||�|�d||�Wd�n1sDwYWd�dSWd�dS1s\wYdS)	NrFrPr�r=)�optimizezemail/__init__zemail/mime/text)r�rr�r�r�rrrCr�r�rer_)r7r�r�Zoptlevel�extr�rGrprrr�test_write_with_optimization�s
�
P�z+PyZipFileTests.test_write_with_optimizationc	Cs�t�t�z�ttj�td�ddd��
}|�d�Wd�n1s"wYttj�td�ddd��
}|�d�Wd�n1sCwYttj�td�ddd��
}|�d	�Wd�n1sdwYt��9}t�	|d��#}|�
t�|��}|�d|�|�d|�|�
d|�Wd�n1s�wYWd�n1s�wYWtt�dSWtt�dStt�w)
N�mod1.pyr=r�r��
print(42)
�mod2.py�print(42 * 42)
zmod2.txtzbla bla bla
�r�mkdirrr4r�r+r5rrCr�r�rerwr�r�r7r8r�rGrprrr�test_write_python_directory�s.
���
��	�	z*PyZipFileTests.test_write_python_directoryc	Cs:t�t�z�ttj�td�ddd��
}|�d�Wd�n1s"wYttj�td�ddd��
}|�d�Wd�n1sCwYt��7}t�	|d��!}|j
tdd	�d
�|��}|�d|�|�
d|�Wd�n1svwYWd�n1s�wYWtt�dSWtt�dStt�w)Nr�r=r�r�r�r�r�cSs|�d�S)Nr�)r�)rlrrrr�rezEPyZipFileTests.test_write_python_directory_filtered.<locals>.<lambda>r�r�r�rrr�$test_write_python_directory_filtered�s&
����	�	z3PyZipFileTests.test_write_python_directory_filteredc
Cs�t��O}t�|d��0}ttddd��
}|�d�Wd�n1s"wY|�t|jt�t	t�Wd�n1s=wYWd�dSWd�dS1sUwYdS)Nr=r�r�z!most definitely not a python file)
rrCr�r4r
r5r��RuntimeErrorr�r)r7r�rGrrrr�test_write_non_pyfiles�
P�z$PyZipFileTests.test_write_non_pyfilec
Cs0t�t�z�ttj�td�ddd��
}|�d�Wd�n1s"wYt��S}t�	|d��=}t
��}|�tj�td��Wd�n1sJwY|�d|�
��|��}|�d|�|�d|�Wd�n1sqwYWd�n1s�wYWtt�dSWtt�dStt�w)Nr�r=r�r�zBad syntax in python file
r�zmod1.pyc)rr�rr4r�r+r5rrCr�rr�r_r\rer�r)r7r8r�rG�srprrr�test_write_pyfile_bad_syntaxs&
�����z+PyZipFileTests.test_write_pyfile_bad_syntaxc	Cs�t�t�zlttj�td�ddd��
}|�d�Wd�n1s"wYt��2}t�	|d��}|�
t�t�d�|�
�}|�d|�Wd�n1sPwYWd�n1s_wYWtt�dSWtt�dStt�w)Nr�r=r�r�r�)rr�rr4r�r+r5rrCr�r�r�r�rerwrr�rrr�test_write_pathlike/s
����z"PyZipFileTests.test_write_pathlikeN)r�r�r�rwrr�r�r�r�r�r�r�r�r�rrrrrt|s
rtc@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Ze�ejjdkd�dd��Ze�ejjdkd�dd ��Zd!d"�Zd#S)$�ExtractTestscCsPt�tdtj��}tD]
\}}|�||�qWd�dS1s!wYdS)Nr=)rCrDrr��SMALL_TEST_DATArE�r7rG�fpath�fdatarrr�make_test_file?s
�"�zExtractTests.make_test_filecCs�t��o|��t�td��L}tD]A\}}|�|�}tj�	t�
�|�}tj�|�}|�||�t
|d��}|�|��|���Wd�n1sIwYt|�qWd�n1s]wYWd�dSWd�dS1suwYdS�NrJr�)rr�rCrDrr��extractrr�r+�getcwd�normpathrXr4�encoderYr)r7rGr�r��writtenfile�correctfilerrrr�test_extractDs"
�
���"�zExtractTests.test_extractc
Cs�|��t�td��R}tD]G\}}|�||�}tj�||�}tj�	|�}|�
tj�||�||f�t|d��}|�
|��|���Wd�n1sKwYt|�q
Wd�n1s_wYtt�dSr�)r�rCrDrr�r�rr�r+r�ra�samefiler4rXr�rYr)r7�targetrGr�r�r�r�rrrr�_test_extract_with_targetWs�
��z&ExtractTests._test_extract_with_targetcC�6t��}|�|�Wd�dS1swYdSr)rr��r7�extdirrrr�test_extract_with_targetj�"�z%ExtractTests.test_extract_with_targetcC�<t��}|�t�|��Wd�dS1swYdSr)rr�r�r�r�rrr�!test_extract_with_target_pathliken�"�z.ExtractTests.test_extract_with_target_pathlikecCs�t��b|��t�td��?}|��tD]0\}}tj�	t�
�|�}t|d��}|�|�
�|���Wd�n1s<wYt|�qWd�n1sPwYWd�dSWd�dS1shwYdSr�)rr�rCrDr�
extractallr�rr�r+r�r4rXr�rYr)r7rGr�r��outfilerrrr�test_extract_allrs�
���"�zExtractTests.test_extract_allc
Cs�|��t�td��>}|�|�tD].\}}tj�||�}t	|d��}|�
|��|���Wd�n1s7wYt
|�qWd�n1sKwYt
t�dSr�)r�rCrDrr�r�rr�r+r4rXr�rYr)r7r�rGr�r�r�rrrr�_test_extract_all_with_targets
�
��
z*ExtractTests._test_extract_all_with_targetcCr�r)rr�r�rrr�test_extract_all_with_target�r�z)ExtractTests.test_extract_all_with_targetcCr�r)rr�r�r�r�rrr�%test_extract_all_with_target_pathlike�r�z2ExtractTests.test_extract_all_with_target_pathlikecCsR|�tj�|��t|d��}|�|��|�Wd�dS1s"wYdS)Nr�)rarr��isfiler4rXrY)r7rVr3rrrr�
check_file�s"�zExtractTests.check_filecCsBtjj}|�|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..r�/�	foo/ba..r)rCrDZ_sanitize_windows_namerX)r7Zsanrrr�test_sanitize_windows_name�sz'ExtractTests.test_sanitize_windows_namecC�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)r7Zcommon_hacknamesrrr�*test_extract_hackers_arcnames_common_cases�s
z7ExtractTests.test_extract_hackers_arcnames_common_cases�\zRequires \ as path separator.cCs	gd�}|�|�dS)N))z
..\foo\barr�)z..\/foo\/barr�)zfoo/\..\/barr�)zfoo\/../\barr�)z	C:foo/barr�)z
C:/foo/barr�)zC://foo/barr�)z
C:\foo\barr�)z//conky/mountpoint/foo/barr�)z\\conky\mountpoint\foo\barr�)z///conky/mountpoint/foo/bar�conky/mountpoint/foo/bar)z\\\conky\mountpoint\foo\barr�)z//conky//mountpoint/foo/barr�)z\\conky\\mountpoint\foo\barr�)z//?/C:/foo/barr�)z\\?\C:\foo\barr�)zC:/../C:/foo/barz
C_/foo/bar)za:b\c<d>e|f"g?h*izb/c_d_e_f_g_h_i)r�r�r�)r7Zwindows_hacknamesrrr�*test_extract_hackers_arcnames_windows_only�sz7ExtractTests.test_extract_hackers_arcnames_windows_onlyr�zRequires / as path separator.cCr�)N))z	//foo/barr�)r�zfoo../ba..r)�
foo/..\barr�r�)r7Zposix_hacknamesrrr�(test_extract_hackers_arcnames_posix_only�sz5ExtractTests.test_extract_hackers_arcnames_posix_onlyc
	Cs:|D�]\}}d|��}t�tdtj��}t��}||_d|_|�||�Wd�n1s0wY|�	t
jd�}t
j�
ddd�}t
jj
|g|�d��R�}t�td��}|�||�}	|j|	|d	||	|fd
�Wd�n1suwY|�||�td�t�td��
}|�|�Wd�n1s�wY|�||�td�t
jj
t
��g|�d��R�}t�td��}|�|�}	|j|	|d|d
�Wd�n1s�wY|�||�t|�d�d�t�td��}|��Wd�n	1�swY|�||�t|�d�d�tt�qdS)
N�foobarr=r�r�r��subdirZsubsubrJzextract %r: %r != %r)�msgz
extract %rr)r�rCrDrr��ZipInforVr�rE�replacerr�r�r+r`r�rXr�rr�r�r)
r7Z	hacknames�arcnameZ	fixednamer3rGr��
targetpathr�r�rrrr��sT�����
��
�
�z+ExtractTests._test_extract_hackers_arcnamesN)r�r�r�r�r�r�r�r�r�r�r�r�r�r�r��unittestZskipIfrr�r�r�r�r�rrrrr�=s$


r�c@steZdZdd�Zdd�Zdd�Zdd�Zd	d
�Ze�dd��Z	d
d�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Zd7d8�Zd9d:�Z d;d<�Z!d=d>�Z"d?d@�Z#dAdB�Z$dCdD�Z%dEdF�Z&dGdH�Z'dIdJ�Z(dKdL�Z)e*�dMdN��Z+e�dOdP��Z,e�dQdR��Z-dSdT�Z.dUS)V�
OtherTestsc
CsBt�tdtj��4}|�dd�|�t��|�dd�Wd�n1s%wY|�|��dgd�Wd�n1s?wYt�td��M}|�	�}d}|D]}|�
|��}||��7}Wd�n1skwYqS|�|dd	h�d}|D]	}||�|�7}q}|�|dd	h�Wd�dS1s�wYdS)
Nr=rvr��barr�rJr'r�sbarfoo)
rCrDrr�rEr�r�rXrerfr4rYr_)r7rGrqr,rsr�rrr�test_open_via_zip_info�s*����"�z!OtherTests.test_open_via_zip_infocCs`t�td�� }dD]}t�|�}|jdO_|�||�q	Wd�dS1s)wYdS)Nr=Zabcdefghijklmnopr?)rCrDrr��	flag_bitsrE)r7Zorig_zipr,r�rrr�-test_writestr_extended_local_header_issue1202s
�"�z8OtherTests.test_writestr_extended_local_header_issue1202cCs�	t�td��}tD]\}}|�||�|�|jd�q
Wd�n1s&wY|�|jd�t�td��}|�|jd�Wd�n1sJwY|�|jd�dS)Nr=zzipfp is not open�zipfp is not closedrJ)rCrDrr�rEZassertIsNotNoner8�assertIsNoner�rrr�
test_closes���zOtherTests.test_closecCs�	t�td��}tD]
\}}|�||�q
Wd�n1swYzt�td��}t���1s3wYWdStjyL|�|jd�YdSw)Nr=rJr�)rCrDrr�rErQr�r8)r7rGr�r�Zzipfp2rrr�test_close_on_exception%s����z"OtherTests.test_close_on_exceptioncCs d}|�ttjt�|�d�dS)NsdPKx!p�@xPKxx!p�@�xPK/rJ)r��NotImplementedErrorrCrDrrr�rrr�test_unsupported_version2s

�z#OtherTests.test_unsupported_versioncCsTtd�}t�|��}|��D]	}|�|���qWd�dS1s#wYdS)Nzzip_cp437_header.zip)rrCrDrer4r�)r7r�rGrvrrr�test_read_unicode_filenames=s�"�z&OtherTests.test_read_unicode_filenamescCs�t�td��}|�dd�|�dd�|�|��djt�Wd�n1s(wYt�td��}|�|j	djd�|�|j	djd�Wd�dS1sSwYdS)Nr=�foo.txtzTest for unicode filenameuö.txtrrJrP)
rCrDr
rEr�rfrVrdrX�filelist�r7r[rrr�test_write_unicode_filenamesEs�"�z'OtherTests.test_write_unicode_filenamescCsPt�td��}|�dd�|�|�d�d�Wd�dS1s!wYdS)Nr=uприкладssample)rCrDrrErXrYr�rrr�'test_read_after_write_unicode_filenamesOs"�z2OtherTests.test_read_after_write_unicode_filenamescCs�	tt�d}d}t�tdtj��}|�||�Wd�n1s"wY|�t��t�tdtj�Wd�n1s?wYt�td��}|�|�	�|g�|�|�
|�|�Wd�dS1shwYdS)N�testfile.txt�#hello, world. this is some content.�xrJ)rrrCrDr�rEr��FileExistsErrorrXrerY)r7rVr3rGrrr�test_exclusive_create_zip_fileTs��"�z)OtherTests.test_exclusive_create_zip_filecCs�tj�t�rt�t�d}d}zt�td��}|�||�Wd�n1s'wYWnty;|�	d�Ynw|�
tj�t��t�td��}|�|�|�|�Wd�dS1s`wYdS)Nr�r�r�z1Could not append data to a non-existent zip file.rJ)
rr��existsr
rrCrDrEr��failrarXrY)r7rVr3r[rrr�(test_create_non_existent_file_for_appendas 
���"�z3OtherTests.test_create_non_existent_file_for_appendcCs`ttddd��
}|�d�Wd�n1swYzt�t�}WdStjy/YdSw)Nr=r�r��this is not a legal zip file
)r4r
r5rCrDrQ)r7r8r[rrr�test_close_erroneous_filess��z$OtherTests.test_close_erroneous_filecCs�	ttddd��
}|�d�Wd�n1swY|�t�t��|�t�t�t���ttd��}|�t�|��Wd�n1sHwYt�	�}|�d�|�t�|��|�
dd�|�t�|��dS)Nr=r�r�rr�sthis is not a legal zip file
r)r4r
r5rrC�
is_zipfiler�r�rrr�r6rrr�test_is_zip_erroneous_file�s��
z%OtherTests.test_is_zip_erroneous_filecCs�	t��}tj|dd��}|�dd�Wd�n1swY|��}tt|��D]}t�|d|��}|�tj	tj|�q,dS)Nr=rAr��O, for a Muse of Fire!)
rrrCrDrEr\r(r^r�rQ)r7r8r�r��Nrrr�test_damaged_zipfile�s��zOtherTests.test_damaged_zipfilecCs�	tjtdd��}|�dd�Wd�n1swY|�t�t��ttd��}|�t�|��|�dd�|��}Wd�n1sHwYt	�
�}|�|�|�t�|��|�dd�|�t�|��dS)Nr=rAr�rr�r)rCrDr
rErarr4r�rYrrr5)r7r�r8Zzip_contentsrrr�test_is_zip_valid_file�s�
�
z!OtherTests.test_is_zip_valid_filecCs|�ttjt�dSr)r�r�rCrDr
r�rrr�%test_non_existent_file_raises_OSError�sz0OtherTests.test_non_existent_file_raises_OSErrorcCsvttddd�}|��|�tjtjt�ttddd��
}|�d�Wd�n1s+wY|�tjtjt�dS)Nr=r�r�z
short file)r4r
r�r�rCrQrDr5)r7rr8rrr�!test_empty_file_raises_BadZipFile�s�z,OtherTests.test_empty_file_raises_BadZipFilecCsFtd�}dD]}t�d|�|dd�<t�|�}|�tjtj|�qdS)N�PK)rPr@rAr	�)	�	bytearrayrrGrrr�rCrQrD)r7�bufferZdirsizerrrr�8test_negative_central_directory_offset_raises_BadZipFile�s
�zCOtherTests.test_negative_central_directory_offset_raises_BadZipFilecCs�	t��}tj|dd��}|�dd�Wd�n1swY|�t|jd�|�t|jd�|�t|j	�|�t|jdd�tt
ddd��
}|�d	�Wd�n1sYwY|�t|jt
�dS)
Nr=rAr��O, for a Muse of Fire!z	bogus.txtr�r�r�zzipfile test data)rrrCrDrEr�r�rYr4rir
r5)r7r,r�rrrr�!test_closed_zip_raises_ValueError�s��z,OtherTests.test_closed_zip_raises_ValueErrorcCs	|�ttjtd�dS)Nrl)r�r�rCrDr
r�rrr�test_bad_constructor_mode�sz$OtherTests.test_bad_constructor_modecCs�	tjtdd��}|�dd�Wd�n1swYtjtdd��)}|�d�|�t|jdd�|�t|jdd�|�t|jdd�Wd�dS1sQwYdS)	Nr=rAr�rrJrl�UZrU)rCrDr
rErYr�r�r4�r7r�rrr�test_bad_open_mode�s�
"�zOtherTests.test_bad_open_modec	Cs�	tjtdd��D}|�dd�|�d�� }tt�D]}|�|�d�d�q|�|��d�Wd�n1s7wYWd�dSWd�dS1sOwYdS)Nr=rAr�rrr'r)	rCrDr
rEr4r(r)rXrY)r7r�rr%rrr�
test_read0�s��"�zOtherTests.test_read0cCsH	tjtdd��}|�t|jdd�Wd�dS1swYdS)Nr=rAr�rJ)rCrDr
r��KeyErrorr4rrrr�test_open_non_existent_items"�z&OtherTests.test_open_non_existent_itemcCs	|�ttjtdd�dS)Nr=r�)r�r�rCrDr
r�rrr�test_bad_compression_modesz$OtherTests.test_bad_compression_modecCsLd}t�t�|�d��}|�t|jd�Wd�dS1swYdS)NsfPK.�C�@xPK..�C�@�xPK/!rJr�)rCrDrrr�r�r4)r7r,r�rrr�test_unsupported_compressions"�z'OtherTests.test_unsupported_compressioncCsT	tjtdd��}|�dd�|�|��dg�Wd�dS1s#wYdS)Nr=rAzfoo.txtqqqrr�)rCrDr
rErXrerrrr�test_null_byte_in_filenames
"�z%OtherTests.test_null_byte_in_filenamecCs>	|�tjd�|�tjd�|�tjd�|�tjd�dS)N��.�8r�)rXrCZsizeEndCentDirZsizeCentralDirZsizeEndCentDir64ZsizeEndCentDir64Locatorr�rrr�test_struct_sizes#s
zOtherTests.test_struct_sizesc	Cs�	tjtdd��}|�|jd�|�dd�Wd�n1s wYtjtdd��}|�|jd�Wd�n1s>wYd}tjtdd��}||_|�dd�Wd�n1s`wYtjtdd��}|�|j|�Wd�n1s~wYd�d	d
�td�D��}|�d�}tjtdd��}||_|�dd�Wd�n1s�wYtjtdd��}|�|j|�Wd�n1s�wYtjtdd��(}|�	t
��
|d
|_Wd�n1s�wY|�dd�Wd�n	1�swYtjtdd��}|�|j|�Wd�n	1�s$wYtjtdd��}d|_|�dd�Wd�n	1�sEwYtjtdd��}d|_Wd�n	1�s`wYtjtdd��}|�|jd�Wd�n	1�swYtjtdd��}d|_|�dd�Wd�n	1�s�wYtj�
t�}tjtdd��}d|_Wd�n	1�s�wY|�|tj�
t�k�tjtdd��}|�|jd�Wd�dS1�s�wYdS)Nr=rAr'r�rrJs9Bravely taking to his feet, he beat a very brave retreat.�cSsg|]
}d|dd�qS)r-r*r�rr#rrrr&>sz,OtherTests.test_comments.<locals>.<listcomp>�r!soopssoriginal commentr�san updated commentsoriginal comment that's longersshorter comment)rCrDr
rXr�rEr+r(r�r�r�rr��getsizera)r7r�Zzipfrr�Zcomment2Zoriginal_zip_sizerrr�
test_comments*sp����
����������$�zOtherTests.test_commentsc	Cs�t�tdtj��/}|�dd�|�t��d|_Wd�n1s"wYWd�dSWd�dS1s:wYdS)Nr=r�rzthis is an error)rCrDr
r�rEr��	TypeErrorr�rrrr�test_unicode_commentds��"�zOtherTests.test_unicode_commentcCs�t�tdtj��}|�|j�d|_Wd�n1swYt�td��}|�|jd�Wd�dS1s:wYdS)Nr�r�rJ)rCrDr
r�rr�r�rXrrrr�$test_change_comment_in_empty_archivejs�"�z/OtherTests.test_change_comment_in_empty_archivecCs�t�tdtj��}|�dd�Wd�n1swYt�tdtj��}|�|j�d|_Wd�n1s:wYt�td��}|�|jd�Wd�dS1sXwYdS)Nr=r�rr�r�rJ)	rCrDr
r�rErar�r�rXrrrr�'test_change_comment_in_nonempty_archiveqs��"�z2OtherTests.test_change_comment_in_nonempty_archivecCs�tjtdd�}|��z	tjtdd�}Wntjy#|�d�Ynwtjtdd�}|��z
tjtdd�}WdS|�d�YdS)Nr=rArJz+Unable to create empty ZIP file in 'w' moder�z+Unable to create empty ZIP file in 'a' mode)rCrDr
r�rQr�rrrr�test_empty_zipfilezs�zOtherTests.test_empty_zipfilecCs.ttddd�}|��|�tjtjtd�dS)Nr=r�r�rJ)r4r
r�r�rCrQrDrwrrr�test_open_empty_file�szOtherTests.test_open_empty_filecCs|�ttjdd�dS)NZ	seventies)i�rPrPrrr)r�r�rCr�r�rrr�test_create_zipinfo_before_1980�s�z*OtherTests.test_create_zipinfo_before_1980cCs"	tjdd�}|�t|�d�dS)N�emptyrUz&<ZipInfo filename='empty' file_size=0>)rCr�rXr��r7�zirrr�test_create_empty_zipinfo_repr�sz)OtherTests.test_create_empty_zipinfo_reprcCs�	t��}|�|jd�|�|jd�|�|jd�|�|jtj�|�|jd�|�|j	d�|�
|jd�|�|jtj
�|�|jtj
�|�|jd�|�|jd�|�|jd�|�|jd�|�|jd�|�|jd�|�|jd�dS)NZNoNamerr')rr*r)rCr�rXZ
orig_filenamerVrr�r�r�r=r_Z
create_systemZcreate_versionZDEFAULT_VERSIONZextract_versionZreservedr�ZvolumeZ
internal_attrr�rgrNr,rrr�,test_create_empty_zipinfo_default_attributes�s$z7OtherTests.test_create_empty_zipinfo_default_attributescCsL	d}t�t�|�d��}|�|���Wd�dS1swYdS)NsnPK���@����abcAPK���@������abcPK3%rJ)rCrDrrr�ri�r7r�r�rrr�#test_zipfile_with_short_extra_field�s�	"�z.OtherTests.test_zipfile_with_short_extra_fieldc
Cspd}d}d}t�tdtj���}|jddd��
}|�|�Wd�n1s&wY|jddd���}|�t��|jddd�Wd�n1sJwY|�t��|jdd	d�Wd�n1sfwY|�t��|�d
d�Wd�n1s�wY|�t��|�t	d�Wd�n1s�wY|�t��|�
�Wd�n1s�wY|�|�Wd�n1s�wY|jd
dd��
}|�|�Wd�n1s�wYWd�n1s�wYt�td	��.}|�|�d�|�|�|�d�|�|�|�d
�|�|�|�
�gd��Wd�dS1�s1wYdS)Ns"It's fun to charter an accountant!s And sail the wide accountant seas#To find, explore the funds offshorer=r�rAr��handlerJrdZabcderK�baz)r�r�r3)rCrDrr�r4r5r�r�rEr�r�rXrYre)r7Zmsg1Zmsg2Zmsg3r�Zw2�w1rrr�test_open_conflicting_handles�sH�����
�����$�z(OtherTests.test_open_conflicting_handlesc	Cs�d}|�d�}t�td��}|�d|�Wd�n1swYt�td��{}|�dd��e}|�|tj�|�	|�
�|�|�|tj�|�	|�
�d�|�|tj�|�	|�
�|�|�	|�d�|||d��|�dtj
�|�	|�
�t|��|�dtj�|�	|�
�d�Wd�n1s�wYWd�n1s�wYt��}tj|dd��}|�d|�Wd�n1s�wYtj|dd���}|�dd��e}|�|tj�|�	|�
�|�|�|tj�|�	|�
�d�|�|tj�|�	|�
�|�|�	|�d�|||d��|�dtj
�|�	|�
�t|��|�dtj�|�	|�
�d�Wd�n1�sDwYWd�dSWd�dS1�s]wYdS)	NsWhere's Bruce?sBrucer=r�rJrrLrA)�findrCrDr
rEr4r�r�SEEK_SETrXr��SEEK_CURrY�SEEK_ENDr^rr)r7�txt�blocr�r8r,rrr�test_seek_tell�sT
����� ��$�zOtherTests.test_seek_tellc	Cs�d}t�|�}tj|dtjd��}|�dd�Wd�n1s!wYt�dd��.t�|��}|�t	|j
d�Wd�n1sEwYWd�dSWd�dS1s]wYdS)Nrr=)r;r��azzipfile.bz2)rrrCrDrrE�mockZpatchr�r�r�)r7r,Zzip_filer[rrr�)test_decompress_without_3rd_party_librarys
���"�z4OtherTests.test_decompress_without_3rd_party_libraryc	Csd}t�t�|�d��v}|�|��ddg�|�d�}|�|jd�|�|jd�|�|j	d�|�d�}|�|jd�|�|jd�|�|j	d�|�t
|�d��d�|�tj
d��
|�d�Wd�n1slwYWd�dSWd�dS1s�wYdS)	Ns�PK�lH�8�	a��0�K\d`PK�lH�8�	aPK�lH�8�	bPK^/rJr��brr�	zFile name.*differ)rCrDrrrXrerhrOrNrgr^rY�assertRaisesRegexrQ�r7r,r�r-rrr�test_full_overlaps&�


��"�zOtherTests.test_full_overlapc	Csd}t�t�|�d��n}|�|��ddg�|�d�}|�|jd�|�|jd�|�|j	d�|�d�}|�|jd�|�|jd	�|�|j	d
�|�
tjd��
|�d�Wd�n1sawY|�t
|�d��d
�Wd�dS1s|wYdS)Ns�PK�lHY�84(a�PK�lH�8�	b��0�K\d`PK�lHY�84(aPK�lH�8�	$bPK^SrJr�r@r�4i(�$rrAzOverlapped entries)rCrDrrrXrerhrOrNrgrBrQrYr^rCrrr�test_quoted_overlap+s"�

�"�zOtherTests.test_quoted_overlapcCr�rr�r�rrrr�Jr�zOtherTests.tearDownN)/r�r�r�r�r�r�r�r�r	r�r�r�r�rrrrrr	r
rrrrrrrrrrr#r%r&r'r(r)r*r.r/r1r5r<r
r?rDrGr�rrrrr��s^



	
:	&
	

r�c@seZdZdd�Zdd�ZdS)�AbstractBadCrcTestscCsR	|j}tjt�|�dd��}|�d|���Wd�dS1s"wYdS)NrJrA�afile)�zip_with_bad_crcrCrDrrrXrir0rrr�test_testzip_with_bad_crcPs
"�z-AbstractBadCrcTests.test_testzip_with_bad_crcc
Cs|	|j}tjt�|�dd��}|�tj|jd�Wd�n1s"wYtjt�|�dd��&}|�dd��}|�tj|j�Wd�n1sKwYWd�n1sZwYtjt�|�dd��K}|�dd��,}d|_	|�tj��|�d�r�	|�d�s�Wd�n1s�wYWd�n1s�wYWd�dSWd�dS1s�wYdS)NrJrArIr�)
rJrCrDrrr�rQrYr4�
MIN_READ_SIZE)r7r�r�Zcorrupt_filerrr�test_read_with_bad_crcXs2����

������"�z*AbstractBadCrcTests.test_read_with_bad_crcN)r�r�r�rKrMrrrrrHOsrHc@�eZdZejZdZdS)�StoredBadCrcTestssxPK ��;:r��afilehello,AworldPK ��;:r���afilePK3/N)r�r�r�rCr�r;rJrrrrrOns�rOc@rN)�DeflateBadCrcTestss|PKn}=FAKEnafile�H���W(�/�Iɠ=PKn}=FAKEn�afilePK33N)r�r�r�rCrr;rJrrrrrPz��rPc@rN)�Bzip2BadCrcTestss�PKnu=FAKE8nafileBZh91AY&SYԨ��@D��  �P�!����u5:���"�(HjTe?�PKnu=FAKE8n ���afilePK3[N)r�r�r�rCrr;rJrrrrrR�rQrRc@rN)�LzmaBadCrcTestss�PKnu=FAKEnafile	]4I���:3`	q!.8PKnu=FAKEn ���afilePK3>N)r�r�r�rCr!r;rJrrrrrS�rQrSc@s\eZdZ	dZdZdZdZdd�Zdd�Zd	d
�Z	dd�Z
e�d
d��Zdd�Z
dd�ZdS)�DecryptionTestss�PKn�i.#y�?&test.txt��gly|�-�=�y�r�Z}Lg���|�䋺�)���lPKn�i.#y�?& ��test.txtPK6Ls�PK	�}38xu��zeroUT	֋�Gڋ�GUx���<M�a�X�Y&�{oEם���PKxu��PK	�}38xu��
��zeroUT֋�GUxPK?[szipfile.py encryption testscCs�ttd��}|�|j�Wd�n1swYt�td�|_ttd��}|�|j�Wd�n1s8wYt�td�|_	dS)Nr2rJ)
r4r
r5r,rCrDr�r�data2�zip2r6rrrr9�s��zDecryptionTests.setUpcCs,|j��t�t�|j��t�t�dSr)r�r�rrr
rVrr�rrrr��s


zDecryptionTests.tearDowncCs(|�t|jjd�|�t|jjd�dS)N�test.txt�zero)r�r�r�rYrVr�rrr�test_no_password�sz DecryptionTests.test_no_passwordcCs@|j�d�|�t|jjd�|j�d�|�t|jjd�dS)NsperlrWrX)r��setpasswordr�r�rYrVr�rrr�test_bad_password�sz!DecryptionTests.test_bad_passwordcCsH|j�d�|�|j�d�|j�|j�d�|�|j�d�|j�dS)N�pythonrWs12345rX)r�rZrXrY�plainrV�plain2r�rrr�test_good_password�sz"DecryptionTests.test_good_passwordcCsV|�t|jjd�|�t|jjdd�|jt|jjddd�|jt|jjddd�dS)N�unicoderWZpython)�pwd)r�r$r�rZrYr4r�r�rrr�test_unicode_password�sz%DecryptionTests.test_unicode_passwordcCs�|j�d�|j}d}|�|�}t|�}|j�dd���}|�|tj�|�	|�
�|�|�|tj�|�	|�
�d�|�|tj�|�	|�
�|�|�	|�|�||||��|j
}d|_
d|_d|_|�dtj�|�	|�
�d�|�|tj�|�	|�|�||||��||_
|�dtj�|�	|�
�t|��|�dtj�|�	|�
�d�|��Wd�dS1s�wYdS)Nr\s
encryptionrWrJrrPr')r�rZr]r6r^r4r�rr7rXr�r8rYrLZ_readbufferZ_offsetr9)r7r:Z	test_wordr;Zbloc_lenr8Z
old_read_sizerrrr<�s8

"�zDecryptionTests.test_seek_tellN)r�r�r�r,rUr]r^r9r�rYr[r	r_rbr<rrrrrT�s �	�

rTc@s`eZdZedd��Zdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�Zdd�Z
dS)�"AbstractTestsWithRandomBinaryFilescCs6tdd�dtdd�}d�dd�t|�D��|_dS)Nr�@r�rPr'css(�|]}t�dt�tdd��VqdS)z<fi���rN)rrGrrr#rrrr#	s� �z@AbstractTestsWithRandomBinaryFiles.setUpClass.<locals>.<genexpr>)rr+r(r,)r.Z	datacountrrrr/	s
�z-AbstractTestsWithRandomBinaryFiles.setUpClasscCr0r1r3r6rrrr9	r:z(AbstractTestsWithRandomBinaryFiles.setUpcCr�rr�r�rrrr�	r�z+AbstractTestsWithRandomBinaryFiles.tearDowncCsLt�|d|��}|�td�|�tt�Wd�dS1swYdS)Nr=r>)rCrDr5r
r9rrrrI	s"�z4AbstractTestsWithRandomBinaryFiles.make_test_archivecCs�|�||�t�|d|��*}|�t�}|�t|�t|j��|�||j�|�|�d�|j�Wd�dS1s:wYdS)NrJr>)rIrCrDrYr
rXr^r,)r7rr;rG�testdatarrrrt#	s
"�z+AbstractTestsWithRandomBinaryFiles.zip_testcCrurrvrwrrr�	test_read-	ryz,AbstractTestsWithRandomBinaryFiles.test_readc	Cs4|�||�t�|d|���}g}|�t��}	|�d�}|sn|�|�qWd�n1s/wYg}|�d��}	|�d�}|sEn|�|�q=Wd�n1sUwYd�|�}	|�t	|	�t	|j
��|�|	|j
�d�|�}
|�t	|
�t	|j
��|�|
|j
�Wd�dS1s�wYdSrz)rIrCrDr4r
rYr|r+rXr^r,)r7rr;rGr}r~rr�r�Z	testdata1Z	testdata2rrrr�1	s:

��

��

"�z0AbstractTestsWithRandomBinaryFiles.zip_open_testcCrurr�rwrrrr�N	ryz,AbstractTestsWithRandomBinaryFiles.test_openc	Cs�|�||�t�|d|��I}g}|�t��}	|�tdd��}|s"n|�|�qWd�n1s2wYd�|�}|�	t
|�t
|j��|�	||j�Wd�dS1sYwYdSr�)rIrCrDr4r
rYrr|r+rXr^r,)r7rr;rGr}r~rrerrrr�R	s 
��
"�z7AbstractTestsWithRandomBinaryFiles.zip_random_open_testcCrurr�rwrrrr�c	ryz3AbstractTestsWithRandomBinaryFiles.test_random_openN)r�r�r�r�r/r9r�rIrtrfr�r�r�r�rrrrrc
	s

rcc@r)� StoredTestsWithRandomBinaryFilesNrorrrrrgh	rqrgc@r)�!DeflateTestsWithRandomBinaryFilesNr^rrrrrhl	rrhc@r)�Bzip2TestsWithRandomBinaryFilesNrrrrrriq	rric@r)�LzmaTestsWithRandomBinaryFilesNr rrrrrjv	rrjc@ra)
�TellablecCs||_d|_dS�Nr)r8�offsetr6rrr�__init__~	s
zTellable.__init__cCs|j�|�}|j|7_|Sr)r8r5rm)r7r,�nrrrr5�	szTellable.writecCs|jSr)rmr�rrrr��	sz
Tellable.tellcC�|j��dSr�r8�flushr�rrrrr�	�zTellable.flushN)r�r�r�rnr5r�rrrrrrrk}	s
rkc@�$eZdZdd�Zdd�Zdd�ZdS)�
UnseekablecCs
||_dSr)r8r6rrrrn�	s
zUnseekable.__init__cCs|j�|�Sr)r8r5r�rrrr5�	rezUnseekable.writecCrprrqr�rrrrr�	rszUnseekable.flushN)r�r�r�rnr5rrrrrrru�	sruc@rt)�UnseekableTestscCsfdd�ttfD]�}|j|d���t��}|�d�t�|�}t�||�dtj	��}|�
dd�|�
dd	�Wd�n1s?wY|�|��dd
�d�tj|dd
��B}|�
d��}|�|��d�Wd�n1spwY|�
d��}|�|��d	�Wd�n1s�wYWd�n1s�wYWd�n1s�wYqdS)NcS�|Srr�rrrrr��	r�z/UnseekableTests.test_writestr.<locals>.<lambda>��wrapper�abcr=�ones�111�twos�222rL�abcPKrJrA)rkru�subTestrrr5�BufferedWriterrCrDr�rErXr\r4rY)r7rzr�bfrGr��zopenrrr�
test_writestr�	s.

���������zUnseekableTests.test_writestrcCs�dd�ttfD]�}|j|d���t��}|�d�t�|�}t�||�dtj	��N}|�
tt�t
td��
}|�d�Wd�n1sDwY|�td�t
td��
}|�d	�Wd�n1sdwY|�td
�Wd�n1sywY|�|��dd�d�tj|d
d��B}|�
d��}|�|��d�Wd�n1s�wY|�
d
��}|�|��d	�Wd�n1s�wYWd�n1s�wYWd�n1s�wYqdS)NcSrwrrrxrrrr��	r�z,UnseekableTests.test_write.<locals>.<lambda>ryr{r=r2r}r|rr~rLr�rJrA)rkrur�rrr5r�rCrDr��
addCleanuprr
r4rXr\rY)r7rzrr�rG�f2r�r�rrr�
test_write�	s<

�����������zUnseekableTests.test_writecCsfdd�ttfD]�}|j|d���t��}|�d�t�|�}t�||�dtj	��>}|�
dd��
}|�d�Wd�n1s?wY|�
dd��
}|�d	�Wd�n1sZwYWd�n1siwY|�|��dd
�d�t�|��}|�|�
d�d�|�|�
d�d	�Wd�n1s�wYWd�n1s�wYqdS)NcSrwrrrxrrrr��	r�z1UnseekableTests.test_open_write.<locals>.<lambda>ryr{r=r|r}r~rrLr�)rkrur�rrr5r�rCrDr�r4rXr\rY)r7rzrr�r�r�rrr�test_open_write�	s.

���������zUnseekableTests.test_open_writeN)r�r�r�r�r�r�rrrrrv�	srvc@sheZdZedd��Zdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�Zdd�Z
dd�ZdS)�TestsWithMultipleOpenscCs dtd�|_dtd�|_dS)Nr}�'r)r�data1rUr-rrrr/�	sz!TestsWithMultipleOpens.setUpClasscCsRt�|dtj��}|�d|j�|�d|j�Wd�dS1s"wYdS)Nr=r|r~)rCrDrrEr�rU)r7rrGrrrrI�	s"�z(TestsWithMultipleOpens.make_test_archivecCs�t|�D]k}|�|�tj|dd��U}|�d��3}|�d��}|�d�}|�d�}||��7}||��7}Wd�n1s?wYWd�n1sNwY|�||�|�||j�Wd�n1sjwYqdS)NrJrAr|��)rrIrCrDr4rYrXr��r7rr��zopen1�zopen2r�rUrrr�test_same_file�	s 


�����z%TestsWithMultipleOpens.test_same_filecCs�t|�D]l}|�|�tj|dd��V}|�d��3}|�d��}|�d�}|�d�}||��7}||��7}Wd�n1s?wYWd�n1sNwY|�||j�|�||j�Wd�n1skwYqdS)NrJrAr|r~r��	rrIrCrDr4rYrXr�rUr�rrr�test_different_file�	s 


�����z*TestsWithMultipleOpens.test_different_filecCs�t|�D]l}|�|�tj|dd��V}|�d��3}|�d�}|�d��}|�d�}||��7}||��7}Wd�n1s?wYWd�n1sNwY|�||j�|�||j�Wd�n1skwYqdS)NrJrAr|r�r~r�)r7rr�r�r�r�rUrrr�test_interleaved�	s"


������z'TestsWithMultipleOpens.test_interleavedc
Cs�t|�D]e}|�|�t���D}t�|d��}|�|�d��}|�|�d��}Wd�n1s1wY|�d�}|�d�}||��7}||��7}Wd�n1sVwY|�	||j
�|�	||j�qdS)NrJr|r~r�)rrI�
contextlib�	ExitStackrCrD�
enter_contextr4rYrXr�rU)r7r�stackr�r�r�r�rUrrr�test_read_after_close
s

�

��z,TestsWithMultipleOpens.test_read_after_closec
Cst|�D]{}t�|dtj��0}|�d|j�|�d|j�|�d��
}|�d�}Wd�n1s2wYWd�n1sAwY|�	||jdd��t�|d��}|�d�}|�d�}Wd�n1slwY|�	||j�|�	||j�qdS)Nr=r|r~r�rJ)
rrCrDrrEr�rUr4rYrX�r7rr�r�r�rUrrr�test_read_after_write
s"���
��z,TestsWithMultipleOpens.test_read_after_writec
Cs�t|�D]p}t�|dtj��0}|�d|j�|�d��}|�d�|�d|j�Wd�n1s2wYWd�n1sAwYt�|d��}|�d�}|�d�}Wd�n1sawY|�	||j�|�	||j�qdS)Nr=r|r�r~rJ)
rrCrDrrEr�r4rYrUrXr�rrr�test_write_after_read"
s 
���
��z,TestsWithMultipleOpens.test_write_after_readc
Cs�|�t�tjtdd��)}td�D]}|�d�|�d��}Wd�n1s(wYqWd�n1s8wYttjd��}|�	|�
�d�Wd�dS1sWwYdS)NrJrAr�r|r�)rIrrCrDr(rYr4r�devnullZ
assertLess�fileno)r7r�r�r�rrrr�test_many_opens/
s

����"�z&TestsWithMultipleOpens.test_many_opensc
Cs:t�tdtj��}|�d|j�Wd�n1swYt�tdtj��E}|�dd��/}|�d�}|�dd��}|�|j	�Wd�n1sKwY||��7}Wd�n1s`wYWd�n1sowY|�
||j�t�t��}|�
|�d�|j	�Wd�dS1s�wYdS)Nr=r|r�rJr�r~)rCrDrrrEr�r4rYr5rUrX)r7r�Zr1r�r4rrr�test_write_while_reading;
s"�
����"�z/TestsWithMultipleOpens.test_write_while_readingcCrcrrdr�rrrr�H
rezTestsWithMultipleOpens.tearDownN)r�r�r�r�r/rIr�r�r�r�r�r�r�r�r�rrrrr��	s


r�c@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�TestWithDirectorycCst�t�dSr)rr�rr�rrrr9M
rszTestWithDirectory.setUpc
Cs�t�td���
}|�t�Wd�n1swY|�tj�tj�	td���|�tj�tj�	tdd���|�tj�
tj�	tddd���dS)N�
zipdir.zipr�r@rZ)rCrDrr�rrarr��isdirr+r�rrrr�test_extract_dirP
s�$z"TestWithDirectory.test_extract_dircCs t�tj�td��|��dS�Nr�)rr�r�r+rr�r�rrr�
test_bug_6050W
szTestWithDirectory.test_bug_6050c	Cs�tj�td�}t�|�t�|�jd@}t�t	d��C}|�
|�|jd}|�|j
�d��|�|j|d>dB�|�
|d�|jd}|�|j
d	�|�|j|d>dB�Wd�n1s`wYt�t	d
��c}|jd}|�|j
�d��|�|j|d>dB�|jd}|�|j
d	�|�|j|d>dB�tj�td�}t�|�|�|�|�tj�tj�|d���|�tt�|��d�Wd�dS1s�wYdS)
Nr�r!r=rz/x/r�yrPzy/rJr�r�)rr�r+rr�r�st_moderCrDr
r5r�rarVr�rXr�r�r�r^�listdir)r7�dirpathrBr�r�r�rrr�test_write_dir\
s4



�	



"�z TestWithDirectory.test_write_dirc	Cs t�tj�td��t�td��!}|�dd�|j	d}|�
|jd�|�
|jd�Wd�n1s4wYt�td��G}|j	d}|�
|j�d��|�
|jd�tj�td�}t�|�|�|�|�
tj�tj�|d���|�
t�|�dg�Wd�dS1s�wYdS)	Nr�r=zx/r'ri�ArJr�)rr�r�r+rrCrDr
rEr�rXrVr�rar�r�r�r�)r7r�r�r�rrr�test_writestr_dirv
s"
�


"�z#TestWithDirectory.test_writestr_dircCs$tt�tj�t�rtt�dSdSr)rrrr�r�r
rr�rrrr��
s�zTestWithDirectory.tearDownN)	r�r�r�r9r�r�r�r�r�rrrrr�L
sr�c@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�ZipInfoTestscCsHtj�t�}|�t�|j�d�|�|�	��|�|j
tj�
t��dS�Nztest_zipfile.py)rCr��	from_filer�rX�	posixpathr�rVr�is_dirrgrr�r"r,rrr�test_from_file�
szZipInfoTests.test_from_filecCsNtj�t�t��}|�t�|j	�d�|�
|���|�|jt
j�t��dSr�)rCr�r�r�r�r�rXr�r�rVrr�rgrr�r"r,rrr�test_from_file_pathlike�
sz$ZipInfoTests.test_from_file_pathlikecCsPtj�t�t�d�}|�t�|j	�d�|�
|���|�|jtj
�t��dS)Nr)rCr�r�r�fsencoder�rXr�r�rVrr�rgr�r"r,rrr�test_from_file_bytes�
sz!ZipInfoTests.test_from_file_bytescCszttd��.}tj�|��d�}|�t�|j	�d�|�
|���|�|jt
j�t��Wd�dS1s6wYdS)Nr�r)r4r�rCr�r�r�rXr�r�rVrr�rgrr�r")r7rr-rrr�test_from_file_fileno�
s"�z"ZipInfoTests.test_from_file_filenocCs`tj�tj�t��}tj�|d�}|�|j	d�|�
|���|�|jtj
�|�|jd�dS)NZstdlib_testsz
stdlib_tests/r)rr�r��abspathr�rCr�r�rXrVrar�r�r�rg)r7r�r-rrr�
test_from_dir�
szZipInfoTests.test_from_dirN)r�r�r�r�r�r�r�r�rrrrr��
sr�c@sJeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Ze�dd��Z	d
d�Z
dS)�CommandLineTestcOs2tjddg|�Ri|��\}}}|�tj��d�S)N�-mrCr$)rrr�r�linesepr�)r7�argsrF�rc�out�errrrr�
zipfilecmd�
s�zCommandLineTest.zipfilecmdcGstjddg|�R�S)Nr�rC)rZassert_python_failure)r7r�rrr�zipfilecmd_failure�
r�z"CommandLineTest.zipfilecmd_failurecCs||��\}}}|�|d�|�d|���|�d|���|�d|���|�dd�\}}}|�|d�|�|��d�dS)Nr'susageserrorsrequired�-lr )r�rXr_rSZassertNotEqual�strip)r7r�r�r�rrr�test_bad_use�
szCommandLineTest.test_bad_usecCsXtd�}dD]}|�||�}|�|��d�qtd�}|�d|�\}}}|�|d�dS)Nr�)�-tz--testsDone testingztesttar.tarr�r')rr�rX�rstripr�)r7�zip_name�optr�r�r�rrr�test_test_command�
sz!CommandLineTest.test_test_commandcCs�td�}t��}t�|d��
}|�|�Wd�n1swY|���dd�}dD]}|j||dd�}|�	||�q-dS)Nr�rJr!�backslashreplace)r�z--listzascii:backslashreplace)ZPYTHONIOENCODING)
rrrZrCrDr[r\r�r�rX)r7r�r�ZtfZexpectedr�r�rrr�test_list_command�
s���z!CommandLineTest.test_list_commandc	Cs`|�tt�ttddd��
}|�d�Wd�n1swYt�t�|�tt�ttj	�
td�ddd��
}|�d�Wd�n1sIwYttg}ttdtdg}d	D]P}zI|j|tg|�R�}|�
|d
�t�t��&}|�
|��|�|�
|�|d�d�|�
|�|d
�d�Wd�n1s�wYWtt�q]tt�wdS)Nr=r�r�ztest 1�file.txtztest 2r�z	/file.txt)�-cz--creater'rstest 1r�stest 2)r�rr
r4r5rr��	TESTFNDIRrr�r+r�rrXrCrDrerY)r7r�filesrer�r�r[rrr�test_create_command�
s.�
����z#CommandLineTest.test_create_commandc	Cstd�}dD]�}t��u}|�|||�}|�|d�t�|��S}|��D]F}tj�	||j
�dtj��}|�
�r@|�tj�|��q#|�tj�|��t|d��}|�|��|�|��Wd�n1sdwYq#Wd�n1stwYWd�n1s�wYqdS)Nr�)z-ez	--extractr'r�r�)rrr�rXrCrDrfrr�r+rVr�r�r�rar�r�r4rY)	r7r�r�r�r�r[r-r�rrrr�test_extract_command�
s.���������z$CommandLineTest.test_extract_commandN)r�r�r�r�r�r�r�r�r	r�r�rrrrr��
s
	
r�c@s�eZdZ	dd�Zdd�Zdd�Zdd�Ze�e	j
d	�e�e�d
ej
�d�dd
���Ze�e	j
d	�e�e�d
ej
�d�dd���ZdS)�TestExecutablePrependedZipcCs tddd�|_tddd�|_dS)NZexe_with_zipZziptestdata)r�Zexe_with_z64)r�exe_zip�	exe_zip64r�rrrr9sz TestExecutablePrependedZip.setUpcCsl|�t�|�d|���t�|��}|��D]
}|�|�}|�d|�qWd�dS1s/wYdS)Nzis_zipfile failed on sFAVORITE_NUMBER)rarCrrDrerYr_)r7rvrGror,rrr�_test_zip_workss�
�"�z*TestExecutablePrependedZip._test_zip_workscC�|�|j�dSr)r�r�r�rrr� test_read_zip_with_exe_prepended�z;TestExecutablePrependedZip.test_read_zip_with_exe_prependedcCr�r)r�r�r�rrr�"test_read_zip64_with_exe_prependedr�z=TestExecutablePrependedZip.test_read_zip64_with_exe_prependedzsys.executable required.z	/bin/bashz#Test relies on #!/bin/bash working.cC�"t�|jtjg�}|�d|�dS�Nsnumber in executable: 5)�
subprocess�check_outputr��sys�
executabler_�r7�outputrrr�test_execute_zip2�z,TestExecutablePrependedZip.test_execute_zip2cCr�r�)r�r�r�r�r�r_r�rrr�test_execute_zip64r�z-TestExecutablePrependedZip.test_execute_zip64N)r�r�r�r9r�r�r�r�Z
skipUnlessr�r�rrx�X_OKr�r�rrrrr�s 
��r�c@�eZdZGdd�d�ZdS)�jaracoc@r�)zjaraco.itertoolsc@rt)zjaraco.itertools.CountercCsd|_t|�|_dSrl)r��iter�
_orig_iter)r7r%rrrrn.sz!jaraco.itertools.Counter.__init__cCrwrrr�rrr�__iter__2sz!jaraco.itertools.Counter.__iter__cCst|j�}|jd7_|Sr�)�nextr�r�)r7�resultrrr�__next__5s
z!jaraco.itertools.Counter.__next__N)r�r�r�rnr�r�rrrr�Counter-sr�N)r�r�r�r�rrrrrV,�rVN)r�r�r�rVrrrrr�+r�r�cCs(	tj�|���D]}|�|d�q	|S)Nr')rC�CompleteDirs�
_implied_dirsrerE)r[rvrrr�add_dirs;sr�cCs\	t��}t�|d�}|�dd�|�dd�|�dd�|�dd	�|�d
d�d|_|S)
Nr=r�scontent of azb/c.txtscontent of cz	b/d/e.txtscontent of ezb/f.txtscontent of fz	g/h/i.txtscontent of izalpharep.zip)rrrCrDrErV)r,r[rrr�build_alpharep_fixtureEsr�cs	t����fdd��}|S)Ncs|��D]}�||d�qdS)N)�alpharep)�zipfile_alpharep)r7r���methrrrzos�zpass_alpharep.<locals>.wrapper)�	functools�wraps)r�rzrr�r�
pass_alpharepisr�c@s�eZdZdd�Zdd�Zdd�Zedd��Zed	d
��Zedd��Z	ed
d��Z
edd��Zdd�Zdd�Z
dd�Zdd�Zdd�Zedd��Zdd�Zedd ��Zed!d"��Zed#d$��Zed%d&��Zed'd(��Zed)d*��Zed+d,��Zed-d.��Zed/d0��Zed1d2��Zed3d4��Zd5Zd6d7�Zd8d9�Z d:d;�Z!ed<d=��Z"ed>d?��Z#ed@dA��Z$edBdC��Z%edDdE��Z&edFdG��Z'edHdI��Z(edJdK��Z)dLS)M�TestPathcCst��|_|�|jj�dSr)r�r��fixturesr�r�r�rrrr9xs
zTestPath.setUpccsl�|���t�VWd�n1swY|���tt��VWd�dS1s/wYdSr)r�r�r�r�rrrr�|s�

�
"�zTestPath.zipfile_alpharepcCsjt�|j�t���}|j}|��||j}|�d��}|�	|�
��Wd�|S1s.wY|Sr1)r�r�r�r�rr8r�rVr4r5r\)r7r�Ztmpdirrr��strmrrr�zipfile_ondisk�s

��zTestPath.zipfile_ondiskcCsHt�|�}|��\}}}|��\}}}|��\}	|��\}
|
��\}dSr)rCr��iterdir)r7r��rootr�r@�grZrrrT�hr%rrr�test_iterdir_and_types�s


zTestPath.test_iterdir_and_typescC�t�|�}dSr�rCr��r7r�rrrr�test_is_file_missing��zTestPath.test_is_file_missingcCsPt�|�}|��\}}}|�t��
|��Wd�dS1s!wYdSr)rCr�r�r�r��r7r�rr�r@rrrr�test_iterdir_on_file�s


"�zTestPath.test_iterdir_on_filecCrrrrrrr�test_subdir_is_dir�rzTestPath.test_subdir_is_dircCs�t�|�}|��\}}}|jdd��}|��}Wd�n1s!wY|�|d�|�dd��}|��}Wd�n1sAwY|�|d�dS)Nr�r�zcontent of arJ)rCr�r�r4rYrX)r7r�rr�r@rr�r,rrrr��s

�
�zTestPath.test_opencCs�t��}t�|d�}|�dd�d��d|_t�|�}|��\}|�	d�}|�
dd��}|��}Wd�n1s:wY|�|d�|j
dd��}|��}Wd�n1sZwY|�|d�dS)	Nr=zpath/16.txtzThis was utf-16zutf-16ztest_open_utf16.zipz16.txtrJr�)
rrrCrDrEr�rVr�r��joinpathr4rYrX)r7�in_memory_filer[rr��u16r�r,rrr�test_open_encoding_utf16�s



�
�z!TestPath.test_open_encoding_utf16c	CsPt��}t�|d�}|�dd�d|_t�|�}|��\}|�d�}|j	ddd�}|�
|d	�|jd
ddd��}|�
|��d�Wd�n1sJwY|�
td
��|j	ddd�}Wd�n1sgwY|jd
ddd��*}|�t��|��Wd�n1s�wYWd�dSWd�dS1s�wYdS)Nr=zpath/bad-utf8.binsinvalid utf-8: ��.z"test_read_text_encoding_errors.zipzbad-utf8.binr��ignore)�errorszinvalid utf-8: .rJ�surrogateescapeuinvalid utf-8: ��.r�r��strict)r�r)rrrCrDrErVr�r�r�	read_textrXr4rYrBr$r��UnicodeDecodeError)r7r
r[rr�rr,rrrr�test_open_encoding_errors�s,


��
��"�z"TestPath.test_open_encoding_errorscCsV	d}tddd|�}|j��}|�t|�d|j�|�|dd�|�|dd	�dS)
Naimport io, zipfile
with zipfile.ZipFile(io.BytesIO(), "w") as zf:
    zf.filename = '<test_encoding_warnings in memory zip file>'
    zf.writestr("path/file.txt", b"Spanish Inquisition")
    root = zipfile.Path(zf)
    (path,) = root.iterdir()
    file_path = path.joinpath("file.txt")
    unused = file_path.read_text()  # should warn
    file_path.open("r").close()  # should warn
z-X�warn_default_encodingr�r�rs^<string>:8: EncodingWarning:rPs^<string>:9: EncodingWarning:)rr�r]rXr^ZassertRegex)r7�code�proc�warningsrrr�test_encoding_warnings�s
zTestPath.test_encoding_warningscCs�	t�tjt��dd��}|�d��d��
}|�d�Wd�n1s%wY|�d�jddd��}|�d	�Wd�dS1sEwYdS)
Nr=rAzfile.binr2sbinary contentsr�r�r�z	text file)rCr�rDrrrr4r5)r7r[r�rrrr��s�"�zTestPath.test_open_writecC�P	t�tt���}|�t��|�d���Wd�dS1s!wYdS�Nr@)rCr�r�r�r��IsADirectoryErrorrr4r�rrr�test_open_extant_directory�
"�z#TestPath.test_open_extant_directorycCs�t�|�}|�t��|�d�jddd�Wd�n1swY|�t��|�d��dd�Wd�dS1s>wYdS)Nr�r�r�r�)rCr�r�r�rr4rrrr�test_open_binary_invalid_argss
�"�z&TestPath.test_open_binary_invalid_argscCr)N�z)rCr�r�r�r��FileNotFoundErrorrr4r�rrr�test_open_missing_directoryr z$TestPath.test_open_missing_directorycCs&t�|�}|��\}}}|�d�dS)Nr�)rCr�r�rr	rrrrfs
zTestPath.test_readcCs.t�|�}|�d�}|�d��d��d�}dS�Nr�r@r�e.txt�rCr�r�r7r�rr�rTrrr�
test_joinpath s

zTestPath.test_joinpathcCst�|�}|�ddd�}dS)Nr@rr&r')r7r�rrTrrr�test_joinpath_multiple(�
zTestPath.test_joinpath_multiplecCs&t�|�}|d}|ddd}dSr%rr(rrr�test_traverse_truediv.s
zTestPath.test_traverse_truedivcCs	tddddd�}t|�dS)Nzzipfile.Path(alpharep) / 'a'z(test)�evalT)�sourcerVrB�dont_inherit)�compiler-)r7r�rrrr�test_traverse_simplediv6s�z TestPath.test_traverse_simpledivcCs(	|�|�}t�t|��}t�|�dSr)r�r�r�rdrC)r7r�r�Zpathlikerrr�test_pathlike_constructionCs
z#TestPath.test_pathlike_constructioncCst�|�}|t�d�dSr�)rCr�r�rrrr�test_traverse_pathlikeLr+zTestPath.test_traverse_pathlikecCrrrrrrr�test_parentQrzTestPath.test_parentcCrrrrrrr�test_dir_parentWrzTestPath.test_dir_parentcCrrrrrrr�test_missing_dir_parent]rz TestPath.test_missing_dir_parentcCsD	t�|�}|��\}}}|�dd�|�dd�|d��\}dS)Nr�r�zbar/baz.txtr3r�)rCr�r�rE)r7r�rr�r@rr3rrr�test_mutabilitybs
zTestPath.test_mutabilityi cCsB	t��}t�|d�}ttt|j��D]}|�||�qd|_	|S)Nr=rJ)
rrrCrD�maprdr(�HUGE_ZIPFILE_NUM_ENTRIESrErB)r7r�r[�entryrrr�huge_zipfilesszTestPath.huge_zipfilecCs8	t�|���}tj�|���}|D]}|�d�qdS)N�suffix)rCr�r;r�rVr�r�r)r7r�entriesr:rrr�test_joinpath_constant_time|s�z$TestPath.test_joinpath_constant_timecCs"dd�td�D�}tj�|�dS)NcSs g|]}d�tjt|���qS)r�)r+�string�ascii_lowercaserd)r$rorrrr&�s z:TestPath.test_implied_dirs_performance.<locals>.<listcomp>r�)r(rCr�r�r�rrr�test_implied_dirs_performance�sz&TestPath.test_implied_dirs_performancecCs\|�|�}t�|��}td�D]}t�|d�jdd�qWd�dS1s'wYdS)Nr�r�r�r�)r�rCrDr(r�r)r7r�rKZreprrr�test_read_does_not_close�s
�"�z!TestPath.test_read_does_not_closecCsGdd�dtj�}||�}dS)Nc@seZdZdS)z(TestPath.test_subclass.<locals>.SubclassN)r�r�r�rrrr�Subclass�srCr)r7r�rCrrrr�
test_subclass�szTestPath.test_subclasscCrrrrrrr�
test_filename�rzTestPath.test_filenamecCs	t�|�}dSrrrrrr�test_root_name�szTestPath.test_root_namecCst�|�}d|j_dS)Nzfoo/bar.zip)rCr�rrVrrrr�test_root_parent�s
zTestPath.test_root_parentcCs~	d|_t�|�}|�t��|jWd�n1swY|�t��|jWd�n1s4wY|d}dSr)rVrCr�r�r$rv�parent)r7r�r�subrrr�test_root_unnamed�s
��zTestPath.test_root_unnamedcCs2tdtjfi�}|��D]
}||��d�j}qdS)NZ	PathChildzsome dir)�typerCr�r�rrH)r7r�r.rKrrr�test_inheritance�s�zTestPath.test_inheritancecCs0	|�|�}t�|�}t�|�|�|j�dSr)r�rCrDr�r�rH)r7r��source_pathr[rrr�#test_extract_orig_with_implied_dirs�s



z,TestPath.test_extract_orig_with_implied_dirsN)*r�r�r�r9r�r�r�rrr
rr�rrrr�rr!r$rfr)r*r,r1r2r3r4r5r6r7r9r;r>rArBrDrErFrGrJrLrNrrrrr�ws�	

















	






r�c@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)�StripExtraTestsrPcCs�t�d�}|�|jd�}|�dd�}|�dd�}|�dt�||jf��|�|t�||jf��|�|dt�|d|jf��|�||t�||||jf��|�||t�||||jf��|�||t�||||jf��dS)NrBrr�r*r'�z�r�StructrG�ZIP64_EXTRArXrC�_strip_extra�r7r�r�r@rZrrr�test_no_data�s
�$$(zStripExtraTests.test_no_datacCs�t�d�}|�|jd�d}|�dd�d}|�dd�d}|�dt�||jf��|�|t�||jf��|�|d	t�|d	|jf��|�||t�||||jf��|�||t�||||jf��|�||t�||||jf��dS)
NrBrPr=r��bbr*scccr'rPrQrUrrr�test_with_data�s
�$$(zStripExtraTests.test_with_datacCst�d�}|�|jd�d}|�dd�d}|�dt�|||jf��|�dt�||||jf��|�dt�||d|jf��|�|dt�|||d|jf��|�|t�||||jf��|�|t�||||jf��|�|t�||||jf��dS)NrBrPr=r�rWr'rPrQ)r7r�r�r@rrr�test_multiples�s
 � �  $zStripExtraTests.test_multiplescCsd|�dt�d|jf��|�dt�d|jf��|�dt�d|jf��|�dt�d|jf��dS)Nr'rPszzszzz)rXrCrTrSr�rrr�test_too_short	
s��zStripExtraTests.test_too_shortN)r�r�r�rSrVrXrYrZrrrrrO�srO�__main__)]rjr��importlib.utilr�rrVrr�r�r?rr�r�Ztest.support.script_helperrrbr�Z
unittest.mockr>rCr��tempfilerrrrZtest.supportrrr	r
rrZtest.support.os_helperr
rrrrrr�r)Z
DATAFILES_DIRr�rr ZTestCaser�rrrr"r7r]r_r`rbrnrprrrsrtr�r�rHrOrPrRrSrTrcrgrhrirjrkrurvr�r�r�r�r��tupleZconsumer�r�r�r�r�rOr��mainrrrr�<module>s	�C�������"BAVg[����
7}A#P'
$_
>�