o
    û›hÔ  ã                   @   s,  d dl Z d dlZd dlZd dlZd dlZd dlmZ d dlmZ d dlm	Z	m
Z
mZ d dlmZ d dlmZ ej e ¡ ¡Zej ed¡Zej ed¡Zej ed	¡Zej ed
¡Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Z dd„ Z!dd„ Z"edd „ ƒZ#d!d"„ Z$d#d$„ Z%d%d&„ Z&dS )'é    N)Úpatch)ÚTemporaryDirectory)Úassert_isdirÚassert_isfileÚmodified_env)Úpaths)Ú
skip_win32Zhome_test_dirZxdg_test_dirZxdg_cache_dirú.ipythonc                   C   s6   t  t¡ t  t j td¡¡ t  t j td¡¡ dS )zRSetup testenvironment for the module:

            - Adds dummy home dir tree
    ÚipythonN)ÚosÚmakedirsÚIP_TEST_DIRÚpathÚjoinÚXDG_TEST_DIRÚXDG_CACHE_DIR© r   r   úSc:\Users\shubh\Videos\agent\nova\Lib\site-packages\IPython/core/tests/test_paths.pyÚsetup_module   s   
r   c                   C   s   t  t¡ dS )zWTeardown testenvironment for the module:

            - Remove dummy home dir tree
    N)ÚshutilÚrmtreeÚTMP_TEST_DIRr   r   r   r   Úteardown_module    s   r   c                 C   s   t jtd| d�S )NZget_home_dir©Úreturn_value)r   Úobjectr   )Údirpathr   r   r   Úpatch_get_home_dir*   s   r   c               	   C   s‚   t j dd¡} tjtddd��" td| iƒ� t ¡ }W d  ƒ n1 s%w   Y  W d  ƒ n1 s4w   Y  || ks?J ‚dS )zZtest_get_ipython_dir_1, Testcase to see if we can call get_ipython_dir without Exceptions.Ú	someplacer	   Ú_writable_dirTr   Ú
IPYTHONDIRN)r   r   r   r   r   r   r   Úget_ipython_dir)Z	env_ipdirÚipdirr   r   r   Útest_get_ipython_dir_1.   s   
ÿ
þ€ r#   c                  C   s  t dƒ�i tjtddd��Q tjtddd��9 tddƒ�$ tdddd	œƒ� t ¡ } W d  ƒ n1 s4w   Y  W d  ƒ n1 sCw   Y  W d  ƒ n1 sRw   Y  W d  ƒ n1 saw   Y  W d  ƒ n1 spw   Y  | tj dd
¡ks€J ‚dS )zZtest_get_ipython_dir_2, Testcase to see if we can call get_ipython_dir without Exceptions.r   Úget_xdg_dirNr   r   Túos.nameÚposix©ÚIPYTHON_DIRr    ZXDG_CONFIG_HOMEr	   )	r   r   r   r   r   r!   r   r   r   ©r"   r   r   r   Útest_get_ipython_dir_27   s.   
ÿþýþü
ø€ € € € 
r*   c                  C   s  t ƒ } zxt| jƒ�O tddƒ�: tddtdœƒ�" tjdd��}t 	¡ }W d  ƒ n1 s.w   Y  W d  ƒ n1 s=w   Y  W d  ƒ n1 sLw   Y  W d  ƒ n1 s[w   Y  |t
j | jtd¡ksmJ ‚t|ƒdksuJ ‚W |  ¡  dS |  ¡  w )	zRtest_get_ipython_dir_3, use XDG if defined and exists, and .ipython doesn't exist.r%   r&   Nr'   T©Úrecordr
   r   )r   r   Únamer   r   r   ÚwarningsÚcatch_warningsr   r!   r   r   r   ÚlenÚcleanup)ZtmphomeÚwr"   r   r   r   Útest_get_ipython_dir_3E   s2   ÿýþ
ú
ù€ € € 	r3   c                  C   s<  t tƒ�� tddƒ�r zt tj td¡¡ W n ty0 }  z| j	t	j
kr&‚ W Y d} ~ nd} ~ ww tddtdœƒ�" tjdd��}t ¡ }W d  ƒ n1 sOw   Y  W d  ƒ n1 s^w   Y  t|ƒdkskJ ‚d	t|d
 ƒv suJ ‚W d  ƒ n1 sw   Y  W d  ƒ dS W d  ƒ dS 1 s—w   Y  dS )z8test_get_ipython_dir_4, warn if XDG and home both exist.r%   r&   r
   Nr'   Tr+   é   ZIgnoringr   )r   ÚHOME_TEST_DIRr   r   Úmkdirr   r   r   ÚOSErrorÚerrnoÚEEXISTr   r.   r/   r   r!   r0   Ústr)Úer2   r"   r   r   r   Útest_get_ipython_dir_4W   s4   
