
    eX                         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mZ ddlmZmZ  G d	 d
ej        ej                  Zedk    r ej                     dS dS )zTests for distutils.dir_util.    N)patch)dir_utilerrors)mkpathremove_treecreate_tree	copy_treeensure_relative)log)support)is_emscriptenis_wasic                        e Zd Zd Z fdZ fdZd Z ej        e	j
                            d          d           ej        eped          d                         Zd	 Zd
 Zd Zd Zd Z xZS )DirUtilTestCasec                     t          |          dk    r| j                            ||z             d S | j                            |           d S )Nr   )len_logsappend)selfmsgargss      /  /home/conda/feedstock_root/build_artifacts/python-split_1708115622739/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehol/lib/python3.11/distutils/tests/test_dir_util.py_logzDirUtilTestCase._log   sM    t99q==JcDj)))))Jc"""""    c                    t          t          |                                            g | _        |                                 }t
          j                            |d          | _        t
          j                            | j        d          | _	        t
          j                            |d          | _
        t          j        | _        | j        t          _        d S )Ndeepheredeep2)superr   setUpr   mkdtempospathjoinroot_targettargettarget2r   infoold_logr   )r   tmp_dir	__class__s     r   r    zDirUtilTestCase.setUp   s    ot$$**,,,
,,..7<<88gll4#3V<<w||GW55x9r   c                 x    | j         t          _        t          t          |                                            d S )N)r)   r   r(   r   r   tearDown)r   r+   s    r   r-   zDirUtilTestCase.tearDown#   s.    <ot$$--/////r   c                    t          | j        d           g }|                     | j        |           t	          | j        d           t          | j        d           d| j        z  d| j        z  g}|                     | j        |           g | _        t	          | j        d           d| j        z  g}|                     | j        |           d S )Nr   verbose   creating %sz'removing '%s' (and everything under it))r   r&   assertEqualr   r   r%   r   wanteds     r   !test_mkpath_remove_tree_verbosityz1DirUtilTestCase.test_mkpath_remove_tree_verbosity'   s    t{A&&&&V,,,D$a0000t{A&&&&$"22$+-/V,,,
D$a0000;d>NNOV,,,,,r   winz5This test is only appropriate for POSIX-like systems.z$Emscripten's/WASI's umask is a stub.c                    t          j        d          }t          j        |           t          | j        d           |                     t          j        t          j        | j                  j                  d| z             t          | j        d           |                     t          j        t          j        | j                  j                  d| z             d S )N   i  im  )	r"   umaskr   r&   r3   statS_IMODEst_moder'   )r   r:   s     r   test_mkpath_with_custom_modez,DirUtilTestCase.test_mkpath_with_custom_mode8   s     
t{E"""L--566	H 	H 	Ht|U###L..677%	I 	I 	I 	I 	Ir   c                 D   t          | j        g dd           |                     | j        g            t	          | j        d           d| j        z  g}t          | j        g dd           |                     | j        |           t	          | j        d           d S )N)onetwothreer   r/   r2   r1   )r   r%   r3   r   r   r4   s     r   test_create_tree_verbosityz*DirUtilTestCase.test_create_tree_verbosityI   s    D$&=&=&=qIIIIR(((D$a0000$"223D$&=&=&=qIIIIV,,,D$a000000r   c                    t          | j        d           t          | j        | j        d           |                     | j        g            t          | j        d           t          | j        d           t          j	        
                    | j        d          }t          |d          5 }|                    d           d d d            n# 1 swxY w Y   d|d| j        g}t          | j        | j        d           |                     | j        |           t          | j        d           t          | j        d           d S )	Nr   r/   ok.txtwsome contentzcopying z -> r1   )r   r&   r	   r'   r3   r   r   r%   r"   r#   r$   openwrite)r   a_filefr5   s       r   test_copy_tree_verbosityz(DirUtilTestCase.test_copy_tree_verbosityU   sx   t{A&&&&$+t|Q7777R(((D$a0000t{A&&&&dk844&# 	$!GGN###	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ )/=>$+t|Q7777V,,,D$a0000DL!,,,,,,s   /CCCc                 6   t          | j        d           t          j                            | j        d          }t          j                            | j        d          }||fD ]?}t          |d          5 }|                    d           d d d            n# 1 swxY w Y   @t          | j        | j                   | 	                    t          j
        | j                  dg           t          | j        d           t          | j        d           d S )Nr   r/   rE   z
.nfs123abcrF   rG   )r   r&   r"   r#   r$   rH   rI   r	   r'   r3   listdirr   r%   )r   rJ   nfs_filerK   fhs        r   #test_copy_tree_skips_nfs_temp_filesz3DirUtilTestCase.test_copy_tree_skips_nfs_temp_filesj   s7   t{A&&&&dk8447<<\::! 	) 	)Aa )((() ) ) ) ) ) ) ) ) ) ) ) ) ) ) 	$+t|,,,DL11H:>>>D$a0000DL!,,,,,,s   7BB	 B	c                 B   t           j        dk    rH|                     t          d          d           |                     t          d          d           d S |                     t          d          d           |                     t          d          d           d S )N/z	/home/foozhome/fooz	some/pathzc:\home\fooz
c:home\foozhome\foo)r"   sepr3   r
   )r   s    r   test_ensure_relativez$DirUtilTestCase.test_ensure_relativey   s    6S==_[99:FFF_[99;GGGGG__==}MMM_[99;GGGGGr   c                 $   t          dt                                5  |                     t          j                  5  | j        d         }t          j        |d           ddd           n# 1 swxY w Y   ddd           dS # 1 swxY w Y   dS )zK
        An exception in listdir should raise a DistutilsFileError
        z
os.listdir)side_effectN)r   OSErrorassertRaisesr   DistutilsFileErrortempdirsr   r	   )r   srcs     r   #test_copy_tree_exception_in_listdirz3DirUtilTestCase.test_copy_tree_exception_in_listdir   s
    <WYY777 	* 	*v899	* 	*-#CsD)))	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	*s4    B#A-!B-A1	1B4A1	5BB	B	)__name__
__module____qualname__r   r    r-   r6   unittestskipIfsysplatform
startswithr   r   r>   rC   rL   rQ   rU   r^   __classcell__)r+   s   @r   r   r      s+       # # #    0 0 0 0 0- - -" X_S\,,U33?A AX_ . 	I 	I	 A A	I
1 
1 
1- - -*- - -H H H* * * * * * *r   r   __main__)__doc__rb   r"   r;   rd   unittest.mockr   	distutilsr   r   distutils.dir_utilr   r   r   r	   r
   r   distutils.testsr   test.supportr   r   TempdirManagerTestCaser   r_   main r   r   <module>rs      s>   # #  				  



       & & & & & & & &1 1 1 1 1 1 1 1 1 1 1 1 1 1       # # # # # # / / / / / / / /w* w* w* w* w*g,h.? w* w* w*t zHMOOOOO r   