Format: application/x-python-code
⬇ Download File (4.6 KB)
   1  o
   2  
   3  ��h��@sdZddlZddlZddlZddlmZddlmZddlmZddl	Z	ddl
   4  mZmZddl
   5  mZddlmZdd	lmZdd
   6  lmZee���ZedZedZd
   7  d�Zdd�ZGdd�de�Ze	jjejj dkoxdejj!kovdkndd�dd��Z"dd�Z#dd�Z$dS)aTests for profile-related functions.
   8  
   9  Currently only the startup-dir functionality is tested, but more tests should
  10  be added for:
  11  
  12      * ipython profile create
  13      * ipython profile list
  14      * ipython profile create --parallel
  15      * security dir permissions
  16  
  17  Authors
  18  -------
  19  
  20  * MinRK
  21  
  22  �N)�Path)�TemporaryDirectory)�TestCase)�list_bundled_profiles�list_profiles_in)�
  23  ProfileDir)�
  24  decorators)�tools)�	getoutputZ
  25  home_test_dirz.ipythoncCst��tjdd�dS)zSSetup test environment for the module:
  26  
  27              - Adds dummy home dir tree
  28      T��parentsN)r�cwd�IP_TEST_DIR�mkdir�rr�Uc:\Users\shubh\Videos\agent\nova\Lib\site-packages\IPython/core/tests/test_profile.py�setup_module1srcCst�t�dS)zXTeardown test environment for the module:
  29  
  30              - Remove dummy home dir tree
  31      N)�shutil�rmtree�TMP_TEST_DIRrrrr�teardown_module;src@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
  32  �Zdd�Zd
  33  S)�ProfileStartupTestcCs*t�td�|_dtddg|_td|_dS)N�testz
  34  --ipython-dirz	--profileztest.py)rZcreate_profile_dir_by_namer�pd�optionsr�fname��selfrrr�setUpJszProfileStartupTest.setUpcCst�|jj�dS�N)rrr�locationrrrr�tearDownPszProfileStartupTest.tearDowncCs�tt|jj�|ddd��
  35  }|�|�Wd�n1swYt|jddd��}|�|�Wd�dS1s;wYdS)N�w�utf-8��encoding)�openrrZstartup_dir�writer)rZstartup_fileZstartupr�frrr�initUs�"�zProfileStartupTest.initcCstj|j|d|jd�dS)N�)r)�ttZipexec_validaterr)r�outputrrr�validate]szProfileStartupTest.validatecC�|�ddd�|�d�dS)Nz00-start.pyzzzz=123
  36  zprint(zzz)
  37  Z123�r)r-rrrr�test_startup_py`�z"ProfileStartupTest.test_startup_pycCr.)Nz00-start.ipyz
  38  %xmode plain
  39  r*zException reporting mode: Plainr/rrrr�test_startup_ipydr1z#ProfileStartupTest.test_startup_ipyN)	�__name__�
  40  __module__�__qualname__rr!r)r-r0r2rrrrrIsr�pypy)���
  41  )r7r8�zQUnicode issues with scandir on PyPy, see https://github.com/pypy/pypy/issues/4860)�reasoncCs�ttjtd��}dD]}t||�jdd�q
  42  tjr$t|d�jdd�t|dddd	��
  43  }|�d
  44  �Wd�n1s=wYt	|�}d}t
  45  |�D]}|�d�rbt�
  46  ||�}|�|�d}nqLtjrl|duslJ�t|�d
  47  dhksvJ�dS)N)�dir)�profile_fooZ
  48  profile_helloZ
  49  not_a_profileTruprofile_ünicodeZprofile_filer"r#r$zI am not a profile directoryFZnicode�fooZhello)r�tempfile�mkdtemprr�decZ
  50  unicode_pathsr&r'r�list�endswithrZfind_profile_dir_by_name�remove�set)�td�namer(ZprofilesZ
  51  found_unicode�prrrr�test_list_profiles_inis(�
  52  
  53  �rIcCstt��}|gksJ�dSr)�sortedr)Zbundledrrr�test_list_bundled_profiles�s
  54  rKc
  55  Cs|t��1}ttjdddddd|g�t|�d}t|���s J�|d}t|���s,J�Wd	�d	S1s7wYd	S)
  56  z-ipython profile create respects --ipython-dirz-mZIPythonZprofile�creater>z--ipython-dir=%sr=zipython_config.pyN)rr
  57  �sys�
  58  executabler�exists)rFZprofile_dirZipython_configrrr�test_profile_create_ipython_dir�s ��"�rP)%�__doc__rrMr?�pathlibrrZunittestrZpytestZIPython.core.profileapprrZIPython.core.profiledirrZIPython.testingrrAr	r+ZIPython.utils.processr
  59  r@rZ
  60  HOME_TEST_DIRrrrr�markZskipif�implementationrG�versionrIrKrPrrrr�<module>s6
  61   �
  62