U
    -e:
                     @   s   d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlZed ddl	m
Z
 dd Zdd Zejd	d
ddd ZdddZdd Zdd Ze  dS )    NzIPython.testing.tools   )toolsc                 C   s4   | D ]*}t |jr|d t |jrtqdS )zThis function is automatically run by pytest passing all collected test
    functions.

    We use it to add asyncio marker to all async tests and assert we don't use
    test functions that are async generators which wouldn't make sense.
    asyncioN)inspectiscoroutinefunctionobjZ
add_markerisasyncgenfunctionAssertionError)itemsitem r   Q/var/www/html/Darija-Ai-Train/env/lib/python3.8/site-packages/IPython/conftest.pypytest_collection_modifyitems   s    
r   c                  C   s:   ddl m}  | jr|  S t }d|j_| j|d}|S )Nr   )TerminalInteractiveShellT)config)Zterminal.interactiveshellr   Z	_instanceinstancer   Zdefault_configZsimple_prompt)r   r   shellr   r   r   get_ipython   s    r   sessionT)scopeZautousec                  c   sP   t d} t|  tjd< |  r,td|   d V  t	
t|   d S )Nz./tmp-ipython-pytest-profiledirZ
IPYTHONDIRzUIPython dir temporary path already exists ! Did previous test run exit successfully ?)pathlibPathstrabsoluteosenvironexists
ValueErrormkdirshutilrmtreeresolve)pathr   r   r   	work_path+   s    
r#   c                 C   s"   t | tr| dd} t|  d S )Nz
text/plain )
isinstancedictgetprint)ZstrngstartZscreen_linesZ	pager_cmdr   r   r   nopage6   s    
r*   c                 C   s.   t | j|ddd dtjd tj  dS )zFReplace the default system call with a capturing one for doctest.
    Fr   )splitdepthr$   )endfileN)r(   	getoutputrstripsysstdoutflush)selfcmdr   r   r   xsys<   s     r6   c                  C   sH   t t_ t  t_t  t_ttttj_tjj	  ddl
m}  t| _d S )Nr   page)r   builtins_ipiptypes
MethodTyper6   systemZbuiltin_trapactivatecorer8   r*   Z
pager_pager7   r   r   r   injectJ   s    rA   )r   r   N)r9   r   r   r   r   r1   r<   ZpytestZregister_assert_rewritetestingr   r   r   Zfixturer#   r*   r6   rA   r   r   r   r   <module>   s"   



