§
    �Ÿjö  ã            
       óD  — d Z ddlZddlZddlZddlZddlmZ ddlZddlZddl	m
Z
mZmZmZmZmZmZ ddlmZ ddlmZ ddlmZ ej                             ej        ¦  «        Zej        d„ ¦   «         Zej        d	„ ¦   «         Zd
„ Z ej        ej!         "                    dddgfdddgfddgfdddgfg¦  «        d„ ¦   «         ¦   «         Z#ej        ej!         "                    dddgfdddgfddgfdddgfg¦  «        d„ ¦   «         ¦   «         Z$ G d„ dej%        ¦  «        Z&dS )z
Tests for platutils.py
é    N)Úinterrupt_main)Úfind_cmdÚFindCmdErrorÚ	arg_splitÚsystemÚ	getoutputÚgetoutputerrorÚget_output_error_code)Úcapture_output)Ú
decorators)Útoolsc                  óR   — t          d¦  «        } |                      d¦  «        sJ ‚dS )z*Make sure we can find the full path to ls.ÚlsN)r   Úendswith©Úpaths    úm/var/www/finuniver-perm.ru/html/student/venv/lib/python3.11/site-packages/IPython/utils/tests/test_process.pyÚtest_find_cmd_lsr   '   s-   € õ �D‰>Œ>€DØ�=Š=˜ÑÔÐÐÐÐÐó    c                  ó†   — t          d¦  «        } |                      ¦   «                              d¦  «        s
J | ¦   «         ‚dS )zTry to find pythonw on Windows.Úpythonwzpythonw.exeN)r   Úlowerr   r   s    r   Útest_find_cmd_pythonwr   .   sA   € õ �IÑÔ€DØ�:Š:‰<Œ<× Ò  Ñ/Ô/Ð5Ð5°Ñ5Ô5Ð5Ð5Ð5r   c                  óF   — t          j        t          t          d¦  «         dS )z?Make sure that FindCmdError is raised if we can't find the cmd.ÚasdfasdfN)ÚpytestÚraisesr   r   © r   r   Útest_find_cmd_failr   5   s   € å
„M•,¥¨*Ñ5Ô5Ð5Ð5Ð5r   zargstr, argvÚhizhello thereÚhelloÚthereu   hÇŽllozsomething "with quotes"Ú	somethingz"with quotes"c                 ó0   — t          | ¦  «        |k    sJ ‚dS ©z?Ensure that argument lines are correctly split like in a shell.N©r   ©ÚargstrÚargvs     r   Útest_arg_splitr*   :   s#   € õ �VÑÔ Ò$Ð$Ð$Ð$Ð$Ð$r   zargstr,argvzwith quotesc                 ó0   — t          | ¦  «        |k    sJ ‚dS r%   r&   r'   s     r   Útest_arg_split_win32r,   L   s#   € õ �VÑÔ Ò$Ð$Ð$Ð$Ð$Ð$r   c                   ód   — e Zd Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Z	e
j        d„ ¦   «         Zd	„ Zd
„ ZdS )ÚSubProcessTestCasec                 ó^   — g d¢}|                       d                     |¦  «        ¦  «         dS )zMake a valid python temp file.)z
import sysz+print('on stdout', end='', file=sys.stdout)z+print('on stderr', end='', file=sys.stderr)zsys.stdout.flush()zsys.stderr.flush()ú
N)ÚmktmpÚjoin)ÚselfÚliness     r   ÚsetUpzSubProcessTestCase.setUp\   s9   € ð'ð 'ð 'ˆð
 	�
Š
�4—9’9˜UÑ#Ô#Ñ$Ô$Ð$Ð$Ð$r   c                 óp   — t          t          › d| j        › d�¦  «        }|                      |d¦  «         d S )Nú "ú"r   )r   ÚpythonÚfnameÚassertEqual©r3   Ústatuss     r   Útest_systemzSubProcessTestCase.test_systeme   s>   € Ý�6Ð2Ð2 T¤ZÐ2Ð2Ð2Ñ3Ô3ˆØ×Ò˜ Ñ#Ô#Ð#Ð#Ð#r   c                 ó`   — t          dt          z  ¦  «        }|                      |d¦  «         d S )Nz%s -c "import sys"r   )r   r9   r;   r<   s     r   Útest_system_quotesz%SubProcessTestCase.test_system_quotesi   s1   € ÝÐ,­vÑ5Ñ6Ô6ˆØ×Ò˜ Ñ#Ô#Ð#Ð#Ð#r   c                 óî  — t          j        ¦   «         t          j        ¦   «         k    rt          j        d¦  «        ‚t          j        t
          j        t
          j        ¦  «         d„ }t          j        |¬¦  «         	                    ¦   «          t          j
        ¦   «         }	  |¦   «         }n# t          $ r Y nw xY wt          j
        ¦   «         }|                      ||z
  dk     d||z
  z  ¦  «         |S )z8
        Interrupt a subprocess after a second.
        z*Can't run this test if not in main thread.c                  óJ   — t          j        d¦  «         t          ¦   «          d S )Ng      à?)ÚtimeÚsleepr   r   r   r   Ú	interruptz7SubProcessTestCase.assert_interrupts.<locals>.interrupty   s!   € åŒJ�s‰OŒOˆOÝÑÔÐÐÐr   )Útargeté   zProcess didn't die quickly: %s)Ú	threadingÚmain_threadÚcurrent_threadr   ÚskipÚsignalÚSIGINTÚdefault_int_handlerÚThreadÚstartrC   ÚKeyboardInterruptÚ
assertTrue)r3   ÚcommandrE   rP   ÚresultÚends         r   Úassert_interruptsz$SubProcessTestCase.assert_interruptsm   sú   € õ Ô Ñ"Ô"¥iÔ&>Ñ&@Ô&@Ò@Ð@Ý”+ÐJÑKÔKÐKõ
 	Œ•f”m¥VÔ%?Ñ@Ô@Ð@ð	ð 	ð 	õ
 	Ô 	Ð*Ñ*Ô*×0Ò0Ñ2Ô2Ð2Ý”	‘”ˆð	Ø�W‘Y”YˆFˆFøÝ ð 	ð 	ð 	àˆDð	øøøõ Œi‰kŒkˆØ�ŠØ�%‰K˜!ŠOÐ=ÀÀuÁÑMñ	
ô 	
ð 	
ð ˆs   Â$
B/ Â/
B<Â;B<c                 ój   — d„ }|                       |¦  «        }|                      |dd|› �¦  «         dS )zr
        When interrupted in the way ipykernel interrupts IPython, the
        subprocess is interrupted.
        c                  ó0   — t          dt          z  ¦  «        S )Nz"%s -c "import time; time.sleep(5)")r   r9   r   r   r   rS   z9SubProcessTestCase.test_system_interrupt.<locals>.command�   s   € ÝÐ>ÅÑGÑHÔHÐHr   r   z(The process wasn't interrupted. Status: N)rV   ÚassertNotEqual)r3   rS   r=   s      r   Útest_system_interruptz(SubProcessTestCase.test_system_interrupt‹   s[   € ð
	Ið 	Ið 	Ið ×'Ò'¨Ñ0Ô0ˆØ×ÒØ�AÐJÀ&ÐJÐJñ	
ô 	
ð 	
ð 	
ð 	
r   c                 óÀ   — t          t          › d| j        › d�¦  «        }	 |                      |d¦  «         d S # t          $ r |                      |d¦  «         Y d S w xY w)Nr7   r8   zon stderron stdoutzon stdouton stderr)r   r9   r:   r;   ÚAssertionError©r3   Úouts     r   Útest_getoutputz!SubProcessTestCase.test_getoutput˜   s   € Ý�6Ð2Ð2 T¤ZÐ2Ð2Ð2Ñ3Ô3ˆð	8Ø×Ò˜SÐ"6Ñ7Ô7Ð7Ð7Ð7øÝð 	8ð 	8ð 	8Ø×Ò˜SÐ"6Ñ7Ô7Ð7Ð7Ð7Ð7ð	8øøøs   ¡9 ¹ AÁAc                 ó„   — t          dt          z  ¦  «        }|                      |                     ¦   «         d¦  «         d S )Nz%s -c "print (1)"Ú1©r   r9   r;   Ústripr]   s     r   Útest_getoutput_quotedz(SubProcessTestCase.test_getoutput_quoted    s9   € ÝÐ+­fÑ4Ñ5Ô5ˆØ×Ò˜Ÿš™œ cÑ*Ô*Ð*Ð*Ð*r   c                 ó  — t          dt          z  ¦  «        }|                      |                     ¦   «         d¦  «         t          dt          z  ¦  «        }|                      |                     ¦   «         d¦  «         d S )Nz%s -c 'print (1)'ra   z%s -c 'print ("1")'rb   r]   s     r   Útest_getoutput_quoted2z)SubProcessTestCase.test_getoutput_quoted2¥   sj   € åÐ+­fÑ4Ñ5Ô5ˆØ×Ò˜Ÿš™œ cÑ*Ô*Ð*ÝÐ/µ&Ñ8Ñ9Ô9ˆØ×Ò˜Ÿš™œ cÑ*Ô*Ð*Ð*Ð*r   c                 ó¢   — t          t          › d| j        › d�¦  «        \  }}|                      |d¦  «         |                      |d¦  «         d S )Nr7   r8   ú	on stdoutú	on stderr)r	   r9   r:   r;   )r3   r^   Úerrs      r   Útest_getoutput_errorz'SubProcessTestCase.test_getoutput_error¬   sX   € Ý!¥VÐ"<Ð"<¨t¬zÐ"<Ð"<Ð"<Ñ=Ô=‰ˆˆSØ×Ò˜˜kÑ*Ô*Ð*Ø×Ò˜˜kÑ*Ô*Ð*Ð*Ð*r   c                 óŽ  — dt           z  }t          |¦  «        \  }}}|                      |d¦  «         |                      |d¦  «         |                      |d¦  «         t          t           › d| j        › d�¦  «        \  }}}|                      |d¦  «         |                      |d¦  «         |                      |d¦  «         d S )	Nz%s -c "import sys; sys.exit(1)"Ú é   r7   r8   rh   ri   r   )r9   r
   r;   r:   )r3   Ú
