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

�h�e�{����ddlZddlZddlZddlZddlmZddlmZmZddl	m
Z
ddlZddlZddl
Z
ddlZddlZddlZddlZddlZddlmZddlmZddlmZddlmZdd	lmZ	ddlZ	ddlZ	ddlZ	ddlZd
�Zej@jCejD�dzZ#e#dzZ$ejJd
�Z&ej@jOe#d�Z(ej@jOe#d�Z)ej@jOe#d�Z*ej@jOe#d�Z+ej@jOe#d�Z,dZ-dZ.Gd�d�Z/ej`�Gd�d��Z1ejd�Gd�d��Z3ejh�Gd�d��Z5Gd�de/�Z6Gd�d e6ejn�Z8Gd!�d"e1e8�Z9Gd#�d$e3e8�Z:Gd%�d&e5e8�Z;Gd'�d(e6ejn�Z<Gd)�d*e1e<�Z=Gd+�d,e3e<�Z>Gd-�d.e5e<�Z?Gd/�d0e6�Z@Gd1�d2e@�ZAGd3�d4eAejn�ZBGd5�d6e1eAejn�ZCGd7�d8e3eAejn�ZDGd9�d:e5eAejn�ZEGd;�d<e@ejn�ZFGd=�d>e1eF�ZGGd?�d@e3eF�ZHGdA�dBe5eF�ZIGdC�dDe/ejn�ZJGdE�dFe1eJ�ZKGdG�dHe3eJ�ZLGdI�dJe5eJ�ZMGdK�dLe1ejn�ZNGdM�dNe6ejn�ZOGdO�dP�ZPGdQ�dRePe6ejn�ZQGdS�dTePe6ejn�ZRGdU�dVe/�ZSGdW�dXeSejn�ZTGdY�dZe1eT�ZUGd[�d\e3eT�ZVGd]�d^e5eT�ZWGd_�d`eSejn�ZXGda�dbe1eX�ZYGdc�dde3eX�ZZGde�dfe5eX�Z[Gdg�dhe/�Z\Gdi�dje3e\ejn�Z]Gdk�dle3e\ejn�Z^Gdm�dne1e\ejn�Z_Gdo�dpe1e\ejn�Z`Gdq�drejn�ZaGds�dtejn�ZbGdu�dveSejn�ZcGdw�dxeSejn�ZdGdy�dze1ed�ZeGd{�d|e3ed�ZfGd}�d~e5ed�ZgGd�d�ed�Zhej�ejed��d��Gd��d�ejn��ZkGd��d�eb�ZlGd��d��ZmGd��d�emejn�ZnGd��d�emejn�ZoGd��d�emejn�ZpGd��d��ZqGd��d�eqejn�ZrGd��d�e1eqejn�ZsGd��d�e3eqejn�ZtGd��d�e5eqejn�ZuGd��d�ejn�ZvGd��d�ejn�ZwGd��d�ejn�ZxGd��d�ejn�Zyej�ejed��d��Gd��d�e6ejn��Z{Gd��d�e3ejn�Z|d��Z}ej�ejed��d��ej�ejed��d��Gd��d�ejn���Z~Gd��d�e6ejn�ZGd��d�e6�Z�Gd��d�e�ejn�Z�Gd��d�e�ejn�Z�Gd��d�e�ejn�Z�Gd��d�e�ejn�Z�Gd��d�ejn�Z�d��Z�Gd��d��Z�e�jrd��Z�nd��Z�Gd��d�ejn�Z�Gd„d�e�jejn�Z�dĄZ�dńZ�e�d�k(re�j�yy#e$rdZY��cwxYw#e$rdZY��lwxYw#e$rdZY��uwxYw#e$rdZY��~wxYw)��N)�sha256)�contextmanager�	ExitStack)�Random)�archiver_tests)�support)�	os_helper)�
script_helper)�warnings_helperc�4�t|�j�S�N)r�	hexdigest)�datas �8/opt/alt/python312/lib64/python3.12/test/test_tarfile.py�	sha256sumr*s���$�<�!�!�#�#�z-tardirz
-extract-testztesttar.tarztesttar.tar.gzztesttar.tar.bz2�testtar.tar.xzztmp.tar�testtar�@e09e4bc8b3c9d9177e77256353b36c159f5f040531bbd4b024a8f9b9196c71ce�@4f05a776071146756345ceee937b33fc5644f5a96b9780d1c7d6a32cdf164d7bc�h�eZdZeZdZejZejjZ
ed��Zy)�TarTest�c�4�|j|jzSr
)�prefix�suffix��selfs r�modezTarTest.modeDs���{�{�T�[�[�(�(rN)
�__name__�
__module__�__qualname__�tarnamer�io�FileIO�open�tarfile�TarFile�taropen�propertyr�rrrr>s6���G�
�F�
�9�9�D��o�o�%�%�G�
�)��)rrc�`�eZdZeZdZerejndZe	jjZy)�GzipTest�gzN)
r r!r"�gzipnamer#r�gzip�GzipFiler&r'r(�gzopenr)r+rrr-r-Hs(���G�
�F� �4�=�=�d�D��o�o�$�$�Grr-c�`�eZdZeZdZerejndZe	jjZy)�Bz2Test�bz2N)
r r!r"�bz2namer#rr5�BZ2Filer&r'r(�bz2openr)r+rrr4r4Os(���G�
�F��3�;�;�4�D��o�o�%�%�Grr4c�`�eZdZeZdZerejndZe	jjZy)�LzmaTest�xzN)
r r!r"�xznamer#r�lzma�LZMAFiler&r'r(�xzopenr)r+rrr:r:Vs(���G�
�F� �4�=�=�d�D��o�o�$�$�Grr:c��eZdZdZd�Zd�Zy)�ReadTest�r:c�f�tj|j|jd��|_y)N�	iso8859-1�r�encoding�r'r&r#r�tarrs r�setUpzReadTest.setUpbs!���<�<����4�9�9�)4�6��rc�8�|jj�yr
)rH�closers r�tearDownzReadTest.tearDownfs�������rN)r r!r"rrIrLr+rrrArA^s��
�F�6�rrAc��eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zej eed
�xr	eed�d�d��Zy)�
UstarReadTestc�F�|jjd�}|jj|�5}|j�}|j	t|�|jd�|j	t|�td�ddd�y#1swYyxYw)N�
ustar/regtype�regular file extraction failed)	rH�	getmember�extractfile�read�assertEqual�len�sizer�sha256_regtype�r�tarinfo�fobjrs    r�test_fileobj_regular_filez'UstarReadTest.test_fileobj_regular_filels����(�(�$�$�_�5��
�X�X�
!�
!�'�
*�	6�d��9�9�;�D����S��Y����4�
6����Y�t�_�n�4�
6�		6�	6�	6�s�AB�B c�X�|jjdtd��|jjd�}t	t
jjtd�d�5}|j�}ddd�|jj|�5}tj|�}|j�}|j|d�|jt|�dd�|j|ddd�ddd�y#1swY��xYw#1swYyxYw)	NrPr��filter�rzfileobj.readlines() failed�r�SzOI will gladly admit that Python is not the fastest running scripting language.
)rH�extract�TEMPDIRrRr&�os�path�join�	readlinesrSr$�
TextIOWrapperrUrV)rrZ�fobj1�lines1r[�fobj2�lines2s       r�test_fileobj_readlinesz$UstarReadTest.test_fileobj_readlinesus��������'�&��A��(�(�$�$�_�5��
�"�'�'�,�,�w��8�#�
>�	'�%��_�_�&�F�	'��X�X�
!�
!�'�
*�
	2�d��$�$�T�*�E��_�_�&�F����V�V�0�
2����S��[�#�0�
2����V�B�Z�4�0�
2�
	2�
	2�	'�	'��
	2�
	2�s�,D� A+D �D� D)c���|jjdtd��|jjd�}t	t
jjtd�d�5}|j�}ddd�|jj|�5}ttj|��}|j|d�ddd�y#1swY�_xYw#1swYyxYw)NrPrr^r`zfileobj.__iter__() failed)rHrcrdrRr&rerfrgrhrS�listr$rirU)rrZrjrkrlrms      r�test_fileobj_iterzUstarReadTest.test_fileobj_iter�s���������'�&��A��(�(�$�$�_�5��
�"�'�'�,�,�w��8�#�
>�	'�%��_�_�&�F�	'�
�X�X�
!�
!�'�
*�	1�e��"�*�*�5�1�2�F����V�V�/�
1�	1�	1�	'�	'��	1�	1�s�,C� 2C'�C$�'C0c�2�|jjdtd��ttj
j
td�d�5}|j�}ddd�|jjd�}|jj|�5}|j�}|jd�|jd|j�d�|jdd�|jd|j�d�|jd	d
�|jd|j�d�|jdd
�|jd|j�d
�|jd�}|j|ddd�|jdd�|j|j|j�d�|j|j�dd�|j|jd�|jd|j�d�|jd�|j�}|jd�|j�}|j||d�|jd�|jt|j!��|j�d�|jd�|jt|j!��dz|j�d�|jd�|j!�}|j|j�|t|�dd�ddd�y#1swY�� xYw#1swYyxYw)NrPrr^�rbrzseek() to file's start failediz"seek() to absolute position failedi�����z+seek() to negative relative position failedz+seek() to positive relative position failed�
i
zread() after seek failed�zseek() to file's end failedrz0read() at file's end did not return empty stringz$relative seek() to file's end failed�zreadlines() after seek failedztell() after readline() failedz)tell() after seek() and readline() failedzread() after readline() failed)rHrcrdr&rerfrgrTrRrS�seekrU�tellrWrhrV�readline)	rr[rrZ�text�s�s1�s2�lines	         r�test_fileobj_seekzUstarReadTest.test_fileobj_seek�s���������'� &�	�	(�
�"�'�'�,�,�w��8�$�
?�	�4��9�9�;�D�	��(�(�$�$�_�5��
�X�X�
!�
!�'�
*�(	;�d��9�9�;�D��I�I�a�L����Q��	�	��8�
:��I�I�d�A�����T�4�9�9�;�=�
?��I�I�e�Q�����T�4�9�9�;�F�
H��I�I�d�A�����T�4�9�9�;�F�
H��	�	�"�
�A����Q��T�$��3�
5��I�I�a��O����W�\�\�4�9�9�;�6�
8����T�Y�Y�[�#�K�
M��I�I�w�|�|�m�Q�'����Q��	�	��?�
A��I�I�c�N����!�B��I�I�c�N����!�B����R��8�
:��I�I�a�L����S�����1�4�9�9�;�9�
;��I�I�c�N����S�����1�C�7�����D�
F��I�I�a�L��=�=�?�D����T�Y�Y�[�$�s�4�y�z�*:�9�
;�O(	;�(	;�		�	��(	;�(	;�s�N� KN
�N
�
Nc�n�|jjd�5}tj|�}|j	�jd�}|j
t|�t�	|jd�ddd�y#t$r|jd�Y�%wxYw#1swYyxYw)NrPrD�dzseeking failed in text mode)rHrSr$rirT�encoderUrrXry�AttributeError�fail�rr[rs   r�test_fileobj_textzUstarReadTest.test_fileobj_text�s���
�X�X�
!�
!�/�
2�		9�d��#�#�D�)�D��9�9�;�%�%�k�2�D����Y�t�_�n�=�
9��	�	�#��		9�		9��"�
9��	�	�7�8�
9��
		9�		9�s*�AB+�1B�B(�%B+�'B(�(B+�+B4c��|jj|�5}|jj|�5}|j|j|j�ddd�ddd�y#1swY�xYw#1swYyxYwr
)rHrSrU�name)r�lnktype�regtype�a�bs     r�_test_fileobj_linkz UstarReadTest._test_fileobj_link�sm��
�X�X�
!�
!�'�
*�	-�a�
�X�X�
!�
!�'�
*�	-�./����Q�V�V�Q�V�V�,�	-�	-�	-�	-��	-�	-�s"�A<�'A0�A<�0A9	�5A<�<Bc�(�|jdd�y)N�
ustar/lnktyperP�r�rs r�test_fileobj_link1z UstarReadTest.test_fileobj_link1���������Arc�(�|jdd�y)N�./ustar/linktest2/lnktype�ustar/linktest1/regtyper�rs r�test_fileobj_link2z UstarReadTest.test_fileobj_link2������� ;� 9�	;rc�(�|jdd�y)N�
ustar/symtyperPr�rs r�test_fileobj_symlink1z#UstarReadTest.test_fileobj_symlink1�r�rc�(�|jdd�y)N�./ustar/linktest2/symtyper�r�rs r�test_fileobj_symlink2z#UstarReadTest.test_fileobj_symlink2�r�rc�(�|jdd�y)N�symtype2rPr�rs r�test_issue14160zUstarReadTest.test_issue14160�s�����
�O�<rc�H�|jd�|jd�y)N�bar�eaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)�add_dir_and_getmemberrs r�test_add_dir_getmemberz$UstarReadTest.test_add_dir_getmember�s���"�"�5�)��"�"�7�+r�getuid�getgidz'Missing getuid or getgid implementationc	�X�d�}tj�5tjtd�5}tj
|_	tj|�|j||��tj|�	ddd�tjt�5}|j|j|�|j|dz��ddd�ddd�y#tj|�wxYw#1swY��xYw#1swY�8xYw#1swYyxYw)Nc�"�dx|_|_|S)Nr�)�uid�gid�rZs rr_z3UstarReadTest.add_dir_and_getmember.<locals>.filter�s��(+�+�G�K�'�+��Nr�wr^�/)
r	�temp_cwdr'r&�tmpname�USTAR_FORMAT�formatre�mkdir�add�rmdirrUrR)rr�r_rHs    rr�z#UstarReadTest.add_dir_and_getmember�s���	��
�
�
!�	����g�s�+�
#�s�$�1�1��
�#��H�H�T�N��G�G�D��G�0��H�H�T�N�

#����g�&�
�#�� � ��M�M�$�'��M�M�$��*�-��
�	�	���H�H�T�N��

#�
#��
�
��	�	�sR�D �D�
(C.�2D�!D �)4D�D �.D�D�D	�
D �D	�D � D)N)r r!r"r\rnrqr�r�r�r�r�r�r�r�r��unittest�
skipUnless�hasattrrer�r+rrrNrNjs|��6�2�$1�/;�b
9�-�
B�;�B�;�=�,�
�X�����X�.�H�7�2�x�3H�B�D��D�rrNc��eZdZy)�GzipUstarReadTestN�r r!r"r+rrr�r����rr�c��eZdZy)�Bz2UstarReadTestNr�r+rrr�r�r�rr�c��eZdZy)�LzmaUstarReadTestNr�r+rrr�r�r�rr�c�$�eZdZd�Zd�Zd�Zd�Zy)�ListTestc�d�tj|j|j��|_y)N�rrGrs rrIzListTest.setUps���<�<����4�9�9�=��rc���tjtj�dd��}tjt
d|�5�jjd��ddd�|j�j�}�jd|��jd|��jd	|��jd
|��jd|��jd|��jd
|��jd|��fd�}�j|d�|��j|d�|��j|d�|��j|d�|��j|d�|��j|d��jd|��jd|�y#1swY��lxYw)N�ascii�
��newline�stdoutF��verbose�ustar/conttype�
ustar/regtypes
ustar/lnktypesustar/12345/12345/12345/12345/12345/12345/12345/12345/12345/12345/12345/12345/12345/12345/12345/12345/12345/12345/12345/12345/12345/12345/12345/12345/12345/12345/12345/12345/12345/12345/12345/12345/12345/12345/12345/12345/12345/12345/12345/1234567/longnames./ustar/linktest2/symtypes./ustar/linktest2/lnktypesustar/dirtype/sustar/dirtype-with-size/c�t��|j�jjd�}|jdd�S)N�surrogateescaper��backslashreplace)�decoderHrFr�)r�r}rs  �r�convz ListTest.test_list.<locals>.conv s0���������*�*�,=�>�A��8�8�G�%7�8�8rsustar/umlauts-�����s'misc/regtype-hpux-signed-chksum-�����s)misc/regtype-old-v7-signed-chksum-�����spax/bad-pax-�spax/hdrcharset-�s)ustar/conttype ?\r?\nustar/regtype ?\r?\nslink tos->)
r$ri�BytesIOr�	swap_attr�sysrHrp�detach�getvalue�assertIn�assertRegex�assertNotIn)r�tio�outr�s`   r�	test_listzListTest.test_lists�������r�z�z�|�W�d�C��
�
�
�s�H�c�
2�	)��H�H�M�M�%�M�(�	)��j�j�l�#�#�%���
�
�'��-��
�
�&��,��
�
�&��,��
�
�B�C�H��
�
�2�C�8��
�
�2�C�8��
�
�'��-��
�
�1�3�7�	9�	
�
�
�d�H�I�3�O��
�
�d�;�<�=@�	B��
�
�d�;�<�=@�	B��
�
�d�6�7��=��
�
�d�9�:�C�@�	
����7�	8�	
����S�)������$�C	)�	)�s�G�Gc��tjtj�dd��}tjt
d|�5|jjd��ddd�|j�j�}|j|d�|jd|�|jd	|�|jd
|�|jd|�|jd|�y#1swY��xYw)
Nr�r�r�r�Tr�s�\?rw-r--r-- tarfile/tarfile\s+7011 \d{4}-\d\d-\d\d\s+\d\d:\d\d:\d\d ustar/\w+type ?\r?\n\?rw-r--r-- tarfile/tarfile\s+7011 \d{4}-\d\d-\d\d\s+\d\d:\d\d:\d\d ustar/\w+type ?\r?\nsustar/symtype -> regtypes1./ustar/linktest2/symtype -> ../linktest1/regtypes;./ustar/linktest2/lnktype link to ./ustar/linktest1/regtypes	gnu/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/longlink link to gnu/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/longnames	pax/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/longlink link to pax/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/longname)r$rir�rr�r�rHrpr�r�r�r�)rr�r�s   r�test_list_verbosezListTest.test_list_verbose6s������r�z�z�|�W�d�C��
�
�
�s�H�c�
2�	(��H�H�M�M�$�M�'�	(��j�j�l�#�#�%��	
����=�	>�	
�
�
�1�3�7��
�
�J�C�P��
�
�3�47�	9��
�
�5�69�	;��
�
�5�69�	;�'	(�	(�s�C6�6C?c��tjtj�dd��}d�}tjt
d|�5|jjd||j���ddd�|j�j�}|jd|�|jd	|�y#1swY�LxYw)
Nr�r�r�c3�\K�|j�D]}d|jvs�|���y�w)N�reg)�
getmembersr�)rHrZs  r�membersz+ListTest.test_list_members.<locals>.membersPs-�����>�>�+�
"���G�L�L�(�!�M�
"�s�",�,r�F)r�r�r�r�)r$rir�rr�r�rHrpr�r�r�r�)rr�r�r�s    r�test_list_memberszListTest.test_list_membersNs������r�z�z�|�W�d�C��	"��
�
�s�H�c�
2�	D��H�H�M�M�%�����1B�M�C�	D��j�j�l�#�#�%���
�
�&��,����*�C�0�		D�	D�s�	.C�CN)r r!r"rIr�r�r�r+rrr�r�s��>�#%�J;�0
1rr�c��eZdZy)�GzipListTestNr�r+rrr�r�[r�rr�c��eZdZy)�Bz2ListTestNr�r+rrr�r�_r�rr�c��eZdZy)�LzmaListTestNr�r+rrr�r�cr�rr�c�H�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zy)�CommonReadTestc��ttd�5	ddd�|jtjt��|jtjtjt���ttd�5}|jtj|��ddd�|jtjtjd���y#1swY��xYw#1swY�MxYw)N�wbrssinvalid)	r&r��assertFalser'�
is_tarfile�pathlib�Pathr$r��rr[s  r�test_is_tarfile_erroneousz(CommonReadTest.test_is_tarfile_erroneousis���
�'�4�
 �	��	�	
����+�+�G�4�5�	
����+�+�G�L�L��,A�B�C��'�4�
 �	7�D����W�/�/��5�6�	7�	
����+�+�B�J�J�z�,B�C�D�	�	��	7�	7�s�C3�%C?�3C<�?Dc	�`�|jtj|j��|jtjt	j
|j���t
|jd�5}|jtj|��ddd�t
|jd�5}|jtjtj|j����ddd�y#1swY�nxYw#1swYyxYw)Nrs)
�
assertTruer'r�r#r�r�r&r$r�rTr�s  r�test_is_tarfile_validz$CommonReadTest.test_is_tarfile_validzs�������*�*�4�<�<�8�9�	
����*�*�7�<�<����+E�F�G��$�,�,��
%�	6���O�O�G�.�.�t�4�5�	6��$�,�,��
%�	I���O�O�G�.�.�r�z�z�$�)�)�+�/F�G�H�	I�	I�		6�	6��	I�	I�s�%D�	AD$�D!�$D-c���t|jd�5}tj|�|j	|j�d�ddd�t|jd�5}t
j|j��}tj|�|j	|j�d�ddd�y#1swY��xYw#1swYyxYw)Nrsr)	r&r#r'r�rUrzr$r�rT)rr[�	file_likes   r�test_is_tarfile_keeps_positionz-CommonReadTest.test_is_tarfile_keeps_position�s����$�,�,��
%�	-�����t�$����T�Y�Y�[�!�,�	-��$�,�,��
%�	2���
�
�4�9�9�;�/�I����y�)����Y�^�^�-�q�1�	2�	2�		-�	-��	2�	2�s�6C
�+AC�
C�C"c���tjt|jj	dd��5	ddd�	tjt|j�}|j�|j
|j�g�j�y#1swY�oxYw#tj$r|jd�Y�CwxYw#j�wxYw)Nr`r�z&tarfile.open() failed on empty archive)r'r&r�r�replace�getnames�assertListEqualr��	ReadErrorr�rK�rrHs  r�test_empty_tarfilez!CommonReadTest.test_empty_tarfile�s���
�\�\�'�4�9�9�#4�#4�S�#�#>�
?�	��	�	��,�,�w��	�	�2�C��L�L�N�
� � ����!1�2�6��I�I�K�	�	��
� � �	@��I�I�>�?�	@��

�I�I�K�s5�B%�4B1�4 C�%B.�1$C�C�C�C�C-c��|jtd�5tjd|j�ddd�y#1swYyxYw)N�xxx)�assertRaisesRegex�FileNotFoundErrorr'r&rrs r�test_non_existent_tarfilez(CommonReadTest.test_non_existent_tarfile�s<���
#�
#�$5�u�
=�	+��L�L���	�	�*�	+�	+�	+�s�!A�A
c�2�ttd�5	ddd�|jtjtjt|j
�|jtjtjt�y#1swY�{xYw�Nr�)r&r��assertRaisesr'rrrs r�test_null_tarfilez CommonReadTest.test_null_tarfile�sd���'�4�
 �	��	����'�+�+�W�\�\�7�D�I�I�N����'�+�+�W�\�\�7�C�	�	�s�B
�
Bc�<�td�jd�}dD]�}|jtd�5}|j	|dz�tjd�}t|�|_|j	|j��|j	|�ddd�tjtdd�	�}	|j|j�dgd
|z�|j���y#1swY�^xYw#|j�wxYw)Nrrx)��ar�ru�foor`T)r�ignore_zerosz3ignore_zeros=True should have skipped the %r-blocks)
r�	randbytesr&r��writer'�TarInforVrW�tobufrrrK)rr�charr[rZrHs      r�test_ignore_zerosz CommonReadTest.test_ignore_zeros�s����a�y�"�"�3�'��!�	�D����7�C�(�
!�D��
�
�4�$�;�'�!�/�/�%�0��"�4�y����
�
�7�=�=�?�+��
�
�4� �
!��,�,�w�S�t�D�C�
��$�$�S�\�\�^�e�W�I�����	�	��!	�
!�
!���	�	��s�A*C=�%D	�=D	�	Dc��dD�]�}tjtd�5}tjd�}d|_|j|t
jd��ddd�ttd�5}|j|�ddd�tjt�5}|jtjd�5|D]}�	ddd�ddd�tjt�5}|j�}|jtjd�5|j|td�	�ddd�|jtjd�5|j|�j�ddd�ddd����y#1swY��FxYw#1swY��)xYw#1swY��xYw#1swY��xYw#1swY��xYw#1swY�SxYw#1swY���xYw)
N)rxiXrui��w:rrusaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaazr+bzunexpected end of datarr^)r'r&r�rrW�addfiler$r��truncaterr�nextrcrdrSrT)rrWrH�tr[s     r�test_premature_end_of_archivez,CommonReadTest.test_premature_end_of_archive�s���*�	.�D����g�t�,�
8���O�O�E�*��������A�r�z�z�+�6�7�
8�
�g�u�%�
$���
�
�d�#�
$����g�&�
�#��+�+�G�,=�,=�?W�X�� ������
�
���g�&�
.�#��H�H�J���+�+�G�,=�,=�?W�X�;��K�K��7�6�K�:�;��+�+�G�,=�,=�?W�X�.��O�O�A�&�+�+�-�.�

.�
.�	.�
8�
8��

$�
$�����
�
��;�;��.�.��

.�
.�sx�AF'�;F4�.!G
�G�G
�1G1�2G�(G1�3 G%�G1�'F1	�4F>	�G
�G
�
G	�G"�G1�%G.�*G1�1G;	c���|jtjd�5tjt	j
d��5}	ddd�ddd�y#1swY�xYw#1swYyxYw)Nz%file could not be opened successfullyz
recursion.tar)rr'rr&r�findfilers  r�test_length_zero_headerz&CommonReadTest.test_length_zero_header�sf���
#�
#�G�$5�$5�7^�
_�	����g�.�.��?�@�
�C��
�	�	�
�
��	�	�s#�)A)�
A�A)�A&	�"A)�)A2c���|jjd�}|jj|�5}|j|jd�ddd�y#1swYyxYw�NrP)rHrRrSrUr�)r�filer[s   r�test_extractfile_namez$CommonReadTest.test_extractfile_name�sS���x�x�!�!�/�2��
�X�X�
!�
!�$�
'�	9�4����T�Y�Y��8�	9�	9�	9�s�A�A&N)
r r!r"r�r�r�rr
rrr r#r'r+rrr�r�gs7��E�"
I�
2��"+�D��,.�0�9rr�c�Z�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zej$eed�d�ej,d���Zej0d��Zej0d��Zd�Zd�Zd�Zd�Zej>e dud�d��Z!d�Z"y)�MiscReadTestBasec��yr
r+rs r�requires_name_attributez(MiscReadTestBase.requires_name_attribute�s��rc���|j�t|jd�5}|j|jt
�t
j||j��5}|j|jt
�|j|jtjj|j��ddd�ddd�y#1swY�xYw#1swYyxYw�Nrs��fileobjr)r+r&r#�assertIsInstancer��strr'rrUrerf�abspath�rr[rHs   r�test_no_name_argumentz&MiscReadTestBase.test_no_name_argument�s����$�$�&�
�$�,�,��
%�	G���!�!�$�)�)�S�1����d����;�
G�s��%�%�c�h�h��4�� � ����2�7�7�?�?�4�9�9�+E�F�
G�	G�	G�
G�
G��	G�	G�s%�AC*�)A$C�
C*�C'	�#C*�*C3c�T�t|jd�5}|j�}ddd�tj�}|jtt|d�tj||j��}|j|j�y#1swY�wxYw)Nrsr�r.)r&r#rTr$r�r
r��getattrr'r�assertIsNoner��rr[rrHs    r�test_no_name_attributez'MiscReadTestBase.test_no_name_attribute�sz��
�$�,�,��
%�	���9�9�;�D�	��z�z�$������.�'�4��@��l�l�4�d�i�i�8�����#�(�(�#�	�	�s�B�B'c�T�t|jd�5}|j�}ddd�tj�}d|_t
j||j��5}|j|j
�ddd�y#1swY�kxYw#1swYyxYw)Nrsrr.)	r&r#rTr$r�r�r'rr7r8s    r�test_empty_name_attributez*MiscReadTestBase.test_empty_name_attributes���
�$�,�,��
%�	���9�9�;�D�	��z�z�$�����	�
�\�\�$�T�Y�Y�
7�	(�3����c�h�h�'�	(�	(�		�	��	(�	(�s�B�-B�B�B'c��tj|jtj�}t|d�5}|j	|j
t�tj||j��5}|j|j
�ddd�ddd�y#1swY�xYw#1swYyxYwr-)
rer&r#�O_RDONLYr0r��intr'rr7)r�fdr[rHs    r�test_int_name_attributez(MiscReadTestBase.test_int_name_attribute
s����W�W�T�\�\�2�;�;�
/��
�"�d�^�	,�t��!�!�$�)�)�S�1����d����;�
,�s��!�!�#�(�(�+�
,�	,�	,�
,�
,��	,�	,�s$�AB6�=B*�B6�*B3	�/B6�6B?c��|j�tj|j�}t	|d�5}|j|jt�tj||j��5}|j|jt�|j|jtjj|j��ddd�ddd�y#1swY�xYw#1swYyxYwr-)
r+re�fsencoder#r&r0r��bytesr'rrUrfr2)rr#r[rHs    r�test_bytes_name_attributez*MiscReadTestBase.test_bytes_name_attributes����$�$�&��+�+�d�l�l�+��
�'�4�
 �	G�D��!�!�$�)�)�U�3����d����;�
G�s��%�%�c�h�h��6�� � ����2�7�7�?�?�4�9�9�+E�F�
G�	G�	G�
G�
G��	G�	G�s%�AC?�>A$C3�"C?�3C<	�8C?�?Dc	�V�tj|j�}tj||j
��5}|j
|jt�|j|jtjjtj|���ddd�|j|�5}|j
|jt�|j|jtjjtj|���ddd�tjj	||j
��5}|j
|jt�|j|jtjjtj|���ddd�|j dk(r�tj|d��5}|j
|jt�|j|jtjjtj|���ddd�yy#1swY���xYw#1swY��TxYw#1swY��xYw#1swYyxYw)Nr�rr`)r�r�r#r'r&rr0r�r1rUrerfr2�fspathr)r(r)rr#rHs   r�test_pathlike_namez#MiscReadTestBase.test_pathlike_names����,�,�t�|�|�,��
�\�\�'��	�	�
2�	L�c��!�!�#�(�(�C�0����S�X�X�r�w�w���r�y�y��7I�'J�K�	L��\�\�'�
"�	L�c��!�!�#�(�(�C�0����S�X�X�r�w�w���r�y�y��7I�'J�K�	L��_�_�
!�
!�'��	�	�
!�
:�	L�c��!�!�#�(�(�C�0����S�X�X�r�w�w���r�y�y��7I�'J�K�	L��;�;�"������s�3�
P�s��%�%�c�h�h��4�� � ����2�7�7�?�?�2�9�9�W�;M�+N�O�
P�
P��	L�	L��	L�	L��	L�	L��
P�
P�s4�A-I9�A-J�'A-J�A-J�9J�J�J�J(c���ttd�5	ddd�|jtd�5|j	td�}ddd�|jtd�5|j	td�}ddd�|jtd�5|j	td�}ddd�y#1swY��xYw#1swY��xYw#1swY�WxYw#1swYyxYw)Nr�z
mode must be �q�rwr)r&r�r�
ValueErrorr)rs  r�test_illegal_mode_argz&MiscReadTestBase.test_illegal_mode_arg/s���
�'�4�
 �	��	�
�
#�
#�J��
@�	-��,�,�w��,�C�	-�
�
#�
#�J��
@�	.��,�,�w��-�C�	.�
�
#�
#�J��
@�	,��,�,�w��+�C�	,�	,�
	�	��	-�	-��	.�	.��	,�	,�s.�B;�C�&C�C�;C�C�C�C(c�B�tj|j|j��}	|j	�|j	�}|j
}|j}|j|�5}|j�}ddd�|j�|j|j�5}|j|�|j|jd|��5}|j	�}|j|j
|�|j�|j|j|�j�d�ddd�ddd�y#1swY��xYw#|j�wxYw#1swY�3xYw#1swYyxYw)Nr�rB�rr/zseek back did not work)
r'r&r#rrr��offsetrSrTrKryrUr�)rrHrr�rO�frr[s        r�test_fileobj_with_offsetz)MiscReadTestBase.test_fileobj_with_offset9sG���l�l�4�<�<�d�i�i�8��	��H�H�J����
�A��6�6�D��X�X�F�����#�
 �q��v�v�x��
 �
�I�I�K��Y�Y�t�|�|�
$�	2���I�I�f�����$�,�,�T�4��@�
2�C��H�H�J��� � �����.���� �� � �����!3�!8�!8�!:�D�0�2�

2�		2�	2�

 �
 ��
�I�I�K��
2�
2��		2�	2�sI�A	E4�6E(�E4�:0F�*A-F	�F�(E1�-E4�4F�	F	�F�Fc�@�|jtjtjt|j
�ttd�5}|jtjtj||j
��ddd�y#1swYyxYwr-)r
r'rr&r#rr�s  r�test_fail_compzMiscReadTestBase.test_fail_compUso�����'�+�+�W�\�\�7�D�I�I�N�
�'�4�
 �	<�D����g�/�/����&*����
�
<�	<�	<�	<�s�<B�Bc��|jjd�}|j|jtj
d�y)Nzmisc/dirtype-old-v7zv7 dirtype failed)rHrRrU�typer'�DIRTYPE�rrZs  r�test_v7_dirtypez MiscReadTestBase.test_v7_dirtype\s6���(�(�$�$�%:�;��������w���#�	%rc�|�	|jjd�y#t$r|jd�YywxYw)Nzmisc/regtype-xstarz3failed to find misc/regtype-xstar (mangled prefix?))rHrR�KeyErrorr�rs r�test_xstar_typez MiscReadTestBase.test_xstar_typeds9��	M��H�H���3�4���	M��I�I�K�L�	M�s��;�;c��|jD]{}|jt|j�dd|jz�|jjd�s�R|j|jdd|jz��}y)N鏽>zwrong mtime for %szustar/r'zwrong uname for %s)rHrUr>�mtimer��
startswith�unamerWs  r�test_check_membersz#MiscReadTestBase.test_check_membersmss���x�x�	9�G����S����/��(�7�<�<�7�
9��<�<�*�*�8�4�����W�]�]�I�(�7�<�<�7�
9�	9rc�t�|j|jj�djdd�y)N���zmisc/eofzcould not find all members)rUrHr�r�rs r�test_find_membersz"MiscReadTestBase.test_find_membersvs/��������,�,�.�r�2�7�7��,�	.r�link�Missing hardlink implementationc�J�tjtdd��5}|jdtd��|jtjtjjtd��|jdtd��|jtjtjjtd��ttjjtd�d�5}|j�}ddd�|jt�t�|jd	td��|jtjtjjtd	��ttjjtd	�d�5}|j�}ddd�|jt|�t�ddd�y#1swY��xYw#1swY�=xYw#1swYyxYw)
NrtrD)�
errorlevelrFrPrr^r�rsr�)r'r&r#rcrd�
addCleanupr	�unlinkrerfrgrTrUrrX)rrHrPrs    r�test_extract_hardlinkz&MiscReadTestBase.test_extract_hardlinkzsm��
�\�\�'�a�+�
F�	>�#��K�K����K�@��O�O�I�,�,�b�g�g�l�l�7�O�.T�U��K�K����K�@��O�O�I�,�,�b�g�g�l�l�7�O�.T�U��b�g�g�l�l�7�O�<�d�C�
 �q��v�v�x��
 ����Y�t�_�n�=��K�K����K�@��O�O�I�,�,�b�g�g�l�l�7�O�.T�U��b�g�g�l�l�7�O�<�d�C�
 �q��v�v�x��
 ����Y�t�_�n�=�	>�	>�
 �
 ��
 �
 ��	>�	>�s=�C#H�H�B/H�H
�'H�H
	�H�
H	�H�H"c��tjtd��}tjjtd�}tj|�	|D�cgc]}|j�s�|��}}|j||d��|D]�}tjj||j�}tjdk7rJ|j|jdztj|�j dz|j�d�}tjj#|�}d	j%||j&�||�|�}	|j|j&||	���	|j)�t+j,|�ycc}w#|j)�t+j,|�wxYw)
NrD�rF�
extractall�
fully_trustedr^�win32�c��t|t�r dj||j��Sdj|�S)Nz{} ({})z
{!r} (int))�
isinstance�floatr��hex)r^s r�format_mtimez6MiscReadTestBase.test_extractall.<locals>.format_mtime�s6��!�%��/�(�/�/��u�y�y�{�C�C�+�2�2�5�9�9rz,tar mtime {0} != file time {1} of path {2!a})r'r&r#rerfrgrdr��isdirrnr�r��platformrUr�stat�st_mode�getmtimer�r^rKr	�rmtree)
rrH�DIRr�directoriesrZrfrv�
file_mtime�errmsgs
          r�test_extractallz MiscReadTestBase.test_extractall�sc���l�l�7�[�9���g�g�l�l�7�L�1��
����
�	"�&)�7��Q�W�W�Y�1�7�K�7��N�N�3��O�N�D�&�
D���w�w�|�|�C����6���<�<�7�*��$�$�W�\�\�E�%9�%'�W�W�T�]�%:�%:�U�%B�%,�\�\�3�:�
 �W�W�-�-�d�3�
�G�N�N� ����/� ��,����� � ����
�F�C�#
D�&
�I�I�K����S�!��-8��*
�I�I�K����S�!�s%�F,�F'�0F'�4DF,�'F,�,'Gc��d}tjjtd�}tj|�	tjtd��5}|j|�}|j||d��tjj||�}|jtjj|�|j�tjdk7r2|jtj|�j dzd	�ddd�t#j$|�y#1swY�xYw#t#j$|�wxYw)
N�
ustar/dirtype�
extractdirrDrmro�rfr_rprqi�)rerfrgrdr�r'r&r#rRrcrUr{r^r�rxryrzr	r|�r�dirtyper}rHrZ�	extracteds      r�test_extract_directoryz'MiscReadTestBase.test_extract_directory�s���!���g�g�l�l�7�L�1��
����
�		"����g��<�
P���-�-��0�����G�#�o��F��G�G�L�L��g�6�	�� � ����!1�!1�)�!<�g�m�m�L��<�<�7�*��$�$�R�W�W�Y�%7�%?�%?�%�%G��O�

P�
���S�!�
P�
P��
���S�!�s$�E�CD:�E�:E�?E�Ec��tjt�dz}tj|�5tjtd��5}|D�cgc]}|j�s�|��}}|j||d��|D]J}||jz}|jtjj|�|j��L	ddd�ddd�ycc}w#1swY�xYw#1swYyxYw)NrnrDrmror^)r�r�rdr	�temp_dirr'r&r#rwrnr�rUrerfr{r^)rr}rHrr~rZrfs       r�test_extractall_pathlike_namez.MiscReadTestBase.test_extractall_pathlike_name�s����l�l�7�#�l�2��
�
�
��
$�	H�
�\�\�'�K�
8�	H�<?�&)�7��Q�W�W�Y�1�7�K�7��N�N�3��O�N�D�&�
H���W�\�\�)��� � ����!1�!1�$�!7����G�
H�		H�	H�	H��7�	H�	H��	H�	H�s<�C5�C)�C$�)C$�-A%C)�C5�$C)�)C2	�.C5�5C>c��d}tjt�dz}tj|�5tjtd��5}|j|�}|j||d��||z}|jtjj|�|j�ddd�ddd�y#1swY�xYw#1swYyxYw)Nr�rnrDrmror�)r�r�rdr	r�r'r&r#rRrcrUrerfr{r^r�s      r�test_extract_pathlike_namez+MiscReadTestBase.test_extract_pathlike_name�s���!���l�l�7�#�l�2��
�
�
��
$�	I�
�\�\�'�K�
8�	I�<?��m�m�G�,�G��K�K��c�/�K�B��g�
�I����R�W�W�-�-�i�8�'�-�-�H�	I�	I�	I�	I��	I�	I�s$�C�A$C�4C�C	�
C�Cc��tjjtd�}t	|d�5}|jd�ddd�	tjtj�}	|j|�|jd�t!j"|�y#1swY�fxYw#tj$r(|j|jj�Y�\wxYw#t!j"|�wxYw)N�emptyr�rzReadError not raised)rerfrgrdr&r�object�__new__r'r(�__init__r�rr�r/�closedr	rj)rr�r[rHs    r�test_init_close_fobjz%MiscReadTestBase.test_init_close_fobj�s��������W�g�.��
�%��
�	�$��J�J�s�O�	�		$��.�.����1�C�
2����U�#��	�	�0�1����U�#�	�	���$�$�
4������� 2� 2�3�
4��

���U�#�s;�B(�#C2�0B4�C2�(B1�48C/�,C2�.C/�/C2�2D	c�>�tj|j�5}t||�D]Y\}}|j	|j
|j
�|j	|j
�|j
���[	ddd�y#1swYyxYwr
)r'r&r#�ziprUrO�get_info)rrH�m1�m2s    r�test_parallel_iterationz(MiscReadTestBase.test_parallel_iteration�sx���\�\�$�,�,�
'�	?�3��c�3�-�
?���B�� � ����B�I�I�6�� � ��������
�>�
?�	?�	?�	?�s�A)B�BNz
requires zlibc�<�tjjd�5}tj|_|j
tj�5tj|j�ddd�ddd�y#1swY�xYw#1swYyxYw)Nztarfile.TarInfo.fromtarfile)r��mock�patch�zlib�error�side_effectr
r'rr&r#)rr�s  r�test_zlib_error_does_not_leakz.MiscReadTestBase.test_zlib_error_does_not_leak�sx���]�]�
 �
 �!>�
?�	+�4�#�z�z�D���"�"�7�#4�#4�5�
+����T�\�\�*�
+�	+�	+�
+�
+��	+�	+�s#�5B� B�5B�B	�B�Bc���tj�}tj|d��}|j	�|jd�tj|d��5}|j
|j�d�ddd�|jd�tj|d��5}|j
|j�d�ddd�y#1swY�[xYw#1swYyxYw)Nr�r.r�r|r`)r$r�r'r&rKryrUr)rr?�tfs   r�test_next_on_empty_tarfilez+MiscReadTestBase.test_next_on_empty_tarfile�s���
�Z�Z�\��
�\�\�"�3�
/��
���
�
����
�
�\�\�"�4�
0�	.�B����R�W�W�Y��-�	.�	����
�
�\�\�"�3�
/�	.�2����R�W�W�Y��-�	.�	.�		.�	.��	.�	.�s�$!C�5!C+�C(�+C4)#r r!r"r+r4r9r;r@rDrGrLrQrSrXr[rardr�r�r�rer	�skip_unless_symlinkrk�skip_unless_working_chmodr�r�r�r�r�r��skipIfr�r�r�r+rrr)r)�s���
�G�$�(�,�G�P� ,�2�8<�%�M�9�.��X�����V�,�:�<��"�"�>�#�<�>�$�(�(�"�)�"�>�(�(�
"�)�
"�H�I�$�&?��X�_�_�T�T�\�?�3�+�4�+�.rr)c��eZdZdZy)�MiscReadTestN)r r!r"rSr+rrr�r�s���Nrr�c��eZdZy)�GzipMiscReadTestNr�r+rrr�r�r�rr�c��eZdZd�Zy)�Bz2MiscReadTestc�&�|jd�y)NzBZ2File have no name attribute��skipTestrs rr+z'Bz2MiscReadTest.requires_name_attributes���
�
�6�7rN�r r!r"r+r+rrr�r�
s��8rr�c��eZdZd�Zy)�LzmaMiscReadTestc�&�|jd�y)NzLZMAFile have no name attributer�rs rr+z(LzmaMiscReadTest.requires_name_attributes���
�
�7�8rNr�r+rrr�r�s��9rr�c�(�eZdZdZd�Zd�Zd�Zd�Zy)�StreamReadTestr�c�,�|jD]O}|j�s�|jj|�5}		|jd�}sn�	ddd��Qy#tj
$r|j
d�Y�6wxYw#1swY��xYw)Nrxz6simple read-through using TarFile.extractfile() failed)rH�isregrSrTr'�StreamErrorr�)rrZr[�bufs    r�test_read_throughz StreamReadTest.test_read_throughs����x�x�	�G��=�=�?�����%�%�g�.�
�$��B�"�i�i��n������
�
�	��#�.�.�B��	�	�#A�B�B��	
�
�s.�B
�A �B
� $B�B
�B�B
�
B	c�D�|jj�}|jj|�5}|j�}ddd�|j	t�|jd�|j	t|�td�y#1swY�PxYw)NrQ)	rHrrSrTrUrVrWrrXrYs    rr\z(StreamReadTest.test_fileobj_regular_file's{���(�(�-�-�/��
�X�X�
!�
!�'�
*�	�d��9�9�;�D�	�����T��G�L�L�0�	2�����4��.�0�	2�		�	�s�B�Bc���|jj�}|jj|d�5}|jtj
|j�ddd�y#1swYyxYw�Nr)rHr�rSr
r'r�rT)r�tarinfosrPs   r�test_provoke_stream_errorz(StreamReadTest.test_provoke_stream_error0s[���8�8�&�&�(��
�X�X�
!�
!�(�1�+�
.�	;�!����g�1�1�1�6�6�:�	;�	;�	;�s�+A-�-A6c��tjtd��}	|j}	|j	�}|j	�}|�n�|j|d�|j
�s|j�r:|jtj�5|j|�ddd���|j|�}|j|�}|���|j|d�|j|j�|j�d���	|j�y#1swY��xYw#|j�wxYw)NrDrmzstream.next() failed.zstream.extractfile() failedzstream extraction failed)r'r&r#rHr�assertIsNotNone�islnk�issymr
r�rSrUrTrK)r�tar1�tar2�t1�t2�v1�v2s       r�test_compare_membersz#StreamReadTest.test_compare_members5s���|�|�G�k�:��	��8�8�D���Y�Y�[���Y�Y�[���:���$�$�R�)@�A��8�8�:������*�*�7�+>�+>�?�-��(�(��,�-���%�%�b�)���%�%�b�)���:���$�$�R�)F�G�� � �����B�G�G�I�2�4�#�� 
�J�J�L�-�-��
�J�J�L�s%�BD>�D2�0A0D>�2D;�7D>�>EN)r r!r"rr�r\r�r�r+rrr�r�s���F�� 2�;�
rr�c��eZdZy)�GzipStreamReadTestNr�r+rrr�r�Pr�rr�c��eZdZy)�Bz2StreamReadTestNr�r+rrr�r�Sr�rr�c��eZdZy)�LzmaStreamReadTestNr�r+rrr�r�Vr�rr�c�*�eZdZd�Zd�Zd�Zd�Zd�Zy)�DetectReadTestc��	tj||�}|j�y#tj$r}|j	�Yd}~yd}~wwxYwr
)r'r&rKrr�)rr�rrH�es     r�_testfunc_filezDetectReadTest._testfunc_file[sE��	��,�,�t�T�*�C�
�I�I�K��� � �	��I�I�K�K��	�s�)�A�A�Ac��	t|d�5}tj|||��}ddd�j�y#1swY�xYw#tj$r}|j	�Yd}~yd}~wwxYw)Nrs�r/)r&r'rKrr�)rr�rrPrHr�s      r�_testfunc_fileobjz DetectReadTest._testfunc_fileobjcse��	��d�D�!�
:�Q��l�l�4��q�9��
:�

�I�I�K�
:�
:��� � �	��I�I�K�K��	�s-�A�A�A�A	�A�A9�A4�4A9c���|j�r2|jtj�5tjt
d|jz��ddd�|jtj�5tjt
d|jz��ddd�|jtj�5tj|j
d��ddd�|jtj�5tj|j
d��ddd�||j
d�||j
d|jz�||j
d�||j
d|jz�||j
d�y#1swY��fxYw#1swY��#xYw#1swY��xYw#1swY��xYw)NrBr�r�r`zr:*�r|*)rr
r'rr&r#)r�testfuncs  r�_test_modeszDetectReadTest._test_modeslsW���;�;��"�"�7�#4�#4�5�
?����W�4�$�+�+�+=�>�
?��"�"�7�#4�#4�5�
?����W�4�$�+�+�+=�>�
?��"�"�7�#4�#4�5�
6����T�\�\��5�
6��"�"�7�#4�#4�5�
6����T�\�\��5�
6�����s�#�����t�d�k�k�1�2�����u�%�����t�d�k�k�1�2�����u�%�
?�
?��
?�
?��
6�
6��
6�
6�s/�)F:�=)G�
"G�"G �:G�G�G� G)c�:�|j|j�yr
)r�r�rs r�test_detect_filezDetectReadTest.test_detect_file|s������,�,�-rc�:�|j|j�yr
)r�r�rs r�test_detect_fileobjz"DetectReadTest.test_detect_fileobjs������/�/�0rN)r r!r"r�r�r�r�r�r+rrr�r�Zs����&� .�1rr�c��eZdZy)�GzipDetectReadTestNr�r+rrr�r��r�rr�c��eZdZd�Zy)�Bz2DetectReadTestc��ttd�5}|j�}ddd�tjt
dd��5}|j
�ddd�|jt
d�y#1swY�VxYw#1swY�,xYw)Nrsr�rt��
compresslevelr�)r&r#rTr5r7r�rr�r�s   r�test_detect_stream_bz2z(Bz2DetectReadTest.test_detect_stream_bz2�sw��
�'�4�
 �	�D��9�9�;�D�	��[�[��$�a�
8�	�D��J�J�t��	�	
���G�U�+�	�	��	�	�s�A7�B�7B�BN)r r!r"r�r+rrr�r��s��,rr�c��eZdZy)�LzmaDetectReadTestNr�r+rrr�r��r�rr�c��eZdZ	d�Zy)� GzipBrokenHeaderCorrectExceptionc���tjd�}|jtj�5tj
|d��ddd�y#1swYyxYw)Ns�zr|gzr.)r$r�r
r'rr&)rrPs  r�runTestz(GzipBrokenHeaderCorrectException.runTest�sN���J�J�
�
���
�
�w�0�0�
1�	1��L�L���0�	1�	1�	1�s�A�AN)r r!r"r�r+rrr�r��s���
1rr�c��eZdZdd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d	�Z
d
�Zd�Zd�Z
d
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zy)�MemberReadTestNc	��|�[|jj|�5}|jt|j	��|d|j
z�ddd�d|d<d|d<d|d<d|j
vr
d	|d
<d	|d<|j
�D]2\}}|jt||�|d|�d
|j
����4y#1swY�vxYw)N�wrong sha256sum for %sr]r^��r�r�r�zold-v7r'r`�gnamezwrong value in z
 field of )rHrSrUrrTr��itemsr6)rrZ�chksum�kwargsrP�k�vs       r�_test_memberzMemberReadTest._test_member�s��������%�%�g�.�
