a
    åze]h  ã                   @   s´  d dl 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mZ d dlmZ d dl	m
Z d dlmZ ejdkr‚d dlmZ ejd	d
gZejd	d d¡gZdd„ ZG dd„ dejƒZG dd„ dejƒZG dd„ dƒZejdkr|G dd„ deƒZG dd„ deejƒZe d¡G dd„ deejƒƒZG dd„ deejƒZG dd„ deejƒZd d!„ Z e !e ƒ d"¡G d#d$„ d$eejƒƒZ"nG d%d&„ d&eejƒZ#G d'd(„ d(ƒZ$e%d)kr°e &¡  dS )*é    N)Úmock)Úbase_subprocess)Ú
subprocess)Úutils)ÚsupportÚwin32)Úunix_eventsú-czimport time; time.sleep(3600)ú;)ú
import syszdata = sys.stdin.buffer.read()zsys.stdout.buffer.write(data)c                   C   s   t  d ¡ d S ©N)ÚasyncioZset_event_loop_policy© r   r   ú7/usr/lib/python3.9/test/test_asyncio/test_subprocess.pyÚtearDownModule   s    r   c                   @   s   e Zd Zdd„ ZdS )ÚTestSubprocessTransportc                 O   s.   t  ¡ | _d | j_d | j_d | j_d| j_d S )Néÿÿÿÿ)r   ÚMockÚ_procÚstdinÚstdoutÚstderrÚpid)ÚselfÚargsÚkwargsr   r   r   Ú_start!   s
    
zTestSubprocessTransport._startN)Ú__name__Ú
__module__Ú__qualname__r   r   r   r   r   r       s   r   c                       s6   e Zd Z‡ fdd„Zd
dd„Zdd„ Zdd	„ Z‡  ZS )ÚSubprocessTransportTestsc                    s$   t ƒ  ¡  |  ¡ | _|  | j¡ d S r   )ÚsuperÚsetUpZnew_test_loopÚloopÚset_event_loop©r   ©Ú	__class__r   r   r"   *   s    

zSubprocessTransportTests.setUpNc                 C   s>   t  ¡ }d|j_d|j_t| j|dgdd d d d|d	}||fS )NFÚtestr   )Úwaiter)r   r   Úconnection_madeZ_is_coroutineÚprocess_exitedr   r#   )r   r)   ÚprotocolÚ	transportr   r   r   Úcreate_transport/   s    
þz)SubprocessTransportTests.create_transportc                 C   sè   | j  ¡ }|  |¡\}}| d¡ | j  |¡ |  | ¡ d¡ |  |jj	¡ |  |j
j	¡ |  |jj	¡ |  |jjd d¡ |  | ¡ ¡ |  |j¡ |  |j¡ |  |j¡ |  t|jtj¡ |  t|j¡ |  t|j¡ | ¡  d S )Né   r   r   )r#   Úcreate_futurer.   Ú_process_exitedÚrun_until_completeÚassertEqualÚget_returncodeÚ
assertTruer*   Úcalledr+   Zconnection_lostZ	call_argsÚassertFalseZ
is_closingÚassertIsNoneZ_loopr   Z	_protocolÚassertRaisesÚProcessLookupErrorÚsend_signalÚsignalÚSIGTERMÚ	terminateÚkillÚclose©r   r)   r-   r,   r   r   r   Útest_proc_exited8   s&    

ÿz)SubprocessTransportTests.test_proc_exitedc                 C   s|   | j  ¡ }|  |¡\}}| d¡ | j  |¡ |  t|ƒd¡ d |_|  t|ƒd¡ d |_d |_|  t|ƒd¡ | 	¡  d S )Nr/   z-<TestSubprocessTransport pid=-1 returncode=6>z(<TestSubprocessTransport pid=-1 running>z%<TestSubprocessTransport not started>)
r#   r0   r.   r1   r2   r3   ÚreprZ_returncodeÚ_pidr@   rA   r   r   r   Útest_subprocess_reprR   s(    

þþþz-SubprocessTransportTests.test_subprocess_repr)N)r   r   r   r"   r.   rB   rE   Ú__classcell__r   r   r&   r   r    )   s   
	r    c                   @   s  e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ Ze	 
