o
    5‘ði”  ã                   @   sª   d Z ddlZddlZddlZddlZddlmZ ddlmZm	Z	 ddl
mZmZmZmZmZ ddlmZ ddlZddlZddlZejdd�dd	„ ƒZG d
d„ dejƒZdS )zTests for distutils.dir_util.é    N)Údir_utilÚerrors)Ú	copy_treeÚcreate_treeÚensure_relativeÚmkpathÚremove_tree)ÚsupportT)Úautousec                 C   sD   | j }| ¡ }tj |d¡|_tj |jd¡|_tj |d¡|_d S )NÚdeepÚhereÚdeep2)ÚinstanceÚmkdtempÚosÚpathÚjoinÚroot_targetÚtargetÚtarget2)ÚrequestÚmonkeypatchÚdistutils_managed_tempdirÚselfÚtmp_dir© r   úh/root/parts/websockify/install/lib/python3.10/site-packages/setuptools/_distutils/tests/test_dir_util.pyÚstuff   s
   r   c                   @   sX   e Zd Zdd„ Zej d¡dd„ ƒZdd„ Zdd	„ Z	d
d„ Z
dd„ Zdd„ Zdd„ ZdS )ÚTestDirUtilc                 C   sˆ   t | jdd� |jrJ ‚t| jdd� t | jdd� d| j› �g}|j|ks(J ‚| ¡  t| jdd� d| j› d�g}|j|ksBJ ‚d S )NF©ÚverboseTú	creating z
removing 'z' (and everything under it))r   r   Úrecordsr   r   ÚmessagesÚclear©r   ÚcaplogÚwantedr   r   r   Ú!test_mkpath_remove_tree_verbosity!   s   
z-TestDirUtil.test_mkpath_remove_tree_verbosityzplatform.system() == 'Windows'c                 C   st   t  d¡}t  |¡ t| jdƒ t t  | j¡j¡d| @ ks!J ‚t| jdƒ t t  | j¡j¡d| @ ks8J ‚d S )Né   iÀ  im  )r   Úumaskr   r   ÚstatÚS_IMODEÚst_moder   )r   r*   r   r   r   Útest_mkpath_with_custom_mode/   s   

"&z(TestDirUtil.test_mkpath_with_custom_modec                 C   sr   t | jg d¢dd� |jg ksJ ‚t| jdd� d| j› �g}t | jg d¢dd� |j|ks0J ‚t| jdd� d S )N)ÚoneÚtwoÚthreeFr   r!   T)r   r   r#   r   r%   r   r   r   Útest_create_tree_verbosity9   s   z&TestDirUtil.test_create_tree_verbosityc                 C   sÂ   t | jdd� t| j| jdd� |jg ksJ ‚t| jdd� t | jdd� t | j¡d }t	j 
ddi| j¡ d|› d| j› �g}t| j| jdd� |j|ksQJ ‚t| jdd� t| jdd� d S )NFr   úok.txtúsome contentzcopying z -> T)r   r   r   r   r#   r   r   r   ÚPathÚjaracoÚbuild)r   r&   Úa_filer'   r   r   r   Útest_copy_tree_verbosityD   s   z$TestDirUtil.test_copy_tree_verbosityc                 C   sh   t | jdd� tj dddœ| j¡ t| j| jƒ t | j¡dgks$J ‚t	| j
dd� t	| jdd� d S )NFr   r4   Ú )r3   z
.nfs123abcr3   )r   r   r6   r   r7   r   r   r   Úlistdirr   r   ©r   r   r   r   Ú#test_copy_tree_skips_nfs_temp_filesW   s   z/TestDirUtil.test_copy_tree_skips_nfs_temp_filesc                 C   sR   t jdkrtdƒdksJ ‚tdƒdksJ ‚d S tdƒdksJ ‚tdƒdks'J ‚d S )Nú/z	/home/foozhome/fooz	some/pathzc:\home\fooz
c:home\foozhome\foo)r   Úsepr   r<   r   r   r   Útest_ensure_relativeb   s
   
z TestDirUtil.test_ensure_relativec              	   C   sˆ   t jdtƒ d��2 t tj¡� | jd }t 	|d¡ W d  ƒ n1 s%w   Y  W d  ƒ dS W d  ƒ dS 1 s=w   Y  dS )zK
        An exception in listdir should raise a DistutilsFileError
        z
os.listdir)Úside_effectéÿÿÿÿN)
ÚmockÚpatchÚOSErrorÚpytestÚraisesr   ÚDistutilsFileErrorÚtempdirsr   r   )r   Úsrcr   r   r   Ú#test_copy_tree_exception_in_listdirj   s   ÿ
þ
Pûz/TestDirUtil.test_copy_tree_exception_in_listdirc                 C   sv   G dd„ dt jƒ}|d }t tj¡� t||ƒƒ W d  ƒ n1 s$w   Y  | ¡ r/J ‚t|ƒ | ¡ s9J ‚dS )zZ
        Caching should not remember failed attempts.

        pypa/distutils#304
        c                   @   s,   e Zd Zdd„ Zejdk re ¡ jZdS dS )z<TestDirUtil.test_mkpath_exception_uncached.<locals>.FailPathc                 _   s   t dƒ‚)NzFailed to create directory)rE   )r   ÚargsÚkwargsr   r   r   Úmkdir}   s   zBTestDirUtil.test_mkpath_exception_uncached.<locals>.FailPath.mkdir)é   é   N)	Ú__name__Ú
__module__Ú__qualname__rN   ÚsysÚversion_infoÚpathlibr5   Ú_flavourr   r   r   r   ÚFailPath|   s
    
ÿrX   ÚfoodirN)rV   r5   rF   rG   r   rH   r   Úexists)r   r   Útmp_pathrX   r   r   r   r   Útest_mkpath_exception_uncachedu   s   ÿz*TestDirUtil.test_mkpath_exception_uncachedN)rQ   rR   rS   r(   rF   ÚmarkÚskipifr.   r2   r9   r=   r@   rK   r\   r   r   r   r   r       s    

	r   )Ú__doc__r   rV   r+   rT   Úunittest.mockrC   Ú	distutilsr   r   Údistutils.dir_utilr   r   r   r   r   Údistutils.testsr	   Újaraco.pathr6   r   rF   Úfixturer   ÚTempdirManagerr   r   r   r   r   Ú<module>   s    

