
    j_                         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 Zd	 Z G d
 de          ZdS )zTests for genutils.path    N   )skip_if_not_win32
skip_win32)path)	py3compat)TemporaryDirectoryc                  `    t          j                    } t          j        | j        d          }d S )N.)tempfileNamedTemporaryFiler   filefindname)fts     @lib/python3.11/site-packages/ipython_genutils/tests/test_path.pytest_filefindr      s'    #%%Aafc""AAA    c                  4   t                      5 } t          j                            | d          }t          j        |           t          j                            |          sJ t          j        |           t          j                            | d          }t          |d                                           t          j	        t                    5  t          j        |           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 )Nu   ∂iru   ƒilew)r   osr   joinensure_dir_existsisdiropenclosentassert_raisesIOError)tddr   s      r   test_ensure_dir_existsr!      sf   			 &GLLX&&q!!!w}}Qq!!!GLLX&&Qg&& 	& 	&"1%%%	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	&& & & & & & & & & & & & & & & & & &s6   CDC5)D5C9	9D<C9	=DDDc                       e Zd Zd Zd Zd Zd Zd Zd Ze	d             Z
e	d             Ze	d	             Ze	d
             Zed             Zd ZdS )TestLinkOrCopyc                     t                      | _        |                     d          | _        t	          | j        d          5 }|                    d           d d d            d S # 1 swxY w Y   d S )Nsrcr   zHello, world!)r   tempdirdstr%   r   write)selfr   s     r   setUpzTestLinkOrCopy.setUp%   s    )++88E??$(C   	%AGGO$$$	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	%s   A&&A*-A*c                 8    | j                                          d S N)r&   cleanup)r)   s    r   tearDownzTestLinkOrCopy.tearDown+   s    r   c                 D    t          j        j        | j        j        g|R  S r,   )r   r   r   r&   r   )r)   argss     r   r'   zTestLinkOrCopy.dst.   s!    w|DL-55555r   c                     t          j        t          j        |          j        t          j        |          j        |d|d           d S )N and z do reference the same indoes)r   assert_not_equalsr   statst_inor)   abs      r   assert_inode_not_equalz%TestLinkOrCopy.assert_inode_not_equal1   sP    
RWQZZ.

0AHI111M	O 	O 	O 	O 	Or   c                     t          j        t          j        |          j        t          j        |          j        |d|d           d S )Nr2   z! do not reference the same indoes)r   assert_equalsr   r4   r5   r6   s      r   assert_inode_equalz!TestLinkOrCopy.assert_inode_equal5   sP    
*BGAJJ,=HI111M	O 	O 	O 	O 	Or   c                    t          |          5 }t          |          5 }t          j        |                                |                                           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 r,   )r   r   r;   read)r)   r7   r8   a_fb_fs        r   assert_content_equalz#TestLinkOrCopy.assert_content_equal9   s    !WW 	9a 9C SXXZZ8889 9 9 9 9 9 9 9 9 9 9 9 9 9 9	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9s4   A>:A&A>&A*	*A>-A*	.A>>BBc                     |                      d          }t          j        | j        |           |                     | j        |           d S Ntarget)r'   r   link_or_copyr%   r<   r)   r'   s     r   test_link_successfulz#TestLinkOrCopy.test_link_successful>   sF    hhx  $(C(((#.....r   c                 2   |                      d          }t          j        |           t          j        | j        |           |                      dt          j                            | j                            }|                     | j        |           d S )Nsome_dir)r'   r   mkdirr   rE   r%   basenamer<   )r)   r'   expected_dsts      r   test_link_into_dirz!TestLinkOrCopy.test_link_into_dirD   sx    hhz""
$(C(((xx
BG,<,<TX,F,FGG,77777r   c                     |                      d          }t          |d                                           t          j        | j        |           |                     | j        |           d S )NrD   r   )r'   r   r   r   rE   r%   r<   rF   s     r   test_target_existsz!TestLinkOrCopy.test_target_existsL   s`    hhx  S#$(C(((#.....r   c                 2   t           j        }	 t           `|                     d          }t          j        | j        |           |                     | j        |           |                     | j        |           |t           _        d S # |t           _        w xY wrC   )r   linkr'   r   rE   r%   rA   r9   )r)   	real_linkr'   s      r   test_no_linkzTestLinkOrCopy.test_no_linkS   s    G		 ((8$$Cdh,,,%%dh444''#666BGGGiBGs   A,B Bc                     |                      d          }t          j        | j        |           |                     | j        |           d S rC   )r'   r   rE   r%   rA   rF   s     r   test_windowszTestLinkOrCopy.test_windows_   sF    hhx  $(C(((!!$(C00000r   c                 N   |                      d          }t          j        | j        |           t          j        | j        |           |                     | j        |           t          j        t          t          j	        | j
        j                            ddg           d S )NrD   r%   )r'   r   rE   r%   r<   r   assert_equalsortedr   listdirr&   r   rF   s     r   test_link_twicezTestLinkOrCopy.test_link_twicee   s     hhx  $(C((($(C(((#...
rz$,*;<<==x?PQQQQQr   N)__name__
__module____qualname__r*   r.   r'   r9   r<   rA   r   rG   rM   rO   rS   r   rU   rZ    r   r   r#   r#   $   s       % % %  6 6 6O O OO O O9 9 9
 / / Z/
 8 8 Z8 / / Z/ 	  	  Z	  1 1 1
R R R R Rr   r#   )__doc__r   sysr   
nose.toolstoolsr   testing.decoratorsr   r    r   r   r&   r   r   r!   objectr#   r^   r   r   <module>rf      s     
 
			 



        > > > > > > > >             ( ( ( ( ( (# # #
	& 	& 	&HR HR HR HR HRV HR HR HR HR HRr   