o
    û›hl  ã                   @   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mZ ddlmZ d	d
„ add„ Zdd„ Zdd„ ZdS )a  Global IPython app to support test running.

We must start our own ipython object and heavily muck with it so that all the
modifications IPython makes to system behavior don't send the doctest machinery
into a fit.  This code should be considered a gross hack, but it gets the job
done.
é    N)ÚPathé   )Útools)Úpage)Úio)ÚTerminalInteractiveShellc                   C   s   t ƒ S )N)Ústart_ipython© r	   r	   úQc:\Users\shubh\Videos\agent\nova\Lib\site-packages\IPython/testing/globalipapp.pyÚget_ipython   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ÚdepthÚ )ÚendÚfileN)ÚprintÚ	getoutputÚrstripÚsysÚstdoutÚflush)ÚselfÚcmdr	   r	   r
   Úxsys"   s    r   c                 C   s   t | j |¡tjd� dS )zDPrint the traceback purely on stdout for doctest to capture it.
    )r   N)r   ZInteractiveTBZstb2textr   r   )r   ÚetypeZevalueZstbr	   r	   r
   Ú_showtraceback+   s   r   c                  C   sÐ   t tdƒrdS dt_tj} tj}tj d¡}t 	¡ }d|j
_t
j|d�}|j t|jjƒ¡ |j ¡  t t|¡|_t t|¡|_|tjd< | t_|t_|}|ja|t_|t_tt_d	dd„}tjt_|t_|S )
zMStart a global IPython shell, which we need for IPython-specific syntax.
    Úalready_calledNTÚ__main__)Úconfigr   c                 S   s"   t | tƒr|  dd¡} t| ƒ d S )Nz
text/plainr   )Ú
isinstanceÚdictÚgetr   )ZstrngÚstartZscreen_linesZ	pager_cmdr	   r	   r
   Únopagej   s   
zstart_ipython.<locals>.nopage)r   r   N) Úhasattrr   r   r   ÚdisplayhookÚ
excepthookÚmodulesr!   r   Zdefault_configr   Zsimple_promptÚinstanceZ	tempfilesÚappendr   ZHistoryManagerZ	hist_fileZbuiltin_trapÚactivateÚtypesÚ
MethodTyper   Úsystemr   r   Úbuiltin_modÚ_ipÚipr   Z
pager_pageZ	orig_page)Z_displayhookÚ_excepthookÚ_mainr   Úshellr/   r#   r	   r	   r
   r   1   s2   



r   )Ú__doc__Úbuiltinsr.   r   r+   Úpathlibr   r   r   ZIPython.corer   ZIPython.utilsr   Z!IPython.terminal.interactiveshellr   r   r   r   r   r	   r	   r	   r
   Ú<module>   s    		