o
    éË·eÄ  ã                   @   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ÚerrÚstd© r$   úX/var/www/ideatree/venv/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   Úspawnr   r   r   ÚtimeoutÚexpectÚsendlineÚTIMEOUTÚprintr   )r+   Ú
ipy_promptr   ÚchildÚpromptedÚer$   r$   r%   Útest_nest_embedB   sŠ   
ÿ






ÿ€€ÿ






ÿ€€ÿ


















r6   )Ú__doc__r   r   r   ÚIPython.utils.tempdirr   ÚIPython.testing.decoratorsr   ÚIPython.testingr   r   r   r&   r6   r$   r$   r$   r%   Ú<module>   s    