403Webshell
Server IP : 121.121.20.254  /  Your IP : 216.73.216.202
Web Server : Microsoft-IIS/10.0
System : Windows NT WEB-SERVER 10.0 build 20348 (Windows Server 2022) AMD64
User : IUSR ( 0)
PHP Version : 8.3.28
Disable Function : NONE
MySQL : ON  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  C:/Python312/Lib/test/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : C:/Python312/Lib/test/__pycache__/test_shutil.cpython-312.opt-1.pyc
�

���g�0���ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlmZmZmZmZmZmZmZmZmZmZmZmZddlZddlZddlZ	ddlZddl!m"Z"ddl#m$Z$ddl%m&Z&m'Z'ddl#m(Z(e&dzZ)e&dzZ*e&d	zZ+ejXj[d
�Z.ejXj[d�Z/ejXddd
k(Z0	ddl1Z1ddl2Z2dZ3	ddl4Z4ejjjmde7d���Z8d�Z9d�Z:d>d�Z;d�Z<d?d�Z=d�Z>d�Z?e?�Z@d�ZAGd�d�ZBGd�deBej��ZDGd�d eBej��ZEGd!�d"eBej��ZFGd#�d$eBej��ZGGd%�d&eBej��ZHGd'�d(eBej��ZIGd)�d*eI�ZJGd+�d,eBej��ZKGd-�d.ej��ZLGd/�d0ej��ZMGd1�d2eN�ZOej�e@d3�Gd4�d5eOej���ZQej�e.d6�Gd7�d8eOej���ZRGd9�d:ej��ZSGd;�d<ej��ZTeUd=k(rej��yy#e $rdZY��OwxYw#e $rdZ3Y���wxYw#e $rdZ4Y���wxYw)@�N)�make_archive�register_archive_format�unregister_archive_format�get_archive_formats�Error�unpack_archive�register_unpack_format�
RegistryError�unregister_unpack_format�get_unpack_formats�
SameFileError�_GiveupOnFastCopy)�support)�	os_helper)�TESTFN�FakePath)�warnings_helper�2�_SRC�_DST�darwin�sunos��aixTFzos.chdirzshouldn't call os.chdir()��side_effectc�8�tttdd�d��)N�EXDEV�zInvalid cross-device link)�OSError�getattr�errno)�args�kwargss  �%C:\Python312\\Lib\test\test_shutil.py�_fake_renamer&;s��
�'�%��"�-�/J�
K�K�c�B��tj���fd��}|S)Nc���	tj}tt_�|i|��|t_S#t_wxYw�N)�os�renamer&)r#r$�builtin_rename�funcs   �r%�wrapzmock_rename.<locals>.wrap@s4���	'��Y�Y�N�$�B�I���(��(�&�B�I���B�I�s	�&5�
A)�	functools�wraps)r.r/s` r%�mock_renamer2?s%����_�_�T��'��'��Kr'c��t|t�rtjj|�}t|t
�r|j
�}t|d�5}|j|�ddd�y#1swYyxYw)z�Write *content* to a file located at *path*.

    If *path* is a tuple instead of a string, os.path.join will be used to
    make a path.
    �xbN)	�
isinstance�tupler+�path�join�str�encode�open�write)r7�content�fps   r%�create_filer?JsZ���$����w�w�|�|�T�"���'�3���.�.�"��	
�d�D�	�R�
�����
�	�	�s�A4�4A=c�\�d�}t|d�}djt|�D�cgc]3}tjt
j�j���5c}�}t|d�5}|||�D]}|j|��	ddd�ycc}w#1swYyxYw)zBCreate a test file with an arbitrary size and random text content.c3�BK�||kDr|��||z}||kDr�|r|��yy�wr*�)�total�steps  r%�chunkszwrite_test_file.<locals>.chunksYs3�����d�l��J��T�M�E��d�l���K��s��i r'�wbN)
�minr8�range�random�choice�string�
ascii_lettersr:r;r<)r7�sizerE�bufsize�i�chunk�f�csizes        r%�write_test_filerSWs�����$��o�G��H�H�$�W�~�/�-�!��m�m�F�$8�$8�9�@�@�B�-�/�
0�E�	
�d�D�	�Q��D�'�*�E�
�G�G�E�N�+�
�	��/�	�	�s�8B�3 B"�"B+c���t|t�rtjj|�}|rdnd}|rdnd}t|||��5}|j
�cddd�S#1swYyxYw)z�Return contents from a file located at *path*.

    If *path* is a tuple instead of a string, os.path.join will be used to
    make a path.  If *binary* is true, the file will be opened in binary
    mode.
    �rb�rN�utf-8��encoding)r5r6r+r7r8r;�read)r7�binary�moderYr>s     r%�	read_filer]isU���$����w�w�|�|�T�"���4�s�D��t�7�H�	
�d�D�8�	,���w�w�y�
-�	,�	,�s�A!�!A*c��g}ttj|��D]�}tjj	||�}tjj|�r[tjj
|�s<|j|dz�t|�D]}|j|dz|z����|j|���|S)N�/)	�sortedr+�listdirr7r8�isdir�islink�append�rlistdir)r7�res�name�p�ns     r%rerews���
�C��r�z�z�$�'�(���G�G�L�L��t�$��
�7�7�=�=���B�G�G�N�N�1�$5��J�J�t�c�z�"��a�[���
�
�4�#�:��>�*�!�
�J�J�t��)��Jr'c�
�ttd�syd}d}	tjdtj�d��5}|j
}|j
d�ddd�t|d�5}tjdtj�d��5}|j
}|j�}|j�}	tj||dd�	ddd�ddd�|�tj|�|�tj|�y	y	#1swY��xYw#t$rBYddd�ddd�|�tj|�|�tj|�yywxYw#1swYnxYw	ddd�n#1swYnxYw|�tj|�|�tj|�yy#|�tj|�|�tj|�wwxYw)
N�sendfileFrF��dir�deletes
0123456789rUr�T)
�hasattrr+�tempfile�NamedTemporaryFile�getcwdrgr<r;�filenorkr�unlinkr )�srcname�dstnamerQ�src�dst�infd�outfds       r%�supports_file2file_sendfiler|�s����2�z�"���G��G�&�
�
(�
(��2�9�9�;�u�
M�QR��f�f�G�
�G�G�M�"�N��'�4�
 �C��,�,�T�r�y�y�{�5�Q�UX��(�(���z�z�|���
�
��� ��K�K��t�Q��2� �R�!������W�%������W�%��%N�
M���!� �R�!������W�%������W�%��!��
R�Q��Q�!�
 �
 �������W�%������W�%��������W�%������W�%��s��*G�D%�G�3+F�-E?�D1�$E?�%F�-G�%D.�*G�1	E<�:E?�;F�G�;E<�<E?�?F	�F�	G�F�G�1Hc���trmtjdk(rZtjdtj
z�}|j
d�dj
�d}t|d�dk\Sy)	Ni���z/usr/bin/dump -o %s�
�����i T)�AIX�sys�maxsize�
subprocess�	getoutput�
executable�split�int)�hdrs�maxdatas  r%�
_maxdataOKr��s_��
�s�{�{�j�(�
�
!�
!�"7�#�.�.�"H�
I���
�
�4� ��$�*�*�,�Q�/���7�2��*�,�,�r'c��eZdZdd�Zy)�BaseTestNc��tj|tj���}|j	t
j|�|S)zjCreate a temporary directory that will be cleaned up.

        Returns the path of the directory.
        )�prefixrm)rq�mkdtempr+rs�
addCleanupr�rmtree)�selfr��ds   r%r�zBaseTest.mkdtemp�s5��

���F��	�	��<�����	�(�(�!�,��r'r*)�__name__�
__module__�__qualname__r�rBr'r%r�r��s��r'r�c��eZdZd�Zej
d��Zej
d��Zej
d��Ze	jed�d��Ze	jed�d��Z
e	jed�d��Zd	�Zd
�Ze	j"ej&ddd
k(d�ej(ej*d����Zd�Ze	j"ej&ddd
k(d�ej(ej*d����Zd�Ze	j"ej&ddd
k(d�ej(ej*d����Zd�Zd�Ze	jej<d�d��Ze	jej<d�d��Z e	j"ej<d�d��Z!d�Z"ej
d��Z#e	jed�d��Z$e	je%e&d�d �e	j"ej&d!k(d"�d#���Z'd$�Z(y)%�
TestRmTreec�b�|j�}tjj|d�}tj|�ttjj|d�d�tj|�}|j|t�tj|�y)N�killme�somefile�foo)r�r+r7r8�mkdirr?�fsencode�assertIsInstance�bytes�shutilr�)r��tmp�victims   r%�test_rmtree_works_on_bytesz%TestRmTree.test_rmtree_works_on_bytes�sp���l�l�n�������c�8�,��
������B�G�G�L�L���4�e�<����V�$�����f�e�,��
�
�f�r'c�>��|j�}tjj|d�}tj|�tjj|d�}tj
||�|j
ttj|�|jtjj|��|jtjj|��g��fd�}tj||��|jt��d�|j�ddtjj �|j�dd|�|j#�dddt�y)Nrm�linkc�(���j|�yr*�rd�r#�errorss �r%�onerrorz@TestRmTree.test_rmtree_fails_on_symlink_onerror.<locals>.onerror������M�M�$�r'�r�r�rro�r�r+r7r8r��symlink�assertRaisesr r�r��
assertTrue�exists�lexists�assertEqual�len�assertIsrcr��r�r��dir_r�r�r�s     @r%�$test_rmtree_fails_on_symlink_onerrorz/TestRmTree.test_rmtree_fails_on_symlink_onerror�s����l�l�n���w�w�|�|�C��'��
������w�w�|�|�C��(��
�
�
�4������'�6�=�=�$�7���������t�,�-����������-�.���	 ��
�
�d�G�,�����V��a�(��
�
�f�Q�i��l�B�G�G�N�N�3�������1��t�,����f�Q�i��l�1�o�w�7r'c�8��|j�}tjj|d�}tj|�tjj|d�}tj
||�|j
ttj|�|jtjj|��|jtjj|��g��fd�}tj||��|jt��d�|j�ddtjj �|j�dd|�|j#�ddt�y)Nrmr�c�(���j|�yr*r�r�s �r%�onexcz<TestRmTree.test_rmtree_fails_on_symlink_onexc.<locals>.onexc�r�r'�r�r�rror��r�r�r�r�r�r�s     @r%�"test_rmtree_fails_on_symlink_onexcz-TestRmTree.test_rmtree_fails_on_symlink_onexc�s����l�l�n���w�w�|�|�C��'��
������w�w�|�|�C��(��
�
�
�4������'�6�=�=�$�7���������t�,�-����������-�.���	 ��
�
�d�%�(�����V��a�(��
�
�f�Q�i��l�B�G�G�N�N�3�������1��t�,����f�Q�i��l�G�4r'c��|j�}tjj|d�}tjj|d�}tjj|d�}|||fD]}tj|��tjj|d�}t|d�tjj|d�}tj||�tjj|d�}tj||�tjj|d�}	tj||	�tj|�|jtjj|��|jtjj|��|jtjj|��y�	N�dir1�dir2�dir3�file1r��link1�link2�link3)r�r+r7r8r�r?r�r�r��assertFalser�r��
r�r�r�r�r�r�r�r�r�r�s
          r%�test_rmtree_works_on_symlinksz(TestRmTree.test_rmtree_works_on_symlinks�sB���l�l�n���w�w�|�|�C��(���w�w�|�|�D�&�)���w�w�|�|�C��(���t�T�!�A��H�H�Q�K�"������S�'�*���E�5�!������T�7�+��
�
�
�4��������T�7�+��
�
�
�4��������T�7�+��
�
�
�5�%� ��
�
�d�����������-�.���������t�,�-���������u�-�.r'zonly relevant on Windowsc�~��|j�}tjj|d�}tj|�tjj|d�}tj||�|jtj|�|jttj|�|jtjj|��|jtjj!|��g��fd�}tj||��|j#t%��d�|j'�ddtjj(�|j#�dd|�|j+�dddt�y)Nrmr�c�(���j|�yr*r�r�s �r%r�zBTestRmTree.test_rmtree_fails_on_junctions_onerror.<locals>.onerrorr�r'r�r�rro�r�r+r7r8r��_winapi�CreateJunctionr�rrur�r r�r�r�r�r�r�r�r�rcr�r�s     @r%�&test_rmtree_fails_on_junctions_onerrorz1TestRmTree.test_rmtree_fails_on_junctions_onerrors+����l�l�n���w�w�|�|�C��'��
������w�w�|�|�C��(�����t�T�*����	�(�(�$�/����'�6�=�=�$�7���������t�,�-����������-�.���	 ��
�
�d�G�,�����V��a�(��
�
�f�Q�i��l�B�G�G�N�N�3�������1��t�,����f�Q�i��l�1�o�w�7r'c�x��|j�}tjj|d�}tj|�tjj|d�}tj||�|jtj|�|jttj|�|jtjj|��|jtjj!|��g��fd�}tj||��|j#t%��d�|j'�ddtjj(�|j#�dd|�|j+�ddt�y)Nrmr�c�(���j|�yr*r�r�s �r%r�z>TestRmTree.test_rmtree_fails_on_junctions_onexc.<locals>.onexc"r�r'r�r�rror�r�s     @r%�$test_rmtree_fails_on_junctions_onexcz/TestRmTree.test_rmtree_fails_on_junctions_onexcs'����l�l�n���w�w�|�|�C��'��
������w�w�|�|�C��(�����t�T�*����	�(�(�$�/����'�6�=�=�$�7���������t�,�-����������-�.���	 ��
�
�d�%�(�����V��a�(��
�
�f�Q�i��l�B�G�G�N�N�3�������1��t�,����f�Q�i��l�G�4r'c��|j�}tjj|d�}tjj|d�}tjj|d�}|||fD]}tj|��tjj|d�}t|d�tjj|d�}t
j||�tjj|d�}t
j||�tjj|d�}	t
j||	�tj|�|jtjj|��|jtjj|��|jtjj|��yr�)
r�r+r7r8r�r?r�r�r�r�r�r�r�r�s
          r%�test_rmtree_works_on_junctionsz)TestRmTree.test_rmtree_works_on_junctions*sH���l�l�n���w�w�|�|�C��(���w�w�|�|�D�&�)���w�w�|�|�C��(���t�T�!�A��H�H�Q�K�"������S�'�*���E�5�!������T�7�+�����t�U�+������T�7�+�����t�U�+������T�7�+�����u�e�,��
�
�d�����������-�.���������t�,�-���������u�-�.r'c�h��tj|j���}|jtt
j|�tj|d��|j�}tjj|d�}t|�|jt�5}tj|�ddd�|jjj|�|jtjj!|��tj|d��|jtjj!|��g��fd�}tj||��|jt#��d�|j%�ddtj&�|j�dd	|�|j)�ddd	t�|j�ddd	j|�|j%�d	dtj*�|j�d	d	|�|j)�d	dd	t�|j�d	dd	j|�y#1swY���xYw)
N�rmT��
ignore_errors�tstfilec�(���j|�yr*r�r�s �r%r�z6TestRmTree.test_rmtree_errors_onerror.<locals>.onerrorSr�r'r�rorr��rq�mktempr�r��FileNotFoundErrorr�r�r+r7r8r?�NotADirectoryErrorr��	exception�filenamer�r�r�r��scandirr��rmdir)r�r��tmpdir�cmr�r�s     @r%�test_rmtree_errors_onerrorz%TestRmTree.test_rmtree_errors_onerror@s�����?�?�t�|�|�~�6�����+�V�]�]�H�E��
�
�h�d�3�������7�7�<�<��	�2���H��
�
�
�1�
2�b��M�M�(�#�3�������.�.��9���������x�0�1��
�
�h�d�3���������x�0�1���	 ��
�
�h��0�����V��a�(��
�
�f�Q�i��l�B�J�J�/�������1��x�0����f�Q�i��l�1�o�/A�B�������1��a��1�1�8�<��
�
�f�Q�i��l�B�H�H�-�������1��x�0����f�Q�i��l�1�o�/A�B�������1��a��1�1�8�<�'3�
2�s�2J'�'J1c�P��tj|j���}|jtt
j|�tj|d��|j�}tjj|d�}t|�|jt�5}tj|�ddd�|jjj|�|jtjj!|��tj|d��|jtjj!|��g��fd�}tj||��|jt#��d�|j%�ddtj&�|j�dd	|�|j)�ddt�|j�ddj|�|j%�d	dtj*�|j�d	d	|�|j)�d	dt�|j�d	dj|�y#1swY���xYw)
Nr�Tr�r�c�(���j|�yr*r�r�s �r%r�z2TestRmTree.test_rmtree_errors_onexc.<locals>.onexcsr�r'r�rorr�r�)r�r�r�r�r�r�s     @r%�test_rmtree_errors_onexcz#TestRmTree.test_rmtree_errors_onexc`s�����?�?�t�|�|�~�6�����+�V�]�]�H�E��
�
�h�d�3�������7�7�<�<��	�2���H��
�
�
�1�
2�b��M�M�(�#�3�������.�.��9���������x�0�1��
�
�h�d�3���������x�0�1���	 ��
�
�h�e�,�����V��a�(��
�
�f�Q�i��l�B�J�J�/�������1��x�0����f�Q�i��l�,>�?�������1��.�.��9��
�
�f�Q�i��l�B�H�H�-�������1��x�0����f�Q�i��l�,>�?�������1��.�.��9�'3�
2�s�2J�J%N��cygwinz2This test can't be run on Cygwin (issue #1071513).c��d|_tjt�|j	t
jt�tjjtd�|_	tjjtd�|_
tj|j�tj|j�tjt�j}tj|j�j}tj|j�j}tjtj z}tj"|j|�tj"|j|�tj"t|�|j	tj"t|�|j	tj"|j|�|j	tj"|j|�tjt|j$��|j'|jdd�y)Nr�a�br�rz1Expected call to onerror function did not happen.)�
errorStater+r�rr�r�r�r7r8�child_file_path�child_dir_pathr�create_empty_file�stat�st_mode�S_IREAD�S_IEXEC�chmod�check_args_to_onerrorr��r��old_dir_mode�old_child_file_mode�old_child_dir_mode�new_modes     r%�
test_on_errorzTestRmTree.test_on_error�s���
���
���������
�
�v�.�!�w�w�|�|�F�C�8��� �g�g�l�l�6�3�7����#�#�D�$8�$8�9�
����$�$�%��w�w�v��.�.�� �g�g�d�&:�&:�;�C�C���W�W�T�%8�%8�9�A�A���<�<����,��
����%�%�x�0�
����$�$�h�/�
�����"�������&�,�7�������$�"6�"6�8K�L�������$�"5�"5�7I�J��
�
�f�d�&@�&@�A�������!�L�	Nr'c��|jdkr�|tjur|j||j�nq|tj
ur|j||j�nB|j|tj�|j|t|jg�|jt|dt��|xjdz
c_y|j|tj
�|j|t�|jt|dt��d|_y)Nrorr�r)r�r+rur�r�r�r�r�ra�assertInrr��
issubclassr �r�r.�arg�excs    r%r�z TestRmTree.check_args_to_onerror�s����?�?�Q���r�y�y� �� � ��d�&:�&:�;�����!�� � ��d�&9�&9�:��
�
�d�B�J�J�/��
�
�c�F�D�,?�,?�#@�A��O�O�J�s�1�v�w�7�8��O�O�q� �O����T�2�8�8�,����S�&�)��O�O�J�s�1�v�w�7�8��D�Or'c��d|_tjt�|j	t
jt�tjjtd�|_	tjjtd�|_
tj|j�tj|j�tjt�j}tj|j�j}tj|j�j}tjtj z}tj"|j|�tj"|j|�tj"t|�|j	tj"t|�|j	tj"|j|�|j	tj"|j|�tjt|j$��|j'|jdd�y)Nrr�r�r�rz/Expected call to onexc function did not happen.)r�r+r�rr�r�r�r7r8r�r�rr�r�r�r�r�r��check_args_to_onexcr�r�s     r%�test_on_exczTestRmTree.test_on_exc�s���
���
���������
�
�v�.�!�w�w�|�|�F�C�8��� �g�g�l�l�6�3�7����#�#�D�$8�$8�9�
����$�$�%��w�w�v��.�.�� �g�g�d�&:�&:�;�C�C���W�W�T�%8�%8�9�A�A���<�<����,��
����%�%�x�0�
����$�$�h�/�
�����"�������&�,�7�������$�"6�"6�8K�L�������$�"5�"5�7I�J��
�
�f�D�$<�$<�=�������!�J�	Lr'c��|jdkr�|tjur|j||j�nq|tj
ur|j||j�nB|j|tj�|j|t|jg�|jt|t��|xjdz
c_y|j|tj
�|j|t�|jt|t��d|_y)Nror�r)r�r+rur�r�r�r�r�rarrr�r5r rs    r%r	zTestRmTree.check_args_to_onexc�s����?�?�Q���r�y�y� �� � ��d�&:�&:�;�����!�� � ��d�&9�&9�:��
�
�d�B�J�J�/��
�
�c�F�D�,?�,?�#@�A��O�O�J�s�G�4�5��O�O�q� �O����T�2�8�8�,����S�&�)��O�O�J�s�G�4�5��D�Or'c����d�d��fd�}�fd�}tjt�|jtj
t�tjjtd�|_tjjtd�|_	tj|j�tj|j�tjt�j}tj|j�j}tj|j�j}tjtjz}tj |j|�tj |j|�tj t|�|jtj t|�|jtj |j|�|jtj |j|�t	j
t||��|j#��|j%��y)NFc�
��d�y�NTrB)r#�onerror_calleds �r%r�z7TestRmTree.test_both_onerror_and_onexc.<locals>.onerror�s���!�Nr'c�
��d�yrrB)r#�onexc_calleds �r%r�z5TestRmTree.test_both_onerror_and_onexc.<locals>.onexcs����Lr'r�r�)r�r�)r+r�rr�r�r�r7r8r�r�rr�r�r�r�r�r�r�r�)	r�r�r�r�r�r�rrrs	       @@r%�test_both_onerror_and_onexcz&TestRmTree.test_both_onerror_and_onexc�s����
����	"�	 �	���������
�
�v�.�!�w�w�|�|�F�C�8��� �g�g�l�l�6�3�7����#�#�D�$8�$8�9�
����$�$�%��w�w�v��.�.�� �g�g�d�&:�&:�;�C�C���W�W�T�%8�%8�9�A�A���<�<����,��
����%�%�x�0�
����$�$�h�/�
�����"�������&�,�7�������$�"6�"6�8K�L�������$�"5�"5�7I�J��
�
�f�g�U�;�����%�����(r'c���	tj��fd�}|t_tjt�t	tdfd�tjt��t_y#�t_wxYw)Nc�:��|tk7r
t���|�Sr*)rr )�fnr#r$�
orig_lstats   �r%�raiserzFTestRmTree.test_rmtree_does_not_choke_on_failing_lstat.<locals>.raisers�����<�!�)�O�%�b�>�)r'r�)r+�lstatr�rr?r�r�)r�rrs  @r%�+test_rmtree_does_not_choke_on_failing_lstatz6TestRmTree.test_rmtree_does_not_choke_on_failing_lstatsT���
	"����J�
*�
�B�H��H�H�V�������/��M�M�&�!�!�B�H��z�B�H�s�A$A3�3
Bc���tjtjtjtjhtj
kxrBtjtjvxr tjtjv}|r�|jtj�|jtjj�|j�}tjj!|d�}tj"|�	tj$}Gd�dt&���fd�}|t_|j)�tj|�|t_y|j+tj�|j+tjj�y#t_wxYw)Nr�c��eZdZy)�HTestRmTree.test_rmtree_uses_safe_fd_version_if_available.<locals>.CalledN)r�r�r�rBr'r%�Calledr9s�r'rc�����r*rB)r#r$rs  �r%�_raiserzITestRmTree.test_rmtree_uses_safe_fd_version_if_available.<locals>._raiser:s��� �Lr')r+r;r�rur��supports_dir_fdra�supports_fd�supports_follow_symlinksr�r��_use_fd_functionsr��avoids_symlink_attacksr�r7r8r��_rmtree_safe_fd�	Exceptionr�r�)r�r#�tmp_dirr��real_rmtreerrs      @r%�-test_rmtree_uses_safe_fd_version_if_availablez8TestRmTree.test_rmtree_uses_safe_fd_version_if_available,s4��� �g�g�r�w�w��	�	�2�8�8�D��/�/�0�D��Z�Z�2�>�>�9�D� �W�W��(C�(C�C�	���O�O�F�4�4�5��O�O�F�M�M�@�@�A��l�l�n�G������W�c�*�A��H�H�Q�K�
5�$�4�4��-�Y�-�!�)0��&��!�!�&�&�-�-��;�)4��&����V�5�5�6����V�]�]�A�A�B��*5��&�s
�%AG
�

Gzrequires safe rmtreec�*����|j�}tjj|d�}tj|�tjj|d�}tj|���fd�}d�tjtd|�5�|jt�5tj|�ddd�ddd�|jtjj|��|j�d�d�g��fd�}tjtd|�5�tj||��ddd�|jt��d�|j�dd|�|j�dd	|�|j�d	d|�|j�d	d	|�|j�d�y#1swY��$xYw#1swY��)xYw#1swY��xYw)
Nr�r�c�*���|��dz
�t�)Nr��r )�fd�close_count�
orig_closes ��r%�closez4TestRmTree.test_rmtree_fails_on_close.<locals>.closeMs����r�N��1��K��Mr'rr0roc�(���j|�yr*r�r�s �r%r�z4TestRmTree.test_rmtree_fails_on_close.<locals>.onexc\r�r'r�r�)r�r+r7r8r�r�	swap_attrr�r r�r�r�rbr�r�r�)	r�r�r�r�r0r�r.r�r/s	      @@@r%�test_rmtree_fails_on_closez%TestRmTree.test_rmtree_fails_on_closeDs�����l�l�n���w�w�|�|�C��(��
������w�w�|�|�D�&�)��
�����	���
�
�
�r�7�E�
2�j��"�"�7�+��
�
�d�#�,�3�	
������
�
�d�+�,�����a�(�����	 �
�
�
�r�7�E�
2�j��M�M�$�e�,�3�����V��a�(��
�
�f�Q�i��l�E�*�������1��t�,��
�
�f�Q�i��l�E�*�������1��t�,�����a�(�!,�+��3�
2��3�
2�s0�!G<�7G/�
G<�H	�/G9	�4G<�<H�	Hzdir_fd is not supportedc��|j�}d}tjj||�}tj|tj
�}|j
tj|�tj|�tjtjj|d��ttjj|dd�d�|jtjj|��tj||��|jtjj|��y)Nr��subdirr�r���dir_fd)r�r+r7r8r;�O_RDONLYr�r0r�r?r�r�r�r�r�)r�r'r��fullnamer7s     r%�test_rmtree_with_dir_fdz"TestRmTree.test_rmtree_with_dir_fdgs����,�,�.�����7�7�<�<���0������"�+�+�.��������&�)�
�����
��������h��1�2��B�G�G�L�L��8�Z�@�%�H���������x�0�1��
�
�f�V�,����������1�2r'zdir_fd is supportedc��|j�}|jt�5tj|d��ddd�|jtjj|��y#1swY�8xYw)Nrr6)	r�r��NotImplementedErrorr�r�r�r+r7r�)r�r's  r%�#test_rmtree_with_dir_fd_unsupportedz.TestRmTree.test_rmtree_with_dir_fd_unsupportedusQ���,�,�.��
�
�
�2�
3��M�M�'�!�,�4���������w�/�0�4�
3�s�A5�5A>c���tj|j���\}}tj|�|jttj|�tj|�y�Nr�)
rq�mkstempr�r+r0r�r�r�r��remove)r��handler7s   r%�test_rmtree_dont_delete_filez'TestRmTree.test_rmtree_dont_delete_file|sJ���'�'�D�L�L�N�;����
��������,�f�m�m�T�B�
�	�	�$�r'c��tjt�	tjj	td�}tjj	td�}tj|�tj
||�|j
ttj|�tj|d��tjtd��y#tjtd��wxYw)N�cheese�shopTr�)
r+r�rr7r8r�r�r r�r��r�rxrys   r%�test_rmtree_on_symlinkz!TestRmTree.test_rmtree_on_symlink�s���	�����	6��'�'�,�,�v�x�0�C��'�'�,�,�v�v�.�C��H�H�S�M��J�J�s�C� ����g�v�}�}�c�:��M�M�#�T�2��M�M�&��5��F�M�M�&��5�s�B/C&�&Dc�^�tjt�	tjj	td�}tjj	td�}tj|�ttjj	|d��t
j||�|jttj|�tj|d��tjtd��y#tjtd��wxYw)NrErF�spamTr�)r+r�rr7r8r?r�r�r�r r�r�rGs   r%�test_rmtree_on_junctionz"TestRmTree.test_rmtree_on_junction�s���
�����		6��'�'�,�,�v�x�0�C��'�'�,�,�v�v�.�C��H�H�S�M�������S�&�1�2��"�"�3��,����g�v�}�}�c�:��M�M�#�T�2��M�M�&��5��F�M�M�&��5�s�CD�D,�mkfifo�requires os.mkfifo()�vxworks�%fifo requires special path on VxWorksc���tjt�	|jt�5tjt�ddd�|jtjjt��tjt�tjt�tjtjjtd��tjt�|jtjjt��y#1swY��xYw#tjt�wxYw)N�mypipe)r+rLrr�r�r�r�r�r7r�rur�r8r��r�s r%�test_rmtree_on_named_pipez$TestRmTree.test_rmtree_on_named_pipe�s���	�	�	�&��	��"�"�#5�6��
�
�f�%�7��O�O�B�G�G�N�N�6�2�3��I�I�f��
�����
�	�	�"�'�'�,�,�v�x�0�1��
�
�f�����������/�0�7�6��
�I�I�f��s"�E�D9�
:E�9E�>E�E c��d}|dz}tjjtgdg|z���}tj|�tj|�5tjt�ddd�y#1swYyxYw)N�(�
r�)	r+r7r8r�makedirsr�infinite_recursionr�r�)r��recursion_limit�directory_depth�bases    r%�!test_rmtree_above_recursion_limitz,TestRmTree.test_rmtree_above_recursion_limit�sa����)�B�.���w�w�|�|�F�?�s�e�o�&=�?��
���D��
�
'�
'��
8��M�M�&�!�9�
8�
8�s�A=�=B))r�r�r�r�r�skip_unless_symlinkr�r�r��unittest�
skipUnlessr�r�r�r�r�r��skipIfr��platform�skip_if_dac_override�skip_unless_working_chmodrr�r
r	rrr)r�r#r3r:r=rCrHrKrpr+rSr\rBr'r%r�r��s�����"�"�8�#�8�$�"�"�5�#�5�$�"�"�/�#�/�*�X����"<�=�8�>�8�&�X����"<�=�5�>�5�&�X����"<�=�/�>�/�*=�@:�@�X�_�_�S�\�\�"�1�%��1�I�K��#�#��(�(�N�)�$�K�N�6 �6�X�_�_�S�\�\�"�1�%��1�I�K��#�#��(�(�L�)�$�K�L�6 �6�X�_�_�S�\�\�"�1�%��1�I�K��#�#��(�(�")�)�$�K�")�H"� C�0�X����1�1�3I�J� )�K� )�D�X����1�1�3L�M�3�N�3��X�_�_�V�-�-�/D�E�1�F�1���"�"�6�#�6��X����"<�=�6�>�6��X�����X�.�0F�G��X�_�_�S�\�\�Y�.�;�=�1�=�H�1�"r'r�c��eZdZd�Zd�Zejd��Zd�Zd�Z	d�Z
ejjd�d��Zd	�Zej eed
�d�ejej&ej*dk(d
�d����Zd�Zejd��Zejd��Zd�Zd�Zy)�TestCopyTreec	�N�|j�}tjj|j�d�}|j	t
j|�|j	t
jtjj|��t|dfd�tjtjj|d��t|ddfd�tj||�|jtjjtjj|d���|jtjjtjj|d���|jtjjtjj|dd���t|df�}|j|d�t|ddf�}|j|d�y)N�destination�test.txt�123�test_dir�456)r�r+r7r8r�r�r��dirnamer?r��copytreer��isfilerbr]r��r��src_dir�dst_dir�actuals    r%�test_copytree_simplez!TestCopyTree.test_copytree_simple�se���,�,�.���'�'�,�,�t�|�|�~�}�=������
�
�w�/�����
�
�r�w�w���w�'?�@��W�j�)�5�1�
��������g�z�2�3��W�j�*�5�u�=������)���������r�w�w�|�|�G�Z�'H�I�J�������
�
�b�g�g�l�l�7�J�&G�H�I���������r�w�w�|�|�G�Z�4>�(@�A�	B��G�Z�0�1�������'��G�Z��<�=�������'r'c	���|j�}|j�}|jtj|�|jtj|�t	|dfd�tjt
jj|d��tjt
jj|d��t	|ddfd�t	|ddfd�tj||d��|jt
jjt
jj|d���|jt
jjt
jj|d���|jt
jjt
jj|dd���t|df�}|j|d�t|ddf�}|j|d�|jt �5tj||d	��ddd�y#1swYyxYw)
Nznonexisting.txtri�existing_dirzexisting.txtzwill be replacedzhas been replacedT)�
dirs_exist_okF)r�r�r�r�r?r+r�r7r8rmr�rnrbr]r�r��FileExistsErrorros    r%�test_copytree_dirs_exist_okz(TestCopyTree.test_copytree_dirs_exist_ok�s����,�,�.���,�,�.������
�
�w�/�����
�
�w�/��W�/�0�%�8�
��������g�~�6�7�
��������g�~�6�7��W�n�n�=�?Q�R��W�n�n�=�?R�S�������=���������r�w�w�|�|�G�=N�'O�P�Q�������
�
�b�g�g�l�l�7�N�&K�L�M���������r�w�w�|�|�G�^�4B�(D�E�	F��G�%6�7�8�������'��G�^�^�D�E������!4�5�
�
�
��
/��O�O�G�W�E�B�0�
/�
/�s�I&�&I/c	�`�|j�}tjj|d�}tjj|d�}tjj|d�}tj|�tj|�t|dfd�tjj|d�}tjj|d�}tjtjj|d�|�ttd�r5tj|tjtjz�ttd	�r4ttd
�r$tj|tj�tj|�}tj ||d��|j#tjj%tjj|dd���tj&tjj|dd��}tj(d
k(r|j+d�r|dd}|j-|tjj|d��tj|�}	ttd�r&|j-|	j.|j.�ttd	�r'|j-|	j0|j0�yy)Nrxry�subzfile.txtr�r�zsub/link�lchmod�lchflags�	UF_NODUMPT��symlinks�ntz\\?\�)r�r+r7r8r�r?r�rpr{r��S_IRWXU�S_IRWXOr|r}rr�rmr�rc�readlinkrg�
startswithr�r��st_flags)
r�r'rprq�sub_dir�src_link�dst_link�src_statrr�dst_stats
          r%�test_copytree_symlinksz#TestCopyTree.test_copytree_symlinks�s���,�,�.���'�'�,�,�w��.���'�'�,�,�w��.���'�'�,�,�w��.��
�����
������W�j�)�5�1��7�7�<�<���0���7�7�<�<���4��
�
�
�2�7�7�<�<���4��	��2�x� ��I�I�h����t�|�|� ;�<��2�z�"�w�t�[�'A��K�K��$�.�.�1��8�8�H�%�������4�8���������r�w�w�|�|�G�U�F�'K�L�M����R�W�W�\�\�'�5�&�A�B���7�7�d�?�v�0�0��;��A�B�Z�F����������g�z�!B�C��8�8�H�%���2�x� ����X�-�-�x�/?�/?�@��2�z�"����X�.�.��0A�0A�B�#r'c
�t�tjj}tjj}|j	�}	||j	�d�}t|dfd�t|dfd�tj||d��t|ddfd�tj||d��t|ddfd�tj||dd��tj||dd	��t|dddfd�t|dd	d
fd�	tjdd�}tj|||��|j|||d���|j|||d���|j|||d���tj|�	tjdd
�}tj|||��|j|||d���|j|||dd	���|j|||dd���tj|�	d�}tj|||��|j|||dd	d
���|j|||dd���tj|�	tj|�tjtjj|��y#tj|�wxYw#tj|�wxYw#tj|�wxYw#tj|�tjtjj��wxYw)Nrgrhriztest.tmprjrk�	test_dir2r5�subdir2ztest.pyz*.tmp��ignorezsubdir*c�R�g}|D]�}tjj||�}tjj|�r(|j	�ddk(r|j|��jtjj
|�ddvs��|j|���|S)Nrr5z.py)r+r7r8rbr�rd�splitext)rx�namesrfrgr7s     r%�_filterz8TestCopyTree.test_copytree_with_exclude.<locals>._filter1s����C� %��!�w�w�|�|�C��6���G�G�M�M�$�/� �J�J�L��,��8��J�J�t�,��W�W�-�-�d�3�B�7�E�B��J�J�t�,�!&��Jr')r+r7r8r�r�r?r�r��ignore_patternsrmr�r�r�rl)r�r8r�rprq�patternsr�s       r%�test_copytree_with_excludez'TestCopyTree.test_copytree_with_exclude	s����w�w�|�|���������,�,�.��:	4��4�<�<�>�=�9�G���*�-�u�5���*�-�u�5��H�H�T�'�:�.�/���*�j�9�5�A��H�H�T�'�;�/�0���+�z�:�E�B��H�H�T�'�;��9�:��H�H�T�'�;�	�:�;���+�x��D�e�L���+�y�)�D�e�L�
'�!�1�1�'�;�G��������B�����t�G�Z�'@� A�B�� � ���W�j�(A�!B�C�� � ���W�k�(B�!C�D��
�
�g�&�
'�!�1�1�'�9�E��������B�� � ���W�j�(A�!B�C�� � ���W�k�9�(M�!N�O�� � ���W�k�8�(L�!M�N��
�
�g�&�
'�
�������A�� � ���W�k�9�-6�)8�"9�:�� � ���W�k�8�(L�!M�N��
�
�g�&��M�M�'�"��M�M�"�'�'�/�/�'�2�3��I�
�
�g�&���
�
�g�&��0�
�
�g�&���M�M�'�"��M�M�"�'�'�/�/�'�2�3�sY�C#M.�*BL �2M.�B
L:�M.�(AM�M.� L7�7M.�:M�M.�M+�+M.�.A	N7c
�L���tjj}tjj}�j	�}||d�}tj
||��tj
||d��tj
tjj|dd��t
|dddfd�g���fd�}|�j	�d�}tj|||���j|||ddd���|�j	�d�}tjt|�||���j|||ddd���|�j	�d�}ttj|��d	}�j|tj�tj|||���j|||ddd����jt!��d
�y)N�sourcerjr5rhrkc����j|��j|t��j|t��j	t|�tt
|���|D]}�j|t��gSr*)rdr�r9�listr�r��set)rxr�rg�invokationsr�s   ��r%�_ignorez?TestCopyTree.test_copytree_arg_types_of_ignore.<locals>._ignoreXsl������s�#��!�!�#�s�+��!�!�%��.����S��Z��S��Z��9����%�%�d�C�0���Ir'rgr�r�	)r+r7r8r�r�r�r?r�rmr�rr�r�r��DirEntryr�r�)	r�r8r�r'rpr�rq�
src_dir_entryr�s	`       @r%�!test_copytree_arg_types_of_ignorez.TestCopyTree.test_copytree_arg_types_of_ignoreJs�����w�w�|�|���������,�,�.���w��)��
����g���
����g�z�*�+�
��������g�z�8�<�=��W�j�(�J�?��G���	��t�|�|�~�}�5��������9�����t�G�Z��$.� 0�1�	2��t�|�|�~�}�5�������)�7�7�C�����t�G�Z��$.� 0�1�	2��t�|�|�~�}�5���R�Z�Z��0�1�!�4�
����m�R�[�[�9����
�w�w�?�����t�G�Z��$.� 0�1�	2�	
����[�)�1�-r'c	���|j�}tjj|d�}tj|�tjj|d�}|jtj|�tj|d�t|dfd�tjtjj|d�d�t|dfd�tjtjj|d�d�tj|�	�}|jtj|�tj|d�t
j||�|jtj|�jtj|�j�|jtjtjj|d��jtjtjj|d��j�|jtjtjj|d��jtjtjj|d��j�tjj|tjj!|�d
�}|jtj|�jtj|�j�y)Nr�rgi�zpermissive.txtrizrestrictive.txtrki�r�r�)r�r+r7r8r�r�r�r�r�r?rqrrmr�r�r�r�)r�r'rprq�restrictive_subdir�restrictive_subdir_dsts      r%�!test_copytree_retains_permissionsz.TestCopyTree.test_copytree_retains_permissionsts3���,�,�.���'�'�,�,�w��1��
������'�'�,�,�w�
�6������
�
�w�/�
����%� ��W�.�/��7�
��������g�'7�8�%�@��W�/�0�%�8�
��������g�'8�9�5�A�%�-�-�'�:�����	�(�(�*<�=�
���#�U�+������)��������)�1�1�2�7�7�7�3C�3K�3K�L������������g�7G�!H�I�Q�Q��'�'�"�'�'�,�,�w�8H�"I�J�R�R�	T������������g�7H�!I�J�R�R��'�'�"�'�'�,�,�w�8I�"J�K�S�S�	U�!#�����g�.0�g�g�m�m�<N�.O�PQ�.R�"T��������!3�4�<�<��'�'�"8�9�A�A�	Cr'zos.chmodc���|j�}tjj|j�d�}|j	t
j|�|j	t
jtjj|��td�|_	|jt
j�5tj||�ddd�y#1swYyxYw)Nrgzka-boom)
r�r+r7r8r�r�r�rl�PermissionErrorrr�rrm)r��
mock_patchrprqs    r%�test_copytree_winerrorz#TestCopyTree.test_copytree_winerror�s���
�,�,�.���'�'�,�,�t�|�|�~�}�=������
�
�w�/�����
�
�r�w�w���w�'?�@�!0��!;�
��
�
�
�v�|�|�
,��O�O�G�W�-�-�
,�
,�s�C+�+C4c�@���������fd�}g��j��tj�j����ttj
j
�d��tj��|���jt��d�y)Nc�@���jd��j|t��j|t��j|tj
j
�d���j|tj
j
�d��y�Nr�)rdr�r9r�r+r7r8)r�r�ry�flagr�rxs  ����r%�custom_cpfunzETestCopyTree.test_copytree_custom_copy_function.<locals>.custom_cpfun�sm����K�K����!�!�!�S�)��!�!�!�S�)����Q������S�%� 8�9����Q������S�%� 8�9r'r�r���
copy_functionr�)r�rqr�r?r+r7r8r�rmr�r�)r�r�ryr�rxs` @@@r%�"test_copytree_custom_copy_functionz/TestCopyTree.test_copytree_custom_copy_function�si���	:����l�l�n���o�o�$�,�,�.�1���B�G�G�L�L��e�,�-�����S��=�����T��A�&r'rLrMrNrOc�|�tjt�	tjj	td�}tj|�tjj	|d�}	tj
|�	tjtt�|jd�tj td�	�tj td�	�y#t$r}|jd|z�Yd}~��d}~wwxYw#tj$rR}|jd}|jt|�d�|d\}}}|jd|z|�Yd}~��d}~wwxYw#tj td�	�tj td�	�wxYw)
Nr5rQ�os.mkfifo(): %sz$shutil.Error should have been raisedrr�z`%s` is a named pipeTr�)r+r�rr7r8rLr��skipTestr�rm�TESTFN2�failrr#r�r�r�)r�r5�pipe�er�rxry�	error_msgs        r%�test_copytree_named_pipez%TestCopyTree.test_copytree_named_pipe�s?��
	�����	7��W�W�\�\�&�(�3�F��H�H�V���7�7�<�<���1�D�
5��	�	�$��
B������0��	�	�@�A��M�M�&��5��M�M�'��6��#�
5��
�
�/�!�3�4�4��
5���<�<�
K�������� � ��V��a�0�&,�Q�i�#��S�)�� � �!7�$�!>�	�J�J��	
K��
�M�M�&��5��M�M�'��6�s[�AF�5C1�D�)F�1	D�:D�F�D�F�F�.AE;�6F�;F�F�8F;c���|j�}tjj|j�d�}t	|dfd�tj
tjj|d��t	|ddfd�g��fd�}t
j|||��|jt��d�y)	Nrgrhrirjrkc�,���j||f�yr*r�)rxry�copieds  �r%�_copyz6TestCopyTree.test_copytree_special_func.<locals>._copy�s����M�M�3��*�%r'r�ro)
r�r+r7r8r?r�r�rmr�r�)r�rprqr�r�s    @r%�test_copytree_special_funcz'TestCopyTree.test_copytree_special_func�s�����,�,�.���'�'�,�,�t�|�|�~�}�=���W�j�)�5�1�
��������g�z�2�3��W�j�*�5�u�=���	&�	������>�����V��a�(r'c�V�|j�}tjj|d�}t	|d�tjj|d�}tj
|�||fD]j}tjdtjj|d��tj|tjj|d���ltjj|j�d�}|jttj||�tjj|j�d�}tj||d	�
�tj|�D]*\}}}|jd|�|jd|��,tjj|j�d�}tj||d	��|jdtj|��y)
Nrh�abc�dir_a�
IDONTEXIST�broken�validrg�destination2T)�ignore_dangling_symlinks�destination3r~)r�r+r7r8r?r�r�r�rr�rm�walk�assertNotInrra)	r�rp�
valid_filer�r�rq�root�dirs�filess	         r%�test_copytree_dangling_symlinksz,TestCopyTree.test_copytree_dangling_symlinks�sm���,�,�.���W�W�\�\�'�:�6�
��J��&������W�g�.��
������%��A��J�J�|�R�W�W�\�\�!�X�%>�?��J�J�z�2�7�7�<�<��7�#;�<� �
�'�'�,�,�t�|�|�~�}�=�����%����'�7�C��'�'�,�,�t�|�|�~�~�>�������4�H�!#����!1��D�$�����X�u�-��M�M�'�5�)�"2�
�'�'�,�,�t�|�|�~�~�>�������4�8��
�
�j�"�*�*�W�"5�6r'c	���|j�}tjj|j�d�}tjtjj|d��ttjj|dd��tjtjj|d�tjj|d�d��tj||d��|jtjjtjj|d���|jdtjtjj|d���tjj|j�d	�}tj||d��|jtjjtjj|d���|jdtjtjj|d���y)
Nrg�real_dirrh�link_to_dirT��target_is_directoryFr~r�)r�r+r7r8r�r?r�r�rmr�rcrrar�)r�rprqs   r%�test_copytree_symlink_dirz&TestCopyTree.test_copytree_symlink_dir�sg���,�,�.���'�'�,�,�t�|�|�~�}�=��
��������g�z�2�3��B�G�G�L�L��*�j�A�B�
�
�
�2�7�7�<�<���4��7�7�<�<���7�'+�	-�	�����5�9��������������W�m�(L�M�N��
�
�j�"�*�*�R�W�W�\�\�'�=�-Q�"R�S��'�'�,�,�t�|�|�~�~�>�������4�8���������r�w�w�|�|�G�]�'K�L�M��
�
�j�"�*�*�R�W�W�\�\�'�=�-Q�"R�Sr'c�@�|j�}|dz}|jtj|d�tj
j
|d�}t|d�tj||�}|jdgt	j|��y)N�destTr�)r�r�r�r�r+r7r8r?rmr�ra)r�rprqrx�rvs     r%�test_copytree_return_valuez'TestCopyTree.test_copytree_return_valuess���,�,�.���F�"������
�
�w��5��g�g�l�l�7�E�*���C���
�_�_�W�g�
.�����%��"�*�*�R�.�1r'c���|j�}|jtj|d��tj
j
|dd�}tj
j
|dd�}t	j|�tj
j
|d�}t|d�tj||�}|jdgt	j|��y)NTr��t�pg�
somevendorz1.0�pol)r�r�r�r�r+r7r8rWr?rmr�ra)r��base_dirrprqrxr�s      r%�test_copytree_subdirectoryz'TestCopyTree.test_copytree_subdirectorys����<�<�>������
�
�x�t��D��'�'�,�,�x��d�3���'�'�,�,�w��e�<��
���G���g�g�l�l�7�E�*���C���
�_�_�W�g�
.�����%��"�*�*�R�.�1r'N)r�r�r�rsrxrr]r�r�r�r�r^�mock�patchr�r�r_rpr+r`r�rar�r�r�r�r�r�rBr'r%rere�s��(�&C�2�"�"�C�#�C�>?4�B(.�TC�6�]�]����$�.�%�.�'�"�X�����X�.�0F�G��"�"��X�_�_�S�\�\�Y�.�;�=�7�=�#�H�7�.)��"�"�7�#�7�4�"�"�T�#�T�$2�
2r'rec��eZdZejd��Zejee	d�xse	jdk(d�ejd���Zejee	d�d�ejd���Z
ejd��Zejee	d	�xreed
�xr	eed�d�d
��Zej"d��Zejej"ej&d����Zd�Zd�Zejd��Zejee	d�d�d��Zejd��Zej"d��Zd�Zd�Zd�Zd�Zejd��Zejee	d�d�d��Z ejd ��Z!ejee	d!�d"�eje"jFd#k(d$�d%���Z$d&�Z%d'�Z&eje'xse(xse)d(�eje*d)�d*���Z+d+�Z,y,)-�TestCopyc���|j�}tjj|d�}tjj|d�}tjj|d�}tjj|d�}t	|d�t	|d�tj
||�tj
||�tj|tjtjz�tj|tj�|jtj|�jtj|�j�tj||�|jtj|�jtj|�j�tj|tj�tj||�|jtj|�jtj|�j�tj|tj�tj||�|jtj|�jtj|�j�tj|tj�tj||�|jtj|�jtj|�j�y)Nr��bar�baz�quux)r�r+r7r8r?r�r�r�r��S_IRWXGr��assertNotEqualr�r��copymoder��r�r'rxryr�r�s      r%�test_copymode_follow_symlinksz&TestCopy.test_copymode_follow_symlinkss���,�,�.���g�g�l�l�7�E�*���g�g�l�l�7�E�*���7�7�<�<���/���7�7�<�<���0���C����C���
�
�
�3��!�
�
�
�3��!�
����d�l�l�4�<�<�/�0�
����d�l�l�#����B�G�G�C�L�0�0�"�'�'�#�,�2F�2F�G�����S�!���������-�-�r�w�w�s�|�/C�/C�D�	����d�l�l�#�����#�&���������-�-�r�w�w�s�|�/C�/C�D�
����d�l�l�#�����X�&���������-�-�r�w�w�s�|�/C�/C�D�
����d�l�l�#�����(�+���������-�-�r�w�w�s�|�/C�/C�Dr'r{r�zrequires os.lchmodc��tjdk(rtjntj}|j	�}tj
j
|d�}tj
j
|d�}tj
j
|d�}tj
j
|d�}t|d�t|d�tj||�tj||�tj|tjtjz�tj|tj�||tjtjz�||tj�tj|�j}tj||d��|j!tj"|�jtj"|�j�|j!tj|�j|�||tj�tj||d��|j!tj|�jtj|�j�||tj�tj||d��|j!tj|�jtj|�j�y)Nr�r�r�r�r�F��follow_symlinks)r+rgr�r{r�r7r8r?r�r�r�r�r�r�r�r�r�r)r��_lchmodr'rxryr�r��old_modes        r%� test_copymode_symlink_to_symlinkz)TestCopy.test_copymode_symlink_to_symlink>s��!�g�g��o�"�(�(�2�9�9���,�,�.���g�g�l�l�7�E�*���g�g�l�l�7�E�*���7�7�<�<���/���7�7�<�<���0���C����C���
�
�
�3��!�
�
�
�3��!�
����d�l�l�4�<�<�/�0�
����d�l�l�#���$�,�,�t�|�|�3�4���$�,�,�'��7�7�3�<�'�'������(�E�B�������(�+�3�3����(�+�3�3�	5���������-�-�x�8���$�,�,�'�����#�u�=���������-�-�r�w�w�s�|�/C�/C�D���$�,�,�'�����X�u�=���������-�-�r�w�w�s�|�/C�/C�Dr'z requires os.lchmod to be missingc���|j�}tjj|d�}tjj|d�}tjj|d�}tjj|d�}t	|d�t	|d�tj
||�tj
||�t
j||d��y)Nr�r�r�r�Fr�)r�r+r7r8r?r�r�r�r�s      r%�*test_copymode_symlink_to_symlink_wo_lchmodz3TestCopy.test_copymode_symlink_to_symlink_wo_lchmod^s����,�,�.���g�g�l�l�7�E�*���g�g�l�l�7�E�*���7�7�<�<���/���7�7�<�<���0���C����C���
�
�
�3��!�
�
�
�3��!�����(�E�Br'c�2�|j�}tjj|d�}tjj|d�}tjj|d�}tjj|d�}t	|d�tj
|�}tj||j|jdz
f�t	|d�|jtj
|�jtj
|�j�tj||�tj||�ttd�r%tj|t
j�n7tjdk(r$tj|t
j�ttd�r4tt
d	�r$tj |t
j"�tj$|�}ttd�stjdk(rQt'j(||d
��|j|j*tj
|�j*�t'j(||d��tj$|�}tjtj,vr0d
D]+}	|j/t1||	�t1||	�dz��-ttd�stjdk(r&|j3|j*|j*�ttd�r2t|d�r&|j3|j4|j4�t'j(||d��|j7t9tj
|�jtj
|�jz
�dk�y)Nr�r�r��quxgE@r{r�r|r}Tr�F��st_atime�st_mtimer�r�g�������?)r�r+r7r8r?r��utimer�r�r�r�rpr{r�rgr�r|r}rr��copystatr�r"�assertLessEqualr!r�r�r��abs)
r�r'rxryr�r�r��
src_link_stat�
dst_link_stat�attrs
          r%�test_copystat_symlinkszTestCopy.test_copystat_symlinksns����,�,�.���g�g�l�l�7�E�*���g�g�l�l�7�E�*���7�7�<�<���/���7�7�<�<���/���C����7�7�3�<��
����x�(�(��(�(�4�/�1�	2��C������B�G�G�C�L�1�1�2�7�7�3�<�3H�3H�I�
�
�
�3��!�
�
�
�3��!��2�x� ��I�I�h����-�
�W�W��_��H�H�X�t�|�|�,��2�z�"�w�t�[�'A��K�K��$�.�.�1�����*�
��2�x� �B�G�G�t�O��O�O�H�h��E����
� 5� 5�r�w�w�s�|�7K�7K�L�����(�E�B�����*�
�
�8�8�r�2�2�2�.���$�$�W�]�D�%A�%,�]�D�%A�A�%E�G�/��2�x� �B�G�G�t�O����]�2�2�M�4I�4I�J��2�z�"�w�}�j�'I����]�3�3�]�5K�5K�L�����#�u�=�����B�G�G�C�L�1�1�B�G�G�C�L�4I�4I�I�J�� �	!r'�chflags�
EOPNOTSUPP�ENOTSUPz)requires os.chflags, EOPNOTSUPP & ENOTSUPc�v�|j�}tjj|d�}tjj|d�}t	|d�t	|d�d�}tj
}	tjtjfD])}||�t_tj||��+|tjtjz�t_|jttj||�|t_y#|t_wxYw)Nr��file2�xxxc�0���t��dd���fd�
}|S)NTr�c�����_��r*)r")r7�flagsr��err�exs   ��r%�_chflags_raiserzlTestCopy.test_copystat_handles_harmless_chflags_errors.<locals>.make_chflags_raiser.<locals>._chflags_raiser�s�������r'r,)rrrs` @r%�make_chflags_raiserzSTestCopy.test_copystat_handles_harmless_chflags_errors.<locals>.make_chflags_raiser�s�����B�@D�
�#�"r')
r�r+r7r8r?rr"rrr�r�r�r )r�r�r�r	r�old_chflagsrs       r%�-test_copystat_handles_harmless_chflags_errorsz6TestCopy.test_copystat_handles_harmless_chflags_errors�s���
����������V�W�-�������V�W�-���E�5�!��E�5�!�	#��j�j��	%��'�'����6��0��5��
�����u�-�7�-�U�-=�-=��
�
�-M�N�B�J����g�v����u�E�$�B�J���B�J�s
�=B"D+�+
D8c����	�
�|j�}tjj|d��
t	�
d�tjj|d�}t	|d�tj�
|�tj�
dd�tj�
dd�tj�
|�|jttj�
��ttj|���|jtj�
d�tj|d��tj|�t	|d�ttjd��	��	fd�}	tj�|t_tj�
|�|j!dtj|���t_d	d
���
fd�
}	tj�|t_
tj�
|��t_
tjj|d��
tjj|d
�}t	�
�
�t	||�tj�
dd�tj|dd�tj"|d�tjj|d�}tjj|d�}t	||�t	||�tj$�
|�tj$||�|jtj|d�d�|jtj|d�d�y#�t_wxYw#�t_
wxYw)Nr�r��user.foo�42zuser.bar�43�EPERMc�*��|dk(r���|||fi|��y)NrrB)�fnamer�valr$�
orig_setxattr�os_errors    ��r%�_raise_on_user_fooz3TestCopy.test_copyxattr.<locals>._raise_on_user_foo�s!����z�!����e�T�3�9�&�9r'Tr�c�V��|�k(rttjd���||��S)NzOperation not supportedr�)r r"r)rr��orig_listxattrrxs  ��r%�
_raise_on_srcz.TestCopy.test_copyxattr.<locals>._raise_on_src�s)�����|��e�m�m�-F�G�G�!�%��I�Ir'�the_original�the_original_rozuser.the_valuesfiddlyi$�the_copy�the_copy_ro)r�r+r7r8r?r��
_copyxattr�setxattrr�r`�	listxattr�getxattrrAr r"rrr�r�)r�r'ryrr!�srcro�dstror rrrxs       @@@@r%�test_copyxattrzTestCopy.test_copyxattr�s�����,�,�.���g�g�l�l�7�E�*���C����g�g�l�l�7�E�*���C���	���#�s�#�
���C��U�+�
���C��U�+����#�s�#��������S� 1�2�F�2�<�<��;L�4M�N�������C��,����C��,�	.�	�	�	�#���C����5�;�;��0��	:�
	(��K�K�M�,�B�K����c�3�'��M�M�*�b�l�l�3�&7�8�'�B�K�48�	J�	*��\�\�N�(�B�L����c�3�'�)�B�L��g�g�l�l�7�N�3�������W�&7�8���C����E�5�!�
���C�)�9�5�
���E�+�Y�7�
�������g�g�l�l�7�J�/�������W�m�4���C����E�5�!�����S�!�����u�%�������S�*:�;�Y�G�������U�,<�=�y�I��9(�B�K��*�B�L�s�
AN!�81N1�!
N.�1
N>c�T�|j�}tjj|d�}tjj|d�}t	|d�tj
||�tj|dd�tj|ddd��tjj|d�}tjj|d	�}t	|d�tj
||�tj||d��|jtj|dd��d�|jttj|d�tj||d��|jtj|d�d�y)
Nr�r�ztrusted.foorrFr�r�r�)
r�r+r7r8r?r�r'r�r&r�r)r�r )r�r'rxr�ryr�s      r%�test_copyxattr_symlinksz TestCopy.test_copyxattr_symlinks�s&���,�,�.���g�g�l�l�7�E�*���7�7�<�<���/���C���
�
�
�3��!�
���C���.�
���H�m�U�E�J��g�g�l�l�7�E�*���7�7�<�<���/���C���
�
�
�3��!����(�H�e�D�������X�}�e�T�V[�\����'�2�;�;��]�C����(�C��?�������S�-�8�%�@r'c��d}|j�}t||fd�tjj	||�}|j�}|||�tjj	||�}||fS)Nrhr
)r�r?r+r7r8)r��methodrr�r��tmpdir2r	s       r%�
_copy_filezTestCopy._copy_filesg����������V�U�O�U�+������V�U�+���,�,�.���u�g�������W�e�,���u�~�r'c�<�|jtj�\}}|jtj
j
|��|jt	j|�jt	j|�j�yr*)
r2r��copyr�r+r7r�r�r�r�)r�r�r	s   r%�	test_copyzTestCopy.test_copys]�����v�{�{�3���u���������u�-�.���������/�/������1G�1G�Hr'c�f�|j�}tjj|d�}tjj|d�}tjj|d�}t	|d�tj
||�t
td�r5tj|tjtjz�tj||d��|jtjj|��|jt!|�t!|��tj"|�tj||d��|j%tjj|��|jtj&|�tj&|��t
td�rM|jtj(|�j*tj(|�j*�yy)Nr�r�r�r{Tr�F)r�r+r7r8r?r�rpr{r�r�r�r�r4r�rcr�r]rAr�r�rr�)r�r'rxryr�s     r%�test_copy_symlinkszTestCopy.test_copy_symlinks"s^���,�,�.���g�g�l�l�7�E�*���g�g�l�l�7�E�*���7�7�<�<���/���C���
�
�
�3��!��2�x� ��I�I�h����t�|�|� ;�<����H�c�4�8����������,�-�����3���3��8�
�	�	�#�����H�c�5�9���������s�+�,�������S�)�2�;�;�x�+@�A��2�x� ����R�X�X�h�/�7�7��X�X�c�]�2�2�
4�!r'r�zrequires os.utimec�,�|jtj�\}}|jtj
j
|��t	j|�}t	j|�}|j|j|j�dD]+}|jt||�t||�dz��-ttd�r4t|d�r'|jt|d�t|d��yyy)Nr�r�rr�)
r2r��copy2r�r+r7r�r�r�r�r�r!rp)r�r�r	�
file1_stat�
file2_statrs      r%�
test_copy2zTestCopy.test_copy2;s������v�|�|�4���u���������u�-�.��W�W�U�^�
��W�W�U�^�
�����+�+�Z�-?�-?�@�*�D�� � ���T�!:�!(��T�!:�Q�!>�
@�+��2�y�!�g�j�*�&E����W�Z��<�$�Z��<�
>�'F�!r'c��|j�}tjj|d�}tjj|d�}tjj|d�}t	|d�tj
||�t
td�r5tj|tjtjz�t
td�r4t
td�r$tj|tj�tj|�}tj|�}tj||d��|j!tjj#|��|j%t'|�t'|��tj(|�tj||d	��|j+tjj#|��|j%tj,|�tj,|��tj|�}tj.tj0vr0d
D]+}|j3t5||�t5||�dz��-t
td�rL|j%|j6|j6�|j9|j6|j6�t
td�r4t
|d�r'|j%|j:|j:�yyy)
Nr�r�r�r{r|r}Tr�Fr�r�r�)r�r+r7r8r?r�rpr{r�r�r�r|r}rr�r9r�rcr�r]rAr�r�r�r"r�r!r�r�r�)	r�r'rxryr�r�rr�rs	         r%�test_copy2_symlinkszTestCopy.test_copy2_symlinksLs+���,�,�.���g�g�l�l�7�E�*���g�g�l�l�7�E�*���7�7�<�<���/���C���
�
�
�3��!��2�x� ��I�I�h����t�|�|� ;�<��2�z�"�w�t�[�'A��K�K��$�.�.�1��7�7�3�<������*�
����X�s�D�9����������,�-�����3���3��8�
�	�	�#�����X�s�E�:���������s�+�,�������S�)�2�;�;�x�+@�A��8�8�C�=��
�8�8�r�2�2�2�.���$�$�W�]�D�%A�%,�X�t�%<�q�%@�B�/��2�x� ����]�2�2�H�4D�4D�E����� 0� 0�(�2B�2B�C��2�z�"�w�}�j�'I����]�3�3�X�5F�5F�G�(J�"r'c��|j�}tjj|d�}tjj|d�}t	|d�tj
|dd�t
j||�|jtj|d�tj|d��tj|�y)Nr�r�rr)r�r+r7r8r?r'r�r9r�r)rA)r�r'rxrys    r%�test_copy2_xattrzTestCopy.test_copy2_xattros����,�,�.���g�g�l�l�7�E�*���g�g�l�l�7�E�*���C���
���C��U�+����S�#��������C��,����C��,�	.�	�	�	�#�r'c��tjtjfD]�}|j�}|j�}tj
j
|d�}t|d�|||�}|j|tj
j
|d��||tj
j
|d��}|j|tj
j
|d����y)Nr�r�)	r�r4r9r�r+r7r8r?r�)r�rrprqrxr�s      r%�test_copy_return_valuezTestCopy.test_copy_return_value|s����;�;����-�B��l�l�n�G��l�l�n�G��'�'�,�,�w��.�C���U�#��C��!�B����R������g�u�!=�>��C������g�u�5�6�B����R������g�u�!=�>�.r'c�B�|jtj�yr*)�_test_copy_dirr�r4rRs r%�
test_copy_dirzTestCopy.test_copy_dir�s�����F�K�K�(r'c�B�|jtj�yr*)rDr�r9rRs r%�test_copy2_dirzTestCopy.test_copy2_dir�s�����F�L�L�)r'c�~�|j�}tjj|d�}|j�}tjj|d�}t	|d�t
jdk(rt}nt}|j||||�|j||||�|||�y�Nr��does_not_exist/�win32)
r�r+r7r8r?r�rar��IsADirectoryErrorr�)r��	copy_funcrp�src_filer�ryrs       r%rDzTestCopy._test_copy_dir�s����,�,�.���7�7�<�<���/���|�|�~���g�g�l�l�7�$5�6���H�e�$��<�<�7�"�!�C�#�C����#�y�$��8�	
���#�y�$��4��(�D�!r'c���|j�}tjj|d�}tjj|d�}tjj|d�}tjj|d�}t	|d�tj
||�t
j||d��|jtjj|��|jtj|�tj|��t
j||�|jtjj|��y)Nrxryr�r�r�Fr�)
r�r+r7r8r?r�r��copyfiler�rcr�r�r�)r�r'rxryr�r�s      r%�test_copyfile_symlinkszTestCopy.test_copyfile_symlinks�s����,�,�.���g�g�l�l�7�E�*���g�g�l�l�7�E�*���7�7�<�<���4���w�w�|�|�G�V�,���C���
�
�
�3�������h��>���������x�0�1�������T�*�B�K�K��,A�B�����c�"����������,�-r'r�zrequires os.linkc���tjt�tjj	td�}tjj	td�}	t|d�	tj||�|jtjtj||�t|dd��5}|j|j�d�ddd�tj |�tj"td�	�y#t$r}|jd|z�Yd}~��d}~wwxYw#1swY�dxYw#tj"td�	�wxYw)
NrErF�cheddarz
os.link(): %srVrWrXTr�)r+r�rr7r8r?r�r�r�r�r�r
rPr;r�rZrAr�)r�rxryr�rQs     r%�'test_dont_copy_file_onto_link_to_itselfz0TestCopy.test_dont_copy_file_onto_link_to_itself�s���	������g�g�l�l�6�8�,���g�g�l�l�6�6�*��	6���Y�'�
3�����S�!�
���f�2�2�F�O�O�S�#�N��c�3��1�Q�� � �����9�5�2��I�I�c�N��M�M�&��5��#�
3��
�
�o��1�2�2��
3��2�1��
�M�M�&��5�sN�#E�0D�>E�!E�%E�	E�'E�;E�E�E�E�
E�E1c��tjt�tjj	td�}tjj	td�}	t|d�tjd|�|jtjtj||�t|dd��5}|j|j�d�ddd�tj|�tjtd��y#1swY�:xYw#tjtd��wxYw)	NrErFrSrVrWrXTr�)r+r�rr7r8r?r�r�r�r
rPr;r�rZrAr�)r�rxryrQs    r%�*test_dont_copy_file_onto_symlink_to_itselfz3TestCopy.test_dont_copy_file_onto_symlink_to_itself�s���	������g�g�l�l�6�8�,���g�g�l�l�6�6�*��	6���Y�'�
�J�J�x��%����f�2�2�F�O�O�S�#�N��c�3��1�Q�� � �����9�5�2��I�I�c�N��M�M�&��5�	2�1��
�M�M�&��5�s%�#A D)�!D�$D)�D&�"D)�)ErLrMrNrOc���	tjt�	|jtjtjtt�|jtjtjtt�tjt�y#t$r}|j	d|z�Yd}~��d}~wwxYw#tjt�wxYw)Nr�)r+rLrr�r�r�r��SpecialFileErrorrPr��__file__rA)r�r�s  r%�test_copyfile_named_pipez!TestCopy.test_copyfile_named_pipe�s���	1��I�I�f��	����f�5�5� &�����
B����f�5�5� &����6�
C�
�I�I�f����	1��M�M�+�a�/�0�0��	1��
�I�I�f��s#�B&�A0C�&	C
�/C�C
�C+c��|j�}|j�}tjj|d�}tjj|d�}t	|d�tj||�}|jtjj|��|jt|�t|��y)Nr�r�)r�r+r7r8r?r�rPr�r�r�r])r�rprq�dst_filerNr�s      r%�test_copyfile_return_valuez#TestCopy.test_copyfile_return_value�s����,�,�.���,�,�.���7�7�<�<���/���7�7�<�<���/���H�e�$�
�_�_�X�x�
0����������r�*�+�����8�,�i��.A�Br'c�J�|j�}tjj|d�}t	|d�|jttj||�|jttj||�|jt|�d�yr�)r�r+r7r8r?r�r
r�rPrr�r])r�rprNs   r%�test_copyfile_same_filez TestCopy.test_copyfile_same_file�sr���,�,�.���7�7�<�<���/���H�e�$����-����(�H�M����%����(�H�E�����8�,�e�4r'zMOn MACOS, Solaris and Windows the errors are not confusing (though different)zNot valid on AIX, see gh-92670c��|j�}tjj|d�}tjj|d�}t	|d�|jttj||�y)Nr�rJ)	r�r+r7r8r?r�r�r�rP)r�rprNrys    r%�test_copyfile_nonexistent_dirz&TestCopy.test_copyfile_nonexistent_dir�s[���,�,�.���7�7�<�<���/���g�g�l�l�7�$5�6���H�e�$����+�V�_�_�h��Lr'c���|j�}tjj|d�}|j�}tjj|d�}t	|d�t
jdk(rt}nt}|j|tj||�|j|tj||�|j|tj||�yrI)r�r+r7r8r?r�rar�rLr�r�rP)r�rprNr�ryrs      r%�test_copyfile_copy_dirzTestCopy.test_copyfile_copy_dirs����,�,�.���7�7�<�<���/���|�|�~���g�g�l�l�7�$5�6���H�e�$��<�<�7�"�!�C�#�C����#�v�����=����#�v����'�B����#�v����g�>r'N)-r�r�r�rr]r�r^r_rpr+rgr�r`r�rr"r�skip_unless_xattrr,�skip_unless_dac_overrider.r2r5r7r<r>r@rBrErGrDrQrTrVr�rarZr]r_�MACOS�SOLARISr�r�rarcrBr'r%r�r�s���"�"�E�#�E�<�X�����X�.�A�"�'�'�T�/�CW�X��"�"�E�#�Y�E�<�X�_�_�W�R��*�,N�O��"�"�
C�#�P�
C��"�"�(!�#�(!�T�X�����Y�/�3� ���5�3� ��	�2�D�F�%�	F�%�6� � �=J�!�=J�~�"�"�� � ��'�'�A�(�!�#�A�.�I��"�"�4�#�4�0�X�����W�-�/B�C�>�D�>� �"�"� H�#� H�D� � �
�!�
�
?�)�*�"�$�"�"�.�#�.� �X�����V�,�.@�A�6�B�6�$�"�"�6�#�6�&�X�����X�.�0F�G��X�_�_�S�\�\�Y�.�;�=��=�H��	C�
5��X�_�_�U�0�g�0��3B�C��X�_�_�S�:�;�M�<�	C�
M�?r'r�c��eZdZd�Zd)d�Zej�d��Zej�d��Zd�Z	ej�e
jejd�d�d���Zej�d	��Zej�d
��Zej�d��Zej�e
jejd�d
�d���Zej�e
jejd�d�d���Zd�Zej�d��Zej�e
jed�d���Zd�Zd�Zd�Zd�Zej�d��Zd�Zd�Zej�d��Zd�Z d�Z!d �Z"d!�Z#ej�d"��Z$ejJ�d#��Z&ejN�e
jPe)xre*�d$�d%���Z+ej�d&��Z,d'�Z-y()*�TestArchivesc��tj|�5}|j�}|j�t	|�cddd�S#1swYyxYwr*)�tarfiler;�getnames�sortr6)r�r7�tarr�s    r%�_tarinfozTestArchives._tarinfo#s7��
�\�\�$�
�3��L�L�N�E��J�J�L���<� �
�
�s�+A�Ac���|j�}tjj||�}tj|d��t|dfd�t|dfd�tjtjj|d��t|ddfd�tjtjj|d��|rt|d	fd�||fS)
NT)�exist_okr�r
r	rz�file3�sub2�outer)r�r+r7r8rWr?r�)r�r��root_dir�dists    r%�
_create_fileszTestArchives._create_files)s����<�<�>���w�w�|�|�H�h�/��
���D�4�(��T�7�O�U�+��T�7�O�U�+�
��������d�E�*�+��T�5�'�*�E�2�
��������d�F�+�,����7�+�U�3���!�!r'c��|j�\}}tj�5t5tj
j
dd�}t|d|�}|j|tj
j|�dz�|jtj
j|��|jtj|��tj|d�5}|j|j!�gd��ddd�ddd�ddd�tj�5t5tj
j
dd�}t|d||�}|j|tj
j|�dz�|jtj
j|��|jtj|��tj|d�5}|j|j!�gd��ddd�ddd�ddd�tj�5t5tj
j
d	d�}t|d|tj
j
|d
��}|j|tj
j|�dz�|jtj
j|��|jtj|��tj|d�5}|j|j!�ddg�ddd�ddd�ddd�y#1swY��wxYw#1swY��|xYw#1swY���xYw#1swY��xYw#1swY���xYw#1swY���xYw#1swY�hxYw#1swY�lxYw#1swYyxYw)
Nry�archivern�.tarrV��.z./distz
./dist/subz./dist/sub2z./dist/file1z./dist/file2z./dist/sub/file3z./outer�dst2�rv�dist/subz	dist/sub2�
dist/file1�
dist/file2�dist/sub/file3�dst3rzrr�)rwr�temp_cwd�no_chdirr+r7r8rr��abspathr�rnrk�
is_tarfiler;�assertCountEqualrl�r�rur��	base_namery�tfs      r%�test_make_tarfilezTestArchives.test_make_tarfile7s���!�/�/�1���(�
�
�
�
!�8������U�I�6�I�"�9�e�X�>�G����W�b�g�g�o�o�i�&@�6�&I�J��O�O�B�G�G�N�N�7�3�4��O�O�G�.�.�w�7�8����g�s�+�r��%�%�b�k�k�m�$�%�,�$,�
!��
�
�
!�8������V�Y�7�I�"�9�e�X�x�H�G����W�b�g�g�o�o�i�&@�6�&I�J��O�O�B�G�G�N�N�7�3�4��O�O�G�.�.�w�7�8����g�s�+�r��%�%�b�k�k�m�G�H�,�$,�
!��
�
�
!�8������V�Y�7�I�"�9�e�X�#%�7�7�<�<��%�#@�B�G����W�b�g�g�o�o�i�&@�6�&I�J��O�O�B�G�G�N�N�7�3�4��O�O�G�.�.�w�7�8����g�s�+�r��%�%�b�k�k�m�#�%5�6�8�,�$,�
!�
!�),�+��$,�8��
!�
!��*,�+��$,�8��
!�
!��(,�+��$,�8��
!�
!�s��N)�CN�7#N�N�"N)�O�
C	O�#N6�9O�O�%O5�,C'O)�#O�6O)�>O5�N�N�N&	�!N)�)N3�6O�;O�O
	�O�O�O&�"O)�)O2	�.O5�5O>c�&�|j�\}}tjj|j	�dd�}tjj||�}t
