o
    ©ZhÄ  ć                   @   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Z
dZdd	 Zed
d ZdS )zTest embedding of IPythoné    N)ŚNamedFileInTemporaryDirectory)Ś
skip_win32)ŚIPYTHON_TESTING_TIMEOUT_SCALEsO   
import IPython

a = 3
b = 14
print(a, '.', b)

IPython.embed()

print('bye!')
s   exitc                  C   sŌ   t d\} |  t” |  ”  |  ”  tj| jg}tj	 
” }d|d< tj||tjtjtjd}| t”\}}| d”}|jdksAJ d|v sGJ tjdkrRd	|v sRJ d
|v sXJ W d   dS 1 scw   Y  dS )z!test that `IPython.embed()` workszfile_with_embed.pyŚ1ŚIPY_TEST_SIMPLE_PROMPT)ŚenvŚstdinŚstdoutŚstderrzUTF-8r   z3 . 14ŚntŚIPythonzbye!N)r   ŚwriteŚ_sample_embedŚflushŚcloseŚsysŚ
executableŚnameŚosŚenvironŚcopyŚ
subprocessŚPopenŚPIPEŚcommunicateŚ_exitŚdecodeŚ
returncode)ŚfŚcmdr   ŚpŚoutŚerrZstd© r#   śX/var/www/html/lang_env/lib/python3.10/site-packages/IPython/terminal/tests/test_embed.pyŚtest_ipython_embed)   s$   


’

"ģr%   c               
   C   sī  ddl } d}tj ” }d|d< | jtjg d¢|d}dt |_| 	|” d	t |_| 
d
” | 	|” | 
d” | 
d” zd}|dkrO| 	|dg”}|dksDW n | jyg } z
t| W Y d}~nd}~ww | 
d” | 	|” | 
d” | 	ddg”dksJ | 	|” | 
d” | 	ddg”dksJ | 	|” | 
d” zd}|dkr³| 	|dg”}|dksØW n | jyĖ } z
t| W Y d}~nd}~ww | 
d” | 	|” | 
d” | 	ddg”dksęJ | 	|” | 
d” | 	ddg”dksūJ | 	|” | 
d” | 	|” | 
d” | 	ddg”dksJ | 	|” | 
d” | 	ddg”dks1J | 	|” | 
d” | 	|” | 
d” | 	ddg”dksQJ | 	|” | 
d” | 	ddg”dksgJ | 	|” | 
d” | ”  dS )z'test that `IPython.embed()` is nestabler   Nz]:r   r   )z-mr   z--colors=nocolor)r   é   é   zimport IPythonzip0 = get_ipython()zIPython.embed()é’’’’z
zembed1 = get_ipython()z/print('true' if embed1 is not ip0 else 'false')ztrue
zfalse
z=print('true' if IPython.get_ipython() is embed1 else 'false')zembed2 = get_ipython()z2print('true' if embed2 is not embed1 else 'false')z=print('true' if embed2 is IPython.get_ipython() else 'false')Śexitz5print('true' if get_ipython() is embed1 else 'false')z2print('true' if get_ipython() is ip0 else 'false')z:print('true' if IPython.get_ipython() is ip0 else 'false'))Śpexpectr   r   r   Zspawnr   r   r   ŚtimeoutŚexpectZsendlineŚTIMEOUTŚprintr   )r*   Z
ipy_promptr   ŚchildZpromptedŚer#   r#   r$   Śtest_nest_embedB   s   
’






’’






’’


















r1   )Ś__doc__r   r   r   ZIPython.utils.tempdirr   ZIPython.testing.decoratorsr   ZIPython.testingr   r   r   r%   r1   r#   r#   r#   r$   Ś<module>   s    