ejdkd¡dd„ ƒZdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd „ Zd!d"„ Zd#d$„ Zd%d&„ Zd'd(„ Zd)d*„ Zd+d,„ Zd-d.„ Zd/d0„ Zd1d2„ Zd3d4„ Zd5d6„ Z d7d8„ Z!d9d:„ Z"d;d<„ Z#d=d>„ Z$d?S )@ÚSubprocessMixinc                    sP   t ‰ ‡ fdd„}|dƒ}t |d¡}| j |¡\}}|  |d¡ |  |d¡ d S )Nc                 “   sh   t jˆ tjtjdœŽI d H }|j | ¡ |j ¡ I d H  |j ¡  |j 	¡ I d H } | 
¡ I d H }|| fS ©N)r   r   )r   Úcreate_subprocess_execr   ÚPIPEr   ÚwriteÚdrainr@   r   ÚreadÚwait)ÚdataÚprocÚexitcode©r   r   r   Úruno   s    ý
z.SubprocessMixin.test_stdin_stdout.<locals>.runó	   some datag      N@r   )ÚPROGRAM_CATr   Úwait_forr#   r2   r3   ©r   rS   ÚtaskrQ   r   r   rR   r   Útest_stdin_stdoutl   s    z!SubprocessMixin.test_stdin_stdoutc                    sR   t ‰ ‡ fdd„}|dƒ}t |tj¡}| j |¡\}}|  |d¡ |  |d¡ d S )Nc                 “   s:   t jˆ tjtjdœŽI d H }| | ¡I d H \}}|j|fS rH   )r   rI   r   rJ   ÚcommunicateÚ
returncode)rO   rP   r   r   rR   r   r   rS   ‰   s    ýz-SubprocessMixin.test_communicate.<locals>.runrT   r   )rU   r   rV   r   ZLONG_TIMEOUTr#   r2   r3   rW   r   rR   r   Útest_communicate†   s    	z SubprocessMixin.test_communicatec                 C   s2   | j  t d¡¡}| j  | ¡ ¡}|  |d¡ d S )Nzexit 7é   ©r#   r2   r   Úcreate_subprocess_shellrN   r3   ©r   rP   rQ   r   r   r   Ú
test_shell˜   s
    ÿzSubprocessMixin.test_shellc                 C   s6   | j  tjddd¡}| j  | ¡ ¡}|  |d¡ d S )Nzexit 8T)Ústart_new_sessioné   r^   r`   r   r   r   Útest_start_new_sessionŸ   s    þÿz&SubprocessMixin.test_start_new_sessionc                 C   sZ   t }| j tj|Ž ¡}| ¡  | j | ¡ ¡}tjdkrF|  	|t
¡ n|  tj |¡ d S ©Nr   )ÚPROGRAM_BLOCKEDr#   r2   r   rI   r?   rN   ÚsysÚplatformÚassertIsInstanceÚintr3   r<   ÚSIGKILL©r   r   rP   r[   r   r   r   Ú	test_killª   s    ÿ
zSubprocessMixin.test_killc                 C   sZ   t }| j tj|Ž ¡}| ¡  | j | ¡ ¡}tjdkrF|  	|t
¡ n|  tj |¡ d S re   )rf   r#   r2   r   rI   r>   rN   rg   rh   ri   rj   r3   r<   r=   rl   r   r   r   Útest_terminate·   s    ÿ
zSubprocessMixin.test_terminater   zDon't have SIGHUPc              
      sŽ   t   t jt j¡}zhd}tjd|g}ˆ j tj|dt	j
iŽ¡}‡ fdd„}ˆ j ||ƒ¡}ˆ  t j |¡ W t   t j|¡ nt   t j|¡ 0 d S )Nz<import time; print("sleeping", flush=True); time.sleep(3600)r	   r   c                 “   s:   | j  ¡ I d H }ˆ  |d¡ |  tj¡ |  ¡ I d H }|S )Ns	   sleeping
)r   Úreadliner3   r;   r<   ÚSIGHUPrN   )rP   Úliner[   r%   r   r   r;   Ô   s
    z5SubprocessMixin.test_send_signal.<locals>.send_signal)r<   rp   ÚSIG_DFLrg   Ú
executabler#   r2   r   rI   r   rJ   r3   )r   Zold_handlerÚcoder   rP   r;   r[   r   r%   r   Útest_send_signalÄ   s    ÿþÿ	z SubprocessMixin.test_send_signalc                 C   s0   dt j }| j tjtjddtj	d¡}||fS )Nó   xr	   Úpass©r   )
r   ZPIPE_MAX_SIZEr#   r2   r   rI   rg   rs   r   rJ   )r   Ú
large_datarP   r   r   r   Úprepare_broken_pipe_testâ   s    
þÿz(SubprocessMixin.prepare_broken_pipe_testc                 C   sp   |   ¡ \}}dd„ }|||ƒ}t ¡ & |  ttf| jj|¡ W d   ƒ n1 sR0    Y  | j | ¡ ¡ d S )Nc                 Ó   s0   t  d¡I d H  | j |¡ | j ¡ I d H  d S )Ng      à?)r   Úsleepr   rK   rL   )rP   rO   r   r   r   Úwrite_stdinó   s    z;SubprocessMixin.test_stdin_broken_pipe.<locals>.write_stdin)	rz   Ú
test_utilsÚdisable_loggerr9   ÚBrokenPipeErrorÚConnectionResetErrorr#   r2   rN   )r   rP   ry   r|   Úcoror   r   r   Útest_stdin_broken_pipeð   s    


ÿ"z&SubprocessMixin.test_stdin_broken_pipec                 C   sB   |   ¡ \}}| j dd„ ¡ | j | |¡¡ | j | ¡ ¡ d S )Nc                 S   s   d S r   r   )r#   Úmsgr   r   r   Ú<lambda>  ó    zESubprocessMixin.test_communicate_ignore_broken_pipe.<locals>.<lambda>)rz   r#   Zset_exception_handlerr2   rZ   rN   )r   rP   ry   r   r   r   Ú#test_communicate_ignore_broken_pipeÿ   s    z3SubprocessMixin.test_communicate_ignore_broken_pipec                    sb   d‰ ˆ d d ‰‡ ‡‡fdd„}ˆj  |ƒ ¡\}}ˆ |dˆ ¡ ˆ |jj¡ ˆ |jj¡ d S )Né
   é   é   c                  “   s|   d  ddˆ df¡} ˆjj‰ ‡ fdd„}|ˆj_tjtjd| tjjtjjˆdI d H }|j	 
d	¡}| ¡ I d H \}}||fS )
NÚ
r   zsys.stdout.write("x" * %s)úsys.stdout.flush()c                  Ÿ   s4   ˆ | i |¤ŽI d H \}}t  ¡ |_t  ¡ |_||fS r   )r   r   Úpause_readingÚresume_reading)r   Úkwr-   r,   ©Úconnect_read_piper   r   Úconnect_read_pipe_mock  s    

z^SubprocessMixin.test_pause_reading.<locals>.test_pause_reading.<locals>.connect_read_pipe_mockr	   )r   r   Úlimitr‰   )Újoinr#   r   r   rI   rg   rs   r   rJ   Z
_transportZget_pipe_transportrZ   )rt   r‘   rP   Zstdout_transportr   r   ©r’   r   Úsizer   r   Útest_pause_reading  s"    ýüz>SubprocessMixin.test_pause_reading.<locals>.test_pause_readingrv   )r#   r2   r3   r5   rŒ   r6   r   )r   r–   r   r-   r   r”   r   r–     s    "z"SubprocessMixin.test_pause_readingc                 C   s<   dd„ }| j  |dƒ¡\}}|  | ¡ d¡ |  |d¡ d S )Nc              	   Ó   sZ   d}t jtjd|t jjt jjt jjddI d H }| | ¡I d H \}}| ¡ I d H }||fS ©Nú5import sys; data = sys.stdin.read(); print(len(data))r	   F©r   r   r   Ú	close_fds©r   rI   rg   rs   r   rJ   rZ   rN   )Úmessagert   rP   r   r   rQ   r   r   r   Úlen_message6  s    ûz?SubprocessMixin.test_stdin_not_inheritable.<locals>.len_messageó   abcó   3r   ©r#   r2   r3   Úrstrip)r   r   ÚoutputrQ   r   r   r   Útest_stdin_not_inheritable3  s    z*SubprocessMixin.test_stdin_not_inheritablec                 C   s:   dd„ }| j  |ƒ ¡\}}|  | ¡ d¡ |  |d¡ d S )Nc               	   Ó   sZ   d} t jtjd| t jjt jjt jjddI d H }| d¡I d H \}}| ¡ I d H }||fS )Nr˜   r	   Fr™   r…   r›   ©rt   rP   r   r   rQ   r   r   r   Úempty_inputI  s    ûz5SubprocessMixin.test_empty_input.<locals>.empty_inputó   0r   r    ©r   r¥   r¢   rQ   r   r   r   Útest_empty_inputG  s    z SubprocessMixin.test_empty_inputc                 C   s:   dd„ }| j  |ƒ ¡\}}|  | ¡ d¡ |  |d¡ d S )Nc               	   Ó   sX   d} t jtjd| t jjt jjt jjddI d H }| ¡ I d H \}}| ¡ I d H }||fS r—   )	r   rI   rg   rs   r   ÚDEVNULLrJ   rZ   rN   r¤   r   r   r   r¥   \  s    ûz7SubprocessMixin.test_devnull_input.<locals>.empty_inputr¦   r   r    r§   r   r   r   Útest_devnull_inputZ  s    z"SubprocessMixin.test_devnull_inputc                 C   s6   dd„ }| j  |ƒ ¡\}}|  |d ¡ |  |d¡ d S )Nc               	   Ó   sZ   d} t jtjd| t jjt jjt jjddI d H }| d¡I d H \}}| ¡ I d H }||fS ©Nr˜   r	   Fr™   rž   ©	r   rI   rg   rs   r   rJ   r©   rZ   rN   r¤   r   r   r   Úempty_outputo  s    ûz9SubprocessMixin.test_devnull_output.<locals>.empty_outputr   ©r#   r2   r3   )r   r­   r¢   rQ   r   r   r   Útest_devnull_outputm  s    z#SubprocessMixin.test_devnull_outputc                 C   s6   dd„ }| j  |ƒ ¡\}}|  |d ¡ |  |d¡ d S )Nc               	   Ó   sZ   d} t jtjd| t jjt jjt jjddI d H }| d¡I d H \}}| ¡ I d H }||fS r«   r¬   r¤   r   r   r   Úempty_error‚  s    ûz7SubprocessMixin.test_devnull_error.<locals>.empty_errorr   r®   )r   r°   r¢   rQ   r   r   r   Útest_devnull_error€  s    z"SubprocessMixin.test_devnull_errorc                    s   ‡ fdd„}ˆ j  |ƒ ¡ d S )Nc                  “   st   t jtŽ I d H } ˆ j |  ¡ ¡}ˆ j |j¡ z|I d H  W n t jyP   Y n0 | ¡  |  	¡  |  ¡ I d H  d S r   )
r   rI   rf   r#   Úcreate_taskrN   Ú	call_soonÚcancelÚCancelledErrorr?   )rP   rX   r%   r   r   Úcancel_wait–  s    z=SubprocessMixin.test_cancel_process_wait.<locals>.cancel_wait©r#   r2   )r   r¶   r   r%   r   Útest_cancel_process_wait“  s    z(SubprocessMixin.test_cancel_process_waitc                    sF   ‡ fdd„}t  ¡  ˆ j |ƒ ¡ W d   ƒ n1 s80    Y  d S )Nc                  “   sL   t jtŽ } ˆ j | ¡}ˆ j |j¡ z|I d H  W n t jyF   Y n0 d S r   )r   rI   rf   r#   r²   r³   r´   rµ   ©r   rX   r%   r   r   Úcancel_make_transport¬  s    
zYSubprocessMixin.test_cancel_make_subprocess_transport_exec.<locals>.cancel_make_transport)r}   r~   r#   r2   ©r   rº   r   r%   r   Ú*test_cancel_make_subprocess_transport_execª  s    
z:SubprocessMixin.test_cancel_make_subprocess_transport_execc                    sR   ‡ fdd„}t  ¡ * ˆ j |ƒ ¡ t  ˆ j¡ W d   ƒ n1 sD0    Y  d S )Nc                  “   sX   ˆ j jtjgt¢R Ž } ˆ j  | ¡}ˆ j  |j¡ z|I d H  W n tjyR   Y n0 d S r   )	r#   Úsubprocess_execr   ÚSubprocessProtocolrf   r²   r³   r´   rµ   r¹   r%   r   r   rº   ½  s    ÿzDSubprocessMixin.test_cancel_post_init.<locals>.cancel_make_transport)r}   r~   r#   r2   Úrun_brieflyr»   r   r%   r   Útest_cancel_post_init»  s    
z%SubprocessMixin.test_cancel_post_initc              	      sŽ   ‡ fdd„}t  ¡ F zˆ j |ƒ ¡\}}W n tjyJ   ˆ  d¡ Y n0 W d   ƒ n1 s`0    Y  ˆ  |¡ ˆ  |¡ t  	ˆ j¡ d S )Nc                  “   sz   ˆj jtjgt¢R Ž } | I d H \}}d‰ ‡ ‡fdd„}| d¡}|j‰||_| ¡ }| ¡  t 	| 
¡ d¡I d H  |ˆ fS )NFc                      s   d‰ ˆƒ  d S )NTr   r   ©Zkill_calledZ	orig_killr   r   r?   Ö  s    zKSubprocessMixin.test_close_kill_running.<locals>.kill_running.<locals>.killr   é   )r#   r½   r   r¾   rf   Úget_extra_infor?   r4   r@   rV   Ú_wait)Úcreater-   r,   r?   rP   r[   r%   rÁ   r   Úkill_runningÐ  s    ÿ
z=SubprocessMixin.test_close_kill_running.<locals>.kill_runningz2Timeout failure on waiting for subprocess stopping)
r}   r~   r#   r2   r   ÚTimeoutErrorZskipTestr8   r5   r¿   )r   rÆ   r[   Úkilledr   r%   r   Útest_close_kill_runningÎ  s    
ÿÿ(

z'SubprocessMixin.test_close_kill_runningc                    sœ   ‡ fdd„}t  ¡ * ˆ j |ƒ ¡}t  ˆ j¡ W d   ƒ n1 sD0    Y  |\}}}ˆ  |¡ ˆ  |¡ ˆ  |¡ tj	dkr˜t
ˆ tƒr˜t ¡ j ¡  d S )Nc                  “   sn   ˆ j jtjgt¢R Ž } | I d H \}}| d¡}| ¡  | ¡  t 	¡ |_| 
¡ }| ¡ }| ¡  |||jjfS )Nr   )r#   r½   r   r¾   rf   rÃ   r?   rN   r   r   Úpollr4   r@   r6   )rÅ   r-   r,   rP   Úproc_returncodeZtransport_returncoder%   r   r   rÆ   õ  s    ÿ