j|�5t5t|d�}|j||dz�|jtjj|��|jtj|��tj|d�5}|j!|j#�gd��ddd�ddd�ddd�t
j|�5t5tjjdd�}t|d|��}|j||d	z�|jtjj|��|jtj|��tj|d
�5}|j!|j#�gd��ddd�ddd�ddd�y#1swY��xYw#1swY��#xYw#1swY��(xYw#1swY�AxYw#1swY�ExYw#1swYyxYw)Nryry�gztar�.tar.gzzr:gzr{rn�r�rzrVr~)rwr+r7r8r��relpathr�
change_cwdr�rr�r�rnrkr�r;r�rlr�s      r%�!test_make_tarfile_without_rootdirz.TestArchives.test_make_tarfile_without_rootdiras���!�/�/�1���(��G�G�L�L������	�B�	��G�G�O�O�I�x�8�	�
�
!�
!�(�
+�X�"�9�g�6�G����W�i�)�&;�<��O�O�B�G�G�N�N�7�3�4��O�O�G�.�.�w�7�8����g�v�.�"��%�%�b�k�k�m�$�%�/�.6�
+��
!�
!�(�
+�X������U�I�6�I�"�9�e�h�G�G����W�i�&�&8�9��O�O�B�G�G�N�N�7�3�4��O�O�G�.�.�w�7�8����g�s�+�r��%�%�b�k�k�m�G�H�,�
.6�
+�
+�/�.��.6�X��
+�
+��$,�+��
.6�X��
+�
+�sz�8I"�?B
I�	#I�,I�4I"�J� B,I;�#I/�/I;�7J�I�
I�I	�I"�"I,�/I8�4I;�;J	�J�Jc���|j�\}}tj�5t5tj
j
dd�}t|d|tj�}|j|tj
j|�dz�|jtj
j|��|jtj|��tj|d�5}|j!|j#�gd��ddd�ddd�ddd�y#1swY�xYw#1swY�xYw#1swYyxYw)NryryrnrzrVr{)rwrr�r�r+r7r8r�curdirr�r�r�rnrkr�r;r�rlr�s      r%�&test_make_tarfile_with_explicit_curdirz3TestArchives.test_make_tarfile_with_explicit_curdir~s���!�/�/�1���(�
�
�
�
!�8������U�I�6�I�"�9�e�X�r�y�y�I�G����W�b�g�g�o�o�i�&@�6�&I�J��O�O�B�G�G�N�N�7�3�4��O�O�G�.�.�w�7�8����g�s�+�r��%�%�b�k�k�m�$�%�,�
$,�
!�
!�,�+��
$,�8��
!�
!�s;�E�CE�#E�)E�1E�E�E�E	�E�E#rnzNeed the tar command to runc��|j�\}}tjj|j	�d�}t
5t
|d||�}ddd�|j|dz�|jtjj|��tjj|d�}ddd|g}tjdk(rGddl}t|j�djd	�d�d
k\r|jdd�t!j"||t j$�
�|jtjj|��|j|j'|�|j'|��t
5t
|d||�}ddd�|j||dz�|jtjj|��t
5t
|d||d��}ddd�|j||dz�|jtjj|��y#1swY��xYw#1swY��xYw#1swY�fxYw)Nryr�r�zarchive2.tarrnz-cfrrr|�r�z--no-mac-metadata��cwd�stdoutrzT��dry_run)rwr+r7r8r�r�rr�r�rnr�rar��mac_verr��insertr��
check_call�DEVNULLro)r�rur�r��tarball�tarball2�tar_cmdras        r%�test_tarfile_vs_tarz TestArchives.test_tarfile_vs_tar�s���"�/�/�1���(��G�G�L�L������;�	�
�"�9�g�x��J�G��	
����)�i�"7�8���������w�/�0��7�7�<�<��.�9���%���:���<�<�8�#�
��8�#�#�%�a�(�.�.�s�3�A�6�7�2�=����q�"5�6����g�8�%/�%7�%7�	9�	
��������x�0�1�������w�/����x�1H�I��"�9�e�X�x�H�G������)�f�"4�5���������w�/�0��"�9�e�X�x�+/�1�G��	
����)�f�"4�5���������w�/�0�O�X��:�X���X�s$�I)�,I6�J�)I3�6I?�Jc��|j�\}}tj�5t5tj
j
dd�}t|d|�}|j|tj
j|�dz�|jtj
j|��|jtj|��tj|�5}|j|j!�gd��ddd�ddd�ddd�tj�5t5tj
j
dd�}t|d||�}|j|tj
j|�dz�|jtj
j|��|jtj|��tj|�5}|j|j!�gd��ddd�ddd�ddd�tj�5t5tj
j
dd�}t|d|tj
j
|d	��}|j|tj
j|�dz�|jtj
j|��|jtj|��tj|�5}|j|j!�d
dg�ddd�ddd�ddd�y#1swY��uxYw#1swY��zxYw#1swY��xYw#1swY��~xYw#1swY���xYw#1swY���xYw#1swY�hxYw#1swY�lxYw#1swYyxYw)Nryry�zip�.zip��dist/�	dist/sub/�
dist/sub2/r�r�r�rtr}�r�r�r�r�r�r�r�rzr�r�)rwrr�r�r+r7r8rr�r�r�rn�zipfile�
is_zipfile�ZipFiler��namelist�r�rur�r�ry�zfs      r%�test_make_zipfilezTestArchives.test_make_zipfile�s���!�/�/�1���(�
�
�
�
!�8������U�I�6�I�"�9�e�X�>�G����W�b�g�g�o�o�i�&@�6�&I�J��O�O�B�G�G�N�N�7�3�4��O�O�G�.�.�w�7�8�����)�R��%�%�b�k�k�m�"�#�*�
$,�
!��
�
�
!�8������V�Y�7�I�"�9�e�X�x�H�G����W�b�g�g�o�o�i�&@�6�&I�J��O�O�B�G�G�N�N�7�3�4��O�O�G�.�.�w�7�8�����)�R��%�%�b�k�k�m�G�H�*�
$,�
!��
�
�
!�8������V�Y�7�I�"�9�e�X�#%�7�7�<�<��%�#@�B�G����W�b�g�g�o�o�i�&@�6�&I�J��O�O�B�G�G�N�N�7�3�4��O�O�G�.�.�w�7�8�����)�R��%�%�b�k�k�m�$�&6�7�9�*�$,�
!�
!�'*�)��
$,�8��
!�
!��&*�)��
$,�8��
!�
!��&*�)��$,�8��
!�
!�s��N&�CN�6#N�N�!N&�O
�CO�#N3�7O�?O
�#O2�*C&O&�#O�3O&�;O2�N�N�N#	�N&�&N0�3N=�8O�O
	�O
