B
    kb                 @   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m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 )    N   )toolsc              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   shell r   /lib/python3.7/site-packages/IPython/conftest.pyget_ipython   s    r
   ZsessionT)Z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 ?)pathlibZPathstrZabsoluteosenvironexists
ValueErrormkdirshutilZrmtreeZ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	   nopage$   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   )splitZdepthr   )endfileN)r   Z	getoutputrstripsysstdoutflush)selfcmdr   r   r	   xsys*   s     r%   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
   builtinsZ_ipZiptypes
MethodTyper%   systemZbuiltin_trapZactivatecorer&   r   Z
pager_page)r&   r   r   r	   inject8   s    r,   )r   r   N)r(   r    r'   r   Zpytestr   r   Ztestingr   r
   Zfixturer   r   r%   r,   r   r   r   r	   <module>   s   
