Format: application/x-python-code
⬇ Download File (7.0 KB)
   1  o
   2  
   3  ��h��@s,ddlZddlZddlZddlZddlZddlmZddlmZddlm	Z	m
   4  Z
   5  mZddlm
   6  Z
   7  ddlmZej�e���Zej�ed�Zej�ed�Zej�ed	�Zej�ed
   8  �Zdd�Zd
   9  d�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Z dd�Z!dd�Z"edd ��Z#d!d"�Z$d#d$�Z%d%d&�Z&dS)'�N)�patch)�TemporaryDirectory)�assert_isdir�
  10  assert_isfile�modified_env)�paths)�
  11  skip_win32Z
  12  home_test_dirZxdg_test_dirZ
  13  xdg_cache_dir�.ipythoncCs6t�t�t�tj�td��t�tj�td��dS)zRSetup testenvironment for the module:
  14  
  15              - Adds dummy home dir tree
  16      �ipythonN)�os�makedirs�IP_TEST_DIR�path�join�XDG_TEST_DIR�
  17  XDG_CACHE_DIR�rr�Sc:\Users\shubh\Videos\agent\nova\Lib\site-packages\IPython/core/tests/test_paths.py�setup_modules
  18  rcCst�t�dS)zWTeardown testenvironment for the module:
  19  
  20              - Remove dummy home dir tree
  21      N)�shutil�rmtree�TMP_TEST_DIRrrrr�teardown_module srcCstjtd|d�S)NZget_home_dir��return_value)r�objectr)�dirpathrrr�patch_get_home_dir*src	Cs�tj�dd�}tjtddd��"td|i��t��}Wd�n1s%wYWd�n1s4wY||ks?J�dS)zZtest_get_ipython_dir_1, Testcase to see if we can call get_ipython_dir without Exceptions.�	someplacer	�
  22  _writable_dirTr�
  23  IPYTHONDIRN)rrrrrrr�get_ipython_dir)Z	env_ipdir�ipdirrrr�test_get_ipython_dir_1.s
  24  �
  25  ��r#cCstd��itjtddd��Qtjtddd��9tdd��$tdddd	���t��}Wd�n1s4wYWd�n1sCwYWd�n1sRwYWd�n1sawYWd�n1spwY|tj�dd
  26  �ks�J�dS)zZtest_get_ipython_dir_2, Testcase to see if we can call get_ipython_dir without Exceptions.r�get_xdg_dirNrrT�os.name�posix��IPYTHON_DIRr ZXDG_CONFIG_HOMEr	)	rrrrrr!rrr�r"rrr�test_get_ipython_dir_27s.
  27  �����
  28  �����
  29  r*cCst�}zxt|j��Otdd��:tddtd���"tjdd��}t�	�}Wd�n1s.wYWd�n1s=wYWd�n1sLwYWd�n1s[wY|t
  30  j�|jtd�ksmJ�t
  31  |�dksuJ�W|��dS|��w)	zRtest_get_ipython_dir_3, use XDG if defined and exists, and .ipython doesn't exist.r%r&Nr'T��recordr
  32  r)rr�namerrr�warnings�catch_warningsrr!rrr�len�cleanup)Ztmphome�wr"rrr�test_get_ipython_dir_3Es2���
  33  �
  34  ����	r3cCs<tt���tdd��rzt�tj�td��Wnty0}z
  35  |j	t	j
  36  kr&�WYd}~nd}~wwtddtd���"tj
  37  dd��}t��}Wd�n1sOwYWd�n1s^wYt|�dkskJ�d	t|d
  38  �vsuJ�Wd�n1swYWd�dSWd�dS1s�wYdS)z8test_get_ipython_dir_4, warn if XDG and home both exist.r%r&r
  39  Nr'Tr+�ZIgnoringr)r�
  40  HOME_TEST_DIRrr�mkdirrrr�OSError�errno�EEXISTrr.r/rr!r0�str)�er2r"rrr�test_get_ipython_dir_4Ws4
  41  ����
  42  �
  43  �
  44  ��P�r<cCs�tt��ntdd��Pzt�tj�td��Wnty0}z
  45  |j	t	j
  46  kr&�WYd}~nd}~wwtddtd���t�
  47  �}Wd�n1sHwY|tksSJ�Wd�n1s]wYWd�dSWd�dS1suwYdS)zRtest_get_ipython_dir_5, use .ipython if exists and XDG defined, but doesn't exist.r%r&r
  48  Nr')rr5rr�rmdirrrrr7r8�ENOENTrrr!r
  49  )r;r"rrr�test_get_ipython_dir_5ms(
  50  ����
  51  �
  52  �P�r?cCsFtj�td�}t�|�t�tj�td��ttj	�t
  53  t��gtjtd|d��Otdd��:t
  54  dddd���"tjd	d
  55  ��}t��}Wd�n1sMwYWd�n1s\wYWd�n1skwYWd�n1szwYWd�n1s�wY|tj�td�ks�J�t|�dks�J�dS)zGtest_get_ipython_dir_6, use home over XDG if defined and neither exist.Zsomexdgr	r$rr%r&Nr'Tr+r)rrrr5r6rr�printrrrrrrr.r/r!r0)Zxdgr2r"rrr�test_get_ipython_dir_6�s<
  56  
  57  
  58  ����
  59  �
  60  �����
  61  rAc	Cs�tj�tj�d��}tdtj�dd�i��$tjtddd��t�	�}Wd�n1s-wYWd�n1s<wY|tj�|d�ksLJ�dS)zCtest_get_ipython_dir_7, test home directory expansion on IPYTHONDIR�~r Z	somewhererTrN)
  62  rr�normpath�
  63  expanduserrrrrrr!)Zhome_dirr"rrr�test_get_ipython_dir_7�s�
  64  ��rEc
  65  Cs�t�dtj�s	dSt�tddd���Itjtddd��(tdddd���t��d	ks-J�Wd�n1s7wYWd�n1sFwYWd�dSWd�dS1s^wYdS)
  66  z-test_get_ipython_dir_8, test / home directory�/NrcSst|�S�N)�bool)rrrr�<lambda>�sz(test_get_ipython_dir_8.<locals>.<lambda>r$r)r(r �HOMEz	/.ipython)r�access�W_OKrrrrr!rrrr�test_get_ipython_dir_8�s"�������PrMc	Cstdti��~tjdkrjt�tj�td��tddi��t��}Wd�n1s+wYtj�tdd�|ks<J�t	|�tdt
  67  i��t��}Wd�n1sUwYt	|�|tj�t
  68  d�ksiJ�nt��t��kstJ�Wd�dSWd�dS1s�wYdS)NrJr&z.cacheZXDG_CACHE_HOMEr
  69  )rr5rr-rrrrZget_ipython_cache_dirrrr!r)rrr�test_get_ipython_cache_dir�s"
  70  
  71  �
  72  ��
  73  "�rNcCst��}t|�dSrG)rZget_ipython_package_dirrr)rrr�test_get_ipython_package_dir�srOcCst�d�}t|�dS)NzIPython.terminal.ipapp)rZget_ipython_module_pathr)Z
  74  ipapp_pathrrr�test_get_ipython_module_path�s
  75  rP)'r8rr�tempfiler.Z
  76  unittest.mockrrZtestpathrrrZIPythonrZIPython.testing.decoratorsrr�realpath�mkdtemprrr5rrr
  77  rrrr#r*r3r<r?rArErMrNrOrPrrrr�<module>s<
  78  		
  79