�
O�O#�O&�&O/	�+O2�2O;c�H�|j�\}}tjj|j	�dd�}tjj||�}t
j|�5t5t|d�}|j||dz�|jtjj|��|jtj|��tj|�5}|j!|j#�gd��ddd�ddd�ddd�|j�\}}t
j|�5t5tjjdd�}t|d|��}|j||dz�|jtjj|��|jtj|��tj|�5}|j!|j#�gd��ddd�ddd�ddd�y#1swY��0xYw#1swY��5xYw#1swY��:xYw#1swY�AxYw#1swY�ExYw#1swYyxYw)Nryryr�r�r�r�r�)rwr+r7r8r�r�rr�r�rr�r�rnr�r�r�r�r�r�s      r%�!test_make_zipfile_without_rootdirz.TestArchives.test_make_zipfile_without_rootdir�s���!�/�/�1���(��G�G�L�L������	�B�	��G�G�O�O�I�x�8�	�
�
!�
!�(�
+�X�"�9�e�4�G����W�i�&�&8�9��O�O�B�G�G�N�N�7�3�4��O�O�G�.�.�w�7�8�����)�R��%�%�b�k�k�m�"�#�*�.6�
+�"�/�/�1���(�
�
!�
!�(�
+�X������U�I�6�I�"�9�e�h�G�G����W�i�&�&8�9��O�O�B�G�G�N�N�7�3�4��O�O�G�.�.�w�7�8�����)�R��%�%�b�k�k�m�G�H�*�
.6�
+�
+�*�)��.6�X��
+�
+��&*�)��
.6�X��
+�
+�sz�8I3�?B	I&�#I�+I&�3I3�+J�2B+J�#J�J�J�I#�I&�&I0	�+I3�3I=�J	�J�J	�J�J!c���|j�\}}tj�5t5tj
j
dd�}t|d|tj�}|j|tj
j|�dz�|jtj
j|��|jtj|��tj|�5}|j!|j#�gd��ddd�ddd�ddd�y#1swY�xYw#1swY�xYw#1swYyxYw)Nryryr�r�r�)rwrr�r�r+r7r8rr�r�r�r�rnr�r�r�r�r�r�s      r%�&test_make_zipfile_with_explicit_curdirz3TestArchives.test_make_zipfile_with_explicit_curdirs���"�/�/�1���(�
�
�
�
!�8������U�I�6�I�"�9�e�X�r�y�y�I�G����W�b�g�g�o�o�i�&@�6�&I�J��O�O�B�G�G�N�N�7�3�4��O�O�G�.�.�w�7�8�����)�R��%�%�b�k�k�m�"�#�*�
$,�
!�
!�*�)��
$,�8��
!�
!�s;�E�CE
�#E�(E
�0E�E
�E
�
E	�E�E"r�zNeed the zip command to runc��|j�\}}tjj|j	�d�}t
5t
|d||�}ddd�|j|dz�|jtjj|��tjj|d�}dddd|g}tj||tj��|jtjj|��tj|�5}|j�}ddd�tj|�5}|j�}	ddd�|jt!�t!	��y#1swY��IxYw#1swY�ixYw#1swY�GxYw)Nryr�r�zarchive2.zipz-qz-rr�)rwr+r7r8r�r�rr�r�rnr�r�r�r�r�r�r`)
r�rur�r�ry�archive2�zip_cmdr�r��names2s
          r%�test_zipfile_vs_zipz TestArchives.test_zipfile_vs_zipsA��"�/�/�1���(��G�G�L�L������;�	�
�"�9�e�X�x�H�G��	
����)�f�"4�5���������w�/�0��7�7�<�<��.�9���$��n�h�?�����g�8�%/�%7�%7�	9�	
��������x�0�1�
�_�_�W�
%���K�K�M�E�&�
�_�_�X�
&�"��[�[�]�F�'��������v��7�'�X��&�
%��
&�
&�s$�F�2F+� F7�F(�+F4�7G�unzipzNeed the unzip command to runc���|j�\}}tjj|j	�d�}t
5t
|d||�}ddd�|j|dz�|jtjj|��dd|g}tj|�5	tj|tj��ddd�y#1swY��xYw#tj$r^}|j j#d��}d	|vr|j%d
�d}|j'|j)||��Yd}~��d}~wwxYw#1swYyxYw)Nryr�r�r�z-t)�stderr�replace)r�zunrecognized option: tzunzip doesn't support -tz{}

**Unzip Output**
{})rwr+r7r8r�r�rr�r�rnrr�r��check_output�STDOUT�CalledProcessError�output�decoder�r��format)	r�rur�r�ryr�r�details�msgs	         r%�test_unzip_zipfilezTestArchives.test_unzip_zipfile-s+��"�/�/�1���(��G�G�L�L������;�	�
�"�9�e�X�x�H�G��	
����)�f�"4�5���������w�/�0��D�'�*��
�
!�
!�(�
+�
4��'�'��
�8I�8I�J�,�
+��X���0�0�
4��*�*�+�+�9�+�=��+�w�6��M�M�"<�=�2���	�	�#�*�*�S�'�2�3�3��
4��,�
+�s=�C,�<E,�>%C8�,C5�8E)�AE$�E,�$E)�)E,�,E5c��|j�}tjj|d�}|j	t
t|d�y)Nryr
)r�r+r7r8r��
ValueErrorr)r�r�r�s   r%�test_make_archivezTestArchives.test_make_archiveFs5��������G�G�L�L���3�	����*�l�I�u�Er'c���tr1tjd�d}tjd�d}ndx}}|j�\}}tjj|j�d�}t|d||||��}|jtjj|��t|d||�}|jtjj|��t|d||||��}|jtjj|��t|d||dd��}|jtjj|��y)	Nrr�ryr���owner�grouprn�	kjhkjhkjg�oihohoh)
�UID_GID_SUPPORT�grp�getgrgid�pwd�getpwuidrwr+r7r8r�rr�rn)r�r�r�rur�r�rfs       r%�test_make_archive_owner_groupz*TestArchives.test_make_archive_owner_groupKs����L�L��O�A�&�E��L�L��O�A�&�E�"�"�E�E�!�/�/�1���(��G�G�L�L������;�	��9�e�X�x�u�!&�(����������s�+�,��9�e�X�x�@����������s�+�,��9�e�X�x�!&�e�5����������s�+�,��9�e�X�x�!,�I�?����������s�+�,r'�Requires grp and pwd supportc
��|j�\}}tjj|j	�d�}tjd�d}tjd�d}tj|�5t5t|d|d||��}ddd�ddd�|jtjj��tj |�}	|j#�D]:}|j%|j&d�|j%|j(d��<	|j+�y#1swY��xYw#1swY��xYw#|j+�wxYw)Nryrr�rvr�)rwr+r7r8r�r�r�r�r�rr�r�rr�rnrkr;�
getmembersr��uid�gidr0)	r�rur�r�r�r��archive_namery�members	         r%�test_tarfile_root_ownerz$TestArchives.test_tarfile_root_ownergs��"�/�/�1���(��G�G�L�L������;�	����Q���"�����Q���"��
�
!�
!�(�
+�X�'�	�7�H�f�.3�5�B�L�.6�
+�
	
��������|�4�5��,�,�|�,��	�!�,�,�.��� � ����Q�/�� � ����Q�/�/�
�M�M�O�.6�X��
+�
+��
�M�M�O�s1�E�E� E�4A
E+�E	�E�E(�+E=c�z���tj����fd�}td|gd�	t5�j	t
�5t
dd�ddd�ddd��jtj���td�y#1swY�AxYw#1swY�ExYw#td�wxYw)Nc����jd|��j|d��jtj���t	���Nru�basename)r�r�r+rs�RuntimeError)r�r��kw�current_dirr�s   ��r%�archiverz<TestArchives.test_make_archive_cwd_default.<locals>.archiver�sA������Z��,����Y�
�3����R�Y�Y�[�+�6��.� r'r
�xxx filer�)	r+rsrr�r�r�rr�r)r�r�r�s` @r%�test_make_archive_cwd_defaultz*TestArchives.test_make_archive_cwd_default~s�����i�i�k��	!�	 ��x��Z�@�	-���&�&�|�4� ��U�3�5��
���R�Y�Y�[�+�6�%�e�,�	5�4�����

&�e�,�s:�B-�B!�
B�B!�,B-�B	�B!�!B*�&B-�-
B:c�������tj���j�����fd�}g���fd�}td|gd�	t	j
td|�5��j
t�5tdd���ddd�ddd��jtj����j���g�td�y#1swY�UxYw#1swY�YxYw#td�wxYw)Nc�����jd|��j|tjj	�d���jtj
���t
��r�)r�r�r+r7r8rsr��r�r�r�r�rur�s   ���r%r�z4TestArchives.test_make_archive_cwd.<locals>.archiver�sP������Z��,����Y������[�*�(M�N����R�Y�Y�[�(�3��.� r'c�8���j|��|�yr*r�)r7r��
orig_chdirs ��r%�_chdirz2TestArchives.test_make_archive_cwd.<locals>._chdir�s����K�K����t�r'r
r��chdirr��ru)r+rsr�rrr2r�r�rr�r)r�r�r�r�r�r�rus`  @@@@r%�test_make_archive_cwdz"TestArchives.test_make_archive_cwd�s�����i�i�k���<�<�>��	!�
��	�	 ��x��Z�@�	-��"�"�2�w��7�:��&�&�|�4� ��U�X�F�5�8�
���R�Y�Y�[�+�6����T�H�k�#:�;�%�e�,�5�4��8�7��
&�e�,�s=�C4�#C(�9C�C(�AC4�C%	�!C(�(C1�-C4�4
Dc�����tj���j�����fd�}d|_t	d|gd�	t
5�j
t�5tdd���ddd�ddd��jtj���td�y#1swY�AxYw#1swY�ExYw#td�wxYw)Nc����j|d��j|d���jtj���t��)Nr�ru)r�r+rsr�r�s   ���r%r�zFTestArchives.test_make_archive_cwd_supports_root_dir.<locals>.archiver�sE������Y�
�3����R�
�^�X�6����R�Y�Y�[�+�6��.� r'Tr
r�r�r�)r+rsr��supports_root_dirrr�r�r�rr�r)r�r�r�rus` @@r%�'test_make_archive_cwd_supports_root_dirz4TestArchives.test_make_archive_cwd_supports_root_dir�s�����i�i�k���<�<�>��	!�
&*��"���x��Z�@�	-���&�&�|�4� ��U�X�F�5��
���R�Y�Y�[�+�6�%�e�,�	5�4�����

&�e�,�s<�C�B<�!B0�0B<�8,C�0B9	�5B<�<C�C�
Cc�B�|j�}tj|�5t5|j	tdd�d�|j
tjjd��ddd�ddd�y#1swY�xYw#1swYyxYw)N�testrnztest.tar�
r�rr�r�r�rr�r+r7rn�r�rus  r%�test_make_tarfile_in_curdirz(TestArchives.test_make_tarfile_in_curdir�sd���<�<�>��
�
!�
!�(�
+�X����\�&�%�8�*�E��O�O�B�G�G�N�N�:�6�7�.6�
+�
+�X�X��
+�
+��#�B�AB	�8B�	B	�B�Bc�B�|j�}tj|�5t5|j	tdd�d�|j
tjjd��ddd�ddd�y#1swY�xYw#1swYyxYw)Nr�r�ztest.zipr�r�s  r%�test_make_zipfile_in_curdirz(TestArchives.test_make_zipfile_in_curdir�sf���<�<�>��
�
!�
!�(�
+�X����\�&�%�8�*�E��O�O�B�G�G�N�N�:�6�7�.6�
+�
+�X�X��
+�
+�r�c��|jttdd�|jttdd�d�|jttdd�ddg�tdd�dgd�t�D��cgc]\}}|��	}}}|j	d|�td�t�D��cgc]\}}|��	}}}|j
d|�ycc}}wcc}}w)	Nr
r�c��tSr*��xrBr'r%�<lambda>z;TestArchives.test_register_archive_format.<locals>.<lambda>����Qr'c��tSr*rrBr'r%rz;TestArchives.test_register_archive_format.<locals>.<lambda>�rr')r�ro)r�rorc��tSr*rrBr'r%rz;TestArchives.test_register_archive_format.<locals>.<lambda>�s��qr'r�)r��	TypeErrorrrrrr�)r�rg�params�formatss    r%�test_register_archive_formatz)TestArchives.test_register_archive_format�s������)�%<�e�Q�G����)�%<�e�Y��	����)�%<�e�Y�!�9�-�	/�	 ��y�6�(�J�G�,?�,A�B�,A�L�D�&�4�,A��B��
�
�e�W�%�!�%�(�,?�,A�B�,A�L�D�&�4�,A��B������(��C��Cs�8C�1Cc	��|jtjt�d��dD�]�}|j	|��5|j�}tjj|d�}|jt�5}ttd||��ddd�|jjjtj�|j|jj |�|j#tjj%t�d���t'j(|��\}}t
j*|�|jt,�5}ttd||��ddd�|j|jjtj.�|j|jj |�|j#tjj%t�d���ddd����y#1swY���xYw#1swY��xYw#1swY��$xYw)Nrz�FTr��nonexistingrnr��r�rrur�subTestr�r+r7r8r�r�rr�r�r"�ENOENTr�r�r�rqr@r0r��ENOTDIR�r�r�r'�nonexisting_filer��tmp_fd�tmp_files       r%�test_make_tarfile_rootdir_nodirz,TestArchives.test_make_tarfile_rootdir_nodir�s������	�(�(�V�H�D�/�:�$�G����g��.��,�,�.��#%�7�7�<�<���#G� ��&�&�'8�9�R� ���0@�'�R�:�� � ����!3�!3�U�\�\�B�� � ����!6�!6�8H�I�� � ������6�(�$��!@�A�$,�#3�#3��#@� ������� ��&�&�'9�:�b� ����'�J�;�� � ����!3�!3�U�]�]�C�� � ����!6�!6��A�� � ������6�(�$��!@�A�#/�.�%�
:�9��;�:��/�.��?�AI�H+�CI�4H8�BI�+H5�0I�8I�=I�I	c	��|jtjt�d��dD�]�}|j	|��5|j�}tjj|d�}|jt�5}ttd||��ddd�|jjjtj�|j|jj |�|j#tjj%t�d���t'j(|��\}}t
j*|�|jt,�5}ttd||��ddd�|j|jjtj.�|j|jj |�|j#tjj%t�d���ddd����y#1swY���xYw#1swY��xYw#1swY��$xYw)Nr�rr�rr�r�rrs       r%�test_make_zipfile_rootdir_nodirz,TestArchives.test_make_zipfile_rootdir_nodir�s���	
���	�(�(�V�H�D�/�:�$�G����g��.��,�,�.��#%�7�7�<�<���#G� ��&�&�'8�9�R� ���0@�'�R�:�� � ����!3�!3�U�\�\�B�� � ����!6�!6�8H�I�� � ������6�(�$��!@�A�$,�#3�#3��#@� ������� ��&�&�'9�:�b� ����'�J�;�� � ����!3�!3�U�]�]�C�� � ����!6�!6��A�� � ������6�(�$��!@�A�#/�.�%�
:�9��;�:��/�.�rc��|j|d�fi|��|j|tfi|��|j|tfi|��y)Nc��|Sr*rB�r7s r%rz3TestArchives.check_unpack_archive.<locals>.<lambda>
s��r')�#check_unpack_archive_with_converterr)r�r�r$s   r%�check_unpack_archivez!TestArchives.check_unpack_archivesT��0��0�0��%�	1�)/�	1�0��0�0��H�	(� &�	(�0��0�0���L�V�Lr'c��|j�\}}t|�}|jd�tjj|j
�d�}t||||�}|j
�}	t||�||	�fi|��|jt|	�|�|j
�}
t||�||
�fd|i|��|jt|
�|�|jtj�5t|t�fi|��ddd�|jt�5t|t�fddi|��ddd�y#1swY�@xYw#1swYyxYw)Nrtryr�r
)rwrerAr+r7r8r�rrr�r�r��	ReadErrorrr�)r�r��	converterr$rur��expectedr�r�r1�tmpdir3s           r%rz0TestArchives.check_unpack_archive_with_converters?��!�/�/�1���(��H�%������ ��G�G�L�L������;�	��	�6�8�X�F���,�,�.���y��*�I�g�,>�I�&�I�����'�*�H�5��,�,�.���y��*�I�g�,>�	!�v�	!��	!�����'�*�H�5�
�
�
�v�/�/�
0��9�V�,�7��7�1�
�
�
�z�
*��9�V�,�E�U�E�f�E�+�
*�1�
0��
*�
*�s�E+�	E7�+E4�7Fc���|j|d��|j|d��tjdtf�5|j|�ddd�y#1swYyxYw)N�
fully_trusted��filter�datazPython 3.14)r r�check_warnings�DeprecationWarning)r�r�s  r%�check_unpack_tarballz!TestArchives.check_unpack_tarball*s]���!�!�&��!�A��!�!�&��!�8�
�
+�
+�� 2�3�5��%�%�f�-�5�5�5�s�A�A&c�&�|jd�y)Nrn�r-rRs r%�test_unpack_archive_tarz$TestArchives.test_unpack_archive_tar1s���!�!�%�(r'c�&�|jd�y)Nr�r/rRs r%�test_unpack_archive_gztarz&TestArchives.test_unpack_archive_gztar4����!�!�'�*r'c�&�|jd�y)N�bztarr/rRs r%�test_unpack_archive_bztarz&TestArchives.test_unpack_archive_bztar8r3r'z(AIX MAXDATA must be 0x20000000 or largerc�&�|jd�y)N�xztarr/rRs r%�test_unpack_archive_xztarz&TestArchives.test_unpack_archive_xztar<s��	
�!�!�'�*r'c��|jd�|jt�5|jdd��ddd�y#1swYyxYw)Nr�r*r()r r�r	rRs r%�test_unpack_archive_zipz$TestArchives.test_unpack_archive_zipAs=���!�!�%�(�
�
�
�y�
)��%�%�e�F�%�;�*�
)�
)�s�A�A
c���t�}�fd�}tdddg|dg�tdd��jttddg|�td�tddg|��j
ddgd	ft���jddgd	ft��td��jt�|�y)
Nc�r���j|d��j|d��j|d�y)Nr��	stuff.boo�xx)r�)r��extract_dir�extrar�s   �r%�_booz/TestArchives.test_unpack_registry.<locals>._booKs3������U�A�&����X�{�3����[�$�/r'�Booz.booz.b2)rAr�r>r?�Boo2�)	rr	rr�r
rrr�r�)r�rrBs`  r%�test_unpack_registryz!TestArchives.test_unpack_registryGs����$�&��	0�
	�u�v�u�o�t�l�^�L��{�D�)�	
