
    ^h                         S r SSKrSSKrSSKrSSKJr  SSKJrJ	r	  SSK
Jr  SSK
Jr  SSKJr  S rS	 r " S
 S\5      rg)zTests for genutils.path    N   )skip_if_not_win32
skip_win32)path)	py3compat)TemporaryDirectoryc                  p    [         R                  " 5       n [        R                  " U R                  S5      ng )N.)tempfileNamedTemporaryFiler   filefindname)fts     Z/home/james-whalen/.local/lib/python3.13/site-packages/ipython_genutils/tests/test_path.pytest_filefindr      s$    ##%Aaffc"A    c                  8   [        5        n [        R                  R                  U S5      n[        R                  " U5        [        R                  R                  U5      (       d   e[        R                  " U5        [        R                  R                  U S5      n[        US5      R                  5         [        R                  " [        5         [        R                  " U5        S S S 5        S S S 5        g ! , (       d  f       N= f! , (       d  f       g = f)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$   CDC:)D:
D	D
Dc                       \ rS rSrS rS rS rS rS rS r	\
S 5       r\
S	 5       r\
S
 5       r\
S 5       r\S 5       rS rSrg)TestLinkOrCopy$   c                     [        5       U l        U R                  S5      U l        [	        U R                  S5       nUR                  S5        S S S 5        g ! , (       d  f       g = f)Nsrcr   zHello, world!)r   tempdirdstr&   r   write)selfr   s     r   setUpTestLinkOrCopy.setUp%   sC    )+88E?$((C AGGO$ !  s   A
A%c                 8    U R                   R                  5         g N)r'   cleanup)r*   s    r   tearDownTestLinkOrCopy.tearDown+   s    r   c                 l    [         R                  R                  " U R                  R                  /UQ76 $ r.   )r   r   r   r'   r   )r*   argss     r   r(   TestLinkOrCopy.dst.   s$    ww||DLL--555r   c                     [         R                  " [        R                  " U5      R                  [        R                  " U5      R                  U< SU< S35        g )N and z do reference the same indoes)r   assert_not_equalsr   statst_inor*   abs      r   assert_inode_not_equal%TestLinkOrCopy.assert_inode_not_equal1   s9    
RWWQZ..
0A0AHI1M	Or   c                     [         R                  " [        R                  " U5      R                  [        R                  " U5      R                  U< SU< S35        g )Nr6   z! do not reference the same indoes)r   assert_equalsr   r8   r9   r:   s      r   assert_inode_equal!TestLinkOrCopy.assert_inode_equal5   s9    
**BGGAJ,=,=HI1M	Or   c                     [        U5       n[        U5       n[        R                  " UR                  5       UR                  5       5        S S S 5        S S S 5        g ! , (       d  f       N= f! , (       d  f       g = fr.   )r   r   r@   read)r*   r;   r<   a_fb_fs        r   assert_content_equal#TestLinkOrCopy.assert_content_equal9   sJ    !WaC  SXXZ8  W Ws"   A.4AA.
A+	'A..
A<c                     U R                  S5      n[        R                  " U R                  U5        U R	                  U R                  U5        g Ntarget)r(   r   link_or_copyr&   rA   r*   r(   s     r   test_link_successful#TestLinkOrCopy.test_link_successful>   s8    hhx $((C(#.r   c                 >   U R                  S5      n[        R                  " U5        [        R                  " U R
                  U5        U R                  S[        R                  R                  U R
                  5      5      nU R                  U R
                  U5        g )Nsome_dir)r(   r   mkdirr   rL   r&   basenamerA   )r*   r(   expected_dsts      r   test_link_into_dir!TestLinkOrCopy.test_link_into_dirD   sf    hhz"
$((C(xx
BGG,<,<TXX,FG,7r   c                     U R                  S5      n[        US5      R                  5         [        R                  " U R
                  U5        U R                  U R
                  U5        g )NrK   r   )r(   r   r   r   rL   r&   rA   rM   s     r   test_target_exists!TestLinkOrCopy.test_target_existsL   sJ    hhx S#$((C(#.r   c                 <   [         R                  n [         ?U R                  S5      n[        R                  " U R
                  U5        U R                  U R
                  U5        U R                  U R
                  U5        U[         l        g ! U[         l        f = frJ   )r   linkr(   r   rL   r&   rG   r=   )r*   	real_linkr(   s      r   test_no_linkTestLinkOrCopy.test_no_linkS   sn    GG		 ((8$Cdhh,%%dhh4''#6BGiBGs   A0B Bc                     U R                  S5      n[        R                  " U R                  U5        U R	                  U R                  U5        g rJ   )r(   r   rL   r&   rG   rM   s     r   test_windowsTestLinkOrCopy.test_windows_   s8    hhx $((C(!!$((C0r   c                 v   U R                  S5      n[        R                  " U R                  U5        [        R                  " U R                  U5        U R	                  U R                  U5        [
        R                  " [        [        R                  " U R                  R                  5      5      SS/5        g )NrK   r&   )r(   r   rL   r&   rA   r   assert_equalsortedr   listdirr'   r   rM   s     r   test_link_twiceTestLinkOrCopy.test_link_twicee   sy     hhx $((C($((C(#.
rzz$,,*;*;<=x?PQr   )r&   r'   N)__name__
__module____qualname____firstlineno__r+   r0   r(   r=   rA   rG   r   rN   rU   rX   r]   r   r`   rf   __static_attributes__ r   r   r#   r#   $   s    %6OO9
 / /
 8 8 / / 	  	  1 1
Rr   r#   )__doc__r   sysr   
nose.toolstoolsr   testing.decoratorsr   r    r   r   r'   r   r   r!   objectr#   rm   r   r   <module>ru      s<    
 
 
   >   (#
	&HRV HRr   