A�!�� � ��1�6�6�8�!4�f�0�7�<�<�?�A�
A�'��w����u�
���u�
��7�<�<�'�'�F�7�O�'�F�7�O��L�L�N�	I�D�A�q����W�W�a�0�!�78�'�,�,�G�
I�	I�
A�
A�s�8C�Cc�j�|jjd�}|j|dt��y)NrP�c�rWr��rHrRr�rXrWs  r�test_find_regtypez MemberReadTest.test_find_regtype�s+���(�(�$�$�_�5�����'��^��Drc�j�|jjd�}|j|dt��y)Nzustar/conttyper�rrrWs  r�test_find_conttypez!MemberReadTest.test_find_conttype�s,���(�(�$�$�%5�6�����'��^��Drc�`�|jjd�}|j|d��y)Nr�r�rW�rHrRr�rWs  r�test_find_dirtypez MemberReadTest.test_find_dirtype�s)���(�(�$�$�_�5�����'���*rc�`�|jjd�}|j|d��y)Nzustar/dirtype-with-size�rrrWs  r�test_find_dirtype_with_sizez*MemberReadTest.test_find_dirtype_with_size�s*���(�(�$�$�%>�?�����'���,rc�b�|jjd�}|j|dd��y)Nr�rrP�rW�linknamerrWs  r�test_find_lnktypez MemberReadTest.test_find_lnktype�s+���(�(�$�$�_�5�����'��O��Drc�b�|jjd�}|j|dd��y)Nr�rr�r
rrWs  r�test_find_symtypez MemberReadTest.test_find_symtype�s+���(�(�$�$�_�5�����'��I��>rc�d�|jjd�}|j|ddd��y)Nz
ustar/blktyper��rW�devmajor�devminorrrWs  r�test_find_blktypez MemberReadTest.test_find_blktype��-���(�(�$�$�_�5�����'��A���Brc�d�|jjd�}|j|ddd��y)Nz
ustar/chrtyperrtrrrrWs  r�test_find_chrtypez MemberReadTest.test_find_chrtype�rrc�`�|jjd�}|j|d��y)Nzustar/fifotyperrrrWs  r�test_find_fifotypez!MemberReadTest.test_find_fifotype�s*���(�(�$�$�%5�6�����'���*rc�j�|jjd�}|j|dt��y)Nzustar/sparse�Pr�rHrRr��
sha256_sparserWs  r�test_find_sparsezMemberReadTest.test_find_sparse�s+���(�(�$�$�^�4�����'��m��Drc�j�|jjd�}|j|dt��y)N�
gnu/sparserrrrWs  r�test_find_gnusparsez"MemberReadTest.test_find_gnusparse�s+���(�(�$�$�\�2�����'��m��Drc�j�|jjd�}|j|dt��y)N�gnu/sparse-0.0rrrrWs  r�test_find_gnusparse_00z%MemberReadTest.test_find_gnusparse_00��,���(�(�$�$�%5�6�����'��m��Drc�j�|jjd�}|j|dt��y)N�gnu/sparse-0.1rrrrWs  r�test_find_gnusparse_01z%MemberReadTest.test_find_gnusparse_01�r(rc�j�|jjd�}|j|dt��y)N�gnu/sparse-1.0rrrrWs  r�test_find_gnusparse_10z%MemberReadTest.test_find_gnusparse_10�r(rc�j�|jjd�}|j|dt��y)Nuustar/umlauts-ÄÖÜäöüßr�rrrWs  r�test_find_umlautsz MemberReadTest.test_find_umlauts�s2���(�(�$�$�&D�E�����'��^��Drc�\�d}|j||jj��y)Naustar/12345/12345/12345/12345/12345/12345/12345/12345/12345/12345/12345/12345/12345/12345/12345/12345/12345/12345/12345/12345/12345/12345/12345/12345/12345/12345/12345/12345/12345/12345/12345/12345/12345/12345/12345/12345/12345/12345/12345/1234567/longname)r�rHr)rr�s  r�test_find_ustar_longnamez'MemberReadTest.test_find_ustar_longname�s"��<���
�
�d�D�H�H�-�-�/�0rc�j�|jjd�}|j|dt��y)Nzmisc/regtype-old-v7r�rrrWs  r�test_find_regtype_oldv7z&MemberReadTest.test_find_regtype_oldv7�s,���(�(�$�$�%:�;�����'��^��Drc��|jj�tj|j|j
d��|_|jj
d�}|j|dt��y)NrDrEupax/umlauts-ÄÖÜäöüßr�r)	rHrKr'r&r#rrRr�rXrWs  r�test_find_pax_umlautsz$MemberReadTest.test_find_pax_umlautss_���������<�<����4�9�9�)4�6����(�(�$�$�&D�E�����'��^��Drr
)r r!r"r�rrrrrrrrrr!r$r'r+r.r0r2r4r6r+rrr�r��so��I�"E�E�+�-�E�?�C�C�+�E�E�E�E�E�E�
1�E�Err�c�*�eZdZd�Zd�Zd�Zd�Zd�Zy)�LongnameTestc��|jdzdzdz}	|jj|�}|jjtjd�y#t$r|j	d�Y�HwxYw)Nr���123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/�longnamezlongname not foundzread longname as dirtype)	�subdirrHrRrZr��assertNotEqualrUr'rV)rr;rZs   r�test_read_longnamezLongnameTest.test_read_longnamesp���;�;��$�|�3�j�@��	,��h�h�(�(��2�G�	
���G�L�L�'�/�/�*�	,���	,��I�I�*�+�	,�s�A�A;�:A;c�
�|jdzdzdz}|jdzdzdz}	|jj|�}|jj|d�y#t$r|j	d�Y�:wxYw)Nr�r:r;�longlinkzlonglink not foundzlinkname wrong)r<rHrRrZr�rUr)rr;r@rZs    r�test_read_longlinkzLongnameTest.test_read_longlinks����;�;��$�|�3�j�@���;�;��$�|�3�j�@��	,��h�h�(�(��2�G�	
����)�)�8�5E�F���	,��I�I�*�+�	,�s�A%�%B�Bc���|jdzdzdz}|jj|�}|j}|jjj|�t
j|jjjd��}|jtj�5tjd|��ddd�y#1swYyxYw)Nr�r:r;izfoo.tar)r�r/)
r<rHrRrOr/ryr$r�rTr
r'rr&)rr;rZrOr[s     r�test_truncated_longnamez$LongnameTest.test_truncated_longnames����;�;��$�|�3�j�@���(�(�$�$�X�.�������������f�%��z�z�$�(�(�*�*�/�/��8�9��
�
�
�w�0�0�
1�	7��L�L�i��6�	7�	7�	7�s�9C�C#c��|jdzdzdz}|jj|�j}t	t
d�5}|j
|�tjj|jd�dd�}|j|j|j�ddd�y#1swYyxYw)Nr�r:r;rsrxrD�strict)r<rHrRrOr&r#ryr'r�frombufrTrUrU�longnametype)rr;rOr[rZs     r�test_header_offsetzLongnameTest.test_header_offset(s����;�;��$�|�3�j�@�����#�#�H�-�4�4��
�'�4�
 �	>�D��I�I�f���o�o�-�-�d�i�i��n�.9�8�E�G����W�\�\�4�+<�+<�=�		>�	>�	>�s
�A(B<�<Cc	��d}tj�5tjtd�5}|j
|_	t
j|�|j|�t
j|jd��	ddd�tjt�5}|j|j|��|j|j|jd���ddd�ddd�y#t
j|jd��wxYw#1swY��xYw#1swY�GxYw#1swYyxYw)Nzfaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/r�r�)r	r�r'r&r�r�rer�r�r��rstripr�rR�removesuffix)r�longdirrHs   r�test_longname_directoryz$LongnameTest.test_longname_directory3s��#��
�
�
�
!�
	O����g�s�+�
2�s�!�[�[��
�2��H�H�W�%��G�G�G�$��H�H�W�^�^�C�0�1�

2����g�&�
O�#��$�$�S�]�]�7�%;�<��$�$�S�]�]�7�3G�3G��3L�%M�N�
O�
	O�
	O���H�H�W�^�^�C�0�1��

2�
2��
O�
O��
	O�
	O�sS�E�D;�&D�+$D;�!E�1AE�E�&D8�8D;�;E	�E�E	�E�EN)r r!r"r>rArCrHrMr+rrr8r8
s��,�G�7�	>�
Orr8c�n�eZdZdZej
ZejZd�Z	d�Z
d�Zd�Zd�Z
ed��Zy)	�GNUReadTest�gnuc���|jj|td��tjjt|�}t
|d�5}|j�}ddd�|jt�td|z�|j�r?tj|�}|j|jdz|j�yy#1swY�|xYw)Nrr^rsr�rx)rHrcrdrerfrgr&rTrUrr �_fs_supports_holesry�
assertLess�	st_blocks�st_size)rr��filenamer[rr}s      r�_test_sparse_filezGNUReadTest._test_sparse_fileOs���������w�v��6��7�7�<�<���.��
�(�D�
!�	�T��9�9�;�D�	�����4��-�(�4�/�	1��"�"�$�����!�A��O�O�A�K�K�#�-�q�y�y�9�%�	�	�s�C�C(c�&�|jd�y)Nr#�rWrs r�test_sparse_file_oldz GNUReadTest.test_sparse_file_old[s�����|�,rc�&�|jd�y)Nr&rYrs r�test_sparse_file_00zGNUReadTest.test_sparse_file_00^������/�0rc�&�|jd�y)Nr*rYrs r�test_sparse_file_01zGNUReadTest.test_sparse_file_01ar]rc�&�|jd�y)Nr-rYrs r�test_sparse_file_10zGNUReadTest.test_sparse_file_10dr]rc��tjjd�r�tjjtd�}t|d�5}|jd�|jd�|j�ddd�tj|�}tj|�|jdz|jkSy#1swY�PxYw)N�linuxzsparse-testr�isxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxrxF)r�rxr_rerfrgrdr&ryrrryr	rjrTrU)r�r[r}s   rrRzGNUReadTest._fs_supports_holesgs����<�<�"�"�7�+��7�7�<�<���7�D��d�D�!�
 �T��	�	�$���
�
�;�'��
�
��	
 �
����
�A����T�"��K�K�#�%��	�	�1�2��
 �
 �s�3C�CN)r r!r"r<r'�GNUTYPE_LONGNAMErG�
GNU_FORMATr�rWrZr\r_ra�staticmethodrRr+rrrOrOBsJ��
�F��+�+�L�
�
�
�F�
:�-�1�1�1����rrOc�L�eZdZdZej
ZejZd�Z	d�Z
y)�PaxReadTest�paxc�>�tjtd��}	|jd�}|j	|j
d�|j	|jd�|j	|jjd�d�|jd�}|j	|j
d	�|j	|jd�|j	|jjd�d�|jd
�}|j	|j
d�|j	|jd�|j	|jjd�d�|j�y#|j�wxYw)NrDrm�pax/regtype1rr�zVENDOR.umlautsuÄÖÜäöüßzpax/regtype2rzpax/regtype3r')
r'r&r#rRrUr`r��pax_headers�getrK�rrHrZs   r�test_pax_global_headersz#PaxReadTest.test_pax_global_headers�sA���l�l�7�[�9��	��m�m�N�3�G����W�]�]�E�2����W�]�]�E�2����W�0�0�4�4�5E�F�;�
=��m�m�N�3�G����W�]�]�B�/����W�]�]�E�2����W�0�0�4�4�5E�F�;�
=��m�m�N�3�G����W�]�]�I�6����W�]�]�I�6����W�0�0�4�4�5E�F�;�
=�
�I�I�K��C�I�I�K�s�EF
�
Fc�z�tjtd��}	|jd�}|j	|j
d�|j	|jd�|j	|jd�|j	|jd�|j	t|j�t�|j	t|jd�d�|j	t|jd�d�|j�y#|j�wxYw)	NrDrmzpax/regtype4r��{g��^�A�atime�ctime)
r'r&r#rRrUrWr�r�r^rUrtrlrKrns   r�test_pax_number_fieldsz"PaxReadTest.test_pax_number_fields�s����l�l�7�[�9��
	��m�m�N�3�G����W�\�\�4�0����W�[�[�#�.����W�[�[�#�.����W�]�]�L�9����T�'�-�-�0�%�8����U�7�#6�#6�w�#?�@�,�O����U�7�#6�#6�w�#?�@�,�O��I�I�K��C�I�I�K�s�C:D(�(D:N)r r!r"r<r'�XHDTYPErG�
PAX_FORMATr�rortr+rrrhrh~s%��
�F��?�?�L�
�
�
�F��.
rrhc��eZdZd�Zd�Zy)�
WriteTestBasec���tj�}tj||j��5}|jtjd��ddd�|j|jd�|j�}~tj�|j|j�|j||j��y#1swY��xYw)Nr.rz#external fileobjs must never closed)
r$r�r'r&rrrr�r�r�r�
gc_collectrU)rr[rHrs    r�test_fileobj_no_closez#WriteTestBase.test_fileobj_no_close�s����z�z�|��
�\�\�$�T�Y�Y�
7�	0�3��K�K�����.�/�	0�������&K�L��}�}��������������%�����t�}�}��/�	0�	0�s�%C � C)c��tjt|j�5}tjd�}tj
tjz
|_|j|tjd|jz��ddd�|jtd�5}|jt|j��tj
dz�ddd�y#1swY�cxYw#1swYyxYw)Nrrrsrw)r'r&r�rr�
RECORDSIZE�	BLOCKSIZErWrr$r�rUrVrT)rrHrr[s    r�test_eof_markerzWriteTestBase.test_eof_marker�s���
�\�\�'�4�9�9�
-�	6������&�A��'�'�'�*;�*;�;�A�F��K�K��2�:�:�d�Q�V�V�m�4�5�	6�
�Y�Y�w��
%�	G�����S�����-�w�/A�/A�A�/E�F�	G�	G�	6�	6��
	G�	G�s�A.C5�1;D�5C>�D
N)r r!r"r{rr+rrrxrx�s
��
0�Grrxc���eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	e
jee
d�d	�d
��Zej d��Zd�Zd
�Zdd�Zej d��Zd�Zd�Zd�Zd�Zy)�	WriteTestrc��d}tjt|j�}	tj|�}|j|�|j
�tjt�}	|j|j�d|d�|j
�y#|j
�wxYw#|j
�wxYw)N�d0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789rz!failed to store 100 char filename)	r'r&r�rrrrKrUr)rr�rHrs    r�test_100_char_namezWriteTest.test_100_char_name�s���
!���l�l�7�D�I�I�.��	�����%�A��K�K��N��I�I�K��l�l�7�#��	����S�\�\�^�A�.��7�
9�
�I�I�K��
�I�I�K��
�I�I�K�s�&B-�8$C�-B?�Cc���tjt|j�}	tj
j
td�}t|d�5}|jd�ddd�|j|�|j�|jtj
jt�dd�y#1swY�_xYw#|j�wxYw)Nr&r��aaarztarfile is empty)
r'r&r�rrerfrgrdrr�rK�
assertGreater�getsize)rrHrfr[s    r�
test_tar_sizezWriteTest.test_tar_size�s����l�l�7�D�I�I�.��	��7�7�<�<���0�D��d�D�!�
#�T��
�
�6�"�
#��G�G�D�M��I�I�K����2�7�7�?�?�7�3�Q�"�	$�
#�
#��
�I�I�K�s#�0C�C�(C�C�C�C$c�<�tjt|j�}	tj
j
td�}t|d�5	ddd�|j|�}|j|jd�t|d�5}|jd�ddd�|j|�}|j|jd�|j�y#1swY��xYw#1swY�SxYw#|j�wxYw)Nr&r�rr�r)
r'r&r�rrerfrgrd�
gettarinforUrWrrK)rrHrfrZr[s     r�test_file_sizezWriteTest.test_file_size�s����l�l�7�D�I�I�.��	��7�7�<�<���0�D��d�D�!�
��
��n�n�T�*�G����W�\�\�1�-��d�D�!�
#�T��
�
�6�"�
#��n�n�T�*�G����W�\�\�1�-��I�I�K�
�
��

#�
#��

�I�I�K�s<�0D	�C1�AD	�C=�+5D	�1C:�6D	�=D�D	�	Dc���tjjtd�}tj|�	tjt|j�}	|j|�}|j|jd�|j�	tj|�y#|j�wxYw#tj|�wxYw)N�	directoryr)rerfrgrdr�r'r&r�rr�rUrWrKr	r��rrfrHrZs    r�test_directory_sizezWriteTest.test_directory_size�s����w�w�|�|�G�[�1��
�����	"��,�,�w��	�	�2�C�
��.�.��.��� � ����q�1��	�	���O�O�D�!���	�	����O�O�D�!�s#�$C	� -B4�
C	�4C�C	�	C c�L�tjjtd�}tj|�ttjj|d�d�j
�ttjj|d�d�j
�	tj
t|j�}	tjjd�5}ddg|_
|j|�ddd�g}|j�D]=}|j!tjj#|j$�d��?|j'|gd��|j
�	t)j*tjj|d��t)j*tjj|d��t)j,|�y#1swY��xYw#|j
�wxYw#t)j*tjj|d��t)j*tjj|d��t)j,|�wxYw)Nr��1r��2z
os.listdirrc)r�r�r�)rerfrgrdr�r&rKr'r�rr�r�r��return_valuer�r��append�splitr�rUr	rjr�)rrfrH�mock_listdir�paths�ms      r�test_ordered_recursionz WriteTest.test_ordered_recursions����w�w�|�|�G�[�1��
������R�W�W�\�\�$��
$�c�*�0�0�2��R�W�W�\�\�$��
$�c�*�0�0�2�	"��,�,�w��	�	�2�C�	
��]�]�(�(��6�"�,�14�c�
�L�-��G�G�D�M�"������)�<�A��L�L������q�v�v�!6�r�!:�;�<�� � ��(?�@��	�	�����R�W�W�\�\�$��4�5����R�W�W�\�\�$��4�5��O�O�D�!�"�"���	�	������R�W�W�\�\�$��4�5����R�W�W�\�\�$��4�5��O�O�D�!�s>�+$H&�H�/H�
A.H�8H&�H�
H�H#�#H&�&A=J#c�@�tjt|j�5}t	j
t�dz}t|d�5}|jd�ddd�|j|�}|jtj|��}|j|jt�|j|j|j�|j|jd�ddd�y#1swY��xYw#1swYyxYw)Nr&r�r�r)r'r&r�rr�r�rdrr�rerFr0r�r1rUrW)rrHrfr[rZ�tarinfo2s      r�test_gettarinfo_pathlike_namez'WriteTest.test_gettarinfo_pathlike_name$s���
�\�\�'�4�9�9�
-�	.���<�<��(�6�1�D��d�D�!�
#�T��
�
�6�"�
#��n�n�T�*�G��~�~�b�i�i��o�6�H��!�!�'�,�,��4����W�\�\�8�=�=�9����W�\�\�1�-�	.�	.�
#�
#��	.�	.�s$�)D�D� BD�D	�
D�Drerfc�@�tjjtd�}tjjtd�}t	|d�5}|jd�ddd�	tj||�	tjt|j�}	|j|�|j|�}|j|jd�|j�	t!j"|�t!j"|�y#1swY��xYw#t$r}|jd|z�Yd}~��d}~wwxYw#|j�wxYw#t!j"|�t!j"|�wxYw)Nre�link_targetr�r��
os.link(): %sr)rerfrgrdr&rre�PermissionErrorr�r'r�rr�rUrWrKr	rj)rre�targetr[r�rHrZs       r�test_link_sizezWriteTest.test_link_size/s+���w�w�|�|�G�V�,�������g�}�5��
�&�$�
�	�4��J�J�v��	�	/��G�G�F�D�!�	#��,�,�w��	�	�2�C�
����v�&��.�.��.��� � ����q�1��	�	�����V�$����T�"�#	�	���	/��M�M�/�A�-�.�.��	/���	�	������V�$����T�"�sH�D&�0D2�$E1�,>E�*E1�&D/�2	E�;E�E�E.�.E1�1,Fc���tjjtd�}tjd|�	tjt|j�}	|j|�}|j|jd�|j�	tj|�y#|j�wxYw#tj|�wxYw)N�symlinkr�r)rerfrgrdr�r'r&r�rr�rUrWrKr	rjr�s    r�test_symlink_sizezWriteTest.test_symlink_sizeGs����w�w�|�|�G�Y�/��
�
�
�=�$�'�	#��,�,�w��	�	�2�C�
��.�.��.��� � ����q�1��	�	�����T�"���	�	������T�"�s#�$C
�!-B5�C
�5C�C
�
C!c�<�tjjt�}t	j
t|j�}	|j|j|d�|j|�|j|j�gd�tjt�5|j|�ddd�|j|j�gd�|j�y#1swY�;xYw#|j�wxYw)Nzarchive name must be absolutezadded the archive to itself)rerfr2r�r'r&rrUr�r�rr	�
change_cwdrdrK)r�dstnamerHs   r�
test_add_selfzWriteTest.test_add_selfUs����'�'�/�/�'�*���l�l�7�D�I�I�.��	����S�X�X�w�3�
5��G�G�G�����S�\�\�^�R�1�
3��%�%�g�.�
!����� �
!����S�\�\�^�R�1�
3�
�I�I�K�
!�
!��

�I�I�K�s%�	A(D	�1C=�)D	�=D�D	�	Dc���tjjtd�}tj|�	dD]7}tjj||�}tj|��9d�}tjt|jd��}	|j|d|��|j�|jt�5|j|ddd|�ddd�tjtd	�}	|D]:}|j|j d
�|j|j"d��<|jt%|j'��d�|j�	tj(|�y#|j�wxYw#1swY��xYw#|j�wxYw#tj(|�wxYw)
Nr_)rr��bazc�|�tjj|j�dk(ryd|_d|_|S)Nr�rqr)rerf�basenamer�r�r`r�s rr_z%WriteTest.test_filter.<locals>.filteros3���7�7�#�#�G�L�L�1�U�:��!��� %��
��rrDrm�	empty_dir)�arcnamer_Tr`rqrr)rerfrgrdr�r	�create_empty_filer'r&r�rr�rKr
�	TypeErrorrUr�r`rVr�r|)r�tempdirr�r_rHrZs      r�test_filterzWriteTest.test_filtergs}���'�'�,�,�w��1��
�����	&�-�
2���w�w�|�|�G�T�2���+�+�D�1�
2�
��,�,�w��	�	�K�H�C�
������V��D��	�	���"�"�9�-�
B������d�D�&�A�
B��,�,�w��,�C�
�"�;�G��$�$�W�[�[�#�6��$�$�W�]�]�E�:�;�� � ��S�^�^�%5�!6��:��	�	�����W�%���	�	���
B�
B���	�	������W�%�sU�A%G�!F"�5%G�F7�0"G�A(G�;G�"F4�4G�7G�<G�G�G�G/Nc���tjjtd�}|st	j
|�ntj|�tjt|j�}	|j||��|j�tjtd�}	|j�}|j�|st	j|�nt	j|�|j!|j"|xs |j%tj&d��y#|j�wxYw#|j�wxYw)Nr�r�r`r�)rerfrgrdr	r�r�r'r&r�rr�rKrrjr�rUr�r�sep)rrf�cmp_path�dirrrHrs       r�_test_pathnamezWriteTest._test_pathname�s����g�g�l�l�7�E�*����'�'��,��H�H�S�M��l�l�7�D�I�I�.��	��G�G�C��G�&��I�I�K��l�l�7�C�(��	����
�A��I�I�K�����S�!��O�O�C� ��������!F�T�\�\�"�&�&�#�-F�G��
�I�I�K��
�I�I�K�s�7E�5E�E�E(c���tjjtd�}tjjtd�}tj|�	tjj|d�}tjj|d�}t|d�5}|j
d�ddd�tj||�tj
|d�5}|j|d��|j|d��ddd�tj
|d�	�5}	|j|d
��ddd�tj|�tj|�y#1swY��xYw#1swY�txYw#t$r|jd�Y�gwxYw#1swY�lxYw#tj|�tj|�wxYw)
N�testsymlinksztestsymlinks.tar�sourcer�r�z
something
r�rw�rhror�z&extractall failed with symlinked files)rerfrgrdr�r&rr�r'r�rn�OSErrorr�r	rjr|)rr��temparchive�source_file�target_filerPrHs       r�test_extractall_symlinksz"WriteTest.test_extractall_symlinks�s����'�'�,�,�w��7���g�g�l�l�7�,>�?��
�����	&��'�'�,�,�w�x�8�K��'�'�,�,�w�y�9�K��k�#�&�
'�!����
�&�
'��J�J�{�K�0����k�3�/�
8�3�����X��6�����Y��7�
8����k�a�8�
H�C�H��N�N��*9�#�;�
H�
���[�)����W�%�!
'�
'��
8�
8���H��I�I�F�G�H��
H�
H��
���[�)����W�%�ss�AG�+E?�=4G�1'F�G�7F7�9F�G�?F�G�F�G�F4�1F7�3F4�4F7�7G�<G�,G/c�$�|jd�|jtjjddd��|jtjjddd��|jtjjdd��|jtjjddd��|jtjjdddd��|jtjjdddd��|jtjjdddd��|jtjjdd��|jtjjddd��|jtjjdddd��|jtjjdddd��|jdtjztjzdz�|jdtjztjzdd��y)Nr�.r��..T)r�)r�rerfrgr�rs r�test_pathnameszWriteTest.test_pathnames�s������E�"����B�G�G�L�L���U�;�<����B�G�G�L�L���e�<�=����B�G�G�L�L��e�4�5����B�G�G�L�L��e�S�9�:����B�G�G�L�L��e�S�%�@�A����B�G�G�L�L��e�T�5�A�B����B�G�G�L�L��e�T�5�A�B����B�G�G�L�L��u�5�6����B�G�G�L�L��u�d�;�<����B�G�G�L�L��u�c�5�A�B����B�G�G�L�L��u�d�E�B�C����E�B�F�F�N�R�V�V�3�e�;�<����E�B�F�F�N�R�V�V�3�U���Erc��tjdk(r|jdd�y|jdd�|jdd�y)NrpzC:\foorz/fooz///foo)r�rxr�rs r�test_abs_pathnameszWriteTest.test_abs_pathnames�s>���<�<�7�"����	�5�1������.�����%�0rc�2�tjt�5tjt
|j�}	|jd�|j�tjt
d�}	|D]G}|jdk7s�|j|jjd�|j��I	|j�	ddd�y#|j�wxYw#|j�wxYw#1swYyxYw)Nr�r`z./)r	r�rdr'r&r�rr�rKr�r�r_�rrHrs   r�test_cwdzWriteTest.test_cwd�s���
�
!�
!�'�
*�
	��,�,�w��	�	�2�C�
