
    R.e                         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y)zTests for genutils.path    N   )skip_if_not_win32
skip_win32)path)	py3compat)TemporaryDirectoryc                  l    t        j                         } t        j                  | j                  d      }y )N.)tempfileNamedTemporaryFiler   filefindname)fts     B/usr/lib/python3/dist-packages/ipython_genutils/tests/test_path.pytest_filefindr      s$    ##%Aaffc"A    c                     t               5 } t        j                  j                  | d      }t        j                  |       t        j                  j                  |      sJ t        j                  |       t        j                  j                  | d      }t        |d      j                          t        j                  t              5  t        j                  |       d d d        d d d        y # 1 sw Y   xY w# 1 sw Y   y xY w)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!      s    		 &GGLLX&q!ww}}Qq!GGLLX&Qg& 	&""1%	&& &	& 	&& &s$   B?C=
C1 C=1C:	6C==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y)TestLinkOrCopyc                     t               | _        | j                  d      | _        t	        | j                  d      5 }|j                  d       d d d        y # 1 sw Y   y xY w)Nsrcr   zHello, world!)r   tempdirdstr%   r   write)selfr   s     r   setUpzTestLinkOrCopy.setUp%   sL    )+88E?$((C  	%AGGO$	% 	% 	%s   AA c                 8    | j                   j                          y N)r&   cleanup)r)   s    r   tearDownzTestLinkOrCopy.tearDown+   s    r   c                 j    t        j                  j                  | j                  j                  g| S r,   )r   r   r   r&   r   )r)   argss     r   r'   zTestLinkOrCopy.dst.   s$    ww||DLL--555r   c                     t        j                  t        j                  |      j                  t        j                  |      j                  |d|d       y )N and z do reference the same indoes)r   assert_not_equalr   statst_inor)   abs      r   assert_inode_not_equalz%TestLinkOrCopy.assert_inode_not_equal1   s9    
BGGAJ--rwwqz/@/@HI1M	Or   c                     t        j                  t        j                  |      j                  t        j                  |      j                  |d|d       y )Nr2   z! do not reference the same indoes)r   assert_equalr   r4   r5   r6   s      r   assert_inode_equalz!TestLinkOrCopy.assert_inode_equal5   s7    

))2771:+<+<HI1M	Or   c                     t        |      5 }t        |      5 }t        j                  |j                         |j                                d d d        d d d        y # 1 sw Y   xY w# 1 sw Y   y xY wr,   )r   r   r;   read)r)   r7   r8   a_fb_fs        r   assert_content_equalz#TestLinkOrCopy.assert_content_equal9   s]    !W 	8a 8C
CHHJ78	8 	88 8	8 	8s"   A(3AA(A%	!A((A1c                     | j                  d      }t        j                  | j                  |       | j	                  | j                  |       y Ntarget)r'   r   link_or_copyr%   r<   r)   r'   s     r   test_link_successfulz#TestLinkOrCopy.test_link_successful>   s8    hhx $((C(#.r   c                 :   | j                  d      }t        j                  |       t        j                  | j
                  |       | j                  dt        j                  j                  | j
                              }| j                  | j
                  |       y )Nsome_dir)r'   r   mkdirr   rE   r%   basenamer<   )r)   r'   expected_dsts      r   test_link_into_dirz!TestLinkOrCopy.test_link_into_dirD   sf    hhz"
$((C(xx
BGG,<,<TXX,FG,7r   c                     | j                  d      }t        |d      j                          t        j                  | j
                  |       | j                  | j
                  |       y )NrD   r   )r'   r   r   r   rE   r%   r<   rF   s     r   test_target_existsz!TestLinkOrCopy.test_target_existsL   sJ    hhx S#$((C(#.r   c                 :   t         j                  }	 t         `| j                  d      }t        j                  | j
                  |       | j                  | j
                  |       | j                  | j
                  |       |t         _        y # |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   sn    GG		 ((8$Cdhh,%%dhh4''#6BGiBGs   A/B Bc                     | j                  d      }t        j                  | j                  |       | j	                  | j                  |       y rC   )r'   r   rE   r%   rA   rF   s     r   test_windowszTestLinkOrCopy.test_windows_   s8    hhx $((C(!!$((C0r   c                 n   | j                  d      }t        j                  | j                  |       t        j                  | j                  |       | j	                  | j                  |       t        j                  t        t        j                  | j                  j                              ddg       y )NrD   r%   )r'   r   rE   r%   r<   r   r;   sortedr   listdirr&   r   rF   s     r   test_link_twicezTestLinkOrCopy.test_link_twicee   sy     hhx $((C($((C(#.
rzz$,,*;*;<=x?PQr   N)__name__
__module____qualname__r*   r.   r'   r9   r<   rA   r   rG   rM   rO   rS   r   rU   rY    r   r   r#   r#   $   s    %6OO8
 / /
 8 8 / / 	  	  1 1
Rr   r#   )__doc__r   sysr   
nose.toolstoolsr   testing.decoratorsr   r    r   r   r&   r   r   r!   objectr#   r]   r   r   <module>re      s<    
 
 
   >   (#
	&HRV HRr   