o
    û›h³  ã                   @   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 ddlmZ ddl	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
lmZ ee ¡ ƒZed Zed Zdd„ Zdd„ ZG dd„ deƒZe	jjejj dkoxdejj!  k ovdk n  dd�dd„ ƒZ"dd„ Z#dd„ Z$dS )a  Tests for profile-related functions.

Currently only the startup-dir functionality is tested, but more tests should
be added for:

    * ipython profile create
    * ipython profile list
    * ipython profile create --parallel
    * security dir permissions

Authors
-------

* MinRK

é    N)ÚPath)ÚTemporaryDirectory)ÚTestCase)Úlist_bundled_profilesÚlist_profiles_in)Ú
ProfileDir)Ú
decorators)Útools)Ú	getoutputZhome_test_dirz.ipythonc                   C   s   t  ¡ t jdd� dS )zSSetup test environment for the module:

            - Adds dummy home dir tree
    T©ÚparentsN)r   ÚcwdÚIP_TEST_DIRÚmkdir© r   r   úUc:\Users\shubh\Videos\agent\nova\Lib\site-packages\IPython/core/tests/test_profile.pyÚsetup_module1   s   r   c                   C   s   t  t¡ dS )zXTeardown test environment for the module:

            - Remove dummy home dir tree
    N)ÚshutilÚrmtreeÚTMP_TEST_DIRr   r   r   r   Úteardown_module;   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dS )ÚProfileStartupTestc                 C   s*   t  td¡| _dtddg| _td | _d S )NÚtestz--ipython-dirz	--profileztest.py)r   Zcreate_profile_dir_by_namer   ÚpdÚoptionsr   Úfname©Úselfr   r   r   ÚsetUpJ   s   zProfileStartupTest.setUpc                 C   s   t  | jj¡ d S ©N)r   r   r   Úlocationr   r   r   r   ÚtearDownP   s   zProfileStartupTest.tearDownc                 C   s„   t t| jjƒ| ddd��}| |¡ W d   ƒ n1 sw   Y  t | jddd��}| |¡ W d   ƒ d S 1 s;w   Y  d S )NÚwúutf-8©Úencoding)Úopenr   r   Zstartup_dirÚwriter   )r   Zstartup_fileZstartupr   Úfr   r   r   ÚinitU   s   ÿ"ÿzProfileStartupTest.initc                 C   s   t j| j|d| jd� d S )NÚ )r   )ÚttZipexec_validater   r   )r   Úoutputr   r   r   Úvalidate]   s   zProfileStartupTest.validatec                 C   ó   |   ddd¡ |  d¡ d S )Nz00-start.pyzzzz=123
zprint(zzz)
Z123©r)   r-   r   r   r   r   Útest_startup_py`   ó   z"ProfileStartupTest.test_startup_pyc                 C   r.   )Nz00-start.ipyz%xmode plain
r*   zException reporting mode: Plainr/   r   r   r   r   Útest_startup_ipyd   r1   z#ProfileStartupTest.test_startup_ipyN)	Ú__name__Ú
__module__Ú__qualname__r   r!   r)   r-   r0   r2   r   r   r   r   r   I   s    r   Úpypy)é   é   é   )r7   r8   é   zQUnicode issues with scandir on PyPy, see https://github.com/pypy/pypy/issues/4860)Úreasonc                  C   sð   t tjtd�ƒ} dD ]}t | | ƒjdd� q
tjr$t | d ƒjdd� t| d ddd	��}| d
¡ W d   ƒ n1 s=w   Y  t	| ƒ}d}t
|ƒD ]}| d¡rbt | |¡}| |¡ d} nqLtjrl|du slJ ‚t|ƒddhksvJ ‚d S )N)Údir)Úprofile_fooZprofile_helloZnot_a_profileTr   u   profile_Ã¼nicodeZprofile_filer"   r#   r$   zI am not a profile directoryFZnicodeÚfooZhello)r   ÚtempfileÚmkdtempr   r   ÚdecZunicode_pathsr&   r'   r   ÚlistÚendswithr   Zfind_profile_dir_by_nameÚremoveÚset)ÚtdÚnamer(   ZprofilesZfound_unicodeÚpr   r   r   r   Útest_list_profiles_ini   s(   ÿ

ürI   c                  C   s   t tƒ ƒ} | g ksJ ‚d S r   )Úsortedr   )Zbundledr   r   r   Útest_list_bundled_profilesŠ   s   
rK   c               
   C   s|   t ƒ �1} ttjdddddd|  gƒ t| ƒd }t|ƒ ¡ s J ‚|d }t|ƒ ¡ s,J ‚W d	  ƒ d	S 1 s7w   Y  d	S )
z-ipython profile create respects --ipython-dirz-mZIPythonZprofileÚcreater>   z--ipython-dir=%sr=   zipython_config.pyN)r   r
   ÚsysÚ
executabler   Úexists)rF   Zprofile_dirZipython_configr   r   r   Útest_profile_create_ipython_dir�   s    ùÿ"ñrP   )%Ú__doc__r   rM   r?   Úpathlibr   r   Zunittestr   ZpytestZIPython.core.profileappr   r   ZIPython.core.profiledirr   ZIPython.testingr   rA   r	   r+   ZIPython.utils.processr
   r@   r   ZHOME_TEST_DIRr   r   r   r   ÚmarkZskipifÚimplementationrG   ÚversionrI   rK   rP   r   r   r   r   Ú<module>   s6   
 ý
