
    ep                         d 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
 ddlmZ ddlmZ ddlmZ  G d	 d
ej        ej                  Zedk    r ej                     dS dS )zTests for distutils.file_util.    N)patch)	move_file	copy_file)log)support)DistutilsFileError)unlinkc                        e Zd Zd Z fdZ fdZd Zd Zd Z e	j
         eed          d          d	             Z e	j
         eed          d          d
             Z xZS )FileUtilTestCasec                     t          |          dk    r| j                            ||z             d S | j                            |           d S )Nr   )len_logsappend)selfmsgargss      0  /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_file_util.py_logzFileUtilTestCase._log   sM    t99q==JcDj)))))Jc"""""    c                    t          t          |                                            g | _        t          j        | _        | j        t          _        |                                 }t          j
                            |d          | _        t          j
                            |d          | _        t          j
                            |d          | _        d S )Nf1f2d1)superr   setUpr   r   infoold_logr   mkdtempospathjoinsourcetarget
target_dir)r   tmp_dir	__class__s     r   r   zFileUtilTestCase.setUp   s    %%++---
x9,,..gll7D11gll7D11',,w55r   c                 x    | j         t          _        t          t          |                                            d S )N)r   r   r   r   r   tearDown)r   r&   s    r   r(   zFileUtilTestCase.tearDown    s/    <%%..00000r   c                    t          | j        d          }	 |                    d           |                                 n# |                                 w xY wt	          | j        | j        d           g }|                     | j        |           t	          | j        | j        d           t	          | j        | j        d           d| j        d| j        g}|                     | j        |           t	          | j        | j        d           g | _        t          j	        | j
                   t	          | j        | j
        d           d| j        d| j
        g}|                     | j        |           d S )Nwsome contentr   verbose   zmoving z -> )openr"   writecloser   r#   assertEqualr   r   mkdirr$   )r   fwanteds      r   test_move_file_verbosityz)FileUtilTestCase.test_move_file_verbosity$   sl   c""	GGN###GGIIIIAGGIIII$+t{A6666V,,, 	$+t{A6666$+t{A66666'+{{{DKK@AV,,, 	$+t{A6666

!!!$+t:::::'+{{{DOODEV,,,,,s   A Ac                    t          dt          dd                    5  |                     t                    5  t	          | j        d          5 }|                    d           d d d            n# 1 swxY w Y   t          | j        | 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 )	N	os.renamewrongr.   side_effectr*   	spam eggsr   r,   )	r   OSErrorassertRaisesr   r/   r"   r0   r   r#   r   fobjs     r   )test_move_file_exception_unpacking_renamez:FileUtilTestCase.test_move_file_exception_unpacking_rename@   s|   ;GGQ,?,?@@@ 	; 	;122	; 	;dk3'' (4

;'''( ( ( ( ( ( ( ( ( ( ( ( ( ( (dk4;::::		; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	;sX   B>B&A3'B&3A77B&:A7;B&B>&B*	*B>-B*	.B>>CCc           	         t          dt          t          j        d                    5  t          dt          dd                    5  |                     t
                    5  t          | j        d          5 }|                    d           d d d            n# 1 swxY w Y   t          | j        | j
        d	           d d d            n# 1 swxY w Y   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 )
Nr8   r9   r:   z	os.unlinkr.   r*   r<   r   r,   )r   r=   errnoEXDEVr>   r   r/   r"   r0   r   r#   r?   s     r   )test_move_file_exception_unpacking_unlinkz:FileUtilTestCase.test_move_file_exception_unpacking_unlinkH   s   ;GEK,I,IJJJ 	; 	;;GGQ,?,?@@@	; 	;122	; 	; dk3'' (4

;'''( ( ( ( ( ( ( ( ( ( ( ( ( ( (dk4;::::	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	;s}    C?
C'%C;B	CB!!C$B!%CC'CC'CC'C?'C+	+C?.C+	/C??DDlinkzrequires os.linkc                    t          | j        d          5 }|                    d           d d d            n# 1 swxY w Y   	 t          j        | j        | j                   t          | j                   n/# t          $ r"}|                     d|z             Y d }~nd }~ww xY wt          j	        | j                  }t          | j        | j        d           t          j	        | j                  }t          j	        | j                  }|                     t          j                            ||          ||f           |                     t          j                            ||          ||f           t          | j        d          5 }|                     |                                d           d d d            d S # 1 swxY w Y   d S )Nr*   r+   zos.link: %shardrF   r)r/   r"   r0   r   rF   r#   r	   r=   skipTeststatr   
assertTruer    samestatr2   read)r   r4   estst2st3s         r   test_copy_file_hard_linkz)FileUtilTestCase.test_copy_file_hard_linkQ   s"   $+s## 	$qGGN###	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$	 GDK--- 4;  	- 	- 	-MM-!+,,,,,,,,	- WT[!!$+t{8888gdk""gdk""((S11B9===((c22S#J???$+s## 	7qQVVXX~666	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7s6   8<<A8 8
B$BB$)GG	G	c                 `   t          | j        d          5 }|                    d           d d d            n# 1 swxY w Y   t          j        | j                  }t          dt          dd                    5  t          | j        | j        d           d d d            n# 1 swxY w Y   t          j        | j                  }t          j        | j                  }| 	                    t          j
                            ||          ||f           |                     t          j
                            ||          ||f           | j        | j        fD ]R}t          |d	          5 }|                     |                                d           d d d            n# 1 swxY w Y   Sd S )
Nr*   r+   zos.linkr   zlinking unsupportedr:   rH   rI   rJ   )r/   r"   r0   r   rL   r   r=   r   r#   rM   r    rN   assertFalser2   rO   )r   r4   rQ   rR   rS   fns         r    test_copy_file_hard_link_failurez1FileUtilTestCase.test_copy_file_hard_link_failuref   s0   
 $+s## 	$qGGN###	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$WT[!!9'!5J*K*KLLL 	= 	=dk4;V<<<<	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	=gdk""gdk""((S11B9===))#s33c3Z@@@;, 	; 	;Bb# ;!  >:::; ; ; ; ; ; ; ; ; ; ; ; ; ; ;	; 	;s0   8<<;B$$B(+B(-)F""F&	)F&	)__name__
__module____qualname__r   r   r(   r6   rA   rE   unittest
skipUnlesshasattrr   rT   rX   __classcell__)r&   s   @r   r   r      s        # # #6 6 6 6 61 1 1 1 1- - -8; ; ;; ; ; XV,,.@AA7 7 BA7( XV,,.@AA; ; BA; ; ; ; ;r   r   __main__)__doc__r\   r   rC   unittest.mockr   distutils.file_utilr   r   	distutilsr   distutils.testsr   distutils.errorsr   test.support.os_helperr	   TempdirManagerTestCaser   rY   main r   r   <module>rl      s    $ $  				        4 4 4 4 4 4 4 4       # # # # # # / / / / / / ) ) ) ) ) )h; h; h; h; h;w-x/@ h; h; h;V zHMOOOOO r   