
    Mhl                     v    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	 ad
 Zd Z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                      t                      S )N)start_ipython     [/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/IPython/testing/globalipapp.pyget_ipythonr      s    ??r   c                     t          |                     |dd                                          dt          j                   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cmds     r   xsysr   "   sS    
 
$..E.
3
3
:
:
<
<"3:VVVVJr   c                 l    t          | j                            |          t          j                   dS )zDPrint the traceback purely on stdout for doctest to capture it.
    )r   N)r   InteractiveTBstb2textr   r   )r   etypeevaluestbs       r   _showtracebackr$   +   s0     
$

%
%c
*
*<<<<<<r   c                  0   t          t          d          rdS dt          _        t          j        } t          j        }t          j                            d          }t          j	                    }d|j
        _        t          j        |          }|j                            t          |j        j                             |j                                         t)          j        t,          |          |_        t)          j        t0          |          |_        |t          j        d<   | t          _        |t          _        |}|j        a|t4          _        |t4          _        t2          t4          _        dd}t:          j        t:          _        |t:          _        |S )	zMStart a global IPython shell, which we need for IPython-specific syntax.
    already_calledNT__main__)configr   c                 z    t          | t                    r|                     dd          } t          |            d S )Nz
text/plainr   )
isinstancedictgetr   )strngstartscreen_lines	pager_cmds       r   nopagezstart_ipython.<locals>.nopagej   s6    eT"" 	/99\2..5er   )r   r   N) hasattrr
   r&   r   displayhook
excepthookmodulesr,   r   default_configr   simple_promptinstance	tempfilesappendr   HistoryManager	hist_filebuiltin_trapactivatetypes
MethodTyper   systemr$   r   builtin_mod_ipipr   
pager_page	orig_page)_displayhook_excepthook_mainr(   shellrC   r1   s          r   r
   r
   1   sP    }.// #'M  ?L.KKOOJ''E !##F48F#1 %-V 0 0 0E 
O4 5 ?@@AAA 
!!!
 #D%00EL +NEBBE $CK
"CO CN
 C/KKOKN)K   
 _DNDOJr   )__doc__builtinsrB   r   r?   pathlibr   r   r   IPython.corer   IPython.utilsr   !IPython.terminal.interactiveshellr   r   r   r$   r
   r   r   r   <module>rQ      s         



                          F F F F F F    = = =A A A A Ar   