ÿÿ€ÿ
ý
ü
û€ Pïr<   c                  C   sø   t tƒ�n tddƒ�P zt tj td¡¡ W n ty0 }  z| j	t	j
kr&‚ W Y d} ~ nd} ~ ww tddtdœƒ� t ¡ }W d  ƒ n1 sHw   Y  |tksSJ ‚W d  ƒ n1 s]w   Y  W d  ƒ dS W d  ƒ dS 1 suw   Y  dS )zRtest_get_ipython_dir_5, use .ipython if exists and XDG defined, but doesn't exist.r%   r&   r
   Nr'   )r   r5   r   r   Úrmdirr   r   r   r7   r8   ÚENOENTr   r   r!   r   )r;   r"   r   r   r   Útest_get_ipython_dir_5m   s(   
ÿÿ€ÿ
ý
ûPñr?   c                  C   sF  t j td¡} t  | ¡ t t j td¡¡ ttj	ƒ t
tƒ�g tjtd| d��O tddƒ�: tddddœƒ�" tjd	d
��}t ¡ }W d  ƒ n1 sMw   Y  W d  ƒ n1 s\w   Y  W d  ƒ n1 skw   Y  W d  ƒ n1 szw   Y  W d  ƒ n1 s‰w   Y  |t j td¡ks™J ‚t|ƒdks¡J ‚dS )zGtest_get_ipython_dir_6, use home over XDG if defined and neither exist.Zsomexdgr	   r$   r   r%   r&   Nr'   Tr+   r   )r   r   r   r5   r6   r   r   Úprintr   r   r   r   r   r   r.   r/   r!   r0   )Zxdgr2   r"   r   r   r   Útest_get_ipython_dir_6€   s<   


ÿþýý
ù
ø€ € € € 
rA   c               	   C   sœ   t j t j d¡¡} tdt j dd¡iƒ�$ tjtddd�� t 	¡ }W d  ƒ n1 s-w   Y  W d  ƒ n1 s<w   Y  |t j | d¡ksLJ ‚dS )zCtest_get_ipython_dir_7, test home directory expansion on IPYTHONDIRú~r    Z	somewherer   Tr   N)
r   r   ÚnormpathÚ
expanduserr   r   r   r   r   r!   )Zhome_dirr"   r   r   r   Útest_get_ipython_dir_7“   s   ÿ
þ€ rE   c                
   C   sÊ   t  dt j¡s	dS t tddd„ ¡�I tjtddd��( tddddœƒ� t ¡ d	ks-J ‚W d  ƒ n1 s7w   Y  W d  ƒ n1 sFw   Y  W d  ƒ dS W d  ƒ dS 1 s^w   Y  dS )
z-test_get_ipython_dir_8, test / home directoryú/Nr   c                 S   s   t | ƒS ©N)Úbool)r   r   r   r   Ú<lambda>¤   s    z(test_get_ipython_dir_8.<locals>.<lambda>r$   r   )r(   r    ÚHOMEz	/.ipython)r   ÚaccessÚW_OKr   r   r   r   r!   r   r   r   r   Útest_get_ipython_dir_8œ   s"   ÿþýÿýõ€P rM   c               	   C   s  t dtiƒ�~ tjdkrjt tj td¡¡ t dd iƒ� t ¡ } W d   ƒ n1 s+w   Y  tj tdd¡| ks<J ‚t	| ƒ t dt
iƒ� t ¡ } W d   ƒ n1 sUw   Y  t	| ƒ | tj t
d¡ksiJ ‚nt ¡ t ¡ kstJ ‚W d   ƒ d S W d   ƒ d S 1 s‡w   Y  d S )NrJ   r&   z.cacheZXDG_CACHE_HOMEr
   )r   r5   r   r-   r   r   r   r   Zget_ipython_cache_dirr   r   r!   r)   r   r   r   Útest_get_ipython_cache_dir±   s"   

ÿ
ÿñ"órN   c                  C   s   t  ¡ } t| ƒ d S rG   )r   Zget_ipython_package_dirr   r)   r   r   r   Útest_get_ipython_package_dirÃ   s   rO   c                  C   s   t  d¡} t| ƒ d S )NzIPython.terminal.ipapp)r   Zget_ipython_module_pathr   )Z
ipapp_pathr   r   r   Útest_get_ipython_module_pathÈ   s   
rP   )'r8   r   r   Útempfiler.   Zunittest.mockr   r   Ztestpathr   r   r   ZIPythonr   ZIPython.testing.decoratorsr   r   ÚrealpathÚmkdtempr   r   r5   r   r   r   r   r   r   r#   r*   r3   r<   r?   rA   rE   rM   rN   rO   rP   r   r   r   r   Ú<module>   s<    
		
