o
    ȷe                     @   s   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	 Zd
d ZG dd deZdS )zTests for genutils.path    N   )skip_if_not_win32
skip_win32)path)	py3compat)TemporaryDirectoryc                  C   s   t  } t| jd}d S )N.)tempfileNamedTemporaryFiler   filefindname)ft r   W/var/www/ideatree/venv/lib/python3.10/site-packages/ipython_genutils/tests/test_path.pytest_filefind   s   r   c               	   C   s   t  R} tj| d}t| tj|sJ t| tj| d}t|d  t	t
 t| W d    n1 s@w   Y  W d    d S W d    d S 1 sXw   Y  d S )Nu   ∂iru   ƒilew)r   osr   joinensure_dir_existsisdiropenclosentassert_raisesIOError)tddr   r   r   r   test_ensure_dir_exists   s   

"r   c                   @   s   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd Ze	dd Z
e	dd Ze	dd Ze	dd Zedd Zdd ZdS )TestLinkOrCopyc                 C   sP   t  | _| d| _t| jd}|d W d    d S 1 s!w   Y  d S )Nsrcr   zHello, world!)r   tempdirdstr    r   write)selfr   r   r   r   setUp%   s
   "zTestLinkOrCopy.setUpc                 C   s   | j   d S N)r!   cleanup)r$   r   r   r   tearDown+   s   zTestLinkOrCopy.tearDownc                 G   s   t jj| jjg|R  S r&   )r   r   r   r!   r   )r$   argsr   r   r   r"   .   s   zTestLinkOrCopy.dstc                 C   *   t t|jt|jd||f  d S )Nz&%r and %r do reference the same indoes)r   assert_not_equalsr   statst_inor$   abr   r   r   assert_inode_not_equal1      
z%TestLinkOrCopy.assert_inode_not_equalc                 C   r*   )Nz*%r and %r do not reference the same indoes)r   assert_equalsr   r,   r-   r.   r   r   r   assert_inode_equal5   r2   z!TestLinkOrCopy.assert_inode_equalc              	   C   sz   t |/}t |}t| |  W d    n1 sw   Y  W d    d S W d    d S 1 s6w   Y  d S r&   )r   r   r3   read)r$   r/   r0   a_fb_fr   r   r   assert_content_equal9   s   

"z#TestLinkOrCopy.assert_content_equalc                 C   *   |  d}t| j| | | j| d S Ntarget)r"   r   link_or_copyr    r4   r$   r"   r   r   r   test_link_successful>      
z#TestLinkOrCopy.test_link_successfulc                 C   sJ   |  d}t| t| j| |  dtj| j}| | j| d S )Nsome_dir)r"   r   mkdirr   r<   r    basenamer4   )r$   r"   expected_dstr   r   r   test_link_into_dirD   s
   

z!TestLinkOrCopy.test_link_into_dirc                 C   s8   |  d}t|d  t| j| | | j| d S )Nr;   r   )r"   r   r   r   r<   r    r4   r=   r   r   r   test_target_existsL   s   
z!TestLinkOrCopy.test_target_existsc                 C   sT   t j}z"t `| d}t| j| | | j| | | j| W |t _d S |t _w r:   )r   linkr"   r   r<   r    r8   r1   )r$   	real_linkr"   r   r   r   test_no_linkS   s   
zTestLinkOrCopy.test_no_linkc                 C   r9   r:   )r"   r   r<   r    r8   r=   r   r   r   test_windows_   r?   zTestLinkOrCopy.test_windowsc                 C   sV   |  d}t| j| t| j| | | j| ttt	| j
jddg d S )Nr;   r    )r"   r   r<   r    r4   r   assert_equalsortedr   listdirr!   r   r=   r   r   r   test_link_twicee   s
   
"zTestLinkOrCopy.test_link_twiceN)__name__
__module____qualname__r%   r(   r"   r1   r4   r8   r   r>   rD   rE   rH   r   rI   rM   r   r   r   r   r   $   s$    




r   )__doc__r   sysr	   
nose.toolstoolsr   testing.decoratorsr   r    r   r   r!   r   r   r   objectr   r   r   r   r   <module>   s   