zCSubprocessMixin.test_close_dont_kill_finished.<locals>.kill_runningr   )r}   r~   r#   r2   r¿   ZassertIsNotNoner8   r7   rg   rh   Ú
isinstanceÚSubprocessFastWatcherTestsr   Úget_child_watcherZ
_callbacksÚclear)r   rÆ   ÚresultrË   Ztransport_return_coderÈ   r   r%   r   Útest_close_dont_kill_finishedó  s    
*




ÿz-SubprocessMixin.test_close_dont_kill_finishedc              
   Ã   sÈ   t jdkrd}nd}t |¡–}t}||_tjdd`}|  |¡* t	j
t jdd|dI d H  W d   ƒ n1 sr0    Y  |  |g ¡ W d   ƒ n1 sœ0    Y  W d   ƒ n1 sº0    Y  d S )	Nr   zasyncio.windows_utils.Popenzsubprocess.PopenT)Úrecordr	   rw   rx   )rg   rh   r   ZpatchÚZeroDivisionErrorZside_effectÚwarningsÚcatch_warningsr9   r   rI   rs   r3   )r   r   ÚtargetÚpopenÚexcZwarnsr   r   r   Ú_test_popen_error  s    
ü*z!SubprocessMixin._test_popen_errorc                 C   s   | j  | jd d¡ d S ©Nrx   )r#   r2   rÙ   r%   r   r   r   Útest_popen_error/  s    z SubprocessMixin.test_popen_errorc                 C   s   | j  | jtjd¡ d S rÚ   )r#   r2   rÙ   r   rJ   r%   r   r   r   Ú test_popen_error_with_stdin_pipe4  s    ÿz0SubprocessMixin.test_popen_error_with_stdin_pipec                 C   s   dd„ }| j  |ƒ ¡ d S )Nc                  Ó   s\   d  g d¢¡} tjtjd| tjjdI d H }|j d¡I d H }|rXt 	d¡I d H  q,qXq,d S )NrŠ   )r   zfor _ in range(64):z     sys.stdout.write("x" * 4096)r‹   zsys.exit(1)r	   )r   i   g333333Ó?)
r“   r   rI   rg   rs   r   rJ   r   rM   r{   )rt   ÚprocessrO   r   r   r   Úexecute<  s    þzDSubprocessMixin.test_read_stdout_after_process_exit.<locals>.executer·   ©r   rÞ   r   r   r   Ú#test_read_stdout_after_process_exit:  s    z3SubprocessMixin.test_read_stdout_after_process_exitc                    s   ‡ fdd„}ˆ j  |ƒ ¡ d S )Nc                   “   sÄ   ˆ   t¡& tjtjddI d H  W d   ƒ n1 s60    Y  ˆ   t¡& tjtjddI d H  W d   ƒ n1 sv0    Y  ˆ   t¡& tjtjddI d H  W d   ƒ n1 s¶0    Y  d S ©NT)Útextzutf-8)ÚencodingÚstrict)Úerrors)r9   Ú
ValueErrorr   rI   rg   rs   r   r%   r   r   rÞ   R  s    ÿ*ÿ*ÿzLSubprocessMixin.test_create_subprocess_exec_text_mode_fails.<locals>.executer·   rß   r   r%   r   Ú+test_create_subprocess_exec_text_mode_failsQ  s    z;SubprocessMixin.test_create_subprocess_exec_text_mode_failsc                    s   ‡ fdd„}ˆ j  |ƒ ¡ d S )Nc                   “   sÄ   ˆ   t¡& tjtjddI d H  W d   ƒ n1 s60    Y  ˆ   t¡& tjtjddI d H  W d   ƒ n1 sv0    Y  ˆ   t¡& tjtjddI d H  W d   ƒ n1 s¶0    Y  d S rá   )r9   ræ   r   r_   rg   rs   r   r%   r   r   rÞ   c  s    ÿ*ÿ*ÿzMSubprocessMixin.test_create_subprocess_shell_text_mode_fails.<locals>.executer·   rß   r   r%   r   Ú,test_create_subprocess_shell_text_mode_failsa  s    z<SubprocessMixin.test_create_subprocess_shell_text_mode_failsc                 C   s    dd„ }|   | j |ƒ ¡¡ d S )Nc                  Ó   sZ   t  t tj¡dd¡I d H } |  ¡ I d H  t  tjddt d¡¡I d H } |  ¡ I d H  d S )Nr	   rw   Ú.)r   rI   r   ÚFakePathrg   rs   rN   )Úpr   r   r   rÞ   s  s    ÿ
ÿ
zFSubprocessMixin.test_create_subprocess_exec_with_path.<locals>.execute©r8   r#   r2   rß   r   r   r   Ú%test_create_subprocess_exec_with_pathr  s    z5SubprocessMixin.test_create_subprocess_exec_with_pathc                    s   ‡ fdd„}ˆ j  |ƒ ¡ d S )Nc                  “   sX   ˆ   t¡, tjtjddˆ jdI d H } W d   ƒ n1 s<0    Y  |  ¡ I d H  d S )Nr	   rw   ©r#   )ÚassertWarnsÚDeprecationWarningr   rI   rg   rs   r#   rN   ©rP   r%   r   r   Úgo~  s    þ*z5SubprocessMixin.test_exec_loop_deprecated.<locals>.gor·   ©r   rò   r   r%   r   Útest_exec_loop_deprecated}  s    z)SubprocessMixin.test_exec_loop_deprecatedc                    s   ‡ fdd„}ˆ j  |ƒ ¡ d S )Nc                  “   sR   ˆ   t¡& tjdˆ jdI d H } W d   ƒ n1 s60    Y  |  ¡ I d H  d S )Nzexit 0rî   )rï   rð   r   r_   r#   rN   rñ   r%   r   r   rò   ˆ  s    þ*z6SubprocessMixin.test_shell_loop_deprecated.<locals>.gor·   ró   r   r%   r   Útest_shell_loop_deprecated‡  s    z*SubprocessMixin.test_shell_loop_deprecatedN)%r   r   r   rY   r\   ra   rd   rm   rn   ÚunittestZskipIfrg   rh   ru   rz   r‚   r†   r–   r£   r¨   rª   r¯   r±   r¸   r¼   rÀ   rÉ   rÑ   rÙ   rÛ   rÜ   rà   rç   rè   rí   rô   rõ   r   r   r   r   rG   j   s>   
,%)
rG   c                       s,   e Zd ZdZ‡ fdd„Z‡ fdd„Z‡  ZS )ÚSubprocessWatcherMixinNc                    sJ   t ƒ  ¡  t ¡ }| ¡ | _|  | j¡ |  ¡ }| | j¡ | 	|¡ d S r   )
r!   r"   r   Úget_event_loop_policyZnew_event_loopr#   r$   ÚWatcherÚattach_loopÚset_child_watcher©r   ZpolicyÚwatcherr&   r   r   r"   ˜  s    

zSubprocessWatcherMixin.setUpc                    s:   t ƒ  ¡  t ¡ }| ¡ }| d ¡ | d ¡ | ¡  d S r   )r!   ÚtearDownr   rø   rÎ   rû   rú   r@   rü   r&   r   r   rþ   ¢  s    


zSubprocessWatcherMixin.tearDown)r   r   r   rù   r"   rþ   rF   r   r   r&   r   r÷   ”  s   
r÷   c                   @   s   e Zd ZejZdS )ÚSubprocessThreadedWatcherTestsN)r   r   r   r   ZThreadedChildWatcherrù   r   r   r   r   rÿ   ª  s   rÿ   zqbpo-38323: MultiLoopChildWatcher has a race condition                     and these tests can hang the test suitec                   @   s   e Zd ZejZdS )ÚSubprocessMultiLoopWatcherTestsN)r   r   r   r   ZMultiLoopChildWatcherrù   r   r   r   r   r   ¯  s   r   c                   @   s   e Zd ZejZdS )ÚSubprocessSafeWatcherTestsN)r   r   r   r   ZSafeChildWatcherrù   r   r   r   r   r  ¶  s   r  c                   @   s   e Zd ZejZdS )rÍ   N)r   r   r   r   ZFastChildWatcherrù   r   r   r   r   rÍ   »  s   rÍ   c                   C   s@   t tdƒsdS zt t t ¡ ¡¡ W n ty:   Y dS 0 dS )NÚ
pidfd_openFT)ÚhasattrÚosr@   r  ÚgetpidÚOSErrorr   r   r   r   Úhas_pidfd_supportÀ  s    
r  z(operating system does not support pidfdsc                   @   s   e Zd ZejZdS )ÚSubprocessPidfdWatcherTestsN)r   r   r   r   ZPidfdChildWatcherrù   r   r   r   r   r  É  s   r  c                       s   e Zd Z‡ fdd„Z‡  ZS )ÚSubprocessProactorTestsc                    s$   t ƒ  ¡  t ¡ | _|  | j¡ d S r   )r!   r"   r   ZProactorEventLoopr#   r$   r%   r&   r   r   r"   Õ  s    

zSubprocessProactorTests.setUp)r   r   r   r"   rF   r   r   r&   r   r	  Ó  s   r	  c                   @   s   e Zd Zdd„ ZdS )ÚGenericWatcherTestsc                    s$   ‡ fdd„}ˆ   ˆ j |ƒ ¡¡ d S )Nc                  “   sr   t  tj¡} d| j_t | ¡ ˆ  t¡, t	 
t tj¡dd¡I d H  W d   ƒ n1 sZ0    Y  | j ¡  d S )NFr	   rw   )r   Zcreate_authspecr   ZAbstractChildWatcherZ	is_activeZreturn_valuerû   r9   ÚRuntimeErrorr   rI   r   rê   rg   rs   Zadd_child_handlerZassert_not_called)rý   r%   r   r   rÞ   ß  s    
ÿ(zWGenericWatcherTests.test_create_subprocess_fails_with_inactive_watcher.<locals>.executerì   rß   r   r%   r   Ú2test_create_subprocess_fails_with_inactive_watcherÝ  s    zFGenericWatcherTests.test_create_subprocess_fails_with_inactive_watcherN)r   r   r   r  r   r   r   r   r
  Û  s   r
  Ú__main__)'r  r<   rg   rö   rÔ   r   r   r   r   Ztest.test_asyncior   r}   r(   r   rh   r   rs   rf   r“   rU   r   ZBaseSubprocessTransportr   ZTestCaser    rG   r÷   rÿ   Úskipr   r  rÍ   r  Z
skipUnlessr  r	  r
  r   Úmainr   r   r   r   Ú<module>   sf   
þ	A    ,ÿÿÿÿ	þÿ