���-�)?��!�(�D�	*�	!��'��v��x��6��
�
�v��x��,�.@�.B�C����%�&��2�.�0B�0D�E�	!��(����+�-�w�7r'N)rv).r�r�r�rorwr�
requires_zlibr�r�r�r^r_r��whichr�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrr rr-r0r2�requires_bz2r6�
requires_lzmar`r�r�r9r;rFrBr'r%riris��� �"��W����'8��'8�R�W����H��H�8
%��W�����X�������e�,�6�8�*1�8��*1�X�W����%9��%9�N�W����H��H�:�W����
#��
#��W�����X�������e�,�6�8�8�8��8�0�W�����X�������g�.�8�:�4�:��4�,F�
�W����-��-�6�W�����X����*H�I��J���*-�"-�.-�&8��W����8��8�)� B�.�W����B��B�2M�F�0.�)��W����+��+��W����+��+��W�����X�_�_�S�-���-�/Y�Z�+�[��+��W����<��<�
8r'ric��eZdZejeed�d�d��Zejed�ejee	d�d�d���Z
y)	�TestMisc�
disk_usagez)disk_usage not available on this platformc�0�tjtjj	t
��}dD]"}|j
t||�t��$|j|jd�|j|jd�|j|jd�|j|j|j�|j|j|j�tjt
�y)N)rC�used�freer)r�rMr+r7rlrYr�r!r��
assertGreaterrCrO�assertGreaterEqualrP)r��usagers   r%�test_disk_usagezTestMisc.test_disk_usageds����!�!�"�'�'�/�/�(�";�<��-�D��!�!�'�%��"6��<�.����5�;�;��*����5�:�:�q�)�����
�
�A�.�������U�Z�Z�8����5�;�;��
�
�3�	���(�#r'r��chownzrequires os.chownc�^����j�}tj|���t�d��j	t
�5t
j��ddd��j	t�5t
j�d��ddd��j	t�5t
j�d��ddd��j	t�5t
j�d�ddd��j	t�5t
j�d�ddd�tj�}tj�}d��fd	�	}t
j�||�|�||�t
j�|�|�|�t
j�|��|�|�t
j�|��|�|�
�t
j|||�||||�t
j||�|||�t
j||��|||�t
j||��|||�
�	tj|�d}tj |�d}t
j�||�|�||�t
j|||�||||�y#1swY���xYw#1swY��YxYw#1swY��1xYw#1swY��
xYw#1swY���xYw#t"$rYywxYw)
Nr�ztesting chown functionznon-existing username)�userznon-existing groupname)r��spamg��Q�	@c���tj��}|��j||j�|��j||j�yyr*)r+r�r��st_uid�st_gid)r7r�r��sr�r�s    ��r%�check_chownz(TestMisc.test_chown.<locals>.check_chown�sH�������!�A���� � ��a�h�h�/���� � ��a�h�h�/�r')r�r)NN)r�rqr�r?r�r�r�rU�LookupErrorr	r+�getuid�getgidr�r�r�r��KeyError)r�rlr�r�r]rWr�r�s`      @r%�
test_chownzTestMisc.test_chownssd����,�,�.���?�?�w�/���H�6�7�
�
�
�z�
*��L�L��"�+��
�
�{�
+��L�L��(?�@�,��
�
�{�
+��L�L��)A�B�,��
�
�y�
)��L�L��7�+�*��
�
�y�
)��L�L��4�(�*��i�i�k���i�i�k��	0�	���X�s�C�(��H�c�3�'����X�s�#��H�c�"����X�C�(��H�c�"����X�S�)��H�#�&����W�c�3�'��G�S�#�&����W�c�"��G�S�!����W�3�'��G�S�!����W�C�(��G��%�
	+��<�<��$�Q�'�D��L�L��%�a�(�E�

�L�L��4��/���#�s�+��L�L��$��.����c�*�k+�
*��,�
+��,�
+��*�
)��*�
)��D�	��	�sN�
K�=K,�2K9�'L�L�,0L �K)�,K6�9L�L�L� 	L,�+L,N)r�r�r�r^r_rpr�rTr�r+rbrBr'r%rLrLbst���X������6�D�F�$�F�$��X����*H�I��X�����W�-�/B�C�:+�D�J�:+r'rLc��eZdZd�Zeej�Zd�Zd�Z	d�Z
d�Zd�Ze
jej dk7d�d	��Ze
jej dk(d
�d��Ze
jej dk(d
�d��Zej*d
��Zd�Zd�Ze
jej dk(d�d��Zd�Zd�Zd�Zd�Zd�Zd�Ze
jej dk(d�d��Z e
jej dk(d�d��Z!e
jej dk(d�d��Z"e
jej dk(d�d��Z#e
jej dk(d�d��Z$e
jej dk(d�d��Z%e
jej dk(d�d��Z&e
jej dk(d�d ��Z'e
jej dk(d�d!��Z(e
jej dk(d�d"��Z)e
jej dk(d�d#��Z*y$)%�	TestWhichc���|jd��}tjj|tdz�}tj
|�tjj|tdz�|_tj
|j�tjj|tdz�|_tj
|j�tdz|_tjj|j|j�|_	|j|j�|j|_tj|_d|_
y)N�Tmp)r�z-basedirz-dirz-dir2z.Exez.EXE)r�r+r7r8rr�rm�	other_dir�file�filepathr?�env_pathr��ext)r��temp_dirr�s   r%�setUpzTestWhich.setUp�s����<�<�u�<�-���7�7�<�<��&�:�*=�>��
������7�7�<�<��&�6�/�:���
������������h���0@�A���
������ ��V�O��	������T�X�X�t�y�y�9��
�������'�����
��i�i�����r'c�F�t|�tj|d�y)Ni�)r?r+r�)r�r7s  r%r?zTestWhich.create_file�s���D��
����u�r'c��|jtjj|�tjj|��yr*)r�r+r7�normcase)r�rrr$s   r%�assertNormEqualzTestWhich.assertNormEqual�s0��������)�)�&�1�2�7�7�3C�3C�H�3M�Nr'c��tj|j|j��}|j	||j
�y�Nr)r�rHrhrmr�ri�r�r�s  r%�
test_basiczTestWhich.test_basic�s.��
�\�\�$�)�)�$�(�(�
3������T�]�]�+r'c��tj|j|j��}|j	||j�yrs)r�rHrirgr�rts  r%�test_absolute_cmdzTestWhich.test_absolute_cmd�s0���\�\�$�-�-�d�n�n�
=������T�]�]�+r'c�&�tjj|j�\}}tjj	||j
�}t
j|��5tj||j��}|j||�ddd�t
j|j��5tj||��}|j|�ddd�y#1swY�[xYw#1swYyxYwrs)
r+r7r�rmr8rhrr�r�rHrgr��assertIsNone)r�r��tail_dirr�r�s     r%�test_relative_cmdzTestWhich.test_relative_cmd�s��� �W�W�]�]�4�8�8�4���(��'�'�,�,�x����3��
�
!�
!�x�
0����g�D�N�N�;�B����R��)�1��
!�
!�t�x�x�
0����g�H�5�B����b�!�1�
0�	1�
0��1�
0�s�-4C;�	)D�;D�DrKztest is for non win32c���tj|j��5tj|j
|j��}|j|�ddd�y#1swYyxYwrs)rr�rmr�rHrhrgryrts  r%�test_cwd_non_win32zTestWhich.test_cwd_non_win32�sH���
!�
!�t�x�x�
0����d�i�i�d�n�n�=�B����b�!�1�
0�
0�s�=A'�'A0ztest is for win32c	���tjj|j�}t	j
|j��5tjjdd��5tj|j|j��}|j|tjj|j|j��ddd�tjjdd��5tj|j|j��}|j!|�ddd�ddd�y#1swY�xxYw#1swY�xYw#1swYyxYw)Nr�shutil._win_path_needs_curdirT��return_valueF)r+r7rlrmrr�r^r�r�r�rHrhrgr�r8r�ry)r�r�r�s   r%�test_cwd_win32zTestWhich.test_cwd_win32�s����7�7�?�?�4�8�8�,��
�
!�
!�t�x�x�
0����$�$�%D�SW�$�X��\�\�$�)�)�$�.�.�A��� � ��R�W�W�\�\�$�+�+�t�y�y�%I�J�Y����$�$�%D�SX�$�Y��\�\�$�)�)�$�.�.�A���!�!�"�%�Z�1�
0�X�X��Z�Y��1�
0�s=�
"E+�,A0E�)E+�=E�E+�E	�E+�E(	�$E+�+E4c	��tjj|j|j�}|j|�tjjdd��5tj|j��5tj|j|j��}|j|tjj|j|j��ddd�tj|j��5tj|j|j��}|j|tjj|j|j��ddd�ddd�y#1swY��xYw#1swY�xYw#1swYyxYw)NrTr�r)r+r7r8rgrhr?r^r�r�rr�rmr�rHr�r�)r��other_file_pathr�s   r%�*test_cwd_win32_added_before_all_other_pathz4TestWhich.test_cwd_win32_added_before_all_other_path�s���'�'�,�,�t�~�~�t�y�y�A������)�
�]�]�
 �
 �!@�t�
 �
T��%�%�4�8�8�4��\�\�$�)�)�$�.�.�A��� � ��R�W�W�\�\�$�+�+�t�y�y�%I�J�5��%�%�4�>�>�:��\�\�$�)�)�$�(�(�;��� � ��R�W�W�\�\�$�+�+�t�y�y�%I�J�;�	U�
T�4�4��;�:��	U�
T�s>�'!F9�A0F!�8(F9� A0F-�F9�!F*	�&F9�-F6	�2F9�9Gc�t�tj|jtj�tj
|jtj�r|jd�tj|j|jtj��}|j|�y)Nzcan't set the file read-only�r7r\)
r+r�rir�r��access�W_OKr�r�rHrhrmryrts  r%�test_non_matching_modez TestWhich.test_non_matching_mode
	si��	���������-�
�9�9�T�]�]�B�G�G�,��M�M�8�9�
�\�\�$�)�)�$�(�(����
A�����"�r'c�h�tjj|j�\}}t	j
|��5t
j|j|��}|j|tjj||j��ddd�y#1swYyxYwrs)r+r7r�rmrr�r�rHrhr�r8)r�r�rzr�s    r%�test_relative_pathzTestWhich.test_relative_path	sn���W�W�]�]�4�8�8�4���(�
�
!�
!�x�
0����d�i�i�h�7�B����R������h��	�	�!B�C�1�
0�
0�s
�AB(�(B1c�h�tjd|j��}|j|�y)Nzfoo.exer)r�rHrmryrts  r%�test_nonexistent_filezTestWhich.test_nonexistent_file	s$��
�\�\�)�$�(�(�
3�����"�r'zpathext check is Windows-onlyc��tj|jdd|j��}|j	||j
dd|jz�y)N���r)r�rHrhrmr�rirkrts  r%�test_pathext_checkingzTestWhich.test_pathext_checking	sF��
�\�\�$�)�)�C�R�.�t�x�x�
8������T�]�]�3�B�/�$�(�(�:�;r'c���tj�5}|j|d<tj|j
�}|j
||j�ddd�y#1swYyxYw�N�PATH)r�EnvironmentVarGuardrjr�rHrhr�ri�r��envr�s   r%�test_environ_pathzTestWhich.test_environ_path&	sO��
�
*�
*�
,���-�-�C��K����d�i�i�(�B����R����/�-�
,�
,�s�AA)�)A2c	��tj�5}d|d<tjj	d|j
d��5t
jtd|j
�5tj|j
�5tj|j�}|j|�ddd�ddd�ddd�ddd�y#1swY�"xYw#1swY�&xYw#1swY�*xYw#1swYyxYw)NrEr��
os.confstrT�r��create�defpath)rr�r^r�r�rmrr2r+r�r�rHrhryr�s   r%�test_environ_path_emptyz!TestWhich.test_environ_path_empty,	s���
�
*�
*�
,���C��K����$�$�\����,0�%�2��"�"�2�y�$�(�(�;��%�%�d�h�h�/��\�\�$�)�)�,���!�!�"�%�0�<�2�-�
,�
0�/��<�;��2�2��-�
,�sS�2D�&C7�- C+�
1C	�>C+�C7�D�C(
�$C+�+C4�0C7�7D	�<D�Dc	�.�|j}tjdk(r*tjj|j|�}tj�5}tj|d<tjjd|jd��5tjtd|j�5t!j"|j�}|j%|�tj&|j�5t!j"|j�}|j)||�ddd�ddd�ddd�ddd�y#1swY�"xYw#1swY�&xYw#1swY�*xYw#1swYyxYw)NrKr�r�Tr�r�)rhr�rar+r7r8r�rr��pathsepr^r�r�rmrr2r�rHryr�r�)r��expected_cwdr�r�s    r%�test_environ_path_cwdzTestWhich.test_environ_path_cwd7	s���y�y���<�<�7�"��7�7�<�<����\�B�L��
*�
*�
,���*�*�C��K����$�$�\����,0�%�2��"�"�2�y�$�(�(�;��\�\�$�)�)�,���!�!�"�%��)�)�$�(�(�3����d�i�i�0�B��$�$�R��6�4�<�2�-�
,�4�3��<�;��2�2��-�
,�sV�AF�&E?�AE3�2E'	�E3�E?�F�'E0
�,E3�3E<�8E?�?F	�F�Fc��tj�5}|d=tjj	dt
d��5t
jtd|j�5tj|j�}ddd�ddd�|j|j�tjj	d|jd��5t
jtdd�5tj|j�}ddd�ddd�|j||j�ddd�y#1swY��xYw#1swY��xYw#1swY�NxYw#1swY�RxYw#1swYyxYw)Nr�r�T)rr�r�r�rE)rr�r^r�r�r�rr2r+rmr�rHrhr�rir�s   r%�test_environ_path_missingz#TestWhich.test_environ_path_missingJ	s ��
�
*�
*�
,���F�����$�$�\�z�,0�%�2��"�"�2�y�$�(�(�;��\�\�$�)�)�,��<�2�
���R����/����$�$�\����,0�%�2��"�"�2�y�"�5��\�\�$�)�)�,��6�2�
���R����/�-�
,�<�;��2�2��6�5��2�2��-�
,�sk�*E>�&E�% E�E�
AE>�E2�9 E&�E2�!$E>�E�E�E#	�E>�&E/�+E2�2E;	�7E>�>Fc��tjj|j�}t	j
|j��5t	j�5}|j|d<tj|jd��}|j|�ddd�ddd�y#1swY�xYw#1swYyxYw)Nrr�rE)r+r7rlrmrr�r�rjr�rHrhry)r�r�r�r�s    r%�test_empty_pathzTestWhich.test_empty_path\	s����7�7�?�?�4�8�8�,��
�
!�
!�t�x�x�
0�
�
*�
*�
,���-�-�C��K����d�i�i�b�1�B����b�!�-�1�
0�
,�
,��1�
0�s%�
B>�AB2�!B>�2B;	�7B>�>Cc��tj�5}|d=tj|j�}|j|�ddd�y#1swYyxYwr�)rr�r�rHrhryr�s   r%�test_empty_path_no_PATHz!TestWhich.test_empty_path_no_PATHd	sC��
�
*�
*�
,���F�����d�i�i�(�B����b�!�-�
,�
,�s�4A�Aztest specific to Windowsc���d}|jt�}||j|�z}tjj	|j
|�}|j
|�tj�5}||d<|jtj||j
��|�|jtj||j
��|�ddd�y#1swYyxYw)N�.xyz�PATHEXTr��to_text_typer�r+r7r8rmr?rr�r�r�rH�r�rk�cmd�cmdextrir�s      r%�test_pathextzTestWhich.test_pathextj	s���������(���t�(�(��-�-���7�7�<�<����&�1������"�
�
*�
*�
,�� �C�	�N����V�\�\�#�D�H�H�=�x�H����V�\�\�&�t�x�x�@�(�K�-�
,�
,��
�;A(C,�,C5c��d}|jt�}||j|�z}tjj	|j
|�}|j
|�tj�5}|dz|d<|jtj||j
��|�|jtj||j
��|�ddd�y#1swYyxYw)Nr��;r�rr�r�s      r%�test_pathext_with_empty_strz%TestWhich.test_pathext_with_empty_strw	s���������(���t�(�(��-�-���7�7�<�<����&�1������"�
�
*�
*�
,�� �3�Y�C�	�N����V�\�\�#�D�H�H�=�x�H����V�\�\�&�t�x�x�@�(�K�-�
,�
,�s
�;A+C/�/C8c���d}|jt�}||j|�z}tjj	|j
|�}|j
|�tj�5}||d<|jtj||j
��|�|jtj||j
��|�ddd�y#1swYyxYw)Nz.foo.barr�rr�r�s      r%�$test_pathext_with_multidot_extensionz.TestWhich.test_pathext_with_multidot_extension�	s���������(���t�(�(��-�-���7�7�<�<����&�1������"�
�
*�
*�
,�� �C�	�N����V�\�\�#�D�H�H�=�x�H����V�\�\�&�t�x�x�@�(�K�-�
,�
,�r�c���|jt�}||jd�z}tjj	|j
|�}|j
|�tj�5}d|d<|jtj||j
���|jtj||j
���d|d<|jtj||j
��|�|jtj||j
��||jd�z�d|d<|jtj||j
��|�|jtj||j
��||jd�z�ddd�y#1swYyxYw)Nr|r�r�rz.xyz;.z.xyz;..)
r�r�r+r7r8rmr?rr�ryr�rHr�)r�r��cmddotrir�s     r%� test_pathext_with_null_extensionz*TestWhich.test_pathext_with_null_extension�	s`������(���t�(�(��-�-���7�7�<�<����#�.������"�
�
*�
*�
,��#�C�	�N����f�l�l�3�T�X�X�>�?����f�l�l�6����A�B�%�C�	�N����V�\�\�#�D�H�H�=�x�H����V�\�\�&�t�x�x�@�%��(9�(9�#�(>�>�
@�&�C�	�N����V�\�\�#�D�H�H�=�x�H����V�\�\�&�t�x�x�@�%��(9�(9�#�(>�>�
@�-�
,�
,�s
�9EG�G#c���d}|jt�}||j|�z}|jd�}tjj	|j
|�}|j
|�tj�5}|dz|d<|jtj||j
��|�|jtj||j
��|�|jtj||z|j
���|jtj||z|j
���ddd�y#1swYyxYw)Nr�r|r�r)
r�r�r+r7r8rmr?rr�r�r�rHry)r�rkr�r��dotrir�s       r%�$test_pathext_extension_ends_with_dotz.TestWhich.test_pathext_extension_ends_with_dot�	s	��������(���t�(�(��-�-������$���7�7�<�<����&�1������"�
�
*�
*�
,�� �3�Y�C�	�N����V�\�\�#�D�H�H�=�x�H����V�\�\�&�t�x�x�@�(�K����f�l�l�3��9�4�8�8�D�E����f�l�l�6�C�<�d�h�h�G�H�-�
,�
,�s
�CE&�&E/c��d}|jt�}||j|�z}tjj	|j
|�}|j
|�tj�5}tj|j
�|d<||d<|jtj|�|�|jtj|�|�ddd�y#1swYyxYw)Nr�r�r�)
r�r�r+r7r8rmr?rr��fsdecoder�r�rHr�s      r%�%test_pathext_applied_on_files_in_pathz/TestWhich.test_pathext_applied_on_files_in_path�	s���������(���t�(�(��-�-���7�7�<�<����&�1������"�
�
*�
*�
,���+�+�d�h�h�/�C��K� �C�	�N����V�\�\�#�.��9����V�\�\�&�1�8�<�	-�
,�
,�s
�;A2C6�6C?c�v�tjjdd��5}|jt	j
dtj��|jd�|j�|jt	j
dd��|j�ddd�tjjdd��5}|jt	j
dtj��|jd�ddd�y#1swY�xxYw#1swYyxYw)Nz&_winapi.NeedCurrentDirectoryForExePathTr��dontcarerF)r^r�r�r�r��_win_path_needs_curdirr+�X_OK�assert_called_once_with�
reset_mock�assert_not_calledr�)r��need_curdir_mocks  r%�test_win_path_needs_curdirz$TestWhich.test_win_path_needs_curdir�	s���
�]�]�
 �
 �!I�X\�
 �
]�aq��O�O�F�9�9�*�b�g�g�N�O��4�4�Z�@��'�'�)��O�O�F�9�9�*�a�H�I��.�.�0�^��]�]�
 �
 �!I�X]�
 �
^�br����V�:�:�:�r�w�w�O�P��4�4�Z�@�_�
^�^�
]��_�
^�s�B
D#�AD/�#D,�/D8c��|j}|jtj||j��|j
�|jtj||jtj��|j
�||jd�z}tjj|j|�}|j|�|jtj||j��|j
�|jtj||jtj��|j
�|jtj||j��|�|jtj||jtj��|�y�Nrr�z.com)rhrqr�rHrmrir+�F_OKr�r7r8r?)r�r��cmd2r�s    r%�$test_same_dir_with_pathext_extensionz.TestWhich.test_same_dir_with_pathext_extension�	s/���i�i�����V�\�\�#�D�H�H�=�t�}�}�M����V�\�\�#�D�H�H�2�7�7�K�!�]�]�	,��T�&�&�v�.�.���'�'�,�,�t�x�x��6������)�	
���V�\�\�#�D�H�H�=�t�}�}�M����V�\�\�#�D�H�H�2�7�7�K�!�]�]�	,����V�\�\�$�T�X�X�>��P����V�\�\�$�T�X�X�B�G�G�L�,�	.r'c���|jdd}|jtj||j��|j
�|jtj||jtj��|j
�tjj|j|�}|j|�|jtj||j��|j
�|jtj||jtj��|�|jtj|j|j��|j
�|jtj|j|jtj��|j
�y�Nr�rr�)rhrqr�rHrmrir+r�r7r8r?)r�r�r�s   r%�'test_same_dir_without_pathext_extensionz1TestWhich.test_same_dir_without_pathext_extension�	s,���i�i���n�����V�\�\�#�D�H�H�=�t�}�}�M����V�\�\�#�D�H�H�2�7�7�K�!�]�]�	,��'�'�,�,�t�x�x��5������)�	
���V�\�\�#�D�H�H�=�t�}�}�M����V�\�\�#�D�H�H�2�7�7�K�,�	.����V�\�\�$�)�)�$�(�(�C�T�]�]�S����V�\�\�$�)�)�$�(�(����Q�!�]�]�	,r'c�^�|j}tjjtj|j
�tj|j�g�}|jtj||��|j�|jtj||tj��|j�||jd�z}tjj|j
|�}|j|�|jtj||��|�|jtj||tj��|�|jtj||��|�|jtj||tj��|�tjjtj|j�tj|j
�g�}|jtj||��|j�|jtj||tj��|j�yr�)rhr+r�r8r�rgrmrqr�rHrir�r�r7r?r�)r�r��search_pathr�r�s     r%�%test_dir_order_with_pathext_extensionz/TestWhich.test_dir_order_with_pathext_extension�	s����i�i���j�j�o�o�r�{�{�4�>�>�'B�')�{�{�4�8�8�'<�'>�?��	
���V�\�\�#�K�@�$�-�-�P����V�\�\�#�K�b�g�g�N�!�]�]�	,��T�&�&�v�.�.���'�'�,�,�t�~�~�t�<������)�	
���V�\�\�#�K�@�/�R����V�\�\�#�K�b�g�g�N�,�	.�	
���V�\�\�$�[�A�?�S����V�\�\�$�[�r�w�w�O�,�	.��j�j�o�o�r�{�{�4�8�8�'<�')�{�{�4�>�>�'B�'D�E��������c��<�d�m�m�L�������c��"�'�'�J����	(r'c��|jdd}tjjtj|j
�tj|j�g�}|jtj||��|j�|jtj||tj��|j�tjj|j
|�}|j|�|jtj||��|j�|jtj||tj��|�|jtj|j|��|j�|jtj|j|tj��|j�tjjtj|j�tj|j
�g�}|jtj||��|j�|jtj||tj��|j�yr�)rhr+r�r8r�rgrmrqr�rHrir�r7r?)r�r�r�r�s    r%�(test_dir_order_without_pathext_extensionz2TestWhich.test_dir_order_without_pathext_extension
s����i�i���n���j�j�o�o�r�{�{�4�>�>�'B�')�{�{�4�8�8�'<�'>�?��	
���V�\�\�#�K�@�$�-�-�P����V�\�\�#�K�b�g�g�N�!�]�]�	,��'�'�,�,�t�~�~�s�;������)�	
���V�\�\�#�K�@�$�-�-�P����V�\�\�#�K�b�g�g�N�,�	.�	
���V�\�\�$�)�)�+�F��
�
�V����V�\�\�$�)�)�+�B�G�G�T�!�]�]�	,��j�j�o�o�r�{�{�4�8�8�'<�')�{�{�4�>�>�'B�'D�E�����V�\�\�#�K�@�$�-�-�P����V�\�\�#�K�b�g�g�N�!�]�]�	,r'N)+r�r�r�rm�staticmethodr+r�r�r?rqrurwr{r^r_r�rar}r�r�rrbr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rBr'r%rdrd�s8���" ����,�L��O�,�
,�"��X�������0�0�2�"�2�"��X�������0�,�.�
&�.�
&��X�������0�,�.�	K�.�	K��#�#��$��D��
�X�������0�8�:�<�:�<�0�	&�7�&0�$"�"��X�������0�2L�M�	L�N�	L��X�������0�2L�M�	L�N�	L��X�������0�2L�M�	L�N�	L��X�������0�2L�M�@�N�@�$�X�������0�2L�M�I�N�I��X�������0�2L�M�
=�N�
=��X�������0�2L�M�
A�N�
A��X�������0�2L�M�.�N�.�&�X�������0�2L�M�,�N�,�(�X�������0�2L�M�(�N�(�:�X�������0�2L�M�,�N�,r'rdc�6�eZdZd�Zeej�Zy)�TestWhichBytesc���tj|�tj|j�|_tj|j
�|_tj|j�|_tj|j�|_tj|j�|_tj|j�|_	yr*)
rdrmr+r�rmrhrirgr�rkrRs r%rmzTestWhichBytes.setUp5
s���������;�;�t�x�x�(����K�K��	�	�*��	����D�M�M�2��
����T�^�^�4����k�k�$�+�+�.����;�;�t�x�x�(��r'N)r�r�r�rmr�r+r�r�rBr'r%r�r�4
s��)� ����,�Lr'r�c���eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	e
d��Ze
d	��Zd
�Z
e
d��Zd�Ze
d
��Zd�Zej&ej*j,d�d��Zd�Zd�Zd�Zd�Zej:e
d���Zej:e
d���Zej:e
d���Z ej:e
d���Z!d�Z"d�Z#e
d��Z$e
d��Z%d�Z&e
d��Z'ej:d��Z(ej:d ��Z)ejTej&e+ed!�xre+e,d"�xr	e+e,d#�d$�d%���Z-y&)'�TestMovec�D�d}|j�|_|j�|_tjj|j|�|_tjj|j|�|_t|jd�y)Nr�rX)	r�rprqr+r7r8rNr\r?)r�r�s  r%rmzTestMove.setUpC
sc�����|�|�~����|�|�~��������T�\�\�8�<��
������T�\�\�8�<��
��D�M�M�7�+r'c�p�t|d�5}|j�}ddd�tj||�t|d�5}|j	|j��ddd�|jtjj|��y#1swY��xYw#1swY�DxYw�NrU)	r;rZr��mover�r�r+r7r�)r�rxry�real_dstrQ�contentss      r%�_check_move_filezTestMove._check_move_fileK
s~��
�#�t�_���v�v�x�H�����C���
�(�D�
!�Q����X�q�v�v�x�0�"����������,�-��_��"�
!�s�B �!B,� B)�,B5c�$�ttj|��}tj||�|j|ttj|���|j
tjj|��yr*)	r`r+rar�r�r�r�r7r�)r�rxryr�r�s     r%�_check_move_dirzTestMove._check_move_dirS
s[���"�*�*�S�/�*�����C�������6�"�*�*�X�*>�#?�@����������,�-r'c�f�|j|j|j|j�yr*)r�rNr\rRs r%�test_move_filezTestMove.test_move_fileY
s �����d�m�m�T�]�]�D�M�M�Jr'c�f�|j|j|j|j�yr*)r�rNrqr\rRs r%�test_move_file_to_dirzTestMove.test_move_file_to_dir]
s �����d�m�m�T�\�\�4�=�=�Ir'c�|�t|j�}|j||j|j�yr*)rrNr�rqr\)r�rxs  r%�"test_move_file_to_dir_pathlike_srcz+TestMove.test_move_file_to_dir_pathlike_srca
s*���t�}�}�%�����c�4�<�<����?r'c�|�t|j�}|j|j||j�yr*)rrqr�rNr\�r�rys  r%�"test_move_file_to_dir_pathlike_dstz+TestMove.test_move_file_to_dir_pathlike_dstf
s*���t�|�|�$�����d�m�m�S�$�-�-�@r'c�$�|j�yr*)r�rRs r%�test_move_file_other_fsz TestMove.test_move_file_other_fsk
s��	
���r'c�$�|j�yr*)r�rRs r%�test_move_file_to_dir_other_fsz'TestMove.test_move_file_to_dir_other_fsp
s��	
�"�"�$r'c���tj|j���}	|j|j||�tj|�y#tj|�wxYwr?)rqr�r�r�rprr��r�rqs  r%�
test_move_dirzTestMove.test_move_diru
sN���/�/�d�l�l�n�5��	&�� � ����w��@����W�%��I���W�%�s�A�A0c�$�|j�yr*)r�rRs r%�test_move_dir_other_fszTestMove.test_move_dir_other_fs}
s��	
���r'c
���|j|j|jtjj|jtjj
|j���yr*)r�rprqr+r7r8r�rRs r%�test_move_dir_to_dirzTestMove.test_move_dir_to_dir�
sF�����T�\�\�4�<�<��G�G�L�L����r�w�w�'7�'7����'E�F�	Hr'c�$�|j�yr*)r�rRs r%�test_move_dir_to_dir_other_fsz&TestMove.test_move_dir_to_dir_other_fs�
s��	
�!�!�#r'c
�&�|j|jtjjz|j
tjj
|j
tjj|j���yr*)r�rpr+r7�seprqr8r�rRs r%�test_move_dir_sep_to_dirz!TestMove.test_move_dir_sep_to_dir�
sS�����T�\�\�B�G�G�K�K�7�����G�G�L�L����r�w�w�'7�'7����'E�F�	Hr'zrequires os.path.altsepc
�&�|j|jtjjz|j
tjj
|j
tjj|j���yr*)r�rpr+r7�altseprqr8r�rRs r%�test_move_dir_altsep_to_dirz$TestMove.test_move_dir_altsep_to_dir�
sS�����T�\�\�B�G�G�N�N�:�D�L�L��G�G�L�L����r�w�w�'7�'7����'E�F�	Hr'c��t|j�|jtjtj
|j|j�yr*)r?r\r�r�rr�rNrqrRs r%�"test_existing_file_inside_dest_dirz+TestMove.test_existing_file_inside_dest_dir�
s2���D�M�M�"����&�,�,����T�]�]�D�L�L�Qr'c���tjj|jd�}|j	t
jt
j|j|�y�Nr�)r+r7r8rpr�r�rr�r�s  r%�test_dont_move_dir_in_itselfz%TestMove.test_dont_move_dir_in_itself�
s:���g�g�l�l�4�<�<��/�����&�,�,����T�\�\�3�Gr'c	��tjt�	dD]{\}}tjj	t|�}tjj	t|�}|jt
j||�d|�d|�d����}	tjt�y#tjt�wxYw)N))�srcdirzsrcdir/dest�)_destinsrc() wrongly concluded that dst (z) is not in src (�)�r�)
r+r�rr7r8r�r��
_destinsrcrr�rGs   r%�test_destinsrc_false_negativez&TestMove.test_destinsrc_false_negative�
s���
�����	%�7���S��g�g�l�l�6�3�/���g�g�l�l�6�3�/������ 1� 1�#�s� ;�>A�3�"H� �I�8�
���V�$��I���V�$���BB6�6Cc	��tjt�	dD]{\}}tjj	t|�}tjj	t|�}|jt
j||�d|�d|�d����}	tjt�y#tjt�wxYw)N))rzsrc/dest)rz
srcdir.newr	z
) is in src (r
r)
r+r�rr7r8r�r�rrr�rGs   r%�test_destinsrc_false_positivez&TestMove.test_destinsrc_false_positive�
s���
�����	%�N���S��g�g�l�l�6�3�/���g�g�l�l�6�3�/��� � ��!2�!2�3��!<�9<�c�!C�!�D�O�
���V�$��I���V�$�rc���tjj|jd�}tj|j
|�t
j||j�|jtjj|j��|jtjj|j
|j��yr)r+r7r8rpr�rNr�r�r\r�rc�samefiler�s  r%�test_move_file_symlinkzTestMove.test_move_file_symlink�
s����g�g�l�l�4�<�<��/��
�
�
�4�=�=�#�&����C����'���������t�}�}�5�6�������(�(�����
�
�F�Gr'c��d}tjj|j|�}tj|j
|�t
j||j�tjj|j|�}|jtjj|��|jtjj|j
|��yr)r+r7r8rpr�rNr�r�rqr�rcr)r�r�ry�
final_links    r%�test_move_file_symlink_to_dirz&TestMove.test_move_file_symlink_to_dir�
s������g�g�l�l�4�<�<��2��
�
�
�4�=�=�#�&����C����&��W�W�\�\�$�,�,��9�
���������z�2�3�������(�(����
�C�Dr'c�L�tjj|jd�}tjj|jd�}tj||�tjj|j
d�}t
j||�|jtjj|��|jtjj|�tjj|��y�Nr�r�r�)r+r7r8rpr�rqr�r�r�rcr��realpath�r�rxryr�s    r%�test_move_dangling_symlinkz#TestMove.test_move_dangling_symlink�
s����g�g�l�l�4�<�<��/���g�g�l�l�4�<�<��/��
�
�
�3����7�7�<�<����f�5�����C��"���������x�0�1�������)�)�#�.����0@�0@��0J�Kr'c�<�tjj|jd�}tjj|jd�}tj|�tj
||�tjj|jd�}tj||�|jtjj|��|jtjj||��yr)r+r7r8rpr�r�rqr�r�r�rcrrs    r%�test_move_dir_symlinkzTestMove.test_move_dir_symlink�
s����g�g�l�l�4�<�<��/���g�g�l�l�4�<�<��/��
����
�
�
�
�3����7�7�<�<����f�5�����C��"���������x�0�1�������(�(��h�7�8r'c	��tj|j|j�}|j	|t
jj|jt
jj|j���yr*)	r�r�rNrqr�r+r7r8r�rts  r%�test_move_return_valuezTestMove.test_move_return_value�
sT��
�[�[�������
5�����������T�\�\�2�7�7�+;�+;�D�M�M�+J�K�	Mr'c��tj|jtjj|jd��}|j|tjj|jd��yr)r�r�rNr+r7r8rqr�rts  r%� test_move_as_rename_return_valuez)TestMove.test_move_as_rename_return_value�
sL��
�[�[���������T�\�\�5�(I�
J������R�W�W�\�\�$�,�,��>�?r'c���g��fd�}tj|j|j|��|j	t��d�y)Nc�,���j||f�yr*r��rxry�moveds  �r%r�z7TestMove.test_move_file_special_function.<locals>._copy�
�����L�L�#�s��$r'r�r�)r�r�rNrqr�r��r�r�r%s  @r%�test_move_file_special_functionz(TestMove.test_move_file_special_function�
s9�����	%����D�M�M�4�<�<�u�E�����U��Q�'r'c���g��fd�}tjtjj	|j
d��tjtjj	|j
d��t
j|j
|j|��|jt��d�y)Nc�,���j||f�yr*r�r$s  �r%r�z6TestMove.test_move_dir_special_function.<locals>._copy�
r&r'�child�child1r�r)rr�r+r7r8rpr�r�rqr�r�r's  @r%�test_move_dir_special_functionz'TestMove.test_move_dir_special_function�
s{�����	%��#�#�B�G�G�L�L����w�$G�H��#�#�B�G�G�L�L����x�$H�I����D�L�L�$�,�,�e�D�����U��Q�'r'c�Z�|j�|_tjj	tjj|j�tjj
|j�j��}|j|j|�	tj|j|�|jtjj|��tj|�y#tj|�wxYwr*)r�rpr+r7r8rlr��upperr�r�r�r�rbr�r�s  r%�test_move_dir_caseinsensitivez&TestMove.test_move_dir_caseinsensitive�
s����|�|�~����'�'�,�,���������-���� � ����.�4�4�6�8��	
���D�L�L�'�2�	��K�K����g�.��O�O�B�G�G�M�M�'�2�3��H�H�W���B�H�H�W��s
�/AD�D*c���tjj|jd�}tjj|jd�}tj
|j|d��t
j||�|jtjj|��|jtjj|j|��|jtjj|��tj
|j|d��|jtj�5t
j||�ddd�|jtjj|j|��|jtjj|��y#1swY�qxYw)N�	linktodirTr�)r+r7r8rprqr�r�r�r�rcrr�r�r�r)r�ryrxr�s    r%�"_test_move_symlink_to_dir_into_dirz+TestMove._test_move_symlink_to_dir_into_dirs'���g�g�l�l�4�<�<��5���7�7�<�<����k�:��
�
�
�4�<�<��$�?����C�����������x�0�1�������(�(����x�@�A����������,�-�	�
�
�4�<�<��$�?�
�
�
�v�|�|�
,��K�K��S�!�-�������(�(����x�@�A���������s�+�,�-�
,�s�#G*�*G3c�:�|j|j�yr*)r3rqrRs r%�!test_move_symlink_to_dir_into_dirz*TestMove.test_move_symlink_to_dir_into_dir!s���/�/����=r'c��tjj|jd�}tj|j
|d��|j
|�y)N�otherlinktodirTr�)r+r7r8rpr�rqr3r�s  r%�,test_move_symlink_to_dir_into_symlink_to_dirz5TestMove.test_move_symlink_to_dir_into_symlink_to_dir%s=���g�g�l�l�4�<�<�)9�:��
�
�
�4�<�<��$�?��/�/��4r'r|�SF_IMMUTABLE�	UF_OPAQUEzrequires lchflagsc� �	tjt�tjttj
�|j
ttjtt�|jttj�v�tjttj�tjtj j#td��tjttj
�|j
ttjtt�|jttj�v�tj j%t�rAtjttj�tj&t�tj j%t�rBtjttj�tj&t�yy#tj j%t�rAtjttj�tj&t�tj j%t�rBtjttj�tj&t�wwxYw)Nr+)r+r��
TESTFN_SRCr|r�r9r�r�r�r��
TESTFN_DSTr�rar:rr�r7r8r�r�rRs r%�test_move_dir_permission_deniedz(TestMove.test_move_dir_permission_denied+s���	-��H�H�Z� ��K�K�
�D�$5�$5�6�
���o�v�{�{�J�
�S����Z�2�:�:�<�7�8�
�K�K�
�D�N�N�3��'�'������Z��(I�J��K�K�
�D�$5�$5�6�
���o�v�{�{�J�
�S����Z�2�:�:�<�7�8��w�w�~�~�j�)����J����7�� � ��,��w�w�~�~�j�)����J����7�� � ��,�*���w�w�~�~�j�)����J����7�� � ��,��w�w�~�~�j�)����J����7�� � ��,�*�s
�E6I�CL
N).r�r�r�rmr�r�r�r�r�r�r2r�r�r�r�r�r�r�r^r_r+r7rrrrr
rrr]rrrrrr!r(r-r0r3r5r8rerpr�r>rBr'r%r�r�A
s7��,�.�.�K�J�@�
A�
�����%��%�&�����H�
�$��$�H��X��������)B�C�H�D�H�R�
H�

%�
%��"�"��H��#�H��"�"��E��#�E��"�"��L��#�L��"�"��9��#�9�M�
@��(��(��(��(��$�-��-�"�"�"�>�#�>��"�"�5�#�5�
�'�'��X�����Z�0�8�$�T�>�:�8�$�T�;�7�,�.�-�	.�(�
-r'r�c��eZdZGd�de�Zd�Zejed�d��Z	ejed�d��Z
ejed�d��Zy)	�TestCopyFilec�2�eZdZdZdZdZdd�Zd�Zd�Zd�Z	y)�TestCopyFile.FauxFNc� �||_||_yr*)�_raise_in_exit�_suppress_at_exit)r��
raise_in_exit�suppress_at_exits   r%�__init__zTestCopyFile.Faux.__init__Ts��"/�D��%5�D�"r'c��y)NrErB)r�r#s  r%rZzTestCopyFile.Faux.readWs��r'c��d|_yr)�_enteredrRs r%�	__enter__zTestCopyFile.Faux.__enter__Ys	�� �D�Mr'c�j�|||f|_|jrd|_td��|jS)NT�Cannot close)�_exited_withrD�_raisedr rE)r��exc_type�exc_val�exc_tbs    r%�__exit__zTestCopyFile.Faux.__exit__[s8�� (�'�6� 9�D���"�"�#����n�-�-��)�)�)r'r)
r�r�r�rKrOrPrHrZrLrTrBr'r%�FauxrBPs%��������	6�	�	!�	*r'rUc���dd�}tjtd|�5|jt�5tj
dd�ddd�ddd�y#1swY�xYw#1swYyxYw)Nc�$�|dk(rtd��y)N�srcfilezCannot open "srcfile"r,)r�r\s  r%�_openz4TestCopyFile.test_w_source_open_fails.<locals>._opencs���9�$��5�6�6�%r'r;rX�destfile�rV)rr2r�r�r rP)r�rYs  r%�test_w_source_open_failsz%TestCopyFile.test_w_source_open_failsbsT��	�
�
�
�v�v�u�
5��"�"�7�+����	�:�6�,�6�
5�+�+��6�
5�s"�A*�A�
A*�A'	�#A*�*A3zskipped on macOSc���|j��d�fd�	}tjtd|�5tjdd�ddd�|j�j�|j�jdtu�|j�jdjd�y#1swY�rxYw)	Nc�4��|dk(r�S|dk(rtd��y)NrXrZ�Cannot open "destfile"r,)r�r\rXs  �r%rYz2TestCopyFile.test_w_dest_open_fails.<locals>._openps)����9�$����:�%��6�7�7�&r'r;rXrZrr�)r_r[)rUrr2r�rPr�rKrOr r�r#)r�rYrXs  @r%�test_w_dest_open_failsz#TestCopyFile.test_w_dest_open_failsls�����)�)�+��	��
�
�v�v�u�
5��O�O�I�z�2�6�����(�(�)�����,�,�Q�/�7�:�;�����-�-�a�0�5�5�4�	6�	6�
5�s�B;�;Cc� ���|j��|jd��d	��fd�	}tjtd|�5tjdd�ddd�|j�j�|j�j�|j�j�|j�jdtu�|j�jdjd�y#1swY��xYw)
NTc�"��|dk(r�S|dk(r�Sy�NrXrZrB�r�r\rZrXs  ��r%rYz3TestCopyFile.test_w_dest_close_fails.<locals>._open��"����9�$����:�%���&r'r;rXrZrr�)rNr[)rUrr2r�rPr�rKrPrOr r�r#�r�rYrZrXs  @@r%�test_w_dest_close_failsz$TestCopyFile.test_w_dest_close_fails~s�����)�)�+���9�9�T�?��	��
�
�v�v�u�
5��O�O�I�z�2�6�����(�(�)�����)�)�*�����(�(�)�����,�,�Q�/�7�:�;�����-�-�a�0�5�5�*�	,�
6�
5�s�D�D
c�P���|jd��|j��d��fd�	}tjtd|�5|j	t
�5tjdd�ddd�ddd�|j�j�|j�j�|j�j�|j�jddu�|j�j�y#1swY��xYw#1swY��xYw)NTc�"��|dk(r�S|dk(r�SyrcrBrds  ��r%rYz5TestCopyFile.test_w_source_close_fails.<locals>._open�rer'r;rXrZrr[)rUrr2r�r�r rPr�rKr�rPrOrfs  @@r%�test_w_source_close_failsz&TestCopyFile.test_w_source_close_fails�s�����)�)�D�/���9�9�;��	��
�
�v�v�u�
5��"�"�7�+����	�:�6�,�6�	
����(�(�)�����)�)�*�����)�)�*�����,�,�Q�/�4�7�8�������(�
,�+��6�
5�s$�D�D�3D�D	�D�D%N)r�r�r��objectrUr\r^r`rfr`rgrjrBr'r%r@r@Nsy��*�v�*�$7��X�_�_�U�.�/�6�0�6�"�X�_�_�U�.�/�,�0�,�(�X�_�_�U�.�/�)�0�)r'r@c��eZdZdZed��Zed��Zd�Zejd��Z
d�Zd�Zd�Z
d	�Zej ej$d
k7d�d��Zy
)�TestCopyFileObji c�8�tt|j�yr*)rSr�FILESIZE��clss r%�
setUpClasszTestCopyFileObj.setUpClass�s�������-r'c�h�tjt�tjt�yr*)rrurr�rps r%�
tearDownClasszTestCopyFileObj.tearDownClass�s������ �����!r'c�6�tjt�yr*�rrur�rRs r%�tearDownzTestCopyFileObj.tearDown��������!r'c#�K�ttd�5}ttd�5}||f��ddd�ddd�y#1swY�xYw#1swYyxYw�w�NrUrF�r;rr�rGs   r%�	get_fileszTestCopyFileObj.get_files��D����
�&�$�
�3��g�t�$���C�j� �%� �
�$�$�� �
��/�A�A�<�A�	A�A	�A�A�
Ac���t|d�5}t|d�5}|j|j�|j��ddd�ddd�y#1swY�xYw#1swYyxYwr�)r;r�rZ)r�rxry�fsrc�fdsts     r%�assert_files_eqzTestCopyFileObj.assert_files_eq�sN��
�#�t�_���c�4��D�� � �����d�i�i�k�:�!��_� ����_�s"�
A&�/A�	A&�A#	�A&�&A/c��|j�5\}}tj||�ddd�|jtt
�y#1swY�$xYwr*)r|r��copyfileobjr�rr�rGs   r%�test_contentzTestCopyFileObj.test_content�s@��
�^�^�
��#�s����s�C�(�����V�W�-��
�s�A�Ac��|j�5\}}tj||�ddd�y#1swYyxYwr*)r|r�r�rGs   r%�test_file_not_closedz$TestCopyFileObj.test_file_not_closed�s.��
�^�^�
��#�s����s�C�(��
�
�s�4�=c�(�|j�5\}}tj||�|j|j	�|j
�|j|j	�|j
�ddd�y#1swYyxYwr*)r|r�r�r��tellrorGs   r%�test_file_offsetz TestCopyFileObj.test_file_offset�sb��
�^�^�
��#�s����s�C�(����S�X�X�Z����7����S�X�X�Z����7��
�
�s�A.B�Br�zWindows onlyc�d�tjjd�5}tjt
t�ddd�|jjddd�tjtj�d��5}|jd�ddd�j}|jt j"|�tjjd�5}tj|t�ddd�|j|jddd�tjtj�d��5}	ddd�|j}|jt j"|�tjjd�5}tj|t�ddd�|j%|t�y#1swY���xYw#1swY��_xYw#1swY��xYw#1swY��xYw#1swY�RxYw)	Nzshutil._copyfileobj_readintorroiFrlsfoor)r^r�r�r�rPrr�r��	call_argsrqrrr+rsr<rgr�rrur�)r��mrQrs    r%�
test_win_implzTestCopyFileObj.test_win_impl�s����]�]�
 �
 �!?�
@�A��O�O�F�G�,�A�
	
������Q���*�O�<��
(�
(�R�Y�Y�[��
G�1�
�G�G�F�O�H��������	�(�(�%�0�
�]�]�
 �
 �!?�
@�A��O�O�E�7�+�A�������Q���*�A�.��
(�
(�R�Y�Y�[��
G�1��H��������	�(�(�%�0�
�]�]�
 �
 �!?�
@�A��O�O�E�7�+�A�	
���U�G�,�3A�
@��H�
G��A�
@��
H�
G��A�
@�s;�G4�H�7H�%H�:H&�4G>�H�H�H#�&H/N)r�r�r�ro�classmethodrrrtrw�
contextlib�contextmanagerr|r�r�r�r�r^r`r+rgr�rBr'r%rmrm�s����H��.��.��"��"�"����!��!�
;�
.�
"�8��X�_�_�R�W�W��_�n�5�-�6�-r'rmc��eZdZdZdZdZdZed��Zed��Z	d�Z
ejd��Z
d	�Zd
�Zd�Zd�Zd
�Zd�Zd�Zd�Zd�Zy)�_ZeroCopyFileTestz#Tests common to all zero-copy APIs.i�r'rEc��tt|j�ttd�5}|j	�|_ddd�y#1swYyxYwr�)rSrror;rZ�FILEDATA)rqrQs  r%rrz_ZeroCopyFileTest.setUpClass�s5�������-�
�&�$�
�1��6�6�8�C�L� �
�
�s�A
�
Ac�6�tjt�yr*)rrurrps r%rtz_ZeroCopyFileTest.tearDownClasss������ r'c�6�tjt�yr*rvrRs r%rwz_ZeroCopyFileTest.tearDownrxr'c#�K�ttd�5}ttd�5}||f��ddd�ddd�y#1swY�xYw#1swYyxYw�wrzr{rGs   r%r|z_ZeroCopyFileTest.get_filesr}r~c��td��)Nzmust be implemented in subclass)r<)r�r#r$s   r%�zerocopy_funz_ZeroCopyFileTest.zerocopy_funs��!�"C�D�Dr'c��|j�|j�|j�|j�yr*)rwrtrrrmrRs r%�resetz_ZeroCopyFileTest.resets*���
�
�����������
�
�r'c���|j�5\}}|j||�ddd�|jttd��|j
�|j�5\}}tjjd�5}tjtt�ddd�ddd�y#1swY��xYw#1swY�xYw#1swYyxYw)NT�r[zshutil.copyfileobj)r|r�r�r]r�r�r^r�r�r�rPr)r�rxryr�s    r%�test_regular_copyz#_ZeroCopyFileTest.test_regular_copys���
�^�^�
��#�s����c�3�'������7�4�8�$�-�-�H�
�^�^�
��#�s����$�$�%9�:�a������0�;��
�	�
��
;�:���
�s/�B=�*#C�
C	�,C�=C�	C	�C�Cc�d�|j|j�|j�5\}}|jtt
f�5|j
||�ddd�ddd�|jttd��|j�y#1swY�=xYw#1swY�AxYw)NTr�)r�r�r|r�r rr�r�r]rr�rGs   r%�test_same_filez _ZeroCopyFileTest.test_same_file#s�������
�
�#�
�^�^�
��#�s��"�"�G�->�#?�@��!�!�#�s�+�A��	
����6�$�7����G�A�@���
�s#�B&�B�B&�B#	�B&�&B/c� �tjtj���}|j	t
�5}t
j|d�ddd�|jjj|�y#1swY�0xYw)Nr��new)rqr�r+rsr�r�r�rPr�r�r�)r�rgr�s   r%�test_non_existent_srcz'_ZeroCopyFileTest.test_non_existent_src+s]�����2�9�9�;�/��
�
�
�0�
1�R��O�O�D�%�(�2�������.�.��5�2�
1�s�B�B
c�t���tdz�tdz�|j�fd��|j�fd��t��t�d�5}t�d�5}|j	||�ddd�ddd�|jt
�d��d	�y#1swY�/xYw#1swY�3xYw)
Nrxryc�.��tj��Sr*�rru)rvs�r%rz3_ZeroCopyFileTest.test_empty_file.<locals>.<lambda>4����	� 0� 0�� 9r'c�.��tj��Sr*r�)rws�r%rz3_ZeroCopyFileTest.test_empty_file.<locals>.<lambda>5r�r'rUrFTr�r')rr�r?r;r�r�r])r�rxryrwrvs   @@r%�test_empty_filez!_ZeroCopyFileTest.test_empty_file1s�����5�.���5�.�����9�:����9�:��G��
�'�4�
 �C��g�t�$���!�!�#�s�+�%�!�	
����7�4�8�#�>�%�$��!�
 �s$�
B.�!B"�4B.�"B+	�'B.�.B7c���tjj|jt��5|jttjtt�ddd�y#1swYyxYw)Nr)
r^r�r��
PATCHPOINT�ZeroDivisionErrorr�r�rPrr�rRs r%�test_unhandled_exceptionz*_ZeroCopyFileTest.test_unhandled_exception>sS��
�]�]�
 �
 ����->�!�@����/�$�o�o�v�w�
@�@�@�@�s�/A(�(A1c�|�tjj|jt	t
jd���5|j�5\}}|jt�5|j||�ddd�ddd�ddd�y#1swY�xYw#1swY�xYw#1swYyxYw�N�yor)r^r�r�r�r r"�EINVALr|r�rr�rGs   r%�test_exception_on_first_callz._ZeroCopyFileTest.test_exception_on_first_callDs����]�]�
 �
 ����-4�U�\�\�4�-H�!�J����!�Z�c�3��&�&�'8�9��%�%�c�3�/�:�"�J�J�:�9��"�!��J�J�s<�B2�B&�.B�B&�	B2�B#�B&�&B/	�+B2�2B;c�H�tjj|jt	t
jd���5|j�5\}}|jt|j||�ddd�ddd�y#1swY�xYw#1swYyxYwr�)
r^r�r�r�r r"�ENOSPCr|r�r�rGs   r%�test_filesystem_fullz&_ZeroCopyFileTest.test_filesystem_fullNs���]�]�
 �
 ����-4�U�\�\�4�-H�!�J����!�Z�c�3��!�!�'�4�+<�+<�c�3�G�"�J�J�!�!��J�J�s$�B�&B�;B�B	�B�B!N)r�r�r��__doc__ror�r�r�rrrtrwr�r�r|r�r�r�r�r�r�r�r�r�rBr'r%r�r��s���-� �H��H��J��5��5��!��!�"����!��!�
E�� �H�6�?�@�0�Hr'r�zos.sendfile() not supportedc�F�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zy)�TestZeroCopySendfile�os.sendfilec�.�tj||�Sr*)r��_fastcopy_sendfile)r�r�r�s   r%r�z!TestZeroCopySendfile.zerocopy_fun[s���(�(��t�4�4r'c��tj|j�5}ttd�5}|jt�5|j||�ddd�tj||�ddd�ddd�|jttd��|j�y#1swY�[xYw#1swY�IxYw#1swY�MxYw)NrFTr�)�io�BytesIOr�r;r�r�rr�r�r�r�r]rGs   r%�test_non_regular_file_srcz.TestZeroCopySendfile.test_non_regular_file_src^s���
�Z�Z��
�
�
&�#��g�t�$���&�&�'8�9��%�%�c�3�/�:��"�"�3��,�%�'�	
����7�4�8�$�-�-�H�	:�9��%�$��'�
&�s:�C�C�B4�C�8C�4B=�9C�C		�C�Cc��ttd�5}tj�5}|j	t
�5|j
||�ddd�tj||�|jd�|j|j�|j�ddd�ddd�y#1swY�kxYw#1swY�xYw#1swYyxYw)NrUr)
r;rr�r�r�rr�r�r��seekr�rZr�rGs   r%�test_non_regular_file_dstz.TestZeroCopySendfile.test_non_regular_file_dstgs���
�&�$�
�3�������&�&�'8�9��%�%�c�3�/�:��"�"�3��,������� � �����T�]�]�;�� �
�9�9����� �
�s:�C�C�B9�AC�(C�9C�>C�C	�
C�Cc�������fd�}g�tj�tjj	dd|��5|j�5\}}|j
t�5}tj||�ddd�ddd�ddd�|jjjtj�y#1swY�NxYw#1swY�RxYw#1swY�VxYw)Nc�n���s�jd��|i|��Sttjd��)Nr�)rdr r"�EBADF)r#r$r��
orig_sendfiles  ��r%rkzDTestZeroCopySendfile.test_exception_on_second_call.<locals>.sendfileqs3�������D�!�$�d�5�f�5�5��e�k�k�4�0�0r'r�T)r�r)r+rkr^r�r�r|r�r r�r�r�r�r"r�)r�rkrxryr�r�r�s     @@r%�test_exception_on_second_callz2TestZeroCopySendfile.test_exception_on_second_callps����	1������
�
�]�]�
 �
 ��t�-5�!�7����!�Z�c�3��&�&�w�/�2��-�-�c�3�7�0�"�7�	
������+�+�U�[�[�9�0�/��"�!��7�7�s;�C#�C�'C�>C�C#�C�C�C 	�C#�#C,c�J�tjjdt��5}|j	�5\}}tj||�ddd�ddd�|jttd��|j�y#1swY�=xYw#1swY�AxYw)N�os.fstatrTr�)r^r�r�r r|r�r�r�r]r�r��r�r�rxrys    r%�test_cant_get_sizez'TestZeroCopySendfile.test_cant_get_size�sx���]�]�
 �
 ���
 �
A�Q����!�Z�c�3��)�)�#�s�3�"�B�	
����7�4�8�$�-�-�H�"�!��B�
A�s"�B�B
�B�
B	�B�B"c��tjj�}d|_tjj	d|��5}|j�5\}}t
j||�ddd�ddd�|jttd��|j�y#1swY�=xYw#1swY�AxYw)Nir�r�Tr�)r^r��Mock�st_sizer�r|r�r�r�r]r�r��r�r�r�rxrys     r%�test_small_chunksz&TestZeroCopySendfile.test_small_chunks�s���
�}�}�!�!�#�� ���
�]�]�
 �
 ��$�
 �
?�1����!�Z�c�3��)�)�#�s�3�"�@�	
����7�4�8�$�-�-�H�"�!��@�
?�s$�B:�B.�2B:�.B7	�3B:�:Cc��tjj�}|jdz|_tjjd|��5}|j
�5\}}tj||�ddd�ddd�|jttd��|j�y#1swY�=xYw#1swY�AxYw)Ni@r�r�Tr�)
r^r�r�ror�r�r|r�r�r�r]r�r�r�s     r%�test_big_chunkz#TestZeroCopySendfile.test_big_chunk�s���
�}�}�!�!�#���}�}�(9�:���
�]�]�
 �
 ��$�
 �
?�1����!�Z�c�3��)�)�#�s�3�"�@�	
����7�4�8�$�-�-�H�"�!��@�
?�s$�C�%B;�?C�;C	�C�Cc��tjjdt��5}|j	tt
jtt�|jdd}|j|tjjt��tjt�t!td�|j#tjtdz�|j	tt
jttdz�|jdd}|j|d�ddd�y#1swYyxYw)Nr�rrrshello�3i�)r^r�r�r�r�r�rPrr�r�r�r+r7�getsizerrur?r�)r�r��	blocksizes   r%�test_blocksize_argz'TestZeroCopySendfile.test_blocksize_arg�s���
�]�]�
 �
 ��->�!�@�CD����/�$�o�o�v�w�
@����A��q�)�I�
���Y�������(?�@����W�%����*��O�O�I�,�,�g��m�<����/�$�o�o�w��#�
�
G����A��q�)�I����Y��0�@�@�@�s�DE�Ec�t�	tjj|jt	t
jd���5}|j�5\}}|jt�5tj||�ddd�ddd�ddd�tjj|j�5}tjtt�ddd�dt_y#1swY�uxYw#1swY�yxYw#1swY�}xYw#1swY�9xYw#dt_wxYw)Nr�rT)r^r�r�r�r r"�ENOTSOCKr|r�rr�r�rPrr��_USE_CP_SENDFILEr�s    r%�test_file2file_not_supportedz1TestZeroCopySendfile.test_file2file_not_supported�s���
	+����$�$��O�O� '����� =�%�?�BC��^�^�%��#�s��*�*�+<�=��1�1�#�s�;�>�&�?����$�$�T�_�_�5�������0�6�'+�F�#�>�=��&�%��?�?��6�5��'+�F�#�sl�AD*�D�D�/C:�D�D�1D*�D�&D*�:D�?D�D	�D�D�D*�D'�#D*�*
D7N)
r�r�r�r�r�r�r�r�r�r�r�r�r�rBr'r%r�r�Ws8���J�5�I�<�:�$I�I�I�1�$+r'r�z
macOS onlyc��eZdZdZd�Zy)�TestZeroCopyMACOSzposix._fcopyfilec�L�tj||tj�Sr*)r��_fastcopy_fcopyfile�posix�_COPYFILE_DATArGs   r%r�zTestZeroCopyMACOS.zerocopy_fun�s���)�)�#�s�E�4H�4H�I�Ir'N)r�r�r�r�r�rBr'r%r�r��s
��#�J�Jr'r�c� �eZdZd�Zd�Zd�Zejeje
jj��d�eje
ed�d�d���Zejej"d�d	��Zy
)�TestGetTerminalSizec��tj�}|j|jd�|j|jd�y)z�Check if get_terminal_size() returns a meaningful value.

        There's no easy portable way to actually check the size of the
        terminal, so let's check if it returns something sensible instead.
        rN)r��get_terminal_sizerR�columns�lines)r�rMs  r%�test_does_not_crashz'TestGetTerminalSize.test_does_not_crash�s:���'�'�)��������a�0�����
�
�A�.r'c��tj�5}d|d<|d=tj�}ddd�|j	j
d�tj�5}|d=d|d<tj�}ddd�|j	|jd�y#1swY�{xYw#1swY�2xYw)z.Check if environment variables have precedence�777�COLUMNS�LINESNi	�888ix)rr�r�r�r�r�r��r�r�rMs   r%�test_os_environ_firstz)TestGetTerminalSize.test_os_environ_first�s����
*�
*�
,��"�C�	�N��G���+�+�-�D�-�	
������s�+�
�
*�
*�
,���I�� �C��L��+�+�-�D�-�	
������S�)�-�
,��-�
,�s�B,�*B8�,B5�8Cc��tj�5}d|d<d|d<tj�}ddd�|j	j
d�|j	|jd�y#1swY�BxYw)Nr
r��yyyr�r)rr�r�r�rRr�r�r�s   r%�test_bad_environz$TestGetTerminalSize.test_bad_environ�sh��
�
*�
*�
,��"�C�	�N� �C��L��+�+�-�D�-�	
������a�0�����
�
�A�.�-�
,�s�A5�5A>z
not on ttyr�zneed os.get_terminal_size()c���	tjddg�j�j�}td�t|d�f}tj�5}|jdd�tj�}ddd�|j|�y#tt
tjf$r|jd�Y��wxYw#1swY�QxYw)	z�Check if stty returns the same results ignoring env

        This test will fail if stdin and stdout are connected to
        different terminals with different sizes. Nevertheless, such
        situations should be pretty rare.
        �sttyrMzstty invocation failedr�rr�r�N)r�r�r�r�r�r�r�r�r�rr��unsetr�r�r�)r�rMr$r�rrs     r%�test_stty_matchz#TestGetTerminalSize.test_stty_match�s���	4��*�*�F�F�+;�<�C�C�E�K�K�M�D���Q��L�#�d�1�g�,�/��
�
*�
*�
,���I�I�g�y�)��-�-�/�F�-�	
����6�*��"�?��-�-�/�	4��M�M�2�3�	4��
-�
,�s�3B'�%'C�'/C�C�C%zWASI has no /dev/nullc���tj�5}|jdd�tjt
dd�5t
jd��}ddd�|jjd�|j|jd�ttjdd	�
�5}tjt
d|�5t
jd��}ddd�ddd�|j|jd�|j|jd
�ddd�y#1swY��xYw#1swY�^xYw#1swY�bxYw#1swYyxYw)Nr�r��
__stdout__)rV�)�fallbackrVr��wrWrX)�rUr�rU)rr�r�rr2r�r�r�r�r�r�r;r+�devnull)r�r�rMrQs    r%�
test_fallbackz!TestGetTerminalSize.test_fallback
s��
�
*�
*�
,���I�I�g�y�)��"�"�3��d�;��/�/��B��<����T�\�\�2�.����T�Z�Z��,��b�j�j�#��8�A��"�"�3��a�8��/�/��B��9�9�
���T�\�\�2�.����T�Z�Z��,�-�
,�<�;��9�8��9�8��-�
,�sU�.E�D:�AE�6E�E�)E�1AE�:E	�?E�E�E�E	�E�E'N)r�r�r�r�r�r�r^r_r+�isattyr�r�rtrpr�r`r�is_wasir�rBr'r%r�r��s���/�
*�/��X�������3�>�>�#8�#8�#:�;�\�J��X�����%8�9�6�8�+�8�K�+�(�X�_�_�W�_�_�&=�>�-�?�-r'r�c��eZdZdZd�Zy)�PublicAPITestsz>Ensures that the correct values are exposed in the public API.c��|jttd��gd�}ttd�stjdk(r|jd�|j
ttj�t|��y)N�__all__)r�rPr�r�r4r9rmr�r�rrX�	ExecErrorrrrrrr	rrr�rUrHr�r
�statvfsr�rM)	r�rpr�r+rgrdr�r�r)r��
target_apis  r%�test_module_all_attributez(PublicAPITests.test_module_all_attribute&
s]�������	�2�3�<�
��2�y�!�R�W�W��_����l�+�����V�^�^�,�c�*�o�>r'N)r�r�r�r�r	rBr'r%rr#
s
��H�?r'r�__main__)r')F)Wr^�
unittest.mockr�rqr�r�r+�os.pathr"r0�pathlibr�rIrKr�r�rrrrrrr	r
rrr
rrk�warningsr�r��ImportErrorr�r�test.supportr�test.support.os_helperrrrr�r<r=rar�rfrgr�r�r�r�r�r�r��AssertionErrorr�r&r2r?rSr]rer|�SUPPORTS_SENDFILEr�r��TestCaser�rer�rirLrdr�r�r@rmrkr�r`r�r�r�rr��mainrBr'r%�<module>rs����
��
��	������
�
��	�6�6�6�6�������"�3�(�
�3�,��
�f�_�
�
�f�_�
�������)��

�,�,�
!�
!�'�
*��	�l�l�2�A��%�������O����=�=���z�"�#>�?��A��L�	��)�$�
�&�:0�1���	�	�}"��8�,�,�}"�@^2�8�X�.�.�^2�@A?�x��*�*�A?�H@	8�8�X�.�.�@	8�FM+�x��*�*�M+�`,��(�+�+�,�D
-�Y�
-�J-�x��*�*�J-�ZY)�8�$�$�Y)�xG-�h�'�'�G-�T`H��`H�F����&�&�(E�F�s+�,�h�.?�.?�s+�G�s+�l����U��L�)�J�)�8�+<�+<�J�*�J�J-�(�+�+�J-�Z?�X�&�&�?�$�z���H�M�M�O���oh���E���$���O���
���G��s6�*J3� 
K�+K�3J>�=J>�K�K�K�K

Youez - 2016 - github.com/yon3zu
LinuXploit