quiet_exitr^   rj   Úcodes        r   Útest_get_output_error_codez-SubProcessTestCase.test_get_output_error_code±   sÏ   € Ø6½Ñ?ˆ
Ý.¨zÑ:Ô:‰ˆˆS�$Ø×Ò˜˜bÑ!Ô!Ð!Ø×Ò˜˜bÑ!Ô!Ð!Ø×Ò˜˜qÑ!Ô!Ð!Ý.µ&Ð/IÐ/I¸D¼JÐ/IÐ/IÐ/IÑJÔJ‰ˆˆS�$Ø×Ò˜˜kÑ*Ô*Ð*Ø×Ò˜˜kÑ*Ô*Ð*Ø×Ò˜˜qÑ!Ô!Ð!Ð!Ð!r   N)Ú__name__Ú
__module__Ú__qualname__r5   r>   r@   rV   rZ   r_   rd   ÚdecÚ
skip_win32rf   rk   rq   r   r   r   r.   r.   [   s¸   € € € € € ð%ð %ð %ð$ð $ð $ð$ð $ð $ðð ð ð<
ð 
ð 
ð8ð 8ð 8ð+ð +ð +ð
 	„^ð+ð +ñ „^ð+ð+ð +ð +ð
	"ð 	"ð 	"ð 	"ð 	"r   r.   )'Ú__doc__ÚsysrL   ÚosrC   Ú_threadr   rH   r   ÚIPython.utils.processr   r   r   r   r   r	   r
   ÚIPython.utils.capturer   ÚIPython.testingr   ru   r   Úttr   ÚbasenameÚ
executabler9   rv   r   Úskip_if_not_win32r   r   ÚmarkÚparametrizer*   r,   ÚTempFileMixinr.   r   r   r   ú<module>r…      sw  ððð ð €
€
€
Ø €€€Ø 	€	€	€	Ø €€€Ø "Ð "Ð "Ð "Ð "Ð "Ø Ð Ð Ð à €€€ð:ð :ð :ð :ð :ð :ð :ð :ð :ð :ð :ð :ð :ð :ð :ð :ð :ð :ð 1Ð 0Ð 0Ð 0Ð 0Ð 0Ø -Ð -Ð -Ð -Ð -Ð -Ø 'Ð 'Ð 'Ð 'Ð 'Ð 'à	Œ×	Ò	˜#œ.Ñ	)Ô	)€ð „ðð ñ „ðð Ôð6ð 6ñ Ôð6ð6ð 6ð 6ð
 „Ø„×ÒØà	�ˆvˆØ	˜ 'Ð*Ð+ð 
˜�~Ð&Ø	" [°/Ð$BÐCðñô ð%ð %ñô ñ „ð%ð
 ÔØ„×ÒØà	�ˆvˆØ	˜ 'Ð*Ð+Ø	˜�~Ð&Ø	" [°-Ð$@ÐAð	ñô ð%ð %ñô ñ Ôð%ð
_"ð _"ð _"ð _"ð _"˜Ô)ñ _"ô _"ð _"ð _"ð _"r   