�������	�	���,�,�w��,�C�
��I�A��v�v��}�������(9�(9�$�(?����H�I��	�	��
	�
	��
�	�	����	�	���
	�
	�sA�%D
�C#�*D
�<C8�7C8�	D
�#C5�5D
�8D
�
D
�
Dc
�h��tttfD]��G�fd�dtj�}|�}|j��5t
jt|j|tjddi��}ddd�|j|j���y#1swY�'xYw)Nc���eZdZdZ�fd�Zy)�8WriteTest.test_open_nonwritable_fileobj.<locals>.BadFileTc�0��|jr	d|_��y�NF)�first)rr�exctypes  �rrz>WriteTest.test_open_nonwritable_fileobj.<locals>.BadFile.write�s����z�z�%*��
�%�
�"rN)r r!r"r�r)r�s�r�BadFiler��s
�����&rr��nonr�)r/r�rl)
r��EOFError�RuntimeErrorr$r�r
r'r&r�rrvr�r�)rr�rPrHr�s    @r�test_open_nonwritable_fileobjz'WriteTest.test_open_nonwritable_fileobj�s������,�6�
	'�G�
&�"�*�*�
&��	�A��"�"�7�+�
A��l�l�7�D�I�I�q�*1�*<�*<�05�w�/?�A��
A�
���Q�X�X�&�
	'�
A�
A�s�	9B(�(B1	r�)r r!r"rr�r�r�r�r�r�r�r�r�rer�r	r�r�r�r�r�r�r�r�r�r�r+rrr�r��s���
�F��($�� "�"�,	.��X�����V�,�:�<�#�<�#�,�"�"�#�#�#��$"&�PH�:�"�"�&�#�&�4F�"1��"'rr�c��eZdZy)�
GzipWriteTestNr�r+rrr�r�r�rr�c��eZdZy)�Bz2WriteTestNr�r+rrr�r�r�rr�c��eZdZy)�
LzmaWriteTestNr�r+rrr�r�	r�rr�c���eZdZdZdZd�Zejejdk7xr	e
ed�d�eje
jxse
jd�d���Zy)	�StreamWriteTest�w|Nc�>�tjt|j�}|j	�|j
rg|j�}ttd�5}|j
�}ddd�|j�}|j|jd�n.|jt�5}|j
�}ddd�|jjd�tjd�y#1swY��xYw#1swY�FxYw)Nrszfound trailing datarzincorrect zero padding)
r'r&r�rrK�decompressorrT�
decompressr��unused_datarU�countr})rrH�decr[rs     r�test_stream_paddingz#StreamWriteTest.test_stream_paddings����l�l�7�D�I�I�.���	�	������#�#�%�C��g�t�$�
#���y�y�{��
#��>�>�$�'�D����S�_�_�.C�D����7�#�
#�t��y�y�{��
#�������E�*�G�,>�,>�0�	2�
#�
#��

#�
#�s�!D�=D�D�Drp�umaskzMissing umask implementationz$Emscripten's/WASI's umask is a stub.c���tjjt�rt	j
t�tjd�}	tjt|j�}|j�tjt�jdz}|j|dd�tj|�y#tj|�wxYw)N�rqi�zwrong file permissions)rerf�existsr�r	rjr�r'r&rrKryrzrU)r�original_umaskrHrs    r�test_file_modezStreamWriteTest.test_file_mode"s����7�7�>�>�'�"����W�%����%���	%��,�,�w��	�	�2�C��I�I�K��7�7�7�#�+�+�e�3�D����T�5�*B�C��H�H�^�$��B�H�H�^�$�s
�A-C�C-)r r!r"rr�r�r�r�r�rxr�rer�r�
is_emscripten�is_wasir�r+rrr�r�
st��
�F��L�2� �X�������0�I�W�R��5I�7�9��X�_�_����0����.��
%�	�9�
%rr�c��eZdZd�Zy)�GzipStreamWriteTestc��	tjt|j�j	�tjt�jd��}y)Nzlatin-1rm)r'r&r�rrKr�r��	read_text)r�payloads  r� test_source_directory_not_leakedz4GzipStreamWriteTest.test_source_directory_not_leaked9s@��	�	���W�d�i�i�(�.�.�0��,�,�w�'�1�1�9�1�E�rN)r r!r"r�r+rrr�r�8s��7rr�c�.�eZdZer
ejZydZy)�Bz2StreamWriteTestN)r r!r"r5�BZ2Decompressorr�r+rrr�r�Cs��*-�3�&�&�L�4�Lrr�c�.�eZdZer
ejZydZy)�LzmaStreamWriteTestN)r r!r"r=�LZMADecompressorr�r+rrr�r�Fs��,0�4�(�(�L�d�Lrr�c�"�eZdZdZd�Zd�Zd�Zy)�_CompressedWriteTestsFAnd we move to Bristol where they have a special, Very Silly candidatec�,�tj�}tjt|j
||��5}|j
tjd�tj|j��ddd�|S#1swY|SxYw)Nr�r)	r$r�r'r&r�rrrr�)rr�r[�tarfls    r�_compressed_tarz$_CompressedWriteTest._compressed_tarOsn���z�z�|��
�\�\�'�4�9�9�d�(5�7�	K�:?��M�M�'�/�/�%�0�"�*�*�T�[�[�2I�J�	K���	K���s�AB	�	Bc�r�|j|�}|j|j�ddd|z�y)NrrvsBZh%d1AY&SY�rrUr��rr�r[s   r�_test_bz2_headerz%_CompressedWriteTest._test_bz2_headerVs7���#�#�M�2����������2�.�'�-�7�	9rc�l�|j|�}|j|j�ddd�y)Nrs�rrs   r�_test_gz_headerz$_CompressedWriteTest._test_gz_header[s/���#�#�M�2����������!�,�o�>rN)r r!r"r�rrrr+rrr�r�Is��&�F��9�
?rr�c��eZdZdZd�Zy)�Bz2CompressWriteTestrc�j�|jd�|jd�|jd�y�Nrt��	�rrs r�test_compression_levelsz,Bz2CompressWriteTest.test_compression_levelsa�,�����a� ����a� ����a� rN�r r!r"rrr+rrr	r	_s��
�F�!rr	c��eZdZdZd�Zy)�Bz2CompressStreamWriteTestr�c�j�|jd�|jd�|jd�yrrrs rrz2Bz2CompressStreamWriteTest.test_compression_levelsirrNrr+rrrrfs��
�F�!rrc��eZdZdZd�Zy)�GzCompressWriteTestrc�j�|jd�|jd�|jd�yr�rrs rrz+GzCompressWriteTest.test_compression_levelsp�,�����Q�����Q�����Q�rNrr+rrrrns��
�F� rrc��eZdZdZd�Zy)�GzCompressStreamWriteTestr�c�j�|jd�|jd�|jd�yrrrs rrz1GzCompressStreamWriteTest.test_compression_levelsxrrNrr+rrrrus��
�F� rrc�@�eZdZd�Zej
�d��Zy)�CompressLevelRaisesc��d}tj�}|jt�5t	j
td||��ddd�y#1swYyxYw)Nrrr�)r$r�r
r�r'r&r�rs   r�test_compresslevel_wrong_modesz2CompressLevelRaises.test_compresslevel_wrong_modes~sK���
��z�z�|��
�
�
�y�
)�	K��L�L��$��M�J�	K�	K�	K�s�A�Ac���tj�}|jt�5t	j
td|d��ddd�|jt�5t	j
td|d��ddd�|jt�5t	j
td|d��ddd�y#1swY��xYw#1swY�QxYw#1swYyxYw)Nzw:bz2rr�rvzw|bz2)r$r�r
rKr'r&r�r�s  r�test_wrong_compresslevelsz-CompressLevelRaises.test_wrong_compresslevels�s����z�z�|��
�
�
�z�
*�	B��L�L��'�4�q�A�	B�
�
�
�z�
*�	C��L�L��'�4�r�B�	C�
�
�
�z�
*�	C��L�L��'�4�r�B�	C�	C�		B�	B��	C�	C��	C�	C�s#�C�%C� C�C�C�C(N)r r!r"r r�requires_bz2r"r+rrrr}s)��K��W����C��Crrc�X�eZdZd�Zdd�Zdd�Zd�Zd�Zd�Zd�Z	d	�Z
d
�Zd�Zd�Z
d
�Zy)�GNUWriteTestc�.�t|�dzdz}|dzS)Nrxrt)rV)rr}�blockss   r�_lengthzGNUWriteTest._length�s���Q��3���"����|�rNc���d}t|�tjkDr|dz
}||j|�z
}|�5t|�tjkDr|dz
}||j|�z
}|S)Nrx)rVr'�LENGTH_NAMEr(�LENGTH_LINK)rr�rer�s    r�
_calc_sizezGNUWriteTest._calc_size�sm�����t�9�w�*�*�*��S�L�E��T�\�\�$�'�'�E����D�	�G�,?�,?� ?��S�L�E��T�\�\�$�'�'�E��rc��tj|�}|r||_tj|_tj
td�}	tj|_|j|�|j||�}|j}|j||d�|j�tj
t�}	|j�}|j|d�|j|j |j d�|j|j|jd�|j�y#|j�wxYw#|j�wxYw)Nr�z%GNU longname/longlink creation failedzunable to read longname member)r'rr�LNKTYPErUr&r�rer�rr,rOrUrKrr�r�)rr�rerZrHr�r��members        r�_testzGNUWriteTest._test�s���/�/�$�'���#�G��"�?�?�G�L��l�l�7�C�(��	� �+�+�C�J��K�K�� �����t�,�B����B����R��%L�M��I�I�K��l�l�7�#��		��X�X�Z�F�� � ��4�
6����W�\�\�6�;�;�4�
6����W�-�-�v���4�
6�
�I�I�K��
�I�I�K��
�I�I�K�s�AE�A0E&�E#�&E8c�&�|jd�y)N�longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam�r0rs r�test_longname_1023zGNUWriteTest.test_longname_1023�s���
�
�1�2rc�&�|jd�y)N�longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnamer3rs r�test_longname_1024zGNUWriteTest.test_longname_1024�s���
�
�2�3rc�&�|jd�y)N�longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longnam/longname_r3rs r�test_longname_1025zGNUWriteTest.test_longname_1025�s���
�
�3�4rc�(�|jdd�y)Nr��longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnkr3rs r�test_longlink_1023zGNUWriteTest.test_longlink_1023�s���
�
�6�9�:rc�(�|jdd�y)Nr��longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlinkr3rs r�test_longlink_1024zGNUWriteTest.test_longlink_1024�s���
�
�6�:�;rc�(�|jdd�y)Nr��longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlnk/longlink_r3rs r�test_longlink_1025zGNUWriteTest.test_longlink_1025�s���
�
�6�;�<rc�(�|jdd�y)Nr2r<r3rs r�test_longnamelink_1023z#GNUWriteTest.test_longnamelink_1023�s���
�
�1�1�	3rc�(�|jdd�y)Nr6r?r3rs r�test_longnamelink_1024z#GNUWriteTest.test_longnamelink_1024�s���
�
�2�2�	4rc�(�|jdd�y)Nr9rBr3rs r�test_longnamelink_1025z#GNUWriteTest.test_longnamelink_1025�s���
�
�3�3�	5rr
)r r!r"r(r,r0r4r7r:r=r@rCrErGrIr+rrr%r%�s>�����:3�4�5�;�<�=�3�4�5rr%c��eZdZdZd�Zy)�DeviceHeaderTestrc�8�tjjtd�}tj|�	tjt|j�}	tjd��}tjd��}t
j|_t
j|_|j|�|j|�|j�tjtd�}	|jd�}|jd�}|j�|j!|j"d�|j!|j$d�|j!|j"d�|j!|j$d�t
td�5}|j'�}ddd�|j(|j*}	||j(|j*}
t-dd	�}|j!|	|d
�|j!|
|d�t/j0|�y#|j�wxYw#|j�wxYw#1swY��xYw#t/j0|�wxYw)N�device_header_test�my_block_device�r��my_regular_filer`rrsiIiYs00000000000000s)rerfrgrdr�r'r&r�rr�BLKTYPErU�REGTYPErrKrRrUrrrTrO�offset_data�slicer	r|)rr�rH�	input_blk�	input_reg�
output_blk�
output_reg�infiler��buf_blk�buf_reg�device_headerss            r�*test_headers_written_only_for_device_filesz;DeviceHeaderTest.test_headers_written_only_for_device_files�s����'�'�,�,�w�(<�=��
�����#	&��,�,�w��	�	�2�C�
�#�O�O�1B�C�	�#�O�O�1B�C�	�!(���	��!(���	�����I�&����I�&��	�	���,�,�w��,�C�
� �]�]�+<�=�
� �]�]�+<�=�
��	�	�����Z�0�0�!�4����Z�0�0�!�4����Z�0�0�!�4����Z�0�0�!�4��g�t�$�
$���k�k�m��
$��*�+�+�J�,B�,B�C�G��*�+�+�J�,B�,B�C�G�#�3��1�N����W�^�4�6F�G����W�^�4�j�A����W�%��3�	�	����	�	���
$�
$��
���W�%�sV�$J� A8I�*J�"I!�%BJ�5I6�A0J�I�J�!I3�3J�6I?�;J�JN)r r!r"rr]r+rrrKrK�s��
�F�'&rrKc��eZdZdZej
j
ed�Zd�Z	e
d��Ze
d��Zd�Z
d�Zd�Zd	�Zd
�Zd�Zy)
�
CreateTestzx:�
spameggs42c�6�tjt�yr
)r	rjr�rs rrIzCreateTest.setUps������!rc�|�t|jd�5}|jd�ddd�y#1swYyxYw)Nr�r�)r&�	file_pathr)�clsr[s  r�
setUpClasszCreateTest.setUpClasss3��
�#�-�-��
&�	�$��J�J�v��	�	�	�s�2�;c�B�tj|j�yr
)r	rjrc�rds r�
tearDownClasszCreateTest.tearDownClasss��������'rc��tjt|j�5}|j	|j
�ddd�|j
t�5}|j�}ddd�|jt�d�|jd|d�y#1swY�hxYw#1swY�FxYw�Nrtr`r)r'r&r�rr�rcr)rrUrVr��r�tobj�namess   r�test_createzCreateTest.test_create!s���
�\�\�'�4�9�9�
-�	%���H�H�T�^�^�$�	%��\�\�'�
"�	$�d��M�M�O�E�	$�����U��Q�'��
�
�l�E�!�H�-�
	%�	%��	$�	$�s�B(�B4�(B1�4B=c��tjt|j�5}|j	|j
�ddd�|j
t�5tjt|j�}ddd�|jt�5}|j�}ddd�|jt�d�|jd|d�y#1swY��xYw#1swY�txYw#1swY�RxYwrj)
r'r&r�rr�rcr
�FileExistsErrorr)rrUrVr�rks   r�test_create_existingzCreateTest.test_create_existing*s���
�\�\�'�4�9�9�
-�	%���H�H�T�^�^�$�	%��
�
��
/�	4��<�<�����3�D�	4��\�\�'�
"�	$�d��M�M�O�E�	$�����U��Q�'��
�
�l�E�!�H�-�	%�	%��	4�	4��	$�	$�s#�C*�%C6� D�*C3�6C?�Dc�d�|jtd�5}|j|j�ddd�|jt�5}|j	�}ddd�|jt
�d�|jd|d�y#1swY�hxYw#1swY�FxYw�N�xrtr`r)r)r�r�rcrrUrVr�rks   r�test_create_taropenzCreateTest.test_create_taropen6s���
�\�\�'�3�
'�	%�4��H�H�T�^�^�$�	%��\�\�'�
"�	$�d��M�M�O�E�	$�����U��Q�'��
�
�l�E�!�H�-�
	%�	%��	$�	$�s�B�B&�B#�&B/c��|jtd�5}|j|j�ddd�|j	t
�5|jtd�5	ddd�ddd�|jt�5}|j
�}ddd�|jt�d�|jd|d�y#1swY��xYw#1swY�|xYw#1swY��xYw#1swY�^xYwrs)
r)r�r�rcr
rprrUrVr�rks   r�test_create_existing_taropenz'CreateTest.test_create_existing_taropen?s���
�\�\�'�3�
'�	%�4��H�H�T�^�^�$�	%��
�
��
/�	����g�s�+�
��
�	��\�\�'�
"�	$�d��M�M�O�E�	$�����U��Q�'��
�
�l�E�!�H�-�	%�	%��
�
��	�	��	$�	$�s;�C�C0�'C$�)C0�C<�C!�$C-	�)C0�0C9�<Dc��tjtjt�|j
�5}|j
|jt�|j|jtjjt��|jtj|j��|j�}ddd�|jt!�d�|j#d|d�|j%t�5}|j�}ddd�|jt!|�d�|j#d|d�y#1swY��xYw#1swY�FxYwrj)r'r&r�r�r�rr0r�r1rUrerfr2r�rcrrVr�r)rks   r�test_create_pathlike_namez$CreateTest.test_create_pathlike_nameLs	��
�\�\�'�,�,�w�/����
;�	$�t��!�!�$�)�)�S�1����T�Y�Y�������(@�A��H�H�W�\�\�$�.�.�1�2��M�M�O�E�		$�
	
����U��Q�'��
�
�l�E�!�H�-�
�\�\�'�
"�	$�d��M�M�O�E�	$�����U��Q�'��
�
�l�E�!�H�-�	$�	$��	$�	$�s�BE+�!E7�+E4�7Fc���|jtjt�d�5}|j	|j
t�|j|j
tjjt��|jtj|j��|j�}ddd�|jt�d�|jd|d�|jt�5}|j�}ddd�|jt|�d�|jd|d�y#1swY��xYw#1swY�FxYwrs)r)r�r�r�r0r�r1rUrerfr2r�rcrrVr�rks   r�!test_create_taropen_pathlike_namez,CreateTest.test_create_taropen_pathlike_nameZs��
�\�\�'�,�,�w�/��
5�	$���!�!�$�)�)�S�1����T�Y�Y�������(@�A��H�H�W�\�\�$�.�.�1�2��M�M�O�E�		$�
	
����U��Q�'��
�
�l�E�!�H�-�
�\�\�'�
"�	$�d��M�M�O�E�	$�����U��Q�'��
�
�l�E�!�H�-�	$�	$��	$�	$�s�BE�E)�E&�)E2N)r r!r"rrerfrgrdrcrI�classmethodrerhrnrqrurwryr{r+rrr_r_sf��
�F������W�l�3�I�"������(��(�.�
.�.�.�.�.rr_c��eZdZd�Zy)�GzipCreateTestc��tjt|jd��5}|j	|j
�ddd�tjtdd��5}	ddd�y#1swY�0xYw#1swYyxYw)Nrtr�zr:gz�r'r&r�rr�rc�rrls  r�test_create_with_compresslevelz-GzipCreateTest.test_create_with_compresslevelksl��
�\�\�'�4�9�9�A�
>�	%�$��H�H�T�^�^�$�	%�
�\�\�'�6��
;�	�t��	�	�	%�	%��	�	���A2�'A>�2A;�>BN�r r!r"r�r+rrr~r~i���rr~c��eZdZd�Zy)�
Bz2CreateTestc��tjt|jd��5}|j	|j
�ddd�tjtdd��5}	ddd�y#1swY�0xYw#1swYyxYw)Nrtr��r:bz2r�r�s  rr�z,Bz2CreateTest.test_create_with_compressleveltsl��
�\�\�'�4�9�9�A�
>�	%�$��H�H�T�^�^�$�	%�
�\�\�'�7�!�
<�	���	�	�	%�	%��	�	�r�Nr�r+rrr�r�rr�rr�c��eZdZd�Zy)�LzmaCreateTestc��tjt|jd��5}|j	|j
�ddd�y#1swYyxYw)Nrt)�presetr�r�s  r�test_create_with_presetz&LzmaCreateTest.test_create_with_presets=��
�\�\�'�4�9�9�Q�
7�	%�4��H�H�T�^�^�$�	%�	%�	%�s�A�AN)r r!r"r�r+rrr�r�{s��%rr�c��eZdZdZdZdZy)�CreateWithXModeTestrtN)r r!r"rrurwr+rrr�r��s��
�F���#'� rr�rerfc�*�eZdZd�Zd�Zd�Zd�Zd�Zy)�HardlinkTestc�R�tjjtd�|_tjjtd�|_t
|jd�5}|jd�ddd�	tj|j|j
�tjtd�|_
|jj|j�y#1swY�yxYw#t$r}|jd|z�Yd}~�sd}~wwxYw)Nrr�r��foor�r�)rerfrgrdrr�r&rrer�r�r'r�rHr�)rr[r�s   rrIzHardlinkTest.setUp�s����7�7�<�<���/����7�7�<�<���/���
�$�(�(�D�
!�	�T��J�J�v��	�	/��G�G�D�H�H�d�h�h�'��<�<���-��������T�X�X��	�	��
�	/��M�M�/�A�-�.�.��	/�s$�)C3�*C?�3C<�?	D&�D!�!D&c��|jj�tj|j�tj|j
�yr
)rHrKr	rjrr�rs rrLzHardlinkTest.tearDown�s4��������������"�������"rc��|jj|j�}|j|jt
jd�y)Nzadd file as regular failed)rHr�rrUrUr'rRrWs  r�test_add_twicezHardlinkTest.test_add_twice�s9���(�(�%�%�d�h�h�/��������w���,�	.rc��|jj|j�}|j|jt
jd�y)Nzadd file as hardlink failed)rHr�r�rUrUr'r.rWs  r�test_add_hardlinkzHardlinkTest.test_add_hardlink�s7���(�(�%�%�d�h�h�/��������w���-�	/rc���d|j_|jj|j�}|j	|j
tjd�y)NTzdereferencing hardlink failed)rH�dereferencer�r�rUrUr'rRrWs  r�test_dereference_hardlinkz&HardlinkTest.test_dereference_hardlink�sC��#������(�(�%�%�d�h�h�/��������w���/�	1rN)r r!r"rIrLr�r�r�r+rrr�r��s��
�#�
.�/�
1rr�c�&�eZdZdd�Zd�Zd�Zd�Zy)�PaxWriteTestNc�p�tj|�}|r||_tj|_tj
tdtj��}	|j|�|j�tj
t�}	|r1|j�dj}|j||d�n0|j�dj}|j||d�|j�y#|j�wxYw#|j�wxYw)Nr��r�rzPAX longlink creation failedzPAX longname creation failed)
r'rrr.rUr&r�rvrrKr�rUr�)rr�rerZrH�l�ns       rr0zPaxWriteTest._test�s����/�/�$�'���#�G��"�?�?�G�L��l�l�7�C��0B�0B�C��	��K�K�� ��I�I�K��l�l�7�#��	���N�N�$�Q�'�0�0��� � ��q�*H�I��N�N�$�Q�'�,�,��� � ��q�*H�I��I�I�K��
�I�I�K��
�I�I�K�s�D�A#D#�D �#D5c�x�dddddd�}tjtdtj|��}	|j	tj
d��|j
�tjtd	�
�}	|j|j|�|j|j�dj|�|jj�D]o\}}|jt|�t�|jt|�t�|tjvs�W	tj||��q	|j
�y#|j
�wxYw#tt f$r|j#d�Y��wxYw#|j
�wxYw)
Nr��0z1.23�äöü�test)rr�r^r�r�r�)r�rlrDrmrz"unable to convert pax header field)r'r&r�rvrrrKrUrlr�r��assertIsNotrUrC�PAX_NUMBER_FIELDSr�rKr�)rrlrH�key�vals     r�test_pax_global_headerz#PaxWriteTest.test_pax_global_header�s`�����&� &�(���l�l�7�C��0B�0B�'�)��	��K�K�����/�0��I�I�K��l�l�7�[�9��
	����S�_�_�k�:����S�^�^�-�a�0�<�<�k�J��O�O�1�1�3�
H���S�� � ��c��E�2�� � ��c��E�2��'�3�3�3�H��1�1�#�6�s�;�
H�
�I�I�K��#
�I�I�K��&�z�2�H��	�	�"F�G�H��
�I�I�K�s<�$E,�B9F'�F�F'�,E>� F$�!F'�#F$�$F'�'F9c�t�ddd�}tjtdtjd��}	tj�}d|_d|_||_|j|�|j�tjtd�	�}	|j�d
}|j|j|�|j|j
d�|j|jd�|j�y#|j�wxYw#|j�wxYw)Nr�123)rfr�r�rD�r�rFr��rmrrq)r'r&r�rvrr�r�rlrrKr�rU)rrlrHrs    r�test_pax_extended_headerz%PaxWriteTest.test_pax_extended_header�s��� %�U�3���l�l�7�C��0B�0B�$/�1��	����!�A�#�A�F��A�E�'�A�M��K�K��N��I�I�K��l�l�7�[�9��	���� ��#�A����Q�]�]�K�8����Q�V�V�U�+����Q�U�U�C�(��I�I�K��
�I�I�K��
�I�I�K�s�:D�A'D%�D"�%D7c�.�tj�}d|_d|_d|_d|_d|_|j�}|j|d��}|j|dd�|j|d	t�|j|d	d
�|j|dd�|j|dd�|j|d
d�|j|dtd�zdztd�zdztd�zdztd�zdztd�zdztd�zdztd�z�tj�}d|_d|_d|_d|_d|_|j�}|j|d��}|j|dd�|j|d	d�|j|dd�|j|dd�|j|d
d�|j|dtd�zdztd�zdztd�zdzdzd ztd!�zd"ztd#�zd$ztd�zdztd�z�y)%Nrg�����@�@r�rq�|rDrmr�r^r�rWr�r�s././@PaxHeader�Vs90000000000000000000000000000002000000000000010205 xsustar00�s16 mtime=1000.1
i�r��as90000644000017300001740000000014400000001750006516 0ufoo㍴ld(	r�irs90000000000000000000000000000013000000000000010207 xs15 path=foo㍴
16 uid=16777216
s$16 gid=16777217
20 size=10000000000
s21 mtime=10000000000
i�sfoo?�`s90000644000000000000000000000000000000000000006540 0)
r'rr�r^rWr�r�r��create_pax_headerrUr0r>rC)rr�info�headers    r�test_create_pax_headerz#PaxWriteTest.test_create_pax_header
s���
�O�O�������������������z�z�|���$�$�T�K�$�@������f��u�-����d�7�m�S�1�����g���-�����f��s�+�����e��c�*�����e��c�*�������b�	�)�\�
]��C�j�
�)�
*�+0��:�
6�#�
#�&+�3�Z�
0�39�
9�<A��9�
E�]�	
]�
�C�j�
�
*�
*�
-2�#�J�
7�	8�
�O�O�������������������z�z�|���$�$�T�K�$�@������f��{�3�����g���*�����f��q�)�����e��a�(�����e��a�(�������b�	�)�\�
]��C�j�
�)�
*�,1�#�J�
7�<�
<�8�	
8�
(�
(�
*/�s��
4�
7>�
>�
AF�b�	�
J�]�

]��C�j�
�*�
*�-2�#�J�
7�	8rr
)r r!r"r0r�r�r�r+rrr�r��s���0�@�258rr�c�6�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	y)	�UnicodeTestc�&�|jd�y)NrD��_test_unicode_filenamers r�test_iso8859_1_filenamez#UnicodeTest.test_iso8859_1_filenameDs���#�#�K�0rc�&�|jd�y)N�utf7r�rs r�test_utf7_filenamezUnicodeTest.test_utf7_filenameGs���#�#�F�+rc�&�|jd�y)N�utf-8r�rs r�test_utf8_filenamezUnicodeTest.test_utf8_filenameJs���#�#�G�,rc���tjtd|j|d��}	d}|j	tj
|��|j
�tjt|��}	|j|j�dj|�|j
�y#|j
�wxYw#|j
�wxYw)Nr�rE�r�rF�errorsr�rmr)
r'r&r�r�rrrKrUr�r�)rrFrHr�s    rr�z"UnicodeTest._test_unicode_filenameMs����l�l�7�C����$,�X�?��	�!�D��K�K�����-�.��I�I�K��l�l�7�X�6��	����S�^�^�-�a�0�5�5�t�<��I�I�K��

�I�I�K��
�I�I�K�s�&B:�<-C�:C�C!c�v�tjtd|jdd��}	tj�}d|_|j
t|j|�d|_d|_	|j
t|j|�|j�y#|j�wxYw)Nr�r�rEr�r�r)r'r&r�r�rr�r
�UnicodeErrorrr`rKrns   r�test_unicode_filename_errorz'UnicodeTest.test_unicode_filename_error\s����l�l�7�C����$+�H�>��
	��o�o�'�G�)�G�L����l�C�K�K��A� �G�L�*�G�M����l�C�K�K��A��I�I�K��C�I�I�K�s�A+B&�&B8c���tjtddd��}	|D]�}|jt	|j
�t�|jt	|j�t�|jt	|j�t�|jt	|j�t���	|j�y#|j�wxYw)Nr`rDrE�rFr�)r'r&r#�assertIsrUr�r1rr`r�rKr�s   r�test_unicode_argumentz!UnicodeTest.test_unicode_argumentks����l�l�7�C�$/��B��	��
2���
�
�d�1�6�6�l�C�0��
�
�d�1�:�:�.��4��
�
�d�1�7�7�m�S�1��
�
�d�1�7�7�m�S�1�	
2�
�I�I�K��C�I�I�K�s�B+C�C.c�<�tjd�}d|_d|_tjt
d|jd��}	|j|�|j�tjt
d��}	|jd�}|j|jd�|j|jd�|jtjk7rt|j�tjt
d��}|jd�}|j|jd�|j|jd�|j�y#|j�wxYw#|j�wxYw)	Nrr�r�rD)rr�rFrmr�u	���)r'rr`r�r&r�r�rrKrRrUrv)rrrHs   r�test_uname_unicodezUnicodeTest.test_uname_unicodews"���O�O�E�"�� ��� ����l�l�7��T�[�[�$/�1��	��K�K��N��I�I�K��l�l�7�[�9��	��
�
�e�$�A����Q�W�W�n�5����Q�W�W�n�5��{�{�g�0�0�0��	�	���l�l�7�W�=���M�M�%�(��� � ����*>�?�� � ����*>�?��I�I�K��
�I�I�K��
�I�I�K�s�E4�	CF	�4F�	FN)
r r!r"r�r�r�r�r�r�r�r+rrr�r�Bs%��1�,�-�
�
�
�rr�c�d�eZdZejZd�Zd�Zd�Zd�Z	d�Z
d�Zdd�Zd	�Z
d
�Zdd�Zy)
�UstarUnicodeTestc��|jd�|jdt�|jd�|jdt�y�Nr��e01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890ud01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567ÿue012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678ÿ��_test_ustar_namerKrs r�test_unicode_name1z#UstarUnicodeTest.test_unicode_name1��B�����/�0����5�z�B����?�@����@�*�Mrc�R�|jd�|jdt�y�Nud012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345ÿÿue0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456ÿÿr�rs r�test_unicode_name2z#UstarUnicodeTest.test_unicode_name2��"�����A�B����B�J�Orc��|jd�|jdt�|jd�|jdt�y)Na01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234/0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789a0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123/40123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789u012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012ÿ/0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789u0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123ÿ/0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789r�rs r�test_unicode_longname1z'UstarUnicodeTest.test_unicode_longname1�sD�����N�O����N�PZ�[����P�Q����Q�S]�^rc�\�|jdt�|jdt�y)Nu01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901ÿ/20123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789u01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901ÿÿ/0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789r�rs r�test_unicode_longname2z'UstarUnicodeTest.test_unicode_longname2�s&�����P�R\�]����S�U_�`rc�~�|jdt�|jd�|jdt�y)Nu01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901ÿÿ/20123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789u01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234/01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567ÿu01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234/012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678ÿr�rs r�test_unicode_longname3z'UstarUnicodeTest.test_unicode_longname3�s5�����T�V`�a����^�_����_�ak�lrc�R�|jd�|jdt�y)Nu01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234/012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345ÿÿu01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234/0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456ÿÿr�rs r�test_unicode_longname4z'UstarUnicodeTest.test_unicode_longname4�s#�����`�a����a�cm�nrNc��tjtd|jd��5}tj|�}|�|j|�n|j
||j
|�ddd�|�Jtjtdd��5}|D]}|j||j�nddd�yy#1swY�VxYw#1swYyxYw)Nr�r�r�r`rm)	r'r&r�r�rrr
rUr��rr��excrHrs     rr�z!UstarUnicodeTest._test_ustar_name�s���
�\�\�'�3�t�{�{�W�
M�	7�QT�����%�A��{����A���!�!�#�s�{�{�A�6�	7��;����g�s�W�=�
����A��$�$�T�1�6�6�2���
�
��	7�	7��
�
�s�AC�%C�C
�Cc��|jd�|jdt�|jd�|jdt�yr���_test_ustar_linkrKrs r�test_unicode_link1z#UstarUnicodeTest.test_unicode_link1�r�rc�R�|jd�|jdt�yr�r�rs r�test_unicode_link2z#UstarUnicodeTest.test_unicode_link2�r�rc���tjtd|jd��5}tjd�}||_|�|j
|�n|j||j|�ddd�|�Jtjtdd��5}|D]}|j||j
�nddd�yy#1swY�VxYw#1swYyxYw)Nr�r�r�rr`rm)	r'r&r�r�rrrr
rUr�s     rr�z!UstarUnicodeTest._test_ustar_link�s���
�\�\�'�3�t�{�{�W�
M�	7�QT�����&�A��A�J��{����A���!�!�#�s�{�{�A�6�
	7��;����g�s�W�=�
����A��$�$�T�1�:�:�6���
�
��	7�	7��
�
�s�AC�%C�C�C r
)r r!r"r'r�r�r�r�r�r�r�r�r�r�r�r�r+rrr�r��sG��
�
!�
!�F�
N�P�_�a�m�
o��N�P�
rr�c�*�eZdZejZd�Zy)�GNUUnicodeTestc���dD]<\}}tjt|d��5}	|j|�}ddd��>y#t$r|jd�Y�'wxYw#1swY�ixYw)N))r�upax/bad-pax-���)rDupax/bad-pax-äöür�r�z%unable to read bad GNU tar pax header�r'r&r#rRrZr��rrFr�rHrs     r�test_bad_pax_headerz"GNUUnicodeTest.test_bad_pax_header�s���<�	G�N�H�d����g��%6�8�
G�;>�G��
�
�d�+�A�
G�
G�	G�� �G��I�I�E�F�G��	
G�
G��(�A#�A�A �A#�A � A#�#A,	N)r r!r"r'rer�r�r+rrr�r��s��
�
�
�F�Grr�c�.�eZdZejZdZd�Zy)�PAXUnicodeTestNc���dD]<\}}tjt|d��5}	|j|�}ddd��>y#t$r|jd�Y�'wxYw#1swY�ixYw)N))r�upax/hdrcharset-���)rDupax/hdrcharset-äöür�r�z)unable to read POSIX.1-2008 binary headerr�r�s     r�test_binary_headerz!PAXUnicodeTest.test_binary_header�s���?�	K�N�H�d����g��%6�8�
K�;>�K��
�
�d�+�A�
K�
K�	K�� �K��I�I�I�J�K��	
K�
K�r�)r r!r"r'rvr�r�r�r+rrr�r��s��
�
�
�F�#'��
Krr�c� �eZdZd�Zdd�Zd�Zy)�AppendTestBasec��t|_tjj	|j�r tj|j�yyr
)r�r#rerfr�r	rjrs rrIzAppendTestBase.setUp	s4�����
�7�7�>�>�$�,�,�'����T�\�\�*�(rc�n�tjtd��5}|jd�}d|_|j|�5}tj|j|�5}|j
||�ddd�ddd�ddd�y#1swY�xYw#1swY�xYw#1swYyxYw)NrDrmrPr)r'r&r#rRr�rSr)rr�srcrrPrHs      r�_create_testtarzAppendTestBase._create_testtar	s���
�\�\�'�K�
8�	&�C��
�
�o�.�A��A�F�����#�
&�q��\�\�$�,�,��5�&���K�K��1�%�&�
&�	&�	&�&�&��
&�
&��	&�	&�s;�*B+�!B�'B�:B�B+�B�B�B(	�$B+�+B4c��|jd|jz�|jtjtj
td�y)Nrr�)rrr
r'rr&r�rs r�test_append_compressedz%AppendTestBase.test_append_compressed	s7�����T�D�K�K�/�0����'�+�+�W�\�\�7�C�HrN)r)r r!r"rIrrr+rrr�r�	s��+�
&�Irr�c�h�eZdZdZdd�Zdgdfd�Zd�Zd�Zd�Zd�Z	d	�Z
d
�Zd�Zd�Z
d
�Zd�Zd�Zy)�
AppendTestNc��tj|jd|��5}|jtjd��ddd�y#1swYyxYw)Nr�r�r�)r'r&r#rr)rr/rHs   r�
_add_testfilezAppendTest._add_testfile	sB��
�\�\�$�,�,��W�
=�	0���K�K�����.�/�	0�	0�	0�s�%A�Ar�c��tj|j|��5}|j|j	�|�ddd�y#1swYyxYw)Nr�)r'r&r#rUr)rrmr/rHs    rr0zAppendTest._test#	sA��
�\�\�$�,�,��
8�	4�C����S�\�\�^�U�3�	4�	4�	4�s�!A�Ac�D�|j�|j�yr
)rr0rs r�test_non_existingzAppendTest.test_non_existing'	s�������
�
�rc��tj|jd�j�|j	�|j�y)Nr)r'r&r#rKrr0rs r�
test_emptyzAppendTest.test_empty+	s2�����T�\�\�4�(�.�.�0������
�
�rc��tjd�}|j|�|jd�|j	|��y)Nsrr�)r$r�rryr0r�s  r�test_empty_fileobjzAppendTest.test_empty_fileobj0	s7���z�z�,�'�����4� ��	�	�!���
�
�4�
� rc�2�|j�t|jd�5}|j�}ddd�t	j
�}|j
|�|jd�|jddg|��y#1swY�VxYw)Nrsrrr�)rmr/)	rr&r#rTr$r�rryr0r�s   r�test_fileobjzAppendTest.test_fileobj6	sy������
�$�,�,��
%�	���9�9�;�D�	��z�z�$������4� ��	�	�!���
�
�%����
�6�	�	�s�B
�
Bc�l�|j�|j�|jddg��y)Nrr�)rm)rrr0rs r�
test_existingzAppendTest.test_existing?	s,�����������
�
�%���
�(rc���t|jd�5}|j|�ddd�|jtj
|j�y#1swY�4xYwr)r&r#rr
r'rr)rrr[s   r�_test_errorzAppendTest._test_errorF	sO��
�$�,�,��
%�	���J�J�t��	����'�+�+�T�-?�-?�@�	�	�s�A�A%c�&�|jd�y)Nr�rrs r�	test_nullzAppendTest.test_nullK	s������rc�&�|jd�y)N�
rrs r�test_incompletezAppendTest.test_incompleteN	�������$rc�l�tjd�j�}|j|�y)Nr�r'rrr�rrs  r�test_premature_eofzAppendTest.test_premature_eofQ	s'�����u�%�+�+�-������rc�r�tjd�j�}|j|dz�y)Nrrrrs  r�test_trailing_garbagez AppendTest.test_trailing_garbageU	s,�����u�%�+�+�-������
�*�+rc�&�|jd�y)Nsaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaarrs r�test_invalidzAppendTest.test_invalidY	rrr
)r r!r"rrr0rr
rrrrrrr r"r$r+rrrr	sS��!��0�!�'�4�4���
!�7�)�A�
�%��,�%rrc��eZdZy)�GzipAppendTestNr�r+rrr&r&\	r�rr&c��eZdZy)�
Bz2AppendTestNr�r+rrr(r(_	r�rr(c��eZdZy)�LzmaAppendTestNr�r+rrr*r*b	r�rr*c��eZdZd�Zd�Zd�Zy)�
LimitsTestc��tjd�}|jtj�tjd�}|j	t
|jtj�tjd�}|jtj�tjd�}|j	t
|jtj�tjd�}|j	t
|jtj�tjd�}d|_|j	t
|jtj�tjd�}d|_|j	t
|jtj�y)	Nr�r�a123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/longnamea1234567/1234567/1234567/1234567/1234567/1234567/1234567/1234567/1234567/1234567/1234567/1234567/1234567/1234567/1234567/1234567/1234567/1234567/1234567/1234567/1234567/1234567/1234567/1234567/1234567/1234567/1234567/1234567/1234567/1234567/1234567/longname�123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/123/longnamer@r�� )r'rrr�r
rKrr�rWs  r�test_ustar_limitszLimitsTest.test_ustar_limitsh	s4���/�/�"3�4���
�
�g�*�*�+��/�/�"9�:�����*�g�m�m�W�5I�5I�J��/�/�":�;���
�
�g�*�*�+��/�/�">�?�����*�g�m�m�W�5I�5I�J��/�/�";�<�����*�g�m�m�W�5I�5I�J��/�/�*�-��4������*�g�m�m�W�5I�5I�J��/�/�&�)�� ������*�g�m�m�W�5I�5I�Jrc�x�tjd�}|jtj�tjd�}d|_|jtj�tjd�}d|_|j
t|jtj�y�Nr.r@r�l)r'rrrerr�r
rKrWs  r�test_gnu_limitszLimitsTest.test_gnu_limits�	s~���/�/�";�<���
�
�g�(�(�)��/�/�*�-��4����
�
�g�(�(�)��/�/�&�)��+������*�g�m�m�W�5G�5G�Hrc�X�tjd�}|jtj�tjd�}d|_|jtj�tjd�}d|_|jtj�yr2)r'rrrvrr�rWs  r�test_pax_limitszLimitsTest.test_pax_limits�	sr���/�/�";�<���
�
�g�(�(�)��/�/�*�-��4����
�
�g�(�(�)��/�/�&�)��+����
�
�g�(�(�)rN)r r!r"r0r3r5r+rrr,r,f	s��K�>I�
*rr,c�0�eZdZd�Zd�Zd�Zd�Zd�Zd�Zy)�MiscTestc�@�|jtjdddd�d�|jtjdddd�d�|jtjddd�d�|jtjd	dd�d�y)
Nr�r�rEsfoo�foobarrr�sfoobar)rUr'�stn�ntsrs r�test_char_fieldszMiscTest.test_char_fields�	s���������U�A�w��A�)�	+�������X�q�'�8�D��	!�������%5�w��I��	 �������]�G�X�F��	 rc��|jtjd�d�|jtjd�d�|jtjd�d�|jtjd�d�|jtjd	�d
�|jtjd�d�|jtjd
�d�|jtjd�d�|jtjd�d�y)N�0000001rt�7777777��� r/������������������rc�����������������rrs       )rUr'�ntirs r�test_read_number_fieldsz MiscTest.test_read_number_fields�	s���	
������^�4�a�8�������^�4�i�@�������%H�I�#�	%�������%H�I�#�	%�������%H�I��	�������%H�I��	�������%H�I�+�	-�	
������U�+�Q�/�������\�2�A�6rc��|jtjd�d�|jtjd�d�|jtjdtj��d�|jtjdtj��d	�|jtjd
tj��d�|jtjdtj��d
�|jtjdtj��d�|jtjdtj��d
�|jtjdtj��d�|jtjtjdtj���d�y)Nrtr?rAr@r/r�rBrDrCrcrErGrFrIrHgY�g0Bs�g��������r)rUr'�itnrerJrs r�test_write_number_fieldsz!MiscTest.test_write_number_fields�	sa��������Q���8�������Y�/��@�������Z��8J�8J�K�<�	>�������Z��8J�8J�K�<�	>�������R��0B�0B�C�<�	>�������T�'�2D�2D�E�<�	>�������%7�,3�,>�,>�@�<�	>�	
������V�G�4F�4F�G�<�	>�������]�7�;M�;M�N�<�	>�������W�[�[��g�>P�>P�%Q�R�TU�Vrc�|�|jt�5tjddtj�ddd�|jt�5tjddtj�ddd�|jt�5tjddtj
�ddd�|jt�5tjddtj
�ddd�y#1swY��xYw#1swY��xYw#1swY�exYw#1swYyxYw)Nrcr9r/l�����l)r
rKr'rMr�rers r�test_number_field_limitsz!MiscTest.test_number_field_limits�	s���
�
�
�z�
*�	5��K�K��A�w�3�3�4�	5�
�
�
�z�
*�	=��K�K�
�A�w�';�';�<�	=�
�
�
�z�
*�	?��K�K���7�+=�+=�>�	?�
�
�
�z�
*�	>��K�K�
�q�'�*<�*<�=�	>�	>�
	5�	5��	=�	=��	?�	?��	>�	>�s/�&D�&D�&D&�&D2�D�D#�&D/�2D;c�D�hd�}tj|t|��y)N>/�NUL�grprMrJr<�pwdr;�mainrQ�CHRTYPErVr.rR�SYMTYPE�XGLTYPEru�version�AREGTYPE�CONTTYPE�FIFOTYPE�filemoder~�	GNU_MAGIC�	GNU_TYPES�
PAX_FIELDSr}r+r*�POSIX_MAGIC�copyfileobj�ExFileObject�calc_chksums�
LENGTH_PREFIX�
REGULAR_TYPES�EOFHeaderError�GNUTYPE_SPARSE�PAX_NAME_FIELDS�SOLARIS_XHDTYPE�SUPPORTED_TYPES�EmptyHeaderError�GNUTYPE_LONGLINKrdr��symlink_exception�InvalidHeaderError�TruncatedHeaderError�SubsequentHeaderError)�not_exported)r�check__all__r')rrss  r�test__all__zMiscTest.test__all__�	s��=��	���T�7��Frc�,�tjjtjjt�d�}|jtj�5}t
jd�f}tjjjtjd|��5t
j|�ddd�ddd�|jdt!j"��y#1swY�7xYw#1swY�;xYw)Nrzlzma module is not availabler?)r�z?
- method xz: CompressionError('lzma module is not available')
)rerfrg�dirname�__file__r
r'r�CompressionErrorr�r�r�r�r(r&r�r1�	exception)r�fname�excinfor�s    r�.test_useful_error_message_when_modules_missingz7MiscTest.test_useful_error_message_when_modules_missing�	s��������R�W�W�_�_�X�6�8H�I��
�
�
�w�0�0�
1�	$�W��,�,�-K�L�M�E����$�$�+�+�G�O�O�X�SX�+�Y�
$����U�#�
$�	$�
	
�
�
�O���!�!�"�	
�
$�
$��	$�	$�s%�!AD
�2C>�D
�>D	�D
�
DN)	r r!r"r=rKrNrQrur}r+rrr7r7�	s"�� �7�(W�.>�
G�

rr7c��eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zy)�CommandLineTestc��tjddg|��i|��\}}}|jtjj�d�S)N�-mr'�
)r
�assert_python_okrre�linesepr�)r�argsr��rcr��errs      r�
tarfilecmdzCommandLineTest.tarfilecmd
sL��$�5�5�d�I�@��@�8>�@���C���{�{�2�:�:�,�,�.��6�6rc�0�tjddg|���S)Nr�r')r
�assert_python_failure)rr�s  r�tarfilecmd_failurez"CommandLineTest.tarfilecmd_failure
s���2�2�4��J�T�J�Jrc�f�tjdd��tjdd��g}|jtj|�tj|d�5}|D]2}|j|tjj|����4	ddd�y#1swYyxYw)N�tokenize_tests.txt�tokenizedata�r<�9tokenize_tests-no-coding-cookie-and-utf8-bom-sig-only.txtr�r�)rr"rir	rjr'r&r�rerfr�)r�tar_name�filesr��tardatas     r�make_simple_tarfilez#CommandLineTest.make_simple_tarfile
s����!�!�"6�)7�9��!�!�#>�)7�9�:��
	
���	�(�(�(�3�
�\�\�(�C�
(�	C�B� �
C�����w����(8�(8��(A��B�
C�	C�	C�	C�s�%8B'�'B0c��|jtj|�tj|d�5}tj
d�}|j
|tjd���tj
d�}|j
|tjd���ddd�y#1swYyxYw)Nr��benignrr��../evil)	rir	rjr'r&rrr$r�)rr�r�r��evils     r�make_evil_tarfilez!CommandLineTest.make_evil_tarfile
s������	�(�(�(�3�
�\�\�(�C�
(�	6�B��_�_�X�.�F��J�J�v�r�z�z�#��J�7��?�?�9�-�D��J�J�t�R�Z�Z��_�J�5�		6�	6�	6�s�A7B7�7Cc��|j�\}}}|j|d�|jd|j��|jd|j��|jd|j��|jdd�\}}}|j|d�|j	|j�d�y)Nrsusageserrorsrequired�-lr)r�rUr��lowerr=�strip)rr�r�r�s    r�test_bad_usezCommandLineTest.test_bad_use
s����.�.�0���C������c�"��
�
�h��	�	��,��
�
�h��	�	��,��
�
�k�3�9�9�;�/��.�.�t�R�8���C������c�"����C�I�I�K��-rc�p�tD]-}dD]&}|j||�}|j|d��(�/y)N)�-tz--testr)�testtarnamesr�rU�rr��optr�s    r�test_test_commandz!CommandLineTest.test_test_command%
s@��$�	+�H�%�
+���o�o�c�8�4��� � ��c�*�
+�	+rc�v�tD]0}dD])}|j|d|d��}|jd|��+�2y)N��-vz	--verboser�r���PYTHONIOENCODINGsis a tar archive.
)r�r�r�r�s    r�test_test_command_verbosez)CommandLineTest.test_test_command_verbose+
sL��$�	;�H�(�
;���o�o�c�4��7>�&�@���
�
�4�c�:�
;�	;rc���tjd�}|jd|�\}}}|jd|�|j	|d�|j	|d�t
D]�}|j
|��5t|d�5}|j�}ddd�	ttd�5}|jdd	�ddd�|jdt�\}}}|j	|d�|j	|d�tjt�	ddd���y#1swY��xYw#1swY�xxYw#tjt�wxYw#1swY��xYw)
N�
zipdir.zipr�� is not a tar archive.rrt)r�rsr�rq)
rr"r�r�rUr��subTestr&rTr�rr	rj)r�zipnamer�r�r�r�rPrs        r�test_test_command_invalid_filez.CommandLineTest.test_test_command_invalid_file2
sK���"�"�<�0���.�.�t�W�=���C���
�
�/��5�����c�"�����Q��$�	.�H����x��0�

.��(�D�)�$�Q��6�6�8�D�$�.��g�t�,�,������T�c�
�+�,�#'�#:�#:�4��#I�L�B��S��$�$�S�#�.��$�$�R��+��$�$�W�-�

.�

.�	.�$�$��,�,���$�$�W�-��

.�

.�sU�=
E*�
D4�E*�$E�4E�	AE�E*�4D=�9E*�E	�E�E'�'E*�*E4	c��tD]�}tj�5}tj|d�5}|jd��ddd�ddd�j
�jdd�}dD](}|j||d��}|j||��*��y#1swY�axYw#1swY�exYw)Nr`Fr�r�r�)r�z--listr��
r�r�captured_stdoutr'r&rpr�r�r�rU�rr�rr��expectedr�r�s       r�test_list_commandz!CommandLineTest.test_list_commandF
s���$�	0�H��(�(�*�
+�a��\�\�(�C�0�+�B��G�G�E�G�*�+�
+��z�z�|�*�*�7�4F�G�H�%�
0���o�o�c�8�7>�&�@��� � ��h�/�
0�	0�+�+��
+�
+�s"�B4�B(�B4�(B1�-B4�4B=	c��tD]�}tj�5}tj|d�5}|jd��ddd�ddd�j
�jdd�}dD])}|j|d|d��}|j||��+��y#1swY�bxYw#1swY�fxYw)	Nr`Tr�r�r�r�r�r�r�r�s       r�test_list_command_verbosez)CommandLineTest.test_list_command_verboseQ
s���$�	0�H��(�(�*�
*�a��\�\�(�C�0�*�B��G�G�D�G�)�*�
*��z�z�|�*�*�7�4F�G�H�(�
0���o�o�c�4��7>�&�@��� � ��h�/�
0�	0�*�*��
*�
*�s"�B5�B)�B5�)B2�.B5�5B>	c���tjd�}|jd|�\}}}|jd|�|j	|d�|j	|d�y)Nr�r�r�rrt)rr"r�r�rU�rr�r�r�r�s     r�test_list_command_invalid_filez.CommandLineTest.test_list_command_invalid_file\
sY���"�"�<�0���.�.�t�W�=���C���
�
�/��5�����c�"�����Q�rc��tjdd��tjdd��g}dD]x}	|j|tg|���}|j	|d�tjt�5}|j�ddd�tjt��zy#1swY�%xYw#tjt�wxYw)Nr�r�r�r�)�-cz--creater)
rr"r�r�rUr'r&r�r	rj�rr�r�r�rHs     r�test_create_commandz#CommandLineTest.test_create_commandc
s����!�!�"6�)7�9��!�!�#>�)7�9�:��
$�	*�C�
*�%�d�o�o�c�7�;�U�;��� � ��c�*��\�\�'�*�%�c��N�N�$�%�� � ��)�	*�%�%��� � ��)�s$�AB9�8B-�	B9�-B6	�2B9�9Cc��tjdd��tjdd��g}dD]|}	|j|dtg|��ddi�}|j	d	|�tjt�5}|j�ddd�tjt��~y#1swY�%xYw#tjt�wxYw)
Nr�r�r�r�r�r�r�r�s file created.)
rr"r�r�r�r'r&r�r	rjr�s     r�test_create_command_verbosez+CommandLineTest.test_create_command_verboser
s����!�!�"6�)7�9��!�!�#>�)7�9�:��
%�	*�C�
*�%�d�o�o�c�4��@�5�@�7>�@���
�
�/��5��\�\�'�*�%�c��N�N�$�%�� � ��)�	*�
%�%��� � ��)�s$�AB=�<B1�
B=�1B:	�6B=�=Cc�t�tjdd��g}	|jdtg|���}|j	|d�tjt�5}|j�ddd�tjt�y#1swY�#xYw#tjt�wxYw)Nr�r�r�r�r)
rr"r��dotlessnamerUr'r&r�r	rj)rr�r�rHs    r�$test_create_command_dotless_filenamez4CommandLineTest.test_create_command_dotless_filename�
s����!�!�"6�~�N�O��	*�!�$�/�/�$��<�e�<�C����S�#�&����k�*�
!�c���� �
!�
���[�)�
!�
!��
���[�)�s$�AB�B�.B�B�B�B7c��tjjtd�}t	j
dd��g}	|jd|g|���}|j|d�tj|�5}|j�ddd�tj|�y#1swY�xYw#tj|�wxYw)Nz.testtarr�r�r�r�r)
rerfrgrdrr"r�rUr'r&r�r	rj)rr�r�r�rHs     r�(test_create_command_dot_started_filenamez8CommandLineTest.test_create_command_dot_started_filename�
s����7�7�<�<���4���!�!�"6�~�N�O��	'�!�$�/�/�$��9�5�9�C����S�#�&����h�'�
!�3���� �
!�
���X�&�
!�
!��
���X�&�s#�;B4�9B(�
B4�(B1�-B4�4Cc���tjdd��tjdd��g}tttfD]y}|j
s�	tdz|jz}|jd|g|���}|j|�5}|j�ddd�tj|��{y#1swY�!xYw#tj�wxYw)Nr�r�r�r�r�r�)
rr"r-r4r:r&r�rr�r)r�r	rj)rr��filetyper�r�rHs      r�test_create_command_compressedz.CommandLineTest.test_create_command_compressed�
s����!�!�"6�)7�9��!�!�#>�)7�9�:��
"�7�H�5�		+�H��=�=��
+�"�S�=�8�?�?�:��%�d�o�o�d�H�=�u�=���%�%�h�/�%�3��N�N�$�%�� � ��*�		+�%�%��� � ��*�s$�;C	�B=�C	�=C	�C	�	C c�X�|jt�dD]f}	tjt�5|j|t�}ddd�|j
d�tjt��hy#1swY�7xYw#tjt�wxYw)N)�-ez	--extractr�r�r�r	r��	tarextdirr�rUr|�rr�r�s   r�test_extract_commandz$CommandLineTest.test_extract_command�
s���� � ��)�$�	,�C�
,��'�'�	�2�8��/�/�#�w�7�C�8�� � ��c�*�� � ��+�
	,�8�8��� � ��+�s"�B�B�B�B	�B�B)c�^�|jt�dD]i}	tjt�5|j|dtd��}ddd�|j
d�tjt��ky#1swY�7xYw#tjt�wxYw)Nr�r�r�r�� file is extracted.)r�r�r	r�r�r�r�r|r�s   r�test_extract_command_verbosez,CommandLineTest.test_extract_command_verbose�
s���� � ��)�$�	,�C�
,��'�'�	�2�D��/�/�#�t�W�;B�*�D�C�D��
�
�4�c�:�� � ��+�	,�D�D��
� � ��+�s"�B�B�B�B	�
B�B,c	��|jt�tjj	t
d�}tjt
�	tj|�5|jdtddd�|jdtdddd��}|jd	|�ddd�tjt
�y#1swY�#xYw#tjt
�wxYw)
N�destr�r�z--filterrror�r�r�)
r�r�rerfrgr�r�r	r�r�r�r�r|)r�destdirr�s   r�test_extract_command_filterz+CommandLineTest.test_extract_command_filter�
s������w�'��'�'�,�,�y�&�1��
�����	(��#�#�G�,�
;��'�'��g�(,�(2�F�<��o�o�d�G�&*�&0�/�7>�&�@���
�
�4�c�:�
;�
���Y�'�
;�
;��
���Y�'�s%�C�)AC�0C�C�C�C9c�L�|jt�	tjt�5|jdtd�}ddd�|j
d�tjt�y#1swY�5xYw#tjt�wxYw)Nr��spamdirrr�)rr�s  r�(test_extract_command_different_directoryz8CommandLineTest.test_extract_command_different_directory�
s}��� � ��)�	(��#�#�I�.�
@��o�o�d�G�Y�?��
@����S�#�&����Y�'�	
@�
@��
���Y�'�s"�B�A<�B�<B�B�B#c�"�tjd�}tjt�5|jd|�\}}}ddd�|j
d�|jd�|jd�y#1swY�@xYw)Nr�r�r�rrt)rr"r	r�r�r�r�rUr�s     r�!test_extract_command_invalid_filez1CommandLineTest.test_extract_command_invalid_file�
s����"�"�<�0��
�
�
�	�
*�	B��2�2�4��A�L�B��S�	B��
�
�/��5�����c�"�����Q��		B�	B�s�B�BN)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+rrrr�	sm��7�
K�	C�6�.�+�;�.�(	0�	0� �
*�*� *�	'�+�",�	,�(�&(� rrc�0�eZdZd�Zd�Zd�Zd�Zd�Zd�Zy)�ContextManagerTestc���tjt�5}|j|jd�ddd�|jjd�y#1swY�&xYw)Nzclosed inside runtime context�context manager failed)r'r&r#r�r�r�rs  r�
test_basiczContextManagerTest.test_basic�
sQ��
�\�\�'�
"�	J�c����S�Z�Z�)H�I�	J�����
�
�$<�=�	J�	J�s�A�A%c���tjt�}|j�|j	t
�5|5	ddd�ddd�y#1swY�xYw#1swYyxYwr
)r'r&r#rKr
r�rs  r�test_closedzContextManagerTest.test_closed�
s^���l�l�7�#���	�	��
�
�
�w�
'�	��
��
�	�	�
�
��	�	�s#�A!�A�A!�A	�A!�!A*c�.�|jt�5}tjt�5}t
�#1swYnxYw	ddd�n#1swYnxYw|j
jt
d�|jjd�y)Nz)wrong exception raised in context managerr�)
r
�	Exceptionr'r&r#r�r0rzr�r�)rr�rHs   r�test_exceptionz!ContextManagerTest.test_exception�
s~��
�
�
�y�
)�	�S����g�&�
�#��
�
�
��
�	�	�	��	
���c�m�m�W�I�	K�����
�
�$<�=s�A
�7�A	�A
�
Ac��	tjtd�5}t�#1swYnxYwn#YnxYw|j	t
jjt�dd�|jjd�y)Nr�rz-context manager wrote an end-of-archive blockr�)
r'r&r�r�rUrerfr�r�r�rs  r�test_no_eofzContextManagerTest.test_no_eof�
sq��	����g�s�+�
 �s���
 �
 ��
 ��	������������1�1�?�	A�����
�
�$<�=s�0�#�,�0�4c���tjtd�5	ddd�|jtj
j
t�dd�y#1swY�>xYw)Nr�rz-context manager wrote no end-of-archive block)r'r&r�r=rerfr�rs r�test_eofzContextManagerTest.test_eofsM���\�\�'�3�
'�	��	����B�G�G�O�O�G�4�a�?�	A�	�	�s�A�A#c�$�ttd�5}	tj|d��5}t�#1swYnxYwn#YnxYw|j	|j
d�|j
j
d�ddd�y#1swYyxYw)Nr�r�r.zexternal file object was closedr�)r&r�r'r�r�r�r�r3s   rrzContextManagerTest.test_fileobjs����'�4�
 �	B�D�
��\�\�$�S�9�$�S�#�O�$�$��$��
������T�[�[�*K�L��O�O�C�J�J�(@�A�	B�	B�	B�s+�B�>�1�:	�>�B�A�=B�BN)	r r!r"r�r�r�r�r�rr+rrr�r��
s"��>�
�>�
>�A�
Brr�zrequires os.link to be missingc�:�eZdZd�Zej
eejd�d�d��Z	ej
eejd�d�d��Z
ej
eed�d�d��Zej
eed�d�d	��Zy
)�LinkEmulationTestc�,�|jj|td��ttj
j
t|�d�5}|j�}ddd�|jt�t�y#1swY�)xYw)Nror^rs)rHrcrdr&rerfrgrTrUrrX)rr�rPrs    r�_test_link_extractionz'LinkEmulationTest._test_link_extraction"sj��������w���?�
�"�'�'�,�,�w��-�t�
4�	���6�6�8�D�	�����4��.�9�	�	�s�B
�
B�islinkz3Skip emulation - has os.path.islink but not os.linkc�&�|jd�y)Nr��r�rs r�test_hardlink_extraction1z+LinkEmulationTest.test_hardlink_extraction1)���	
�"�"�?�3rc�&�|jd�y)Nr�r�rs r�test_hardlink_extraction2z+LinkEmulationTest.test_hardlink_extraction2.���	
�"�"�#>�?rr�z Skip emulation if symlink existsc�&�|jd�y)Nr�r�rs r�test_symlink_extraction1z*LinkEmulationTest.test_symlink_extraction13r�rc�&�|jd�y)Nr�r�rs r�test_symlink_extraction2z*LinkEmulationTest.test_symlink_extraction28r�rN)
r r!r"r�r�r�r�rerfr�r�r�r�r+rrr�r�s���:��X�_�_�W�R�W�W�h�/�J�L�4�L�4��X�_�_�W�R�W�W�h�/�J�L�@�L�@��X�_�_�W�R��+�7�9�4�9�4��X�_�_�W�R��+�7�9�@�9�@rr�c��eZdZd�Zd�Zd�Zy)�Bz2PartialReadTestc�T��G�fd�dtj��tjt	j
d�j
��}tt|�dz�D]#}	t	j�|d|�|���%y#tj$rY�<wxYw)Nc�2���eZdZdZ��fd�Z��fd�Z�xZS)�9Bz2PartialReadTest._test_partial_input.<locals>.MyBytesIOFc���|jrtd��|j�t|j	��k(|_t
�|�|�S)Nz(infinite loop detected in tarfile.open())�hit_eof�AssertionErrorrzrVr��superrT)rr��	MyBytesIO�	__class__s  ��rrTz>Bz2PartialReadTest._test_partial_input.<locals>.MyBytesIO.readEsK����<�<�(�*:�;�;�#�y�y�{�c�$�-�-�/�.B�B����Y��2�1�5�5rc�*��d|_t�|�
|�Sr�)rrry)rr�rrs  ��rryz>Bz2PartialReadTest._test_partial_input.<locals>.MyBytesIO.seekKs���$����Y��2�D�9�9r)r r!r"rrTry�
__classcell__)rrs@�rrr�Cs����G�
6�
:�
:rrrrtr.)r$r�r5�compressr'rr�rangerVr&r)rrrrtrs    @r�_test_partial_inputz&Bz2PartialReadTest._test_partial_inputBs����
	:��
�
�
	:��|�|�G�O�O�E�2�8�8�:�;���s�4�y�1�}�%�	�A�
����Y�t�B�Q�x�%8�t�D�	���$�$�
��
�s�. B�B'�&B'c�&�|jd�y�Nr`�r
rs r�test_partial_inputz%Bz2PartialReadTest.test_partial_inputVs��� � ��%rc�&�|jd�y)Nr�r
rs r�test_partial_input_bz2z)Bz2PartialReadTest.test_partial_input_bz2Ys��� � ��)rN)r r!r"r
rrr+rrr�r�>s���(&�*rr�c��	ddl}ddl}|jd�ddk7ry|j	d�ddk7ryy#t$rYywxYw)NrF�rootT)rUrT�ImportError�getpwuid�getgrgid)rUrTs  r�root_is_uid_gid_0r]sS�����|�|�A��q��V�#��
�|�|�A��q��V�#����
����s�;�	A�A�chownzmissing os.chown�geteuidzmissing os.geteuidc���eZdZed��Zeed���Zejjd�ejjd�ejjd�d����Z
ejjd�ejjd�ejjd�d����Zeje
�d�ejjd�ejjd�ejjd�d	�����Zejjd�d
��Zy)�NumericOwnerTestc���tjd�}|ddtj|f|ddtjdf|ddtj|fg}tj
td�5}|D]R\}}}}	}
tj|�}||_||_	d	|_
d	|_|	|_|j||
��T	ddd�tS#1swYtSxYw)
Nscontent�c�b�M�L�X�Wr�r)r$r�r'rRrVr&r�rr�r�r`r�rUr)�
filename_1�	dirname_1�
filename_2r[r�rr�r�r��typ�contentsrs            r�_make_test_archivez#NumericOwnerTest._make_test_archivers����z�z�*�%���b�"�g�o�o�t�<��b�"�g�o�o�t�<��b�"�g�o�o�t�<����\�\�'�3�
'�	+�5�16�
+�-��c�3��X��O�O�D�)�������� ��� �������
�
�a��*�
+�	+���	+���s
�.AC�C#c#�K�d|_d}d}|}|}tjj||�}tj|||�}t
j|�5}||||f��ddd�y#1swYyxYw�w)Nrznumeric-owner-testfiler�)r�rerfrgrr'r'r&)�mock_geteuidr{rwr"r#r$�tar_filenamers        r�_setup_testzNumericOwnerTest._setup_test�s�����%&��!�(�����
��	��W�W�\�\�'�5�1�
�(�:�:�:�;D�;E�G���\�\�,�
'�	;�5���Y�
�:�:�	;�	;�	;�s�AA<�	A0�'	A<�0A9�5A<zos.chownzos.chmodz
os.geteuidc���|j|�5\}}}}|j|tdd��|j|tdd��ddd�tjjt�}tjjt�}	|j
tjj|dd�tjj|	dd�gd��y#1swY��xYw)	NTro��
numeric_ownerr_rrr r!��	any_order)
r+rcrdrerfrg�assert_has_callsr�r��call)
rr)�
mock_chmod�
mock_chownrr"�_r$�f_filename_1�f_filename_2s
          r�test_extract_with_numeric_ownerz0NumericOwnerTest.test_extract_with_numeric_owner�s���
�
�
�l�
+�	2�0<��z�1�0:��M�M�*�g�T�!0�
�
2��M�M�*�w�d�!0�
�
2�		2��w�w�|�|�G�Z�8���w�w�|�|�G�Z�8���#�#�X�]�]�%7�%7��b�"�%M�%-�]�]�%7�%7��b�"�%M�%'�/3�	$�	4�	2�	2�s�8C.�.C7c	�H�|j|�5\}}}}|jtdd��ddd�tjjt�}tjjt�}	tjjt�}
|j
tjj|dd�tjj|	dd�tjj|
dd	�gd�
�y#1swY��xYw)NTror-rrrrr r!r/)
r+rnrdrerfrgr1r�r�r2)rr)r3r4rr"r#r$r6�f_dirname_1r7s           r�"test_extractall_with_numeric_ownerz3NumericOwnerTest.test_extractall_with_numeric_owner�s���
�
�
�l�
+�	5�0<��z�9�0:����W�D�$3�
�
5�	5��w�w�|�|�G�Z�8���w�w�|�|�G�Y�7���w�w�|�|�G�Z�8���#�#�X�]�]�%7�%7��b�"�%M�%-�]�]�%7�%7��R��%L�%-�]�]�%7�%7��b�"�%M�%'�/3�		$�	4�	5�	5�s�D�D!z uid=0,gid=0 must be named "root"c��|j|�5\}}}}|j|tdd��ddd�tjjt�}|j
|dd�y#1swY�AxYw)NFror-r)r+rcrdrerfrg�assert_called_with)rr)r3r4rr"r5r6s        r�"test_extract_without_numeric_ownerz3NumericOwnerTest.test_extract_without_numeric_owner�st���
�
�l�
+�	2�/H��z�1�a��M�M�*�g�U�!0�
�
2�	2�
�w�w�|�|�G�Z�8���%�%�l�A�q�9�	2�	2�s�A1�1A:c	��|j|�5\}}}}|jt|j|tdd�ddd�y#1swYyxYw)NFT)r+r
r�rcrd)rr)rr"r5s     r�test_keyword_onlyz"NumericOwnerTest.test_keyword_only�sT��
�
�
�l�
+�	O�/H��z�1�a����i�#�m�m�Z��%��
O�	O�	O�	O�s�.A	�	AN)r r!r"rfr'rr+r�r�r�r8r;r�rr>r@r+rrrrish������.��;���;�(�]�]����$�
�]�]����$�
�]�]����&�4�'�%�%�4�$�]�]����$�
�]�]����$�
�]�]����&�4�'�%�%�4�,�X���*�,�;�=�
�]�]����$�
�]�]����$�
�]�]����&�	:�'�%�%�=�
	:��]�]����&�O�'�Orrc�*�eZdZd�Zd�Zd�Zd�Zd�Zy)�ReplaceTestsc�8�|jjd�}|jd��}|j|jd�|j|jd�|j|jjd�jd�y)NrPz
misc/otherrO)rHrRrrUr��rr/�replaceds   r�test_replace_namezReplaceTests.test_replace_name�sv�����#�#�O�4���>�>�|�>�4���������5�������o�6�������+�+�O�<�A�A�(�	*rc�&�|jjd�}|j�}d|jd<|j	|jdd�|j	|jjd�jdd�y)Nrk�not-barr�r��rHrRrrlrUrDs   r�test_replace_deepzReplaceTests.test_replace_deep�s{�����#�#�N�3���>�>�#��(1����W�%�����+�+�G�4�e�<�����H�H���~�.�:�:�7�C�U�	Lrc�*�|jjd�}|jd��}d|jd<|j	|jdd�|j	|jjd�jdd�y)NrkF)�deeprHr�rIrDs   r�test_replace_shallowz!ReplaceTests.test_replace_shallow�s�����#�#�N�3���>�>�u�>�-��(1����W�%�����+�+�G�4�i�@�����H�H���~�.�:�:�7�C�Y�	Prc�.�|jjd�}dD]i}|j|��5|jdi|di��}|j	t||�d�|j
t||�d�ddd��ky#1swY�vxYw)NrP)r�r^rrr�r�r`r���	attr_namer+)rHrRr�rrUr6r=)rr/rPrEs    r�test_replace_allzReplaceTests.test_replace_all�s������#�#�O�4��:�	F�I����	��2�
F�)�6�>�>�>�Y��,=�>��� � ���9�!=�t�D��#�#�G�F�I�$>��E�
F�
F�	F�
F�
F�s�A
B�B	c��|jjd�}|jt�5|j	d��ddd�y#1swYyxYw)NrPi�[)rO)rHrRr
r�r)rr/s  r�test_replace_internalz"ReplaceTests.test_replace_internalsG�����#�#�O�4��
�
�
�y�
)�	-��N�N�)�N�,�	-�	-�	-�s�A
�
AN)r r!r"rFrJrMrQrSr+rrrBrB�s��*�L�P�F�-rrBc�p�eZdZdZed��Zed��Zd�Zed��Z	d�Z
d�Zd�Zd	�Z
d
�Zd�Zd�Zy)
�NoneInfoExtractTestsNc�0��tjtdd��}tjt
�dz�_d|_t�5}�j�*|jtjdt���|j�j�j��ddd�|j�t!�fd	�tj�j�j#d
�D���_y#1swY�_xYw)Nr`rDrE�extractall_ctrlr�ignore)�action�categoryr^c3�T�K�|]}|j�j����!y�wr
)�relative_to�control_dir)�.0�prds  �r�	<genexpr>z2NoneInfoExtractTests.setUpClass.<locals>.<genexpr>!s(����� A��
�M�M�#�/�/�*� A�s�%(�**/*)r'r&r#r�r�rdr]rhr�extraction_filter�
enter_context�warnings�catch_warnings�DeprecationWarningrnrK�set�glob�
control_paths)rdrH�cms`  rrezNoneInfoExtractTests.setUpClasss�����l�l�7��{�C��!�,�,�w�/�2C�C������
�[�	J�B��$�$�,�� � ��!8�!8�#�.@�"B�C��N�N�3�?�?�3�3H�3H�N�I�		J�
	�	�	��� A��\�\�#�/�/�2�7�7��?� A�A���
	J�	J�s
�AD�Dc�B�tj|j�yr
)�shutilr|r]rgs rrhz"NoneInfoExtractTests.tearDownClass%s���
�
�c�o�o�&rc���t�fd�tj��jd�D��}|j	|j
|�y)Nc3�@�K�|]}|j�����y�wr
)r\)r^r_r�s  �rr`z;NoneInfoExtractTests.check_files_present.<locals>.<genexpr>*s"�����;��
�M�M�)�$�;�s�ra)rgr�r�rhrUri)rr��	got_pathss ` r�check_files_presentz(NoneInfoExtractTests.check_files_present)sF����;��\�\�)�,�1�1�&�9�;�;�	�	
����+�+�Y�7rc'�K�tjt�dz}d|j_|jj�D]}|D]}t
||d���tj|�5|jj|d��|j|�|��ddd�y#1swYyxYw�w)N�extractall_nonerror^)r�r�rdrHrhr��setattrr	r�rnrp)r�
attr_namesr}r/rPs     r�extract_with_nonez&NoneInfoExtractTests.extract_with_none/s������l�l�7�#�&7�7��������h�h�)�)�+�	1�F�'�
1�	���	�4�0�
1�	1��
�
��
$�	��H�H����O��<��$�$�S�)��I�	�	�	�s�A6C�83B4�+	C�4B=�9Cc��tjt�j�j}|jd�5}tj|�j
d�D]b}|j|��5	|j�j}|j|j�j|�ddd��d	ddd�y#t$r|j�s�Y�0wxYw#1swY��xYw#1swYyxYw)Nr^ra�rf)r�r�rdry�st_mtimerurhr��assertGreaterEqualr��
is_symlink)r�nowr}rfr^s     r�test_extractall_none_mtimez/NoneInfoExtractTests.test_extractall_none_mtime;s����l�l�7�#�(�(�*�3�3��
�
#�
#�G�
,�
	K�����S�)�.�.�v�6�	
K���\�\�t�\�,�K�K� $�	�	�� 4� 4���/�/��	�	��0D�0D�c�J�K�K�	
K�
	K�
	K��
#�"�#���0�!� 1�"��K�K��
	K�
	K�sH�:D�=C7�?C�*C7�
D�C4	�1C7�3C4	�4C7�7D�<D�Dc���tjt�j�j}tjt�dz}|jd�|j�j}|j
d�5}tj|�jd�D]�}|j|��5|j�r+|j|j�j|�n:|j�r*|j|j�j|�ddd���	ddd�y#1swY��xYw#1swYyxYw)N�regular_filerrrarw)r�r�rdryrz�
write_textrurhr��is_dirrU�is_file)r�dir_moder~�regular_file_moder}rfs      r�test_extractall_none_modez.NoneInfoExtractTests.test_extractall_none_modeKs���<�<��(�-�-�/�7�7���|�|�G�,�~�=������#�(�-�-�/�7�7��
�
#�
#�F�
+�	<�s����S�)�.�.�v�6�
<���\�\�t�\�,�<��{�{�}��(�(�����)<�)<�h�G������(�(�����)<�)<�):�<�	<�<�
<�	<�	<�<�<��	<�	<�s%�
:E�A6E�:
E�E�E�E#c�R�|jd�5	ddd�y#1swYyxYw)Nr��rurs r�test_extractall_none_uidz-NoneInfoExtractTests.test_extractall_none_uid[�(��
�
#�
#�E�
*�	��	�	�	����&c�R�|jd�5	ddd�y#1swYyxYw)Nr�r�rs r�test_extractall_none_gidz-NoneInfoExtractTests.test_extractall_none_gid_r�r�c�R�|jd�5	ddd�y#1swYyxYw)Nr`r�rs r�test_extractall_none_unamez/NoneInfoExtractTests.test_extractall_none_unamec�(��
�
#�
#�G�
,�	��	�	�	�r�c�R�|jd�5	ddd�y#1swYyxYw)Nr�r�rs r�test_extractall_none_gnamez/NoneInfoExtractTests.test_extractall_none_gnamegr�r�c�X�|jdddd�5	ddd�y#1swYyxYw)Nr�r�r`r�r�rs r�test_extractall_none_ownershipz3NoneInfoExtractTests.test_extractall_none_ownershipks.��
�
#�
#�E�5�'�7�
C�	��	�	�	�s� �))r r!r"rbr|rerhrprrur|r�r�r�r�r�r�r+rrrUrU
so�����A��A��'��'�8��	��	�K� <� ����rrUc��eZdZdZy)�NoneInfoExtractTests_DatarN�r r!r"rbr+rrr�r�os���rr�c��eZdZdZy)�!NoneInfoExtractTests_FullyTrustedroNr�r+rrr�r�rs��'�rr�c��eZdZdZy)�NoneInfoExtractTests_TarrHNr�r+rrr�r�vs���rr�c��eZdZdZy)�NoneInfoExtractTests_DefaultNr�r+rrr�r�ys���rr�c��eZdZd�Zd�Zy)�NoneInfoTests_Miscc
��tj�}tjtjtj
fD]�}|j
|��5tj|d|��}|jt�}	|j|�dD]b}|j
|��5|jdi|di��}|jt|��5|j|�ddd�ddd��d	ddd���y#1swY�xYw#1swY��xYw#t$r|tjk(rn�Y�CwxYw#1swY��xYw)N)�	tarformatr�)r/rr�)r^rr�r�r`r�rOr+)r$r�r'r�rervr�r&r�r#rrrrKr�)r�bior�rHrZrPrEs       r�test_addzNoneInfoTests_Misc.test_add~sD���j�j�l��!�.�.��0B�0B�!�,�,�.�	6�I����	��2�
6��l�l�3�S��K���.�.��1��6��K�K��(�&6�6�	�!�\�\�I�\�>�6�'6�w���'K�)�T�9J�'K�H�!%�!7�!7�
�;D�+�"H�6� #���H� 5�6�6�6�6�
6�
6�	6�&6�6��6�6��!�� �G�$8�$8�8����	��
6�
6�s`�.E�D$�E�0,D	�D�.D	�6E�D�D	�D!
�E�$E�E�E�E�E	c
�	�dhdhdhdhdhdhddhddhfD�]�}|j|��5tjtd�	�5}t	j
t	j�d
d��}tjtd
|�5|j�ddd�|j�D]}|D]}t||d���t	j
t	j�d
d��}tjtd
|�5|j�ddd�t|j�j�j!�|j�j�j!��D�]\}}|dhk(r)t#j$d|�r|j'|d��6|dhk(r)t#j$d|�r|j'|d��e|dhk(r)t#j$d|�r|j'|d���|dhk(r^|j)d�rM|j!d�\}	}
|j!d�\}}|j'||
�|j+|d���|dhk(r_|j-d�rN|j!d�\}	}
|j!d�\}}|j'||	�|j+|d���]|dhk(r_|j)d�rN|j!d�\}	}
|j!d�\}}|j'||
�|j'|d����|dhk(r_|j-d�rN|j!d�\}	}
|j!d�\}}|j'||	�|j'|d���'|ddhk(r_|j)d�rN|j!d�\}	}
|j!d�\}}|j'||
�|j'|d����|ddhk(r_|j-d�rN|j!d�\}	}
|j!d�\}}|j'||	�|j'|d����|j'||���	ddd�ddd����y#1swY��xYw#1swY���xYw#1swY�/xYw#1swY���xYw)Nr^rr�r�r`r�)rtrDrmr�r�r�r�s2003-01-\d\ds
????-??-??s\d\d:\d\d:\d\ds??:??:??s.([r-][w-][x-]){3}s
??????????)�tarfile/�lars/�foo/�/s[0-9]+)�/tarfile�/users�/bar�1000/sNone�/100)r�r�r�r�)r�r�r�r�)r�r'r&r#r$rir�rr�r�rpr�rsr�r�r�r��re�matchrUr_r��endswith)
rrtrH�tio_prevr/rP�tio_newr��got�exp_user�	exp_group�got_user�	got_groups
             rr�zNoneInfoTests_Misc.test_list�sr��
$�9�v�h���%��#�9�w�i�!�7�+�e�W�-=�?�<	8�J��,�,�*�,�5�9
8��,�,�w��=�9
8�AD��+�+�B�J�J�L�'�4�P���&�&�s�H�h�?���H�H�J��!�n�n�.�9�F�%/�9�	���	�4�8�9�9��*�*�2�:�:�<��$�O���&�&�s�H�g�>���H�H�J��%(����):�)C�)C�)E�)K�)K�)M�)0���)9�)B�)B�)D�)J�)J�)L�&N�.8�M�H�c�!�g�Y�.�2�8�8�<L�h�3W��(�(��m�<�#��y�0�R�X�X�>P�RZ�5[��(�(��k�:�#��x�/�B�H�H�2�H�5>��(�(��m�<�#��y�0�X�5H�5H�<�6>�.6�n�n�T�.B�+��)�.1�i�i��o�+��)��(�(��I�>��(�(��9�=�#��y�0�X�5F�5F�=�6?�.6�n�n�T�.B�+��)�.1�i�i��o�+��)��(�(��8�<��(�(��I�>�#��w�.�8�3F�3F�%�4(�.6�n�n�T�.B�+��)�.1�i�i��o�+��)��(�(��I�>��(�(��7�;�#��w�.�8�3D�3D�g�3O�.6�n�n�T�.B�+��)�.1�i�i��o�+��)��(�(��8�<��(�(��G�<�#��w�'7�7�H�<O�<O�F�=H�.6�n�n�T�.B�+��)�.1�i�i��o�+��)��(�(��I�>��(�(��7�;�#���'7�7�H�<M�<M�F�=H�.6�n�n�T�.B�+��)�.1�i�i��o�+��)��(�(��8�<��(�(��G�<��(�(��3�7�].8�9
8�9
8�9
8�<	8�������9
8�9
8��9
8�9
8�sV�S�AS�
R*	�A6S�R7	�%M0S�S�*R4
�/S�7S
�<S�S
�	S�S	N)r r!r"r�r�r+rrr�r�}s
��6�4A8rr�c��	|dd}tjdd�|dtjdd�|dztjdtjtjztjd�|dztj
dd�|dztjdd�|dztjdtjtjztjd�|d	ztjdd�|d
ztjdd�|dztjdtjtjztjd�|d
z}|S)Nrtr)r`�-)r�r�)rtr�r}�Srwr�rrP�)rtr�r�Tr9)
ry�S_IRUSR�S_IWUSR�S_IXUSR�S_ISUID�S_IRGRP�S_IWGRP�S_IXGRP�S_ISGID�S_IROTH�S_IWOTH�S_IXOTH�S_ISVTX)r�str_mode�results   r�_filemode_to_intr��se����A�B�x�H����1�
%�h�q�k�
2����1�
%�h�q�k�
2�3����1����t�|�|�+�����&�q�k�+�+�
���1�
%�h�q�k�
2�3����1�
%�h�q�k�
2�
3����1����t�|�|�+�����&�q�k�+�	+����1�
%�h�q�k�
2�
3����1�
%�h�q�k�
2�3����1����t�|�|�+�����&�q�k�+�+��(�Mrc�:�eZdZ	d�Zd�Zd�Zdddddd�d�Zd�Zy)�ArchiveMakerc�6�tj�|_yr
)r$r�r�rs rr�zArchiveMaker.__init__
s���:�:�<��rc�R�tjd|j��|_|S)Nr�rN)r'r(r��tar_wrs r�	__enter__zArchiveMaker.__enter__
s���_�_�#�t�x�x�@��
��rc��|jj�|jj�|_d|_yr
)r�rKr�r�r&)rr�s  r�__exit__zArchiveMaker.__exit__	
s-���
�
�������)�)�+��
���rN)rU�
symlink_to�hardlink_torrWc�*�	t|�}tj|�jdi|��}|�||_|rt|�|_|� tj}t|�|_|� tj}t|�|_|jd�r|�tj}|�||_|j�r)tjt!|j��}	nd}	|j"j%||	�y)Nr�r+)r1r'rrrWr�rrXrr.r�rVrUr�r$r�rCr�r)
rr�rUr�r�rrWr�rZr/s
          rr�zArchiveMaker.add
s���C��4�y��/�'�/�/�$�'�/�/�9�&�9�����G�L��+�D�1�G�L��!��?�?�D�"�:��G���"��?�?�D�"�;�/�G���=�=���$�,��?�?�D����G�L��=�=�?��j�j��w�|�|�!4�5�G��G��
�
���7�G�,rc�p�	tj|j�}tjdd|i|��S)Nr/r+)r$r�r&r'r&)rr�r�s   rr&zArchiveMaker.open'
s.��G��j�j����'���|�|�2�C�2�6�2�2r)r r!r"r�r�r�r�r&r+rrr�r��s.��	� ���
!%��4��D�-�23rr�c�8�tjd�|�S)NzWASI: Skip symlink test for now)r��skip�rPs r�symlink_testr�2
s��?�x�}�}�>�?��B�Brc��|Sr
r+r�s rr�r�5
s���rc�@�eZdZeje�dzZedzZed��Z			d d�Z
d!d�Zd�Zd�Z
ed	��Zed
��Zed��Zd�Zed
��Zed��Zed��Zed��Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z!d�Z"d�Z#d�Z$d�Z%y)"�TestExtractionFilters�outerdirr�c#�K�	tj|j�5	|j|j|��d|_t
|jjd��|_|jj|j�	d��|j�|j
r|j
�|j|jt
��ddd�y#t$r }||_t
�|_Yd}~�~d}~wwxYw#|j�wxYw#1swYyxYw�w)Nr^ra)
r	r�r�rnr��raised_exceptionrgrh�expected_paths�discardr�rKrU)rrHr_r�s    r�
check_contextz#TestExtractionFilters.check_contextC
s����	��
�
��
�
�
.�	9�
:����t�|�|�F��;�
)-��%�&)�$�-�-�*<�*<�V�*D�&E��#��#�#�+�+�D�L�L�9�
���	�	���$�$��+�+�+����T�0�0�#�%�8�!	9�	9���
,�(+��%�&)�e��#�#��
,���	�	���	9�	9�s_�!D>�D2�C1�AD2�D�AD2�(	D>�1	D�:D�D2�D�D2�D/�/D2�2D;�7D>Nc�.�	|jr|j�tjtjj|j|z��}|j||j�|jj|�|�ytj�retjdk7rRtjtj|j�j ��}|j#||�|�1t%|t&�r!|j)d�rt*j,}|�X|j|zj/�}tj|�}||k7r�|j1|j3|��n�|t*j4k(s|� |j1|j7��nq|t*j,k(r |j1|j9��n>|t*j:k(r |j1|j=��nt?|��|�*|j#|j�j@|�|jBD]}	|jjE|	��y)N�ntr�)#r�r�r�rerf�normpathr�r�r��remover	�	can_chmodr�ryr^�S_IMODErzrUrsr1r�r'rV�readlinkr��samefilerRr�r�r]�is_fifo�NotImplementedErrorrU�parentsr�)
rr�rUr�rrWrfr�r��parents
          r�expect_filez!TestExtractionFilters.expect_file`
s���5�� � ��'�'�'��|�|�B�G�G�,�,�T�\�\�D�-@�A�B���
�
�d�D�/�/�0����"�"�4�(���	� 3� 3� 5�"�'�'�T�/��-�-����T�Y�Y�[�-@�-@� A�B�C����S�$�'��<�J�t�S�1�d�m�m�C�6H��?�?�D��!��<�<�$�&�0�0�2�C��|�|�J�/�H��3��������X� 6�7�
�W�_�_�
$����O�O�D�L�L�N�+�
�W�_�_�
$��O�O�D�K�K�M�*�
�W�%�%�
%��O�O�D�L�L�N�+�%�d�+�+������T�Y�Y�[�0�0�$�7��l�l�	0�F����'�'��/�	0rc��|j||�5|j�|j�	ddd�d|_y#1swYd|_yxYwr
)rr�)r�exc_type�
message_res   r�expect_exceptionz&TestExtractionFilters.expect_exception�
sS��
�
#�
#�H�j�
9�	,��$�$�0��+�+�+�1�	,�!%���	,�!%���s	�=�A
c��t�5}|jd�ddd�dD]<}|jj�|�5|j	d�ddd��>y#1swY�KxYw#1swY�UxYw)Nz
benign.txt)rorHr�r�r�r�r&r��r�arcr_s   r�test_benign_filez&TestExtractionFilters.test_benign_file�
sw��
�^�	"�s��G�G�L�!�	"�4�	/�F��#�#�C�H�H�J��7�
/�� � ��.�
/�
/�	/�	"�	"��
/�
/�s�A'�
A3�'A0�3A<	c�|�t�5}|j|jdz�ddd�|jj	�d�5|jd�ddd�dD]�}|j|j	�|�5t
|j�jd�r9t
|j�jd�}|j|�d��n |jtjd�ddd���y#1swY��xYw#1swY��xYw#1swY��xYw)Nzescaped.evilroz../escaped.evil�rHrr�z
/escaped.evilz+['"].*escaped.evil['"] has an absolute path)r�r�r�r�r&r�r1r_�lstripr�r'�AbsolutePathError)rr�r_�outerdir_strippeds    r�
test_absolutez#TestExtractionFilters.test_absolute�
s ���^�	4�s��G�G�D�M�M�N�2�3�	4��
�
����
�O�
<�	0����.�/�	0�$�	K�F��#�#�C�H�H�J��7�

K��t�}�}�%�0�0��5�),�D�M�M�(:�(A�(A�#�(F�%��$�$�(9�':�-�%H�I��)�)��1�1�I�K�

K�

K�	K�
	4�	4��	0�	0��

K�

K�s$�D�D&�A>D2�D#�&D/�2D;	c�
�t�5}|jdd��|jdd��|jd�ddd�tj��r|j	j�d�5|j�|jt�	ddd�y|jdd��|jdd��|jd�	ddd�|j	|j�d	�5|jtjd
�ddd�|j	|j�d�5|jtjd�ddd�y|j	j�d�5|jd�ddd�|j	|j�d	�5|jd�ddd�|j	|j�d�5|jd�ddd�y#1swY���xYw#1swY��YxYw#1swY��xYw#1swYyxYw#1swY��xYw#1swY��xYw#1swYyxYw)
N�currentr��r�r�z
current/..�parent/evilror�rH�T'parent/evil' would be extracted to ['"].*evil['"], which is outside the destinationrzK'parent' would link to ['"].*outerdir['"], which is outside the destination)
r�r�r	�can_symlinkr�r&r�r�rpr�r'�OutsideDestinationError�LinkOutsideDestinationError�rr�s  r�test_parent_symlinkz)TestExtractionFilters.test_parent_symlink�
s4���^�
	#�s�

�G�G�I�#�G�.�
�G�G�H��G�6��G�G�M�"�
	#�� � �"��#�#�C�H�H�J��@�
0��(�(�4��)�)�/�:��
0�
0��$�$�Y�3�$�?��$�$�X�,�$�G��$�$�Y�/�
0��#�#�C�H�H�J��6�
:��%�%��3�3�9�:�
:��#�#�C�H�H�J��7�
:��%�%��7�7�9�:�
:�
:��#�#�C�H�H�J��@�
0�� � ��/�
0��#�#�C�H�H�J��6�
0�� � ��/�
0��#�#�C�H�H�J��7�
0�� � ��/�
0�
0�Y
	#�
	#��
0�
0��
:�
:��
:�
:��
0�
0��
0�
0��
0�
0�sY�8H.�#H;�,7H;�!I�!I�I!�I-�I9�.H8�;I�I�I�!I*�-I6�9Jc��tj��r/tjj	t
d�}tj|�tjdtjj	|d��ttjj	|ddd�d�5	ddd�tjjtjj	|d��rd}nLtjjtjj	|dd��rd}ntd	��t�5}|jdd�
�|jdd�
�|jd�ddd�|jj�d
�5tj�r8|jdd�
�|jdd�
�|jd�n"|jd�|jd�ddd�|j|j�d�5tj�r!|jt j"d�n"|jd�|jd�ddd�|j|j�d�5tj�rDr!|jt j"d�nC|jt j$d�n"|jd�|jd�ddd�y#1swY���xYw#1swY���xYw#1swY��HxYw#1swY��xYw#1swYyxYw)N�resolution_testr�rr�r&r�TFz#Could not determine link resolutionrzcurrent/parentrror�r�zcurrent/rHrrzS'current/parent' would link to ['"].*outerdir['"], which is outside the destination)r	rrerfrgrdr�r�r&r�rr�r�r�r�r�r'rr)r�testpath�dotdot_resolves_earlyr�s    r�test_parent_symlink2z*TestExtractionFilters.test_parent_symlink2�
s���� � �"��w�w�|�|�G�->�?�H��H�H�X��
�J�J�s�B�G�G�L�L��9�=�>��b�g�g�l�l�8�Y��f�E�s�K�
��
��w�w�~�~�b�g�g�l�l�8�V�<�=�)-�%�����������X�t�V� D�E�).�%�$�%J�K�K�
�^�
	#�s�
�G�G�I�#�G�.�
�G�G�$��G�6��G�G�M�"�
	#��
�
����
�O�
<�	0��$�$�&�� � ��s� �;�� � ��d� �;�� � ��+�� � ��,�� � ��/�	0��
�
����
�E�
2�
	0��$�$�&��%�%��7�7�,�-�� � ��,�� � ��/�
	0��
�
����
�F�
3�	0��$�$�&�(��)�)�#�;�;�0�1��)�)�#�?�?�0�1�� � ��,�� � ��/�%	0�	0�_
�
��
	#�
	#��	0�	0��
	0�
	0��	0�	0�s?�/M
�8M�/A/M$�AM1�A;M=�
M�M!�$M.�1M:�=Nc�R�t�5}|jd|j��|jd�ddd�|jj	�d�5tj�r/|jd|j��|jd�n|jd�ddd�|j|j	�d�5tj�r!|jtjd�n|jd�ddd�|j|j	�d�5|jtjd	�ddd�y#1swY��@xYw#1swY��xYw#1swY�lxYw#1swYyxYw)
Nr�rrror�rHrr�&'parent' is a link to an absolute path)r�r�r�r�r&r	rr�r�r'r�AbsoluteLinkErrorrs  r�test_absolute_symlinkz+TestExtractionFilters.test_absolute_symlink3s]���^�	#�s��G�G�H����G�7��G�G�M�"�	#��
�
����
�O�
<�	0��$�$�&�� � ��d�m�m� �D�� � ��+�� � ��/�	0��
�
����
�E�
2�	0��$�$�&��%�%��7�7�,�-�� � ��/�	0��
�
����
�F�
3�	:��!�!��)�)�8�
:�	:�	:�+	#�	#��	0�	0��	0�	0��	:�	:�s1�/E8�"AF�AF�!F�8F�F�F�F&c�X�t�5}|jd|jdz��ddd�|jj	�d�5|jtd�ddd�|j|j	�d�5|jtd�ddd�|j|j	�d�5|jtjd�ddd�y#1swY��xYw#1swY��xYw#1swY�kxYw#1swYyxYw)	Nr�r�r�roz.*foo. not foundrHrr)	r�r�r�r�r&r�rZr'rrs  r�test_absolute_hardlinkz,TestExtractionFilters.test_absolute_hardlinkQs
���^�	A�s��G�G�H�$�-�-�%�*?�G�@�	A��
�
����
�O�
<�	@��!�!�(�,>�?�	@��
�
����
�E�
2�	@��!�!�(�,>�?�	@��
�
����
�F�
3�	:��!�!��)�)�8�
:�	:�	:�	A�	A��	@�	@��	@�	@��	:�	:�s/�!C<�D�D�!D �<D�D�D� D)c�^�t�5}|jdd��ddd�	|jj�d��5t	j
�rDt
|jt�r|jt�n|jdd��n	ddd�dD]K}|jj�|�5|jtjd�ddd��My#1swY��xYw#1swY�fxYw#t$rY�twxYw#1swY�xYw)N�../mooz..//tmp/moorror^r�zH'../moo' would be extracted to '.*moo', which is outside the destination)
r�r�r�r&r	rrsr�rpr�r�r'rr�s   r�test_sly_relative0z(TestExtractionFilters.test_sly_relative0bs���^�	8�s��G�G�H��G�7�	8�	��#�#�C�H�H�J��#�G�
��(�(�*�!�$�"7�"7��I��-�-�o�>��(�(��m�(�L��
�&$�	-�F��#�#�C�H�H�J��7�
-��%�%��7�7�,�-�
-�
-�	-�1	8�	8��

�
�� �	��	��
-�
-�sA�C<�!D�	AD�#D�!D#�<D�D�
D�	D �D �#D,	c�<�t�5}|jd�|jdd��ddd�|jj�d�5|j	dt
j��tj�r|j	dd	��ddd�d
D]K}|j|j�|�5|jt
jd�ddd��My#1swY��xYw#1swY�fxYw#1swY�pxYw)Nztmp/z
tmp/../../mooztmp/../..//tmp/moorro�tmp�rUrztmp/../../tmp/moor�zU'tmp/../../moo' would be extracted to ['"].*moo['"], which is outside the destination)r�r�r�r&r�r'rVr	rr�rr�s   r�test_sly_relative2z(TestExtractionFilters.test_sly_relative2�s���^�	F�s��G�G�F�O��G�G�O�0D�G�E�	F��
�
����
�O�
<�	K����U�����9��$�$�&�� � ��6I� �J�	K�
$�	%�F��#�#�C�H�H�J��7�
%��%�%��3�3�$�%�
%�
%�	%�	F�	F��	K�	K��
%�
%�s$�%C:�A	D�!D�:D�D�D	c	�j�t�5}|jdd��|jdtjj	dd���|jdtjj	d	dd��
�ddd�dD]�}|jj
�|�5|jdd��|jdd��tj�r|jddd�
�n|jdd��ddd���y#1swY��xYw#1swY��xYw)N�targetdir/targetrr�linkdir/hardlink�	targetdirr�r�linkdir/symlinkr�r�rHrroz../targetdir/target�rWr��
r�r�rerfrgr�r&r�r	rr�s   r�test_deep_symlinkz'TestExtractionFilters.test_deep_symlink�s-��
�^�	.�s��G�G�&�Q�G�/��G�G�&�B�G�G�L�L��X�5'�G�
(�
�G�G�%�"�'�'�,�,��k�8�3-�G�
.�
	.�5�	@�F��#�#�C�H�H�J��7�
@�� � �!3�!� �<�� � �!3�!� �<��(�(�*��$�$�%6�Q�0E�%�G��$�$�%6�Q�$�?�
@�
@�	@�	.�	.��
@�
@�s�A7D�/A#D)�D&�)D2	c���t�5}|jdd��|jdtjj	dd���|jdd�	�|jd
d��|jdd��ddd�d
D]�}|jj
�|�5|jdd�	�|jd
d�	�|jdd�	�tj�r)|jddd��|jddd��n&|jdd�	�|jdd�	�ddd���y#1swY��xYw#1swY��xYw)Nr!�hardlinkr�symlink2�linkdir�	hardlink2rrrrrzlinkdir/hardlink2r"r#r$r�s   r�test_chainsz!TestExtractionFilters.test_chains�sv���^�	H�s��G�G�%�*�G�=��G�G�J�2�7�7�<�<��;�,(�G�
)��G�G�&�Q�G�/��G�G�&�4F�G�G��G�G�'�5F�G�G�
	H�5�	9�F��#�#�C�H�H�J��7�
9�� � �!3�!� �<�� � �!3�!� �<�� � �!4�1� �=��(�(�*��$�$�%6�Q�0:�%�<��$�$�Z�a�0C�%�E��$�$�%6�Q�$�?��$�$�Z�a�$�8�
9�
9�	9�	H�	H��
9�
9�s�A>E�6BE*�E'�*E3	c�	�t�5}|jdd��|jdd��|jdd��|jdd	��|jd
d��|jdd
��ddd�tjj	t
d�}t
|d�5	ddd�		tj|tj|�jtjz�tj|�jtjz}tj|�tj |�tj|tj|�jtjz�tj|�jtjz}tj"|�|j%j
�d�5|r|j'dd��n|j'dd��|j'dd��|j'dd��|j'dd	��|j'd
d��|r|j'dd
��n|j'dd��ddd�|j%|j
�d�5|j'dd��|j'dd��|j'dd��|j'dd	��|j'd
d��|j'dd��ddd�|j%|j
�d�5tj(tj*|j,j�j��}|j'dd��|j'dd��|j'dd��|j'dd��|j'd
d��|j'd|��ddd�y#1swY���xYw#1swY���xYw#t$r<}|jttdd�k(r|jd�n�Yd}~���d}~wwxYw#tj|�wxYw#1swY��xYw#1swY��yxYw#1swYyxYw)N�all_bitsz
?rwsrwsrwtr��	perm_bitsz
?rwxrwxrwx�exec_group_otherz
?rw-rwxrwx�read_group_onlyz
?---r-----�no_bitsz
?---------zdir/z
?---rwsrwtztmp.filer��EFTYPErz?chmod() failed with EFTYPE: regular users cannot set sticky bitroz
?rwsrwsrwxz
?---rwsrwxrHz
?rwxr-xr-xz
?rw-r-xr-xz
?---r-xr-xrz
?rw-r--r--z
?rw-r-----z
?rw-------)r�r�rerfrgrdr&�chmodryrzr�r��errnor6r�rjr�r�r�r�r^r�r�)rr��tmp_filenamer��have_sticky_files�have_sticky_dirs�normal_dir_modes       r�
test_modesz TestExtractionFilters.test_modes�s
���^�	/�s��G�G�J�\�G�2��G�G�K�l�G�3��G�G�&�\�G�:��G�G�%�L�G�9��G�G�I�L�G�1��G�G�F��G�.�
	/��w�w�|�|�G�Z�8��
�,��
$�	��	�	$�

���������.�6�6����E�G�"$����!6�!>�!>����!M���I�I�l�#�
�����
����r�w�w�|�4�<�<�t�|�|�K�L��G�G�L�1�9�9�D�L�L�H��
�����
�
�
����
�O�
<�	<� �� � ��,� �?�� � ��,� �?����[�|��<����/�l��C����.�\��B����Y�\��:��� � ��l� �;�� � ��l� �;�	<��
�
����
�E�
2�	8����Z�l��;����[�|��<����/�l��C����.�\��B����Y�\��:����V�,��7�
	8��
�
����
�F�
3�	;�"�m�m�D�L�L��
�
�"�"�$�,�,�-.�/�O����Z�l��;����[�|��<����/�l��C����.�\��B����Y�\��:����V�/��:�	;�	;�q	/�	/��	�	���
��9�9���x�� ;�;��M�M�#H�I��I��	
��
�I�I�l�#��	<�	<��	8�	8��	;�	;�sp�A3P1�6P>�AQ�0R�	BR-�A3R:�+B=S�1P;�>Q�	R�1R�R�R�R�R*�-R7�:S�Sc��t�5}|jdtj��ddd�dD]^}|j	j�|�5t
td�r"|jdtj��n	ddd��`|j	j�d�5|jtjd�ddd�y#1swY��xYw#1swY��xYw#1swYyxYw)Nrr)rorH�mkfiforz'foo' is a special file)r�r�r'r]r�r&r�rer�r��SpecialFileErrorr�s   r�	test_pipezTestExtractionFilters.test_pipes���
�^�	2�s��G�G�E�� 0� 0�G�1�	2�-�	�F��#�#�C�H�H�J��7�
��2�x�(��$�$�U��1A�1A�$�B��
�
�	��
�
����
�F�
3�	+��!�!��(�(�)�
+�	+�	+�	2�	2��
�
��	+�	+�s#�"C"�4C.�8!C:�"C+�.C7	�:Dc��tjtjtjfD�]}tjd�}||_tj|d�}|j||�tj|d�}|j|j
|�|jtj�5}tj|d�ddd�|jjjtj�|j|jjj d���y#1swY�qxYw)Nrr)r'r]rWrQrrU�fully_trusted_filterr��
tar_filterrUr
r<�data_filterr0rzrZr�)r�special_typerZ�trustedrHrjs      r�test_special_filesz(TestExtractionFilters.test_special_files"s���$�,�,�g�o�o�w���N�
	?�L��o�o�e�,�G�'�G�L��2�2�7�B�?�G��M�M�'�7�+��$�$�W�b�1�C����S�X�X�|�4��"�"�7�#;�#;�<�
1���#�#�G�R�0�
1��!�!�"�,�,�"6�"6����H����R�\�\�1�1�6�6��>�
	?�
1�
1�s�	E�E	c���tjjt�5}|j	�D]*}tj
|d�}|j
||��,	ddd�y#1swYyxYw�Nr)r'r(r&r#r�r?r��rrHrZ�filtereds    r�test_fully_trusted_filterz/TestExtractionFilters.test_fully_trusted_filter1sa��
�_�_�
!�
!�'�
*�	1�c��>�>�+�
1��"�7�7���D���
�
�h��0�
1�	1�	1�	1�s�>A,�,A5c�d�tjjt�5}|j	�D]d}tj
|d�}|j
|j|j�|j
|j|j��f	ddd�y#1swYyxYwrF)	r'r(r&r#r�r@r�r�rUrGs    r�test_tar_filterz%TestExtractionFilters.test_tar_filter8s����_�_�
!�
!�'�
*�	;�c��>�>�+�
;��"�-�-�g�r�:���
�
�h�m�m�W�\�\�:��
�
�h�m�m�W�\�\�:�
;�	;�	;�	;�s�A8B&�&B/c��tjjt�5}|j	�D]e}	tj
|d�}|j|j|j�|j|j|j��g	ddd�y#tj$rY��wxYw#1swYyxYwrF)
r'r(r&r#r�rA�FilterErrorr�r�rUrGs    r�test_data_filterz&TestExtractionFilters.test_data_filterBs����_�_�
!�
!�'�
*�	;�c��>�>�+�
;���&�2�2�7�B�?�H��
�
�h�m�m�W�\�\�:��
�
�h�m�m�W�\�\�:�

;�	;�	;���*�*�����		;�	;�s/�C�B'�AC�'B=�:C�<B=�=C�C	c�R�	t�5}|jd�ddd�tjdtf�5|jj
�d�5|jd�ddd�ddd�y#1swY�hxYw#1swY�xYw#1swYyxYw)NrzPython 3.14)r�r�r�check_warningsrfr�r&r�rs  r�test_default_filter_warnsz/TestExtractionFilters.test_default_filter_warnsNs���-�
�^�	�s��G�G�E�N�	�
�
+�
+�� 2�3�5�	(��#�#�C�H�H�J��5�
(�� � ��'�
(�	(�	(�	�	��
(�
(��	(�	(�s/�B�!B�"B�4B�B�B	�B�B&c��tjtd�}d�}||_|j	|d�5|jd�ddd�y#1swYyxYw)Nr`c�&�|jdk(r|Syr%rO�rZrfs  r�
strict_filterzSTestExtractionFilters.test_change_default_filter_on_instance.<locals>.strict_filterY����|�|��.���rrP)r'r(r#rbr�r�)rrHrUs   r�&test_change_default_filter_on_instancez<TestExtractionFilters.test_change_default_filter_on_instanceWsT���o�o�g�s�+��	�
!.���
�
�
��T�
*�	.����_�-�	.�	.�	.�s�A�Ac�4�d�}tjtd�}tjtjdt|��5|j
|d�5|jd�ddd�ddd�y#1swY�xYw#1swYyxYw)Nc�&�|jdk(r|Syr%rOrTs  rrUzPTestExtractionFilters.test_change_default_filter_on_class.<locals>.strict_filtercrVrr`rbrP)r'r(r#rr�rfr�r�)rrUrHs   r�#test_change_default_filter_on_classz9TestExtractionFilters.test_change_default_filter_on_classbs���	�
�o�o�g�s�+��
�
�
�w���0C�+�M�:�<�	2��#�#�C��.�
2�� � ��1�
2�	2�	2�
2�
2��	2�	2�s$�B�B�1B�B	�B�Bc��Gd�dtj�}|td�}|j|d�5|j	d�ddd�y#1swYyxYw)Nc��eZdZd�Zy)�QTestExtractionFilters.test_change_default_filter_on_subclass.<locals>.TarSubclassc�&�|jdk(r|Syr%rO�rrZrfs   rrbzcTestExtractionFilters.test_change_default_filter_on_subclass.<locals>.TarSubclass.extraction_filterps���<�<�?�2�"�N�rNr�r+rr�TarSubclassr]os��
 rr`r`rP)r'r(r#r�r�)rr`rHs   r�&test_change_default_filter_on_subclassz<TestExtractionFilters.test_change_default_filter_on_subclassnsS��	 �'�/�/�	 ��'�3�'��
�
�
��T�
*�	.����_�-�	.�	.�	.�s�A�Ac��tjtd�}d|_|j	|d�5|jt�ddd�y#1swYyxYw)Nr`r)r'r(r#rbr�r�r�rs  r�$test_change_default_filter_to_stringz:TestExtractionFilters.test_change_default_filter_to_stringzsM���o�o�g�s�+�� &���
�
�
��T�
*�	-��!�!�)�,�	-�	-�	-�s�A�Ac�b���fd�}t�5}|jd�|jd�|jd�ddd��jj�|�5�j	d��j	d�ddd�y#1swY�UxYw#1swYyxYw)Nc����j|�j�|jdk(r|jd��S|jdk(ry|S)N�	move_this�movedrO�ignore_this)r�r�r�r)rZrfrs  �r�
custom_filterz?TestExtractionFilters.test_custom_filter.<locals>.custom_filter�sF����M�M�$����-��|�|�{�*����G��4�4��|�|�}�,���Nrrfrh�keeprgr�)rrir�s`  r�test_custom_filterz(TestExtractionFilters.test_custom_filter�s����	��^�	�s��G�G�K� ��G�G�M�"��G�G�F�O�	��
�
����
�M�
:�	%����W�%����V�$�	%�	%�		�	��	%�	%�s�4B�-#B%�B"�%B.c��t�5}|jd�ddd�|jj�d�5|j	t
�ddd�y#1swY�HxYw#1swYyxYw)Nrzbad filter name)r�r�r�r&r�rKrs  r�test_bad_filter_namez*TestExtractionFilters.test_bad_filter_name�sh��
�^�	�s��G�G�E�N�	�
�
�
����
�,=�
>�	.��!�!�*�-�	.�	.�	�	��	.�	.�s�A$�A0�$A-�0A9c���Gd�d�}t�5}|jd�|jdd��|jd�ddd�|�5}|jj�|�5|j	d�ddd�ddd�|jjd�|j|jd�y#1swY��xYw#1swY�VxYw#1swY�ZxYw)	Nc��eZdZd�Zd�Zd�Zy)�BTestExtractionFilters.test_stateful_filter.<locals>.StatefulFilterc��d|_|Sr�)�num_files_processedrs rr�zLTestExtractionFilters.test_stateful_filter.<locals>.StatefulFilter.__enter__�s��+,��(��rc��	tj||�}|xjdz
c_|S#tj$rYywxYw)Nrt)r'rArMrrr_s   r�__call__zKTestExtractionFilters.test_stateful_filter.<locals>.StatefulFilter.__call__�sK�� �%�1�1�'�4�@�G��(�(�A�-�(�����*�*� �� �s�/�A�Ac��d|_y)NT)�done)r�exc_infos  rr�zKTestExtractionFilters.test_stateful_filter.<locals>.StatefulFilter.__exit__�s	�� ��	rN)r r!r"r�rtr�r+rr�StatefulFilterrp�s��
�
�
!rrx�good�badr�rrwT)r�r�r�r&r�rUrrrv)rrxr�ris    r�test_stateful_filterz*TestExtractionFilters.test_stateful_filter�s���	!�	!� �^�	�s��G�G�F�O��G�G�E�c�G�*��G�G�F�O�	��
�	)���#�#�C�H�H�J�
�>�
)�� � ��(�
)�	)�	
����:�:�A�>�����+�+�T�2�	�	��

)�
)��	)�	)�s/�6C�!C.�;C"�
C.�C�"C+	�'C.�.C7c�z
�d�}d�}d�}d�}d�}t�5}|jd�ddd�|jjd��|�5|j	d�ddd�|j|jd��|�5|j	d�ddd�|j|jd��|�5|j	d�ddd�|j|jd��|�5|jtj�ddd�|j|jd��|�5|jt�ddd�|j|jd	��|�5|j	d�ddd�|j|jd	��|�5|jtj�ddd�|j|jd	��|�5|jt�ddd�|j|jd	��|�5|jtj�ddd�|j|jd	��|�5|jt�ddd�|j|jd
��|�5|jtj�ddd�|j|jd
��|�5|jtj�ddd�|j|jd
��|�5|jt�ddd�|j|jd
��|�5|jtj�ddd�|j|jd
��|�5|jt�ddd�|j|jd��|�5|jt�ddd�y#1swY��7xYw#1swY��xYw#1swY���xYw#1swY���xYw#1swY��mxYw#1swY��:xYw#1swY��xYw#1swY���xYw#1swY���xYw#1swY��^xYw#1swY��+xYw#1swY���xYw#1swY���xYw#1swY��~xYw#1swY��AxYw#1swY��xYw#1swYyxYw)Nc�,�tjd��)Nzfailed with ExtractError)r'�ExtractErrorrTs  r�extracterror_filterzBTestExtractionFilters.test_errorlevel.<locals>.extracterror_filter�s���&�&�'A�B�Brc�,�tjd��)Nzfailed with FilterError)r'rMrTs  r�filtererror_filterzATestExtractionFilters.test_errorlevel.<locals>.filtererror_filter�s���%�%�&?�@�@rc��td��)Nzfailed with OSError)r�rTs  r�oserror_filterz=TestExtractionFilters.test_errorlevel.<locals>.oserror_filter�s���/�0�0rc�,�tjd��)Nzfailed with base TarError)r'�TarErrorrTs  r�tarerror_filterz>TestExtractionFilters.test_errorlevel.<locals>.tarerror_filter�s���"�"�#>�?�?rc��td��)Nzfailed with ValueError)rKrTs  r�valueerror_filterz@TestExtractionFilters.test_errorlevel.<locals>.valueerror_filter�s���5�6�6rr&rr�rtrwzboo!)
r�r�r�r&r�r�r'r�rKrMr�r~r�)rrr�r�r�r�r�s       r�test_errorlevelz%TestExtractionFilters.test_errorlevel�s{��	C�	A�	1�	@�	7��^�	�s��G�G�F�O�	�
�
�
����A�� 6�8K�
L�	%����V�$�	%��
�
����A�� 6�8J�
K�	%����V�$�	%��
�
����A�� 6��
G�	%����V�$�	%��
�
����A�� 6��
H�	4��!�!�'�"2�"2�3�	4��
�
����A�� 6�8I�
J�	.��!�!�*�-�	.�
�
�
����A�� 6�8K�
L�	%����V�$�	%��
�
����A�� 6�8J�
K�	7��!�!�'�"5�"5�6�	7��
�
����A�� 6��
G�	+��!�!�'�*�	+��
�
����A�� 6��
H�	4��!�!�'�"2�"2�3�	4��
�
����A�� 6�8I�
J�	.��!�!�*�-�	.�
�
�
����A�� 6�8K�
L�	8��!�!�'�"6�"6�7�	8��
�
����A�� 6�8J�
K�	7��!�!�'�"5�"5�6�	7��
�
����A�� 6��
G�	+��!�!�'�*�	+��
�
����A�� 6��
H�	4��!�!�'�"2�"2�3�	4��
�
����A�� 6�8I�
J�	.��!�!�*�-�	.�
�
�
����F�� ;�=O�
P�	-��!�!�)�,�	-�	-�q	�	��
	%�	%��	%�	%��	%�	%��	4�	4��	.�	.��
	%�	%��	7�	7��	+�	+��	4�	4��	.�	.��
	8�	8��	7�	7��	+�	+��	4�	4��	.�	.��
	-�	-�s��Q!�Q.�Q;�R�
 R�R"�R/� R<�S	� S�$S#�$ S0�. S=�8T
�8 T�T$�T1�!Q+�.Q8�;R�R�R�"R,�/R9�<S�	S�S �#S-�0S:�=T�
T�T!�$T.�1T:)NNNN)r�)&r r!r"r�r�rdr�r�rr�r�r�r�r�r�r	rrrrrr%r+r9r=rDrIrKrNrQrWrZrarcrkrmr{r�r+rrr�r�9
s=��
�w�|�|�G�$�z�1�H����G��9��9�8BF��!0�F%�/�K�2�00��00�d�T0��T0�l�:��:�::�"� -�� -�D�%��%�&�@��@�.�9��9�2C;�J+�$
?�1�;�
;�(�	.�
2�
.�-�%�".�3�<E-rr�c�`�eZdZejjed�Zed��Z	d�Z
d�Zy)�OverwriteTests�
testoverwritec�,�tjjtd�x}|_|jtj|�tj|d�5}tjd�}d|_|j|tjd��ddd�tjjtd�x}|_|jtj|�tj|d�5}|j|j!tj"d��ddd�tjjtd�}||_|jtj|�tj|d�5}tjd�}d|_|j|tjd��ddd�y#1swY��OxYw#1swY��xYw#1swYyxYw)	Nztar-with-file.tarr�r�rvs
newcontentztar-with-dir.tarztar-with-implicit-dir.tarz	test/file)rerfrgrd�ar_with_file�addClassCleanupr	rjr'r&rrWrr$r��ar_with_dirr��curdir�ar_with_implicit_dir)rdr_rHrs    rrezOverwriteTests.setUpClasss���!�w�w�|�|�G�5H�I�I��C�����I�,�,�a�0�
�\�\�!�S�
!�	6�S�����'�A��A�F��K�K��2�:�:�m�4�5�	6�
!�g�g�l�l�7�4F�G�G��C�O����I�,�,�a�0�
�\�\�!�S�
!�	;�S��K�K����r�y�y�&�9�:�	;�
�G�G�L�L��"=�>��#$�� ����I�,�,�a�0�
�\�\�!�S�
!�	6�S�����,�A��A�F��K�K��2�:�:�m�4�5�	6�	6�	6�	6��	;�	;��	6�	6�s&�"AG1�
0G>�&AH
�1G;�>H�
Hc�.�tj|d�Sr)r'r&)rrfs  rr&zOverwriteTests.opens���|�|�D�#�&�&rc�>�|j|jd��y)Nror^)rn�testdir)r�ars  rrnzOverwriteTests.extractalls��
�
�
�d�l�l�?�
�;rN)r r!r"rerfrgrdr�r|rer&rnr+rrr�r��s2���g�g�l�l�7�O�4�G��6��6�*'�<rr�c�&�tjt�tjt�t
gatt
d�5}|j�}ddd�tttfD]�}|js�tj|j
�tj|j
�|j|j
d�5}|j�ddd���y#1swY��xYw#1swY��xYw)Nrsr�)r	rjrdre�makedirsr#r�r&rTr-r4r:r�r)r[r�crHs    r�setUpModuler�s���
���W���K�K����9�L�	
�g�t�	����y�y�{����w��
(� ���6�6����Q�Y�Y�'�����	�	�*�����	�	�4�(�
 �C��	�	�$��
 �
 �	 �	���
 �
 �s�
C;�D�;D�D	c�~�tjjt�rt	j
t�yyr
)rerfr�rdr	r|r+rr�tearDownModuler�.s%��	�w�w�~�~�g������!�r�__main__)�r4r�rer$�hashlibr�
contextlibrr�randomrr�rlr�rdryr��
unittest.mockr'r�rr�test.supportr	r
rr0rr�r5r=rrfr2�TESTFNrdr�r"r#rgr/r6r<r�r�rXr r�
requires_gzipr-r#r4�
requires_lzmar:rA�TestCaserNr�r�r�r�r�r�r�r�r)r�r�r�r�r�r�r�r�r�r�r�r�r�r�r8rOrhrxr�r�r�r�r�r�r�r�r�r	rrrrr%rKr_r~r�r�r�r�r�r�r�r�r�r�r�r�rr&r(r*r,r7rr�r�r�r�rrrBrUr�r�r�r�r�r�r�r�r�r�r�r�r�r rVr+rr�<module>r�sd���
�	�	��0���
�	��������"�&�(���������$�
�'�'�/�/�)�*�*�
+�i�
7���o�%�	�
�'�
�
�=�
)��
�7�7�<�<��!1�2��
�'�'�,�,�w� 1�
2��	�����g�/�	0��
�'�'�,�,�w�	�
*���g�g�l�l�7�I�.��G��G��
)�)������%�%��%������&�&��&������%�%��%�	�w�	�U�H�h�/�/�U�n	��-�	�	�w�
�	�	��-�	�M1�x��*�*�M1�`	�8�X�	�	�'�8�	�	�8�X�	�G9�X�G9�TQ.�~�Q.�f�#�X�%6�%6��	�x�!1�8�3D�3D�	�8�g�/��1B�1B�8�9�x�!1�8�3D�3D�9�
;�^�X�%6�%6�;�z	��>�	�	���	�	��>�	�&1�W�h�/�/�&1�P	��>�	�
,���
,�	��>�	�1�x��1B�1B�1�"^E�X�x�0�0�^E�B6O�6O�p9�,��(�*;�*;�9�x*�,��(�*;�*;�*�ZG�G�G�<u'�
�x�0�0�u'�p		�H�i�	�	�7�I�	�	�H�i�	�(%�m�X�%6�%6�(%�V7�(�O�7�8��/�8�;�(�O�;�?�7�?�,!�7�$8�(�:K�:K�!�!��*>����!� �(�%9�8�;L�;L� � ��*>���� �C�(�+�+�C�$O5�8�$�$�O5�d+&�}�h�&7�&7�+&�\W.��� 1� 1�W.�t�X�z���G�Z��%�X�z�%�(�*�(�����W�R��(�*K�L�'1�8�$�$�'1�M�'1�TH8�<�H8�VN�N�bL�{�H�$5�$5�L�^G�[�(�"3�"3�G�$K�[�(�"3�"3�K�(I�I�(>%���!2�!2�>%�@	�X�~�x�/@�/@�	�	�G�^�X�->�->�	�	�X�~�x�/@�/@�	�8*��"�"�8*�vZ
�x� � �Z
�za �h�'�'�a �H7B��*�*�7B�t������V�$�&F�G�@��(�"3�"3�@�H�@�B*��(�"3�"3�*�>	�����W�R��)�+=�>�����W�R��+�-A�B�wO�x�(�(�wO�C�?�wO�t%-�8�X�.�.�%-�P`�8�`�D� 4�h�6G�6G��(�(<�(0�(9�(9�(��3�X�5F�5F���#7�#+�#4�#4��\8��*�*�\8�|�833�33�t�?�?�C��A-�H�-�-�A-�H<�^�2�2�H�4E�4E�<�@ �""��z���H�M�M�O���o@���D������D�����
�C������D��sH�$_�)_�._�3_+�_�_�_�_�_(�'_(�+_6�5_6