a
    åzeQ ã                   @   sŒ  d dl Zd dlZd dlZd dlZd dlZd dlZd dlZd dl	Z	d dl
Z
zd dlZW n eyj   dZY n0 d dlZ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ejdkrÂ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 d	lmZ d d
l m!Z! d dl m"Z"m#Z#m$Z$ dd„ Z%dd„ Z&dd„ Z'G dd„ dƒZ(G dd„ dej)ƒZ*G dd„ de*ƒZ+G dd„ dej,ƒZ-G dd„ dej)ƒZ.G dd„ dej/ƒZ0G dd„ dej1ƒZ2G d d!„ d!ƒZ3G d"d#„ d#ƒZ4ejdkrG d$d%„ d%e3ej5ƒZ6G d&d'„ d'e3e4ej5ƒZ7n”d dl8Z8G d(d)„ d)e3ƒZ9e:e8d*ƒrPG d+d,„ d,e9e4ej5ƒZ;e:e8d-ƒrrG d.d/„ d/e9e4ej5ƒZ<e:e8d0ƒr”G d1d2„ d2e9e4ej5ƒZ=G d3d%„ d%e9e4ej5ƒZ6d4d5„ Z>G d6d7„ d7ej5ƒZ?G d8d9„ d9ej5ƒZ@G d:d;„ d;ej5ƒZAG d<d=„ d=ej5ƒZBG d>d?„ d?ƒZCG d@dA„ dAeCej5ƒZDzd dlEZEW n ey<   Y n0 G dBdC„ dCeCej5ƒZFG dDdE„ dEej5ƒZGG dFdG„ dGej5ƒZHeIdHkrˆe J¡  dS )Ié    N)ÚmockÚwin32)Ú
coroutines)Úevents)Úproactor_events)Úselector_events)Úutils)Úsupport)Úsocket_helper)Ú	ALWAYS_EQÚLARGESTÚSMALLESTc                   C   s   t  d ¡ d S ©N)ÚasyncioÚset_event_loop_policy© r   r   ú3/usr/lib/python3.9/test/test_asyncio/test_events.pyÚtearDownModule'   s    r   c                  C   sF   t j d¡rdS t jdkrdS t ¡ d } ttt|  d¡ƒƒ} | dk S )NZaixTÚdarwinFr   Ú.)é
   é   )ÚsysÚplatformÚ
startswithZmac_verÚtupleÚmapÚintÚsplit)Úversionr   r   r   Úbroken_unix_getsockname+   s    
r    c                  C   s&   dd„ } t  ¡ }t  |¡ | | ƒ ¡S )Nc                   Ó   s   dS ©NÚhellor   r   r   r   r   Údoit7   s    z8_test_get_event_loop_new_process__sub_proc.<locals>.doit)r   Únew_event_loopÚset_event_loopÚrun_until_complete)r#   Úloopr   r   r   Ú*_test_get_event_loop_new_process__sub_proc6   s    
r(   c                   @   s,   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	S )
ÚCoroLikec                 C   s   d S r   r   )ÚselfÚvr   r   r   Úsend@   s    zCoroLike.sendc                 G   s   d S r   r   ©r*   Úexcr   r   r   ÚthrowC   s    zCoroLike.throwc                 C   s   d S r   r   ©r*   r   r   r   ÚcloseF   s    zCoroLike.closec                 C   s   d S r   r   r0   r   r   r   Ú	__await__I   s    zCoroLike.__await__N)Ú__name__Ú
__module__Ú__qualname__r,   r/   r1   r2   r   r   r   r   r)   ?   s   r)   c                   @   s>   e Zd ZdZdZddd„Zdd„ Zdd„ Zdd	„ Zd
d„ Z	dS )ÚMyBaseProtoNc                 C   s2   d | _ d| _d| _|d ur.| ¡ | _| ¡ | _d S ©NÚINITIALr   )Ú	transportÚstateÚnbytesÚcreate_futureÚ	connectedÚdone©r*   r'   r   r   r   Ú__init__Q   s    
zMyBaseProto.__init__c                 C   s"   || _ d| _| jr| j d ¡ d S ©NÚ	CONNECTED©r9   r:   r=   Ú
set_result©r*   r9   r   r   r   Úconnection_madeY   s    zMyBaseProto.connection_madec                 C   s   |  j t|ƒ7  _ d S r   ©r;   Úlen©r*   Údatar   r   r   Údata_received`   s    zMyBaseProto.data_receivedc                 C   s
   d| _ d S ©NÚEOF)r:   r0   r   r   r   Úeof_receivedd   s    zMyBaseProto.eof_receivedc                 C   s   d| _ | jr| j d ¡ d S ©NÚCLOSED©r:   r>   rD   r-   r   r   r   Úconnection_losth   s    zMyBaseProto.connection_lost)N)
r3   r4   r5   r=   r>   r@   rF   rK   rN   rR   r   r   r   r   r6   M   s   
r6   c                       s   e Zd Z‡ fdd„Z‡  ZS )ÚMyProtoc                    s   t ƒ  |¡ | d¡ d S )Ns%   GET / HTTP/1.0
Host: example.com

)ÚsuperrF   ÚwriterE   ©Ú	__class__r   r   rF   p   s    zMyProto.connection_made©r3   r4   r5   rF   Ú__classcell__r   r   rV   r   rS   o   s   rS   c                   @   s:   e Zd ZdZddd„Zdd„ Zdd„ Zdd	„ Zd
d„ ZdS )ÚMyDatagramProtoNc                 C   s"   d| _ d| _|d ur| ¡ | _d S r7   )r:   r;   r<   r>   r?   r   r   r   r@   x   s    zMyDatagramProto.__init__c                 C   s   || _ d| _d S )NÚINITIALIZED©r9   r:   rE   r   r   r   rF   ~   s    zMyDatagramProto.connection_madec                 C   s   |  j t|ƒ7  _ d S r   rG   ©r*   rJ   Úaddrr   r   r   Údatagram_receivedƒ   s    z!MyDatagramProto.datagram_receivedc                 C   s   d S r   r   r-   r   r   r   Úerror_received‡   s    zMyDatagramProto.error_receivedc                 C   s   d| _ | jr| j d ¡ d S rO   rQ   r-   r   r   r   rR   Š   s    zMyDatagramProto.connection_lost)N)	r3   r4   r5   r>   r@   rF   r_   r`   rR   r   r   r   r   rZ   u   s   
rZ   c                   @   s:   e Zd ZdZddd„Zdd„ Zdd„ Zdd	„ Zd
d„ ZdS )ÚMyReadPipeProtoNc                 C   s*   dg| _ d| _d | _|d ur&| ¡ | _d S r7   )r:   r;   r9   r<   r>   r?   r   r   r   r@   ”   s
    zMyReadPipeProto.__init__c                 C   s   || _ | j d¡ d S rA   )r9   r:   ÚappendrE   r   r   r   rF   ›   s    zMyReadPipeProto.connection_madec                 C   s   |  j t|ƒ7  _ d S r   rG   rI   r   r   r   rK       s    zMyReadPipeProto.data_receivedc                 C   s   | j  d¡ d S rL   )r:   rb   r0   r   r   r   rN   ¤   s    zMyReadPipeProto.eof_receivedc                 C   s8   d| j vr| j  d¡ | j  d¡ | jr4| j d ¡ d S )NrM   rP   )r:   rb   r>   rD   r-   r   r   r   rR   ¨   s
    
zMyReadPipeProto.connection_lost)N)	r3   r4   r5   r>   r@   rF   rK   rN   rR   r   r   r   r   ra   ‘   s   
ra   c                   @   s*   e Zd ZdZddd„Zdd„ Zdd„ ZdS )	ÚMyWritePipeProtoNc                 C   s"   d| _ d | _|d ur| ¡ | _d S )Nr8   )r:   r9   r<   r>   r?   r   r   r   r@   ´   s    zMyWritePipeProto.__init__c                 C   s   || _ d| _d S rA   r\   rE   r   r   r   rF   º   s    z MyWritePipeProto.connection_madec                 C   s   d| _ | jr| j d ¡ d S rO   rQ   r-   r   r   r   rR   ¿   s    z MyWritePipeProto.connection_lost)N)r3   r4   r5   r>   r@   rF   rR   r   r   r   r   rc   ±   s   
rc   c                   @   s<   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ ZdS )ÚMySubprocessProtocolc                    sb   d| _ d | _ˆ  ¡ | _ˆ  ¡ | _‡ fdd„tdƒD ƒ| _dddœ| _d | _t	 
¡ t	 
¡ dœ| _d S )Nr8   c                    s   i | ]}|ˆ   ¡ “qS r   )r<   )Ú.0Úfd©r'   r   r   Ú
<dictcomp>Í   ó    z1MySubprocessProtocol.__init__.<locals>.<dictcomp>é   ri   ©é   é   )r:   r9   r<   r=   Ú	completedÚrangeÚdisconnectsrJ   Ú
returncoder   ÚEventÚgot_datar?   r   rg   r   r@   È   s    

ÿzMySubprocessProtocol.__init__c                 C   s   || _ d| _| j d ¡ d S rA   rC   rE   r   r   r   rF   Ó   s    z$MySubprocessProtocol.connection_madec                 C   s   d| _ | j d ¡ d S rO   )r:   rn   rD   r-   r   r   r   rR   Ù   s    z$MySubprocessProtocol.connection_lostc                 C   s$   | j |  |7  < | j|  ¡  d S r   )rJ   rs   Úset)r*   rf   rJ   r   r   r   Úpipe_data_receivedÞ   s    z'MySubprocessProtocol.pipe_data_receivedc                 C   s*   |r| j |  |¡ n| j |  |¡ d S r   )rp   Úset_exceptionrD   )r*   rf   r.   r   r   r   Úpipe_connection_lostã   s    z)MySubprocessProtocol.pipe_connection_lostc                 C   s   | j  ¡ | _d S r   )r9   Zget_returncoderq   r0   r   r   r   Úprocess_exitedê   s    z#MySubprocessProtocol.process_exitedN)	r3   r4   r5   r@   rF   rR   ru   rw   rx   r   r   r   r   rd   Æ   s   rd   c                       s0  e Zd Z‡ fdd„Z‡ f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e eedƒd¡dd„ ƒZe eedƒd ¡d!d"„ ƒZe eedƒd ¡d#d$„ ƒZdœd&d'„Zd(d)„ Zejd*d+„ ƒZd%d,i fd-d.„Zdd/d0„Zdžd1d2„Ze e d,u d3¡d4d5„ ƒZ!eje e d,u d3¡d6d7„ ƒƒZ"d8d9„ Z#d:d;„ Z$dŸd<d=„Z%e e d,u d3¡d>d?„ ƒZ&d@dA„ Z'e( )dB¡dCdD„ ƒZ*dEdF„ Z+dGdH„ Z,dIdJ„ Z-e ee.dKƒdL¡dMdN„ ƒZ/dOdP„ Z0ejdQdR„ ƒZ1e ee.dSƒdT¡dUdV„ ƒZ2d dWdX„Z3d¡dYdZ„Z4d¢d[d\„Z5e e d,u d3¡d]d^„ ƒZ6eje e d,u d3¡d_d`„ ƒƒZ7e e d,u d3¡dadb„ ƒZ8eje e d,u d3¡dcdd„ ƒƒZ9e e d,u d3¡dedf„ ƒZ:eje e d,u d3¡dgdh„ ƒƒZ;e e d,u d3¡didj„ ƒZ<dkdl„ Z=dmdn„ Z>e ej?do¡dpdq„ ƒZ@drds„ ZAdtdu„ ZBdvdw„ ZCe ej?do¡dxdy„ ƒZDdzd{„ ZEd|d}„ ZFe eGjHd~kd¡d€d„ ƒZIe eGjHd~kd¡d‚dƒ„ ƒZJe eGjHd~kd¡d„d…„ ƒZKe eGjHd~kd¡d†d‡„ ƒZLe eGjHd~kd¡dˆd‰„ ƒZMe eGjHd~kd¡eN OdŠd‹¡dŒd„ ƒƒZPe eGjHd~kd¡eN OdŠd‹¡dŽd„ ƒƒZQdd‘„ ZRd’d“„ ZSd”d•„ ZTd–d—„ ZUd˜d™„ ZVdšd›„ ZW‡  ZXS )£ÚEventLoopTestsMixinc                    s$   t ƒ  ¡  |  ¡ | _|  | j¡ d S r   )rT   ÚsetUpÚcreate_event_loopr'   r%   r0   rV   r   r   rz   ñ   s    

zEventLoopTestsMixin.setUpc                    s4   | j  ¡ st | j ¡ |  ¡  t ¡  tƒ  ¡  d S r   )	r'   Ú	is_closedÚ
test_utilsÚrun_brieflyZ
doCleanupsr	   Ú
gc_collectrT   ÚtearDownr0   rV   r   r   r€   ö   s
    
zEventLoopTestsMixin.tearDownc                    sZ   dd„ ‰ ‡ ‡fdd„}ˆ  td¡$ ˆ tˆjj|ƒ ¡ W d   ƒ n1 sL0    Y  d S )Nc                   Ó   s   t  d¡I d H  d S ©Nr   )r   Úsleepr   r   r   r   Úcoro1   s    zBEventLoopTestsMixin.test_run_until_complete_nesting.<locals>.coro1c                   “   s"   ˆ  ˆj ¡ ¡ ˆj ˆ ƒ ¡ d S r   )Ú
assertTruer'   Ú
is_runningr&   r   ©rƒ   r*   r   r   Úcoro2  s    zBEventLoopTestsMixin.test_run_until_complete_nesting.<locals>.coro2zcoroutine \S+ was never awaited)ZassertWarnsRegexÚRuntimeWarningÚassertRaisesÚRuntimeErrorr'   r&   )r*   r‡   r   r†   r   Útest_run_until_complete_nestingÿ   s    þÿz3EventLoopTestsMixin.test_run_until_complete_nestingc                 C   sR   | j  ¡ }| j  t d¡¡ | j  ¡ }|  d||   ko@dkn  || ¡ d S )Nçš™™™™™¹?g{®Gáz´?gš™™™™™é?)r'   Útimer&   r   r‚   r„   )r*   Út0Út1r   r   r   Útest_run_until_complete  s    

z+EventLoopTestsMixin.test_run_until_completec                    s(   ‡ fdd„}|ƒ }ˆ   tˆ jj|¡ d S )Nc                   “   s   ˆ j  ¡  t d¡I d H  d S )NrŒ   )r'   Ústopr   r‚   r   r0   r   r   Úcb  s    
z?EventLoopTestsMixin.test_run_until_complete_stopped.<locals>.cb)r‰   rŠ   r'   r&   )r*   r’   Ztaskr   r0   r   Útest_run_until_complete_stopped  s
    ÿz3EventLoopTestsMixin.test_run_until_complete_stoppedc                    s>   g ‰ ‡ ‡fdd„}ˆj  d|d¡ ˆj  ¡  ˆ ˆ dg¡ d S )Nc                    s   ˆ   | ¡ ˆj ¡  d S r   ©rb   r'   r‘   ©Úarg©Úresultsr*   r   r   Úcallback#  s    
z5EventLoopTestsMixin.test_call_later.<locals>.callbackrŒ   zhello world)r'   Ú
call_laterÚrun_foreverÚassertEqual©r*   r™   r   r—   r   Útest_call_later   s
    
z#EventLoopTestsMixin.test_call_laterc                    s>   g ‰ ‡ ‡fdd„}ˆj  |dd¡ ˆj  ¡  ˆ ˆ dg¡ d S )Nc                    s   ˆ   | |f¡ ˆj ¡  d S r   r”   )Zarg1Zarg2r—   r   r   r™   .  s    z4EventLoopTestsMixin.test_call_soon.<locals>.callbackr"   Úworld)r"   rŸ   )r'   Ú	call_soonr›   rœ   r   r   r—   r   Útest_call_soon+  s
    
z"EventLoopTestsMixin.test_call_soonc                    sž   g ‰t  ¡ ‰‡‡fdd„‰ ‡ ‡‡fdd„}ˆ ¡  t j|d}| ¡  ˆ( ˆj ˆ d¡ ˆj ¡  W d   ƒ n1 sx0    Y  | ¡  ˆ 	ˆddg¡ d S )Nc                    s$   ˆ   | ¡ tˆ ƒdkr ˆj ¡  d S ©Nrm   ©rb   rH   r'   r‘   r•   r—   r   r   r™   :  s    
z?EventLoopTestsMixin.test_call_soon_threadsafe.<locals>.callbackc                      s   ˆj  ˆ d¡ ˆ ¡  d S r!   )r'   Úcall_soon_threadsafeÚreleaser   )r™   Úlockr*   r   r   Úrun_in_thread?  s    zDEventLoopTestsMixin.test_call_soon_threadsafe.<locals>.run_in_thread©ÚtargetrŸ   r"   )
Ú	threadingÚLockÚacquireÚThreadÚstartr'   r    r›   Újoinrœ   )r*   r§   Útr   )r™   r¦   r˜   r*   r   Útest_call_soon_threadsafe6  s    (z-EventLoopTestsMixin.test_call_soon_threadsafec                    sL   g ‰ ‡ ‡fdd„}ˆj  |d¡ ˆj  |d¡ ˆj  ¡  ˆ ˆ ddg¡ d S )Nc                    s$   ˆ   | ¡ tˆ ƒdkr ˆj ¡  d S r¢   r£   r•   r—   r   r   r™   P  s    
zKEventLoopTestsMixin.test_call_soon_threadsafe_same_thread.<locals>.callbackr"   rŸ   )r'   r¤   r    r›   rœ   r   r   r—   r   Ú%test_call_soon_threadsafe_same_threadM  s    
z9EventLoopTestsMixin.test_call_soon_threadsafe_same_threadc                 C   sH   dd„ }| j  d |d¡}| j  |¡\}}|  |d¡ |  |t ¡ ¡ d S )Nc                 S   s   | t  ¡ fS r   )rª   Ú	get_identr•   r   r   r   Úrun[  s    z5EventLoopTestsMixin.test_run_in_executor.<locals>.runZyo)r'   Úrun_in_executorr&   rœ   ZassertNotEqualrª   r³   )r*   r´   Úf2ÚresZ	thread_idr   r   r   Útest_run_in_executorZ  s
    z(EventLoopTestsMixin.test_run_in_executorc                    sr   d‰ ‡ fdd„}dd„ }| j  d |¡}| ¡  | j  | j  ¡ ¡ | j  ¡  || j _|| j _t 	d¡ |  
ˆ ¡ d S )NFc                     s   d‰ d S ©NTr   ©Úargs©Zcalledr   r   Úpatched_call_soone  s    zJEventLoopTestsMixin.test_run_in_executor_cancel.<locals>.patched_call_soonc                   S   s   t  d¡ d S )Ngš™™™™™©?)r   r‚   r   r   r   r   r´   i  s    z<EventLoopTestsMixin.test_run_in_executor_cancel.<locals>.rungš™™™™™Ù?)r'   rµ   Úcancelr&   Zshutdown_default_executorr1   r    r¤   r   r‚   ÚassertFalse)r*   r½   r´   r¶   r   r¼   r   Útest_run_in_executor_cancelb  s    ÿ

z/EventLoopTestsMixin.test_run_in_executor_cancelc                    sÂ   t  ¡ \‰}ˆ d¡ tƒ ‰ ‡ ‡‡fdd„}ˆj ˆ ¡ |¡ ˆj |jd¡ t	 
ˆj‡ fdd„¡ ˆj |jd¡ t	 
ˆj‡ fdd„¡ ˆj |j¡ ˆj ˆjj¡ ˆj ¡  ˆ ˆ d	¡ d S )
NFc                     sV   zˆ  d¡} W n ty"   Y d S 0 | r4ˆ  | ¡ nˆ ˆj ˆ ¡ ¡¡ ˆ ¡  d S ©Né   )ÚrecvÚBlockingIOErrorÚextendr„   r'   Úremove_readerÚfilenor1   ©rJ   ©Ú
bytes_readÚrr*   r   r   Úreader{  s    z8EventLoopTestsMixin.test_reader_callback.<locals>.readers   abcc                      s   t ˆ ƒdkS )Nrj   ©rH   r   ©rÊ   r   r   Ú<lambda>Š  ri   z:EventLoopTestsMixin.test_reader_callback.<locals>.<lambda>s   defc                      s   t ˆ ƒdkS )Né   rÍ   r   rÎ   r   r   rÏ   Œ  ri   s   abcdef)ÚsocketÚ
socketpairÚsetblockingÚ	bytearrayr'   Ú
add_readerrÇ   r    r,   r}   Ú	run_untilr1   r‘   r›   rœ   )r*   ÚwrÌ   r   rÉ   r   Útest_reader_callbackv  s    

z(EventLoopTestsMixin.test_reader_callbackc                    s¤   t  ¡ \}‰ˆ d¡ ‡ ‡fdd„}d}ˆ j ˆ ¡ ||¡ ˆ j ¡  ˆ  ˆ j ˆ ¡ ¡¡ ˆ  	ˆ j ˆ ¡ ¡¡ ˆ 
¡  | t|ƒd ¡}| 
¡  ˆ  ||¡ d S )NFc                    s   ˆ  | ¡ ˆ j ¡  d S r   )r,   r'   r‘   rÈ   ©r*   r×   r   r   Úwriter–  s    
z8EventLoopTestsMixin.test_writer_callback.<locals>.writers   xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxrm   )rÑ   rÒ   rÓ   r'   Ú
add_writerrÇ   r›   r„   Úremove_writerr¿   r1   rÃ   rH   rœ   )r*   rË   rÚ   rJ   Úreadr   rÙ   r   Útest_writer_callback’  s    

z(EventLoopTestsMixin.test_writer_callbackÚSIGKILLz
No SIGKILLc                    sX  d‰ ‡ fdd„}|   t| jjd|¡ |   t| jjd¡ |   t| jjtjd |¡ |   t| jjtjd ¡ |   t| jjd|¡ |   t| jjd¡ |   t| jjd|¡ |   t| jjd¡ |   t| jjtj	|¡ |  
| j tj	¡¡ | j tj|¡ t t ¡ tj¡ t | j‡ fdd„¡ |  | j tj¡¡ |  t tj¡tj¡ |  
| j tj¡¡ d S )	Nr   c                      s   ˆ d7 ‰ d S ©Nrl   r   r   ©Úcaughtr   r   Ú
my_handlerª  s    z?EventLoopTestsMixin.test_add_signal_handler.<locals>.my_handlerZboomrl   éÿÿÿÿc                      s   ˆ S r   r   r   rá   r   r   rÏ   É  ri   z=EventLoopTestsMixin.test_add_signal_handler.<locals>.<lambda>)r‰   Ú	TypeErrorr'   Úadd_signal_handlerÚremove_signal_handlerÚ
ValueErrorÚsignalÚNSIGrŠ   rß   r¿   ÚSIGINTÚosÚkillÚgetpidr}   rÖ   r„   rœ   Ú	getsignalÚdefault_int_handler©r*   rã   r   rá   r   Útest_add_signal_handler¦  sP    ÿ
ÿþÿÿ
ÿÿ
ÿþÿz+EventLoopTestsMixin.test_add_signal_handlerÚSIGALRMz
No SIGALRMc                    s^   d‰ ‡ ‡fdd„}ˆj  tj|¡ t tjdd¡ ˆj  dˆj j¡ ˆj  ¡  ˆ 	ˆ d¡ d S )Nr   c                      s   ˆ d7 ‰ ˆj  ¡  d S rà   )r'   r‘   r   ©râ   r*   r   r   rã   ×  s    zLEventLoopTestsMixin.test_signal_handling_while_selecting.<locals>.my_handlerç{®Gáz„?é<   rl   ©
r'   ræ   ré   ró   Ú	setitimerÚITIMER_REALrš   r‘   r›   rœ   rñ   r   rô   r   Ú$test_signal_handling_while_selectingÒ  s    
z8EventLoopTestsMixin.test_signal_handling_while_selectingc                    sl   d‰d‰ ‡ ‡‡fdd„}ˆj jtj|gˆ¢R Ž  t tjdd¡ ˆj  dˆj j¡ ˆj  ¡  ˆ 	ˆ d¡ d S )N)é*   r   c                     s"   ˆ d7 ‰ ˆ  | ˆ¡ ˆj ¡  d S rà   )rœ   r'   r‘   rº   ©râ   r*   Z	some_argsr   r   rã   è  s    zAEventLoopTestsMixin.test_signal_handling_args.<locals>.my_handlerrŒ   rö   rl   r÷   rñ   r   rü   r   Útest_signal_handling_argsã  s    
z-EventLoopTestsMixin.test_signal_handling_argsTc                 C   sv   | j  |¡\}}|  |tj¡ |  |tj¡ |  |j|¡ |rN|  | 	d¡¡ | j  |j
¡ |  |jd¡ | ¡  d S )NÚsocknamer   )r'   r&   ÚassertIsInstancer   Ú	TransportÚProtocolÚassertIsr9   ÚassertIsNotNoneÚget_extra_infor>   ÚassertGreaterr;   r1   )r*   Úconnection_futÚcheck_socknameÚtrÚprr   r   r   Ú_basetest_create_connectionõ  s    z/EventLoopTestsMixin._basetest_create_connectionc                    sT   t  ¡ 8}ˆ jj‡ fdd„g|j¢R Ž }ˆ  |¡ W d   ƒ n1 sF0    Y  d S )Nc                      s   t ˆ jdS ©Nrg   ©rS   r'   r   r0   r   r   rÏ     ri   z<EventLoopTestsMixin.test_create_connection.<locals>.<lambda>)r}   Úrun_test_serverr'   Úcreate_connectionÚaddressr
  )r*   ÚhttpdÚconn_futr   r0   r   Útest_create_connection   s    

ÿÿz*EventLoopTestsMixin.test_create_connectionc                    sX   t ƒ  }t ¡ 4}ˆ j ‡ fdd„|j¡}ˆ  ||¡ W d   ƒ n1 sJ0    Y  d S )Nc                      s   t ˆ jdS r  r  r   r0   r   r   rÏ     ri   zAEventLoopTestsMixin.test_create_unix_connection.<locals>.<lambda>)r    r}   Úrun_test_unix_serverr'   Úcreate_unix_connectionr  r
  )r*   r  r  r  r   r0   r   Útest_create_unix_connection  s    
ÿz/EventLoopTestsMixin.test_create_unix_connectionNc                 C   s  |r|   | d¡¡ |r,|  || d¡¡ n|   | d¡¡ |  || d¡¡ | d¡}|  |t¡ |  t|ƒd|¡ |  |d t¡ |  |d t¡ |  |d t¡ | d	¡}|   |¡ |  | ¡ | d
¡¡ |  | 	¡ | d¡¡ |  | 
¡ | d¡¡ |  | ¡ | d
¡¡ d S )Nrþ   ÚpeernameÚpeercertÚcipherrj   r   rl   rm   Z
ssl_objectÚcompression)r  r  rœ   rÿ   r   rH   Ústrr   r  r  Zgetpeercert)r*   Úclientr  r  r  r  Zsslobjr   r   r   Úcheck_ssl_extra_info  s<    ÿÿ



ÿ
ÿ
ÿ
ÿz(EventLoopTestsMixin.check_ssl_extra_infoc                 C   sx   | j  |¡\}}|  |tj¡ |  |tj¡ |  d|jj 	¡ v ¡ |  
|||¡ | j  |j¡ |  |jd¡ | ¡  d S )NÚsslr   )r'   r&   rÿ   r   r   r  r„   rW   r3   Úlowerr  r>   r  r;   r1   )r*   r  r  r  r  r	  r   r   r   Ú_basetest_create_ssl_connection1  s    z3EventLoopTestsMixin._basetest_create_ssl_connectionc           	   	      s  |t  ¡ d}ˆ  |||¡ ttdƒr˜tjjfd d d dœ‡ fdd„}tjd|d6}|dd}ˆ  |||¡ ˆ  	|j
d	¡ W d   ƒ n1 sŽ0    Y  ˆ  tj¡P}|dd}t  ¡  ˆ  |||¡ W d   ƒ n1 sÜ0    Y  W d   ƒ n1 sú0    Y  ˆ  	|jjd
¡ d S )N©r  ÚPurpose)ÚcafileÚcapathÚcadatac                   s   ˆ   | tjj¡ t ¡ S r   )rœ   r  r!  ÚSERVER_AUTHr}   Údummy_ssl_context)Zpurposer"  r#  r$  r0   r   r   Ú_dummy_ssl_create_contextE  s    zREventLoopTestsMixin._test_create_ssl_connection.<locals>._dummy_ssl_create_contextzssl.create_default_context)Úside_effectTrl   ZCERTIFICATE_VERIFY_FAILED)r}   r&  r  Úhasattrr  r!  r%  r   Úpatchrœ   Z
call_countr‰   ÚSSLErrorÚdisable_loggerÚ	exceptionÚreason)	r*   r  r  r  r  r  r'  ÚmÚcmr   r0   r   Ú_test_create_ssl_connection=  s2    ÿ
þÿ
ÿ,

ÿ@z/EventLoopTestsMixin._test_create_ssl_connectionzNo ssl modulec                    sd   t jddD}tjˆ jj‡ fdd„g|j¢R Ž }ˆ j|||jd W d   ƒ n1 sV0    Y  d S )NT©Zuse_sslc                      s   t ˆ jdS r  r  r   r0   r   r   rÏ   g  ri   z@EventLoopTestsMixin.test_create_ssl_connection.<locals>.<lambda>©r  )r}   r  Ú	functoolsÚpartialr'   r  r  r1  )r*   r  r  r   r0   r   Útest_create_ssl_connectionb  s    
þýÿz.EventLoopTestsMixin.test_create_ssl_connectionc                    sl   t ƒ  }tjddD}tjˆ jj‡ fdd„|jdd}ˆ j||||jd W d   ƒ n1 s^0    Y  d S )NTr2  c                      s   t ˆ jdS r  r  r   r0   r   r   rÏ   v  ri   zEEventLoopTestsMixin.test_create_ssl_unix_connection.<locals>.<lambda>ú	127.0.0.1)Úserver_hostnamer3  )	r    r}   r  r4  r5  r'   r  r  r1  )r*   r  r  r  r   r0   r   Útest_create_ssl_unix_connectionl  s    ýþz3EventLoopTestsMixin.test_create_ssl_unix_connectionc                    s–   t  ¡ z}t ¡ }ˆ jj‡ fdd„g|j¢R d|jd |fiŽ}ˆ j |¡\}}|j 	d¡d }ˆ  
||¡ | ¡  W d   ƒ n1 sˆ0    Y  d S )Nc                      s   t ˆ jdS r  r  r   r0   r   r   rÏ     ri   zGEventLoopTestsMixin.test_create_connection_local_addr.<locals>.<lambda>Ú
local_addrr   rþ   rl   )r}   r  r
   Úfind_unused_portr'   r  r  r&   r9   r  rœ   r1   )r*   r  ÚportÚfr  r	  Zexpectedr   r0   r   Ú!test_create_connection_local_addr}  s    

ÿþþz5EventLoopTestsMixin.test_create_connection_local_addrc              	      s°   t  ¡ ”}ˆ jj‡ fdd„g|j¢R d|jiŽ}ˆ  t¡}ˆ j |¡ W d   ƒ n1 s\0    Y  ˆ  |j	j
t
j¡ ˆ  t|jƒ|j	j¡ W d   ƒ n1 s¢0    Y  d S )Nc                      s   t ˆ jdS r  r  r   r0   r   r   rÏ   ‹  ri   zNEventLoopTestsMixin.test_create_connection_local_addr_in_use.<locals>.<lambda>r:  )r}   r  r'   r  r  r‰   ÚOSErrorr&   rœ   r-  ÚerrnoÚ
EADDRINUSEÚassertInr  Ústrerror)r*   r  r=  r0  r   r0   r   Ú(test_create_connection_local_addr_in_useˆ  s    

ÿþþ*z<EventLoopTestsMixin.test_create_connection_local_addr_in_usec           	         s  | j ‰G ‡‡fdd„dtƒ}tjddd}| ¡ ‰ d‰d ‰d‰‡ ‡‡‡fdd	„}tj|d
d}| ¡  | ¡ \}}|ˆd‰ˆˆ_ ˆ 	ˆj
‡fdd„||d¡ ˆ ¡  ˆj ¡  | ¡  t |¡ |  | ¡ ¡ |  ˆjd¡ |  ˆjtˆƒ¡ |  ˆˆ¡ d S )Nc                       s,   e Zd Z‡ ‡fdd„Z‡ ‡fdd„Z‡  ZS )zAEventLoopTestsMixin.test_connect_accepted_socket.<locals>.MyProtoc                    s   t ƒ  |¡ ˆ ˆj¡ d S r   )rT   rR   r    r‘   r-   )rW   r'   r   r   rR   —  s    zQEventLoopTestsMixin.test_connect_accepted_socket.<locals>.MyProto.connection_lostc                    s   t ƒ  |¡ | j ˆ¡ d S r   )rT   rK   r9   rU   rI   )rW   Úexpected_responser   r   rK   ›  s    zOEventLoopTestsMixin.test_connect_accepted_socket.<locals>.MyProto.data_received)r3   r4   r5   rR   rK   rY   r   )rE  r'   rV   r   rS   •  s   rS   ©r7  r   rl   )Úbacklogs	   test datas   rogerc               
      sx   zDt   ¡ } ˆd urˆ | ¡} |  ˆ ¡ |  ˆ¡ |  d¡‰|  ¡  W n. tyr } ztd|ƒ W Y d }~n
d }~0 0 d S )Néc   z8Failure in client thread in test_connect_accepted_socket)rÑ   Zwrap_socketÚconnectÚsendallrÃ   r1   Ú	ExceptionÚprint)Zcsockr.   )r^   Ú
client_sslÚmessageÚresponser   r   r  ¦  s    



þz@EventLoopTestsMixin.test_connect_accepted_socket.<locals>.clientT)r©   Údaemonrg   c                      s   ˆ S r   r   r   ©Úprotor   r   rÏ   ½  ri   zBEventLoopTestsMixin.test_connect_accepted_socket.<locals>.<lambda>r   rP   )r'   r6   rÑ   Úcreate_serverÚgetsocknamerª   r­   r®   Úacceptr&   Úconnect_accepted_socketr›   r9   r1   r	   Újoin_threadr¿   Úis_aliverœ   r:   r;   rH   )	r*   Z
server_sslrM  rS   Zlsockr  ÚthreadÚconnÚ_r   )r^   rM  rE  r'   rN  rR  rO  r   Útest_connect_accepted_socket’  s4    

ÿÿ

z0EventLoopTestsMixin.test_connect_accepted_socketc                 C   sL   t jdkr,t jdk r,t| jtjƒr,t d¡‚t	 
¡ }t	 ¡ }|  ||¡ d S )Nr   )rj   r   z=SSL not supported with proactor event loops before Python 3.5)r   r   Úversion_infoÚ
isinstancer'   r   ZBaseProactorEventLoopÚunittestÚSkipTestr}   Zsimple_server_sslcontextZsimple_client_sslcontextr\  )r*   Zserver_contextZclient_contextr   r   r   Ú test_ssl_connect_accepted_socketÈ  s    
ÿþÿz4EventLoopTestsMixin.test_ssl_connect_accepted_socketc                 C   sd   t   ¡ }|  |j¡ | jjt|tjd}|  t	d¡ | j 
|¡ W d   ƒ n1 sV0    Y  d S )N)Zssl_handshake_timeoutz1ssl_handshake_timeout is only meaningful with ssl)rÑ   Ú
addCleanupr1   r'   rV  rS   r	   ZLOOPBACK_TIMEOUTÚassertRaisesRegexrè   r&   )r*   ÚsockÚcoror   r   r   Ú9test_connect_accepted_socket_ssl_timeout_for_plain_socket×  s    ÿþzMEventLoopTestsMixin.test_connect_accepted_socket_ssl_timeout_for_plain_socketzasyncio.base_events.socketc           	         sÊ   ‡ fdd„‰‡‡fdd„}t |ƒ}ˆ tjkrDdd„ |D ƒ| ¡ j_ndd„ |D ƒ| ¡ j_|ˆj_t ¡ ˆj_	t ¡ ˆj_
ˆj ‡fdd	„|d
¡}ˆj |¡}ˆ |j¡ dd„ |jD ƒ}ˆ ||¡ d S )Nc                 Ÿ   s>   ˆ t jkr ˆ t jdd| |ffgS ˆ t jdd| |ddffgS d S )NrÐ   Ú r   )rÑ   ÚAF_INETÚSOCK_STREAM)Úhostr<  r»   Úkw)Úfamilyr   r   Úgetaddrinfoã  s    
zEEventLoopTestsMixin.create_server_multiple_hosts.<locals>.getaddrinfoc                     s   ˆj  ˆ | i |¤Ž¡S r   )r'   Úcreate_task)r»   Úkwds)rm  r*   r   r   Úgetaddrinfo_taské  s    zJEventLoopTestsMixin.create_server_multiple_hosts.<locals>.getaddrinfo_taskc                 S   s   g | ]}|d f‘qS )éP   r   ©re   rj  r   r   r   Ú
<listcomp>ï  s   zDEventLoopTestsMixin.create_server_multiple_hosts.<locals>.<listcomp>c                 S   s   g | ]}|d ddf‘qS )rq  r   r   rr  r   r   r   rs  ò  s   c                      s
   t ˆ jƒS r   r  r   r0   r   r   rÏ   ÷  ri   zBEventLoopTestsMixin.create_server_multiple_hosts.<locals>.<lambda>rq  c                 S   s   h | ]}|  ¡ d  ’qS )r   )Úgetsockbyname)re   rd  r   r   r   Ú	<setcomp>ú  ri   zCEventLoopTestsMixin.create_server_multiple_hosts.<locals>.<setcomp>)rt   rÑ   rh  rt  r(  r'   rm  r   ÚMockZ_start_servingÚ_stop_servingrS  r&   rb  r1   Úsocketsrœ   )	r*   rl  ZhostsZ	mock_sockrp  Zunique_hostsr=  ÚserverZserver_hostsr   )rl  rm  r*   r   Úcreate_server_multiple_hostsá  s$    
ÿÿz0EventLoopTestsMixin.create_server_multiple_hostsc                 C   s   |   tjg d¢¡ d S )N)ú1.2.3.4z5.6.7.8r{  )rz  rÑ   rh  r0   r   r   r   Ú&test_create_server_multiple_hosts_ipv4ý  s    ÿz:EventLoopTestsMixin.test_create_server_multiple_hosts_ipv4c                 C   s   |   tjg d¢¡ d S )N)ú::1z::2r}  )rz  rÑ   ÚAF_INET6r0   r   r   r   Ú&test_create_server_multiple_hosts_ipv6  s    ÿz:EventLoopTestsMixin.test_create_server_multiple_hosts_ipv6c                    s&  t | jƒ‰ | j ‡ fdd„dd¡}| j |¡}|  t|jƒd¡ |jd }| ¡ \}}|  |d¡ t ¡ }| 	d|f¡ | 
d¡ | j ˆ j¡ |  dˆ j¡ t | j‡ fd	d„¡ |  d
ˆ j¡ |  ˆ j d¡¡ |  dˆ j d¡d ¡ ˆ j ¡  | j ˆ j¡ |  dˆ j¡ | ¡  | ¡  d S )Nc                      s   ˆ S r   r   r   rQ  r   r   rÏ     ri   z8EventLoopTestsMixin.test_create_server.<locals>.<lambda>ú0.0.0.0r   rl   r7  ó   xxxrB   c                      s
   ˆ j dkS r   ©r;   r   rQ  r   r   rÏ     ri   rj   rþ   r  rP   )rS   r'   rS  r&   rœ   rH   rx  rT  rÑ   rI  rJ  r=   r:   r}   rÖ   r;   r  r9   r  r1   r>   ©r*   r=  ry  rd  rj  r<  r  r   rQ  r   Útest_create_server  s.    


ÿ
z&EventLoopTestsMixin.test_create_serverÚSO_REUSEPORTzNo SO_REUSEPORTc                    sä   t | jƒ‰ | j ‡ fdd„dd¡}| j |¡}|  t|jƒd¡ |jd }|  | t	j
t	j¡¡ | ¡  t | j¡ t | jƒ‰ | jj‡ fdd„dddd}| j |¡}|  t|jƒd¡ |jd }|  | t	j
t	j¡¡ | ¡  d S )	Nc                      s   ˆ S r   r   r   rQ  r   r   rÏ   -  ri   zCEventLoopTestsMixin.test_create_server_reuse_port.<locals>.<lambda>r€  r   rl   c                      s   ˆ S r   r   r   rQ  r   r   rÏ   :  ri   T)Ú
reuse_port)rS   r'   rS  r&   rœ   rH   rx  r¿   Ú
getsockoptrÑ   Ú
SOL_SOCKETr…  r1   r}   r~   r„   )r*   r=  ry  rd  r   rQ  r   Útest_create_server_reuse_port)  s6    
ÿ
ÿÿ
ÿ
ÿÿz1EventLoopTestsMixin.test_create_server_reuse_portc                    sD   t  ¡ ‰ |  ‡ fdd„¡ | jj|ˆ fi |¤Ž}| j |¡}|ˆ fS )Nc                      s   t j ˆ ¡ot  ˆ ¡S r   )rì   ÚpathÚexistsÚunlinkr   ©rŠ  r   r   rÏ   E  ri   z7EventLoopTestsMixin._make_unix_server.<locals>.<lambda>)r}   Zgen_unix_socket_pathrb  r'   Úcreate_unix_serverr&   )r*   ÚfactoryÚkwargsr=  ry  r   r  r   Ú_make_unix_serverC  s
    z%EventLoopTestsMixin._make_unix_serverc                    sÎ   t | jd‰ |  ‡ fdd„¡\}}|  t|jƒd¡ t tj¡}| |¡ | 	d¡ | j 
ˆ j¡ |  dˆ j¡ t | j‡ fdd„¡ |  dˆ j¡ ˆ j ¡  | j 
ˆ j¡ |  d	ˆ j¡ | ¡  | ¡  d S )
Nrg   c                      s   ˆ S r   r   r   rQ  r   r   rÏ   O  ri   z=EventLoopTestsMixin.test_create_unix_server.<locals>.<lambda>rl   r  rB   c                      s
   ˆ j dkS r   r‚  r   rQ  r   r   rÏ   X  ri   rj   rP   )rS   r'   r‘  rœ   rH   rx  rÑ   ÚAF_UNIXrI  rJ  r&   r=   r:   r}   rÖ   r;   r9   r1   r>   )r*   ry  rŠ  r  r   rQ  r   Útest_create_unix_serverL  s    


z+EventLoopTestsMixin.test_create_unix_serverr’  zNo UNIX Socketsc              	      sŽ   t | jd‰ t ¡ }|b | jj‡ fdd„d|d}|  td¡ | j |¡ W d   ƒ n1 sb0    Y  W d   ƒ n1 s€0    Y  d S )Nrg   c                      s   ˆ S r   r   r   rQ  r   r   rÏ   m  ri   zOEventLoopTestsMixin.test_create_unix_server_path_socket_error.<locals>.<lambda>z/test©rd  z3path and sock can not be specified at the same time)rS   r'   rÑ   rŽ  rc  rè   r&   )r*   rd  r=  r   rQ  r   Ú)test_create_unix_server_path_socket_errorh  s    ÿz=EventLoopTestsMixin.test_create_unix_server_path_socket_errorc                 C   s,   t  t j¡}| jt jO  _| ||¡ |S r   )r  Ú
SSLContextZPROTOCOL_TLS_SERVERÚoptionsÚOP_NO_SSLv2Zload_cert_chain)r*   ÚcertfileÚkeyfileÚ
sslcontextr   r   r   Ú_create_ssl_contexts  s    z'EventLoopTestsMixin._create_ssl_contextc           
      C   sX   |   ||¡}| jj|dd|d}| j |¡}|jd }| ¡ \}}	|  |d¡ |||	fS )Nr7  r   r   )rœ  r'   rS  r&   rx  rT  rœ   )
r*   r  r™  rš  r›  r=  ry  rd  rj  r<  r   r   r   Ú_make_ssl_servery  s    
z$EventLoopTestsMixin._make_ssl_serverc                 C   s   |   ||¡}| j||dS )Nr   )rœ  r‘  )r*   r  r™  rš  r›  r   r   r   Ú_make_ssl_unix_server„  s    z)EventLoopTestsMixin._make_ssl_unix_serverc                    sê   t | jd‰ |  ‡ fdd„tjtj¡\}}}| jjt||t ¡ d}| j 	|¡\}}| 
d¡ | j 	ˆ j¡ |  dˆ j¡ t | j‡ fdd„¡ |  dˆ j¡ | j|||fd	 ˆ j ¡  | j 	ˆ j¡ |  d
ˆ j¡ | ¡  | ¡  d S )Nrg   c                      s   ˆ S r   r   r   rQ  r   r   rÏ   Œ  ri   z<EventLoopTestsMixin.test_create_server_ssl.<locals>.<lambda>r   r  rB   c                      s
   ˆ j dkS r   r‚  r   rQ  r   r   rÏ   –  ri   rj   r3  rP   )rS   r'   r  r}   ÚONLYCERTÚONLYKEYr  r6   r&  r&   rU   r=   rœ   r:   rÖ   r;   r  r9   r1   r>   )r*   ry  rj  r<  Úf_cr  r	  r   rQ  r   Útest_create_server_sslˆ  s&    ÿ
ÿ

z*EventLoopTestsMixin.test_create_server_sslc                    sÖ   t | jd‰ |  ‡ fdd„tjtj¡\}}| jjt|t ¡ dd}| j 	|¡\}}| 
d¡ | j 	ˆ j¡ |  dˆ j¡ t | j‡ fdd„¡ |  d	ˆ j¡ ˆ j ¡  | j 	ˆ j¡ |  d
ˆ j¡ | ¡  | ¡  d S )Nrg   c                      s   ˆ S r   r   r   rQ  r   r   rÏ   ­  ri   zAEventLoopTestsMixin.test_create_unix_server_ssl.<locals>.<lambda>rg  ©r  r8  r  rB   c                      s
   ˆ j dkS r   r‚  r   rQ  r   r   rÏ   ¸  ri   rj   rP   )rS   r'   rž  r}   rŸ  r   r  r6   r&  r&   rU   r=   rœ   r:   rÖ   r;   r9   r1   r>   )r*   ry  rŠ  r¡  r  r	  r   rQ  r   Útest_create_unix_server_ssl¨  s&    ÿ
þ

z/EventLoopTestsMixin.test_create_unix_server_sslc              
      s(  t | jd‰ |  ‡ fdd„tj¡\}}}t tj¡}| jtj	O  _tj
|_t|dƒr\d|_| jjt |||d}tj | jd¡~ t ¡ J |  tjd¡ | j |¡ W d   ƒ n1 s¼0    Y  W d   ƒ n1 sÚ0    Y  t | j¡ W d   ƒ n1 s0    Y  |  ˆ j¡ | ¡  d S )	Nrg   c                      s   ˆ S r   r   r   rQ  r   r   rÏ   Ë  ri   zJEventLoopTestsMixin.test_create_server_ssl_verify_failed.<locals>.<lambda>Úcheck_hostnameTr   Úcall_exception_handlerú(?i)certificate.verify.failed)rS   r'   r  r}   ÚSIGNED_CERTFILEr  r–  ÚPROTOCOL_TLS_CLIENTr—  r˜  ÚCERT_REQUIREDÚverify_moder)  r¥  r  r   r*  Úobjectr,  rc  r+  r&   r~   ÚassertIsNoner9   r1   ©r*   ry  rj  r<  Ússlcontext_clientr¡  r   rQ  r   Ú$test_create_server_ssl_verify_failedÇ  s*    ÿ

ÿ
ÿH,z8EventLoopTestsMixin.test_create_server_ssl_verify_failedc              
      s&  t | jd‰ |  ‡ fdd„tj¡\}}t tj¡}| jtj	O  _tj
|_t|dƒrZd|_| jjt ||dd}tj | jd¡~ t ¡ J |  tjd	¡ | j |¡ W d   ƒ n1 sº0    Y  W d   ƒ n1 sØ0    Y  t | j¡ W d   ƒ n1 s0    Y  |  ˆ j¡ | ¡  d S )
Nrg   c                      s   ˆ S r   r   r   rQ  r   r   rÏ   é  ri   zOEventLoopTestsMixin.test_create_unix_server_ssl_verify_failed.<locals>.<lambda>r¥  TÚinvalidr£  r¦  r§  )rS   r'   rž  r}   r¨  r  r–  r©  r—  r˜  rª  r«  r)  r¥  r  r   r*  r¬  r,  rc  r+  r&   r~   r­  r9   r1   )r*   ry  rŠ  r¯  r¡  r   rQ  r   Ú)test_create_unix_server_ssl_verify_failedä  s,    ÿ

þ
ÿH,z=EventLoopTestsMixin.test_create_unix_server_ssl_verify_failedc              
      s*  t | jd‰ |  ‡ fdd„tj¡\}}}t tj¡}| jtj	O  _tj
|_|jtjd t|dƒrjd|_| jjt |||d}tj | jd¡r t ¡ J |  tjd	¡ | j |¡ W d   ƒ n1 sÊ0    Y  W d   ƒ n1 sè0    Y  W d   ƒ n1 s0    Y  |  ˆ j¡ | ¡  d S )
Nrg   c                      s   ˆ S r   r   r   rQ  r   r   rÏ     ri   zIEventLoopTestsMixin.test_create_server_ssl_match_failed.<locals>.<lambda>©r"  r¥  Tr   r¦  z=IP address mismatch, certificate is not valid for '127.0.0.1')rS   r'   r  r}   r¨  r  r–  r©  r—  r˜  rª  r«  Úload_verify_locationsÚ
SIGNING_CAr)  r¥  r  r   r*  r¬  r,  rc  ZCertificateErrorr&   r­  r9   r1   r®  r   rQ  r   Ú#test_create_server_ssl_match_failed  s0    ÿ
ÿ
ÿ
þhz7EventLoopTestsMixin.test_create_server_ssl_match_failedc                    sÆ   t | jd‰ |  ‡ fdd„tj¡\}}t tj¡}| jtj	O  _tj
|_|jtjd t|dƒrhd|_| jjt ||dd}| j |¡\}}| j ˆ j¡ ˆ j ¡  | ¡  | ¡  | j ˆ j¡ d S )	Nrg   c                      s   ˆ S r   r   r   rQ  r   r   rÏ   %  ri   zJEventLoopTestsMixin.test_create_unix_server_ssl_verified.<locals>.<lambda>r³  r¥  TÚ	localhostr£  )rS   r'   rž  r}   r¨  r  r–  r©  r—  r˜  rª  r«  r´  rµ  r)  r¥  r  r&   r=   r9   r1   r>   )r*   ry  rŠ  r¯  r¡  r  r	  r   rQ  r   Ú$test_create_unix_server_ssl_verified   s(    ÿ

þ
z8EventLoopTestsMixin.test_create_unix_server_ssl_verifiedc                    sà   t | jd‰ |  ‡ fdd„tj¡\}}}t tj¡}| jtj	O  _tj
|_|jtjd t|dƒrjd|_| jjt |||dd}| j |¡\}}| j ˆ j¡ | j|||ftjd	 ˆ j ¡  | ¡  | ¡  | j ˆ j¡ d S )
Nrg   c                      s   ˆ S r   r   r   rQ  r   r   rÏ   ?  ri   zEEventLoopTestsMixin.test_create_server_ssl_verified.<locals>.<lambda>r³  r¥  Tr·  r£  )r  r  )rS   r'   r  r}   r¨  r  r–  r©  r—  r˜  rª  r«  r´  rµ  r)  r¥  r  r&   r=   r  ZPEERCERTr9   r1   r>   )r*   ry  rj  r<  r¯  r¡  r  r	  r   rQ  r   Útest_create_server_ssl_verified;  s.    ÿ

þÿ
z3EventLoopTestsMixin.test_create_server_ssl_verifiedc           	         s®   | j  ¡ ‰ G ‡ fdd„dtƒ}t d¡}| j j||d}| j  |¡}|jd }|  | ¡ | ¡ ¡ | 	¡ \}}|  |d¡ t ¡ }| 
d|f¡ | d¡ | ¡  | ¡  d S )	Nc                       s   e Zd Z‡ ‡fdd„Z‡  ZS )z@EventLoopTestsMixin.test_create_server_sock.<locals>.TestMyProtoc                    s   t ƒ  |¡ ˆ | ¡ d S r   ©rT   rF   rD   rE   )rW   rR  r   r   rF   ]  s    zPEventLoopTestsMixin.test_create_server_sock.<locals>.TestMyProto.connection_maderX   r   rQ  rV   r   ÚTestMyProto\  s   r»  ©r€  r   r”  r   r€  r7  r  )r'   r<   rS   rÑ   rS  r&   rx  rœ   rÇ   rT  rI  r,   r1   )	r*   r»  Úsock_obr=  ry  rd  rj  r<  r  r   rQ  r   Útest_create_server_sockY  s    



z+EventLoopTestsMixin.test_create_server_sockc                 C   s¢   t  d¡}| jjt|d}| j |¡}|jd }| ¡ \}}| jjt||d}|  t¡}| j |¡ W d   ƒ n1 sz0    Y  |  	|j
jtj¡ | ¡  d S )Nr¼  r”  r   ©rj  r<  )rÑ   rS  r'   rS   r&   rx  rT  r‰   r?  rœ   r-  r@  rA  r1   )r*   r½  r=  ry  rd  rj  r<  r0  r   r   r   Útest_create_server_addr_in_usep  s    

*z2EventLoopTestsMixin.test_create_server_addr_in_usezIPv6 not supported or enabledc           	   
      s<  | j  ¡ ‰ G ‡ fdd„dtƒ}d}z*t ¡ }| j j|d |d}| j  |¡}W q¦ ty  } z<|jtj	krŠ|d7 }|  
d|¡ W Y d }~q"n‚ W Y d }~q"d }~0 0 q¦q"t ¡ }| d|f¡ | d¡ | j  ˆ ¡}|j ¡  | ¡  | j  ¡ ‰ t tj¡}| d	|f¡ | d¡ | j  ˆ ¡}|j ¡  | ¡  | ¡  d S )
Nc                       s   e Zd Z‡ ‡fdd„Z‡  ZS )zFEventLoopTestsMixin.test_create_server_dual_stack.<locals>.TestMyProtoc                    s   t ƒ  |¡ ˆ | ¡ d S r   rº  rE   )rW   Úf_protor   r   rF   „  s    zVEventLoopTestsMixin.test_create_server_dual_stack.<locals>.TestMyProto.connection_maderX   r   ©rÁ  rV   r   r»  ƒ  s   r»  r   r¿  rl   r   r7  r  r}  )r'   r<   rS   r
   r;  rS  r&   r?  r@  rA  ZassertGreaterEqualrÑ   rI  r,   r9   r1   r~  )	r*   r»  Z	try_countr<  r=  ry  Úexr  rR  r   rÂ  r   Útest_create_server_dual_stack  s8    





z1EventLoopTestsMixin.test_create_server_dual_stackc                 C   sŠ   | j  tdd¡}| j  |¡}|jd }| ¡ \}}t ¡ }| d|f¡ | d¡ | 	¡  | 	¡  t ¡ }|  
t|jd|f¡ | 	¡  d S )Nr€  r   r7  r  )r'   rS  rS   r&   rx  rT  rÑ   rI  r,   r1   r‰   ÚConnectionRefusedErrorrƒ  r   r   r   Útest_server_close¨  s    

ÿz%EventLoopTestsMixin.test_server_closec           
         s„  G ‡fdd„dt ƒ}ˆjj|||d}ˆj |¡\}‰| d¡}t |tjtjB ¡\}}ˆ 	|t
j¡ ˆ 	ˆ|¡ ˆ dˆj¡ ˆ ˆj|¡ ˆjj‡fdd„||fd}ˆj |¡\}	‰ ˆ 	|	t
j¡ ˆ 	ˆ t ¡ ˆ dˆ j¡ ˆ ˆ j|	¡ |	 d	¡ t ˆj‡fd
d„¡ ˆ dˆj¡ t ˆj‡ fdd„¡ ˆ dˆ j¡ ˆ |	 d¡¡ |	 ¡  ˆj ˆ j¡ ˆ dˆ j¡ ˆj ¡  d S )Nc                       s*   e Zd Z‡ ‡fdd„Z‡ fdd„Z‡  ZS )zOEventLoopTestsMixin._test_create_datagram_endpoint.<locals>.TestMyDatagramProtoc                    s   t ƒ jˆjd d S r  )rT   r@   r'   )Z
inner_self)rW   r*   r   r   r@   ¼  s    zXEventLoopTestsMixin._test_create_datagram_endpoint.<locals>.TestMyDatagramProto.__init__c                    s$   t ƒ  ||¡ | j d| |¡ d S )Ns   resp:)rT   r_   r9   Úsendtor]   rV   r   r   r_   ¿  s    zaEventLoopTestsMixin._test_create_datagram_endpoint.<locals>.TestMyDatagramProto.datagram_received)r3   r4   r5   r@   r_   rY   r   r0   rV   r   ÚTestMyDatagramProto»  s   rÈ  )r:  rl  rþ   r[   c                      s   t ˆ jdS r  ©rZ   r'   r   r0   r   r   rÏ   Ð  ri   zDEventLoopTestsMixin._test_create_datagram_endpoint.<locals>.<lambda>)Zremote_addrr  c                      s   ˆ j S r   r‚  r   )ry  r   r   rÏ   Ú  ri   rj   c                      s   ˆ j S r   r‚  r   )r  r   r   rÏ   Ü  ri   é   rP   )rZ   r'   Úcreate_datagram_endpointr&   r  rÑ   ÚgetnameinfoÚNI_NUMERICHOSTÚNI_NUMERICSERVrÿ   r   r   rœ   r:   r  r9   rÇ  r}   rÖ   r;   r  r1   r>   )
r*   r:  rl  rÈ  re  Zs_transportrþ   rj  r<  r9   r   )r  r*   ry  r   Ú_test_create_datagram_endpointº  s@    ÿ
ÿ
þ
z2EventLoopTestsMixin._test_create_datagram_endpointc                 C   s   |   dtj¡ d S )NrF  )rÏ  rÑ   rh  r0   r   r   r   Útest_create_datagram_endpointê  s    z1EventLoopTestsMixin.test_create_datagram_endpointc                 C   s   |   dtj¡ d S )N)r}  r   )rÏ  rÑ   r~  r0   r   r   r   Ú"test_create_datagram_endpoint_ipv6í  s    z6EventLoopTestsMixin.test_create_datagram_endpoint_ipv6c                    sÎ   d }d}ˆ j  ˆ j j|dtjiŽ¡}|D ]H\}}}}}z(tj|||d}| d¡ | |¡ W n   Y q(0  qrq(ˆ j j‡ fdd„|d}	ˆ j  |	¡\}
}ˆ  |
t	j
¡ ˆ  |t¡ |
 ¡  ˆ j  |j¡ d S )NrF  Útype)rl  rÒ  rR  Fc                      s   t ˆ jdS r  rÉ  r   r0   r   r   rÏ     ri   zHEventLoopTestsMixin.test_create_datagram_endpoint_sock.<locals>.<lambda>r”  )r'   r&   rm  rÑ   Ú
SOCK_DGRAMrÓ   ÚbindrË  rÿ   r   r   rZ   r1   r>   )r*   rd  Zlocal_addressZinfosrl  rÒ  rR  Zcnamer  r=  r  r	  r   r0   r   Ú"test_create_datagram_endpoint_sockñ  s2    ÿÿÿ
ÿz6EventLoopTestsMixin.test_create_datagram_endpoint_sockc                 C   sf   |   ¡ }t|tjƒs&| ¡  |  d¡ |  d|j¡ | ¡  |  d|j¡ |  |j	¡ |  |j
¡ d S )Nz#loop is not a BaseSelectorEventLooprl   r   )r{   r^  r   ZBaseSelectorEventLoopr1   ZskipTestrœ   Z_internal_fdsr­  Z_csockZ_ssockr?   r   r   r   Útest_internal_fds  s    
z%EventLoopTestsMixin.test_internal_fdsr   zDon't support pipes for Windowsc                    sö   t ˆjd‰t ¡ \}}t |dd¡‰ ‡ ‡‡fdd„}ˆj |ƒ ¡ t |d¡ t 	ˆj‡fdd„¡ ˆ 
d	ˆj¡ t |d
¡ t 	ˆj‡fdd„¡ ˆ 
ddgˆj¡ ˆ 
dˆj¡ t |¡ ˆj ˆj¡ ˆ 
g d¢ˆj¡ ˆ ˆj d¡¡ d S )Nrg   ÚrbrÂ   c                  “   s^   ˆj  ‡fdd„ˆ ¡I d H \} }ˆ |ˆ¡ ˆ | ˆj¡ ˆ ddgˆj¡ ˆ dˆj¡ d S )Nc                      s   ˆ S r   r   r   rQ  r   r   rÏ   !  ri   zEEventLoopTestsMixin.test_read_pipe.<locals>.connect.<locals>.<lambda>r8   rB   r   ©r'   Úconnect_read_piper  r9   rœ   r:   r;   ©r°   Úp©ÚpipeobjrR  r*   r   r   rI    s    ÿz3EventLoopTestsMixin.test_read_pipe.<locals>.connectó   1c                      s
   ˆ j dkS rà   r‚  r   rQ  r   r   rÏ   *  ri   z4EventLoopTestsMixin.test_read_pipe.<locals>.<lambda>rl   ó   2345c                      s
   ˆ j dkS ©Nr   r‚  r   rQ  r   r   rÏ   .  ri   r8   rB   r   ©r8   rB   rM   rP   Úpipe)ra   r'   rì   râ  ÚioÚopenr&   rU   r}   rÖ   rœ   r;   r:   r1   r>   r  r9   r  )r*   ÚrpipeÚwpiperI  r   rÜ  r   Útest_read_pipe  s$    

ÿz"EventLoopTestsMixin.test_read_pipec                    s°   |   ¡ ‰ tˆ d‰tˆ d‰t ¡ \}}t |dd¡‰t |dd¡‰‡ ‡‡‡‡fdd„}ˆ  |ƒ ¡\}}ˆ  ¡  |  	dt
|ƒ¡ |  	dt
|ƒ¡ ˆ ¡  ˆ ¡  d |_d |_d S )Nrg   r×  rÂ   r×   c                  “   sD   ˆ   ‡fdd„ˆ¡I d H \} }ˆ  ‡fdd„ˆ¡I d H \}}| |fS )Nc                      s   ˆ S r   r   r   ©Ú
read_protor   r   rÏ   G  ri   zSEventLoopTestsMixin.test_unclosed_pipe_transport.<locals>.connect.<locals>.<lambda>c                      s   ˆ S r   r   r   ©Úwrite_protor   r   rÏ   I  ri   )rÙ  Úconnect_write_pipe)Úread_transportr[  Úwrite_transport©r'   ré  ZrpipeobjZwpipeobjrë  r   r   rI  E  s    ÿÿzAEventLoopTestsMixin.test_unclosed_pipe_transport.<locals>.connecträ  )r{   ra   rc   rì   râ  rã  rä  r&   r1   rB  ÚreprZ_pipe)r*   rå  ræ  rI  rí  rî  r   rï  r   Útest_unclosed_pipe_transport9  s    

z0EventLoopTestsMixin.test_unclosed_pipe_transportc                    s   t ˆjd‰t ¡ \}}t |dd¡‰ ‡ ‡‡fdd„}ˆj |ƒ ¡ t |d¡ t 	ˆj‡fdd„¡ ˆ 
d	ˆj¡ t |d
¡ t 	ˆj‡fdd„¡ ˆ 
ddgˆj¡ ˆ 
dˆj¡ t |¡ ˆj ¡  ˆj ˆj¡ ˆ 
g d¢ˆj¡ ˆ ˆj d¡¡ d S )Nrg   r×  r   c                  “   s^   ˆj  ‡fdd„ˆ ¡I d H \} }ˆ |ˆ¡ ˆ | ˆj¡ ˆ ddgˆj¡ ˆ dˆj¡ d S )Nc                      s   ˆ S r   r   r   rQ  r   r   rÏ   d  ri   zKEventLoopTestsMixin.test_read_pty_output.<locals>.connect.<locals>.<lambda>r8   rB   r   rØ  rÚ  ©Zmaster_read_objrR  r*   r   r   rI  c  s    ÿz9EventLoopTestsMixin.test_read_pty_output.<locals>.connectrÞ  c                      s   ˆ j S r   r‚  r   rQ  r   r   rÏ   n  ri   z:EventLoopTestsMixin.test_read_pty_output.<locals>.<lambda>rl   rß  c                      s
   ˆ j dkS rà  r‚  r   rQ  r   r   rÏ   r  ri   r8   rB   r   rá  râ  )ra   r'   rì   Úopenptyrã  rä  r&   rU   r}   rÖ   rœ   r;   r:   r1   r9   r>   r  r  )r*   ÚmasterÚslaverI  r   rò  r   Útest_read_pty_output[  s&    


ÿz(EventLoopTestsMixin.test_read_pty_outputc                    s6  t  ¡ \‰}t |dd¡}t| jd‰| j ‡fdd„|¡}| j |¡\}}|  |ˆ¡ |  |ˆj	¡ |  
dˆj¡ | d¡ tƒ ‰ ‡fdd	„‰t | j‡ ‡fd
d„¡ |  
dˆ ¡ | d¡ t | j‡ ‡fdd„¡ |  
dˆ ¡ |  
dˆj¡ t  ˆ¡ |  ˆj	 d¡¡ ˆj	 ¡  | j ˆj¡ |  
dˆj¡ d S )NÚwbrÂ   rg   c                      s   ˆ S r   r   r   rQ  r   r   rÏ   …  ri   z5EventLoopTestsMixin.test_write_pipe.<locals>.<lambda>rB   rÞ  c                    s   t  ˆ d¡}| |7 } t| ƒS rÁ   ©rì   rÝ   rH   ©rJ   Úchunk)rå  r   r   rÌ   Ž  s    z3EventLoopTestsMixin.test_write_pipe.<locals>.readerc                      s   ˆˆ ƒdkS rà   r   r   ©rJ   rÌ   r   r   rÏ   “  ri   rß  c                      s   ˆˆ ƒdkS rà  r   r   rû  r   r   rÏ   —  ri   ó   12345râ  rP   )rì   râ  rã  rä  rc   r'   rì  r&   r  r9   rœ   r:   rU   rÔ   r}   rÖ   r1   r  r  r>   )r*   ræ  rÝ  rI  r9   rÛ  r   )rJ   rR  rÌ   rå  r   Útest_write_pipe~  s,    



z#EventLoopTestsMixin.test_write_pipec                    sÖ   t  ¡ \}}| d¡ t | ¡ dd¡}t| jd‰ | j ‡ fdd„|¡}| j 	|¡\}}|  
|ˆ ¡ |  
|ˆ j¡ |  dˆ j¡ | d¡ | j 	| j |d¡¡}|  d|¡ | ¡  | j 	ˆ j¡ |  d	ˆ j¡ d S )
NFr÷  rÂ   rg   c                      s   ˆ S r   r   r   rQ  r   r   rÏ   ­  ri   zIEventLoopTestsMixin.test_write_pipe_disconnect_on_close.<locals>.<lambda>rB   rÞ  rP   )rÑ   rÒ   rÓ   rã  rä  Údetachrc   r'   rì  r&   r  r9   rœ   r:   rU   Ú	sock_recvr1   r>   )r*   ZrsockZwsockrÝ  rI  r9   rÛ  rJ   r   rQ  r   Ú#test_write_pipe_disconnect_on_close¥  s    

z7EventLoopTestsMixin.test_write_pipe_disconnect_on_closer   rÐ   c                    sB  t  ¡ \‰}t |dd¡}t| jd‰| j ‡fdd„|¡}| j |¡\}}|  |ˆ¡ |  |ˆj	¡ |  
dˆj¡ | d¡ tƒ ‰ ‡fdd	„‰tj| j‡ ‡fd
d„tjd |  
dˆ ¡ | d¡ tj| j‡ ‡fdd„tjd |  
dˆ ¡ |  
dˆj¡ t  ˆ¡ |  ˆj	 d¡¡ ˆj	 ¡  | j ˆj¡ |  
dˆj¡ d S )Nr÷  r   rg   c                      s   ˆ S r   r   r   rQ  r   r   rÏ   Æ  ri   z4EventLoopTestsMixin.test_write_pty.<locals>.<lambda>rB   rÞ  c                    s   t  ˆ d¡}| |7 } t| ƒS rÁ   rø  rù  ©rô  r   r   rÌ   Ï  s    z2EventLoopTestsMixin.test_write_pty.<locals>.readerc                      s   ˆˆ ƒdkS rà   r   r   rû  r   r   rÏ   Ô  ri   ©Útimeoutrß  c                      s   ˆˆ ƒdkS rà  r   r   rû  r   r   rÏ   Ù  ri   rü  râ  rP   )rì   ró  rã  rä  rc   r'   rì  r&   r  r9   rœ   r:   rU   rÔ   r}   rÖ   r	   ÚSHORT_TIMEOUTr1   r  r  r>   )r*   rõ  Úslave_write_objrI  r9   rÛ  r   )rJ   rô  rR  rÌ   r   Útest_write_pty¼  s4    
ÿ
ÿ

z"EventLoopTestsMixin.test_write_ptyc           
         sÂ  t  ¡ \‰}t  |¡}t |¡ t |dd¡}t| jd‰| j 	‡fdd„|¡}| j 
|¡\}}|  |ˆ¡ |  |ˆj¡ |  ddgˆj¡ |  dˆj¡ t |dd¡}t| jd‰| j ‡fd	d„|¡}| j 
|¡\}	}|  |ˆ¡ |  |	ˆj¡ |  dˆj¡ tƒ ‰ ‡fd
d„‰|	 d¡ tj| j‡ ‡fdd„tjd |  dˆ ¡ |  ddgˆj¡ |  dˆj¡ t  ˆd¡ tj| j‡fdd„tjd |  ddgˆj¡ |  dˆj¡ |  dˆj¡ |	 d¡ tj| j‡ ‡fdd„tjd |  dˆ ¡ |  ddgˆj¡ |  dˆj¡ t  ˆd¡ tj| j‡fdd„tjd |  ddgˆj¡ |  dˆj¡ |  dˆj¡ t  ˆ¡ | ¡  | j 
ˆj¡ |  g d¢ˆj¡ |	 ¡  | j 
ˆj¡ |  dˆj¡ d S )Nr×  r   rg   c                      s   ˆ S r   r   r   rè  r   r   rÏ   ô  ri   z<EventLoopTestsMixin.test_bidirectional_pty.<locals>.<lambda>r8   rB   r÷  c                      s   ˆ S r   r   r   rê  r   r   rÏ   ÿ  ri   c                    s   t  ˆ d¡}| |7 } t| ƒS rÁ   rø  rù  r  r   r   rÌ     s    z:EventLoopTestsMixin.test_bidirectional_pty.<locals>.readerrÞ  c                      s   ˆˆ ƒdkS rà   r   r   rû  r   r   rÏ     ri   r  ó   ac                      s
   ˆ j dkS rà   r‚  r   rè  r   r   rÏ     ri   rl   rß  c                      s   ˆˆ ƒdkS rà  r   r   rû  r   r   rÏ     ri   rü  s   bcdec                      s
   ˆ j dkS rà  r‚  r   rè  r   r   rÏ   "  ri   r   rá  rP   )rì   ró  ÚdupÚttyZsetrawrã  rä  ra   r'   rÙ  r&   r  r9   rœ   r:   r;   rc   rì  rÔ   rU   r}   rÖ   r	   r  r1   r>   )
r*   Z
read_slaveZwrite_slaveZslave_read_objZread_connectrí  rÛ  r  Zwrite_connectrî  r   )rJ   rô  ré  rÌ   rë  r   Útest_bidirectional_ptyè  sz    

ÿÿ
ÿÿ
ÿÿ

ÿz*EventLoopTestsMixin.test_bidirectional_ptyc                    sæ   t  ¡ \}}| d¡ ˆj ˆj |d¡¡‰ tˆ dd ƒ}|d urLˆ |j¡ ‡ ‡fdd„}t	 
¡ }ˆj |ƒ ¡}ˆj ¡  t	 
¡ | }ˆ |d¡ ˆ | ¡ d¡ ˆ tjˆ j¡ |d urÆˆ |j¡ ˆj |¡ | ¡  | ¡  d S )NFrl   Úovc                  “   sZ   zHzˆj  ˆ j¡ ˆ I d H  W n tjy6   d} Y n0 d } W ˆj  ¡  nˆj  ¡  0 | S )NÚ	cancelled)r'   r    r¾   r   ÚCancelledErrorr‘   )r·   ©r=  r*   r   r   Úmain;  s    
z:EventLoopTestsMixin.test_prompt_cancellation.<locals>.mainrŒ   r  )rÑ   rÒ   rÓ   r'   rn  rÿ  Úgetattrr„   Úpendingr   Ú	monotonicr›   Z
assertLessrœ   Úresultr‰   r   r  r¿   rw  r1   )r*   rË   r×   r  r  r®   r°   Úelapsedr   r  r   Útest_prompt_cancellation3  s&    

z,EventLoopTestsMixin.test_prompt_cancellationc                    sh   ‡ ‡fdd„}ˆj j‰ dˆj _|ˆj _‡fdd„}ˆj  |ƒ ¡ ˆ ˆj jdˆj jˆj jjjdœ¡ d S )Nc                      s   ˆj  jd7  _ˆ ƒ  d S rà   )r'   Ú_run_once_counterr   ©Zorig_run_oncer*   r   r   Ú	_run_onceW  s    z<EventLoopTestsMixin.test_timeout_rounding.<locals>._run_oncer   c                  “   sZ   ˆ j } t d¡I d H  t d¡I d H  t d¡I d H  t d¡I d H  t d¡I d H  d S )Nrõ   g-Cëâ6?gíµ ÷Æ°>g:Œ0âŽyE>g»½×Ùß|Û=)r'   r   r‚   rg   r0   r   r   Úwait_  s    z7EventLoopTestsMixin.test_timeout_rounding.<locals>.waité   )Zclock_resolutionÚselector)	r'   r  r  r&   ZassertLessEqualZ_clock_resolutionÚ	_selectorrW   r3   )r*   r  r  r   r  r   Útest_timeout_roundingV  s    
ÿÿz)EventLoopTestsMixin.test_timeout_roundingc                 C   sx   |   ¡ }dd„ }t ¡ \}}|  |j¡ |  |j¡ | ||¡ | ||¡ | ¡  |  | |¡¡ |  | 	|¡¡ d S )Nc                   S   s   d S r   r   r   r   r   r   rÏ   r  ri   zCEventLoopTestsMixin.test_remove_fds_after_closing.<locals>.<lambda>)
r{   rÑ   rÒ   rb  r1   rÕ   rÛ   r¿   rÆ   rÜ   ©r*   r'   r™   rË   r×   r   r   r   Útest_remove_fds_after_closingp  s    z1EventLoopTestsMixin.test_remove_fds_after_closingc                 C   s¬   |   ¡ }dd„ }t ¡ \}}|  |j¡ |  |j¡ | ¡  |  t¡ | ||¡ W d   ƒ n1 sh0    Y  |  t¡ | ||¡ W d   ƒ n1 sž0    Y  d S )Nc                   S   s   d S r   r   r   r   r   r   rÏ   ~  ri   z@EventLoopTestsMixin.test_add_fds_after_closing.<locals>.<lambda>)	r{   rÑ   rÒ   rb  r1   r‰   rŠ   rÕ   rÛ   r  r   r   r   Útest_add_fds_after_closing|  s    *z.EventLoopTestsMixin.test_add_fds_after_closingc                    sP   ‡ fdd„}|ˆ j ƒ}ˆ  t¡ ˆ j  |¡ W d   ƒ n1 sB0    Y  d S )Nc                 “   s   ˆ j  ¡  d S r   )r'   r1   rg   r0   r   r   Ú
close_loop‰  s    zEEventLoopTestsMixin.test_close_running_event_loop.<locals>.close_loop)r'   r‰   rŠ   r&   )r*   r!  re  r   r0   r   Útest_close_running_event_loopˆ  s    
z1EventLoopTestsMixin.test_close_running_event_loopc                 C   sJ  | j  ¡  dd„ }dd„ }|ƒ }|  |j¡ |  t¡ | j  ¡  W d   ƒ n1 sV0    Y  |  t¡& | j  ¡ }| j  |¡ W d   ƒ n1 s–0    Y  |  t¡ | j  |¡ W d   ƒ n1 sÌ0    Y  |  t¡ | j  	|¡ W d   ƒ n1 s0    Y  |  t¡ | j  
d|¡ W d   ƒ n1 s>0    Y  |  t¡( | j  | j  ¡ d |¡ W d   ƒ n1 s‚0    Y  |  t¡ | j  |¡ W d   ƒ n1 sº0    Y  |  t¡  | j  tj|¡ W d   ƒ n1 sö0    Y  |  t¡* | j  d |¡ ¡ }t|ƒ W d   ƒ n1 s<0    Y  d S )Nc                   Ó   s   d S r   r   r   r   r   r   Útest“  s    z,EventLoopTestsMixin.test_close.<locals>.testc                   S   s   dS ©NFr   r   r   r   r   rÏ   –  ri   z0EventLoopTestsMixin.test_close.<locals>.<lambda>g      ð?g        )r'   r1   rb  r‰   rŠ   r›   r<   r&   r    r¤   rš   Úcall_atr   rn  ræ   ré   ÚSIGTERMrµ   r2   Únext)r*   r#  Úfuncre  ZfutÚitr   r   r   Ú
test_close  s2    
(
**,.8,0zEventLoopTestsMixin.test_close)T)TN)TN)NN)N)N)N)Yr3   r4   r5   rz   r€   r‹   r   r“   rž   r¡   r±   r²   r¸   rÀ   rØ   rÞ   r_  Ú
skipUnlessr)  ré   rò   rú   rý   r
  r  r
   Zskip_unless_bind_unix_socketr  r  r  r1  ÚskipIfr  r6  r9  r>  rD  r\  ra  rf  r   r*  rz  r|  r  r„  rÑ   r‰  r‘  r“  r•  rœ  r  rž  r¢  r¤  r°  r²  r¶  r¸  r¹  r¾  rÀ  ZIPV6_ENABLEDrÄ  rÆ  rÏ  rÐ  rÑ  rÕ  rÖ  r   r   rç  rñ  rö  rý  r   r	   Úrequires_mac_verr  r
  r  r  r  r   r"  r*  rY   r   r   rV   r   ry   ï   sò   		
+




ÿ
!  þ
 ÿ
%
	

6


$
	










(0
ÿ
 ÿ
 ÿ
!ÿ
%ÿ
ÿ
'ÿ
F#ry   c                   @   sž   e Z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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#S )$ÚSubprocessTestsMixinc                 C   s,   t jdkr|  |t¡ n|  tj |¡ d S ©Nr   )r   r   rÿ   r   rœ   ré   r&  ©r*   rq   r   r   r   Úcheck_terminated·  s    
z%SubprocessTestsMixin.check_terminatedc                 C   s,   t jdkr|  |t¡ n|  tj |¡ d S r/  )r   r   rÿ   r   rœ   ré   rß   r0  r   r   r   Úcheck_killed¾  s    
z!SubprocessTestsMixin.check_killedc                 C   sô   t j t j t¡d¡}| j t t	| j¡t
j|¡}| j |¡\}}|  |t	¡ | j |j¡ |  d|j¡ | d¡}| d¡ | j |jd  ¡ ¡ t ¡  | ¡  W d   ƒ n1 sº0    Y  | j |j¡ |  |j¡ |  d|jd ¡ d S )Núecho.pyrB   r   ó   Python The Winnerrl   )rì   rŠ  r¯   ÚdirnameÚ__file__r'   Úsubprocess_execr4  r5  rd   r   Ú
executabler&   rÿ   r=   rœ   r:   Úget_pipe_transportrU   rs   r  r}   r,  r1   rn   r2  rq   rJ   ©r*   ÚprogrI  ÚtransprR  Ústdinr   r   r   Útest_subprocess_execÅ  s"    þ


&z)SubprocessTestsMixin.test_subprocess_execc                 C   s6  t j t j t¡d¡}| j t t	| j¡t
j|¡}| j |¡\}}|  |t	¡ | j |j¡ |  d|j¡ | d¡}| d¡ | j |jd  ¡ ¡ |jd  ¡  |  d|jd ¡ | d¡ | j |jd  ¡ ¡ |  d|jd ¡ t ¡  | ¡  W d   ƒ n1 s0    Y  | j |j¡ |  |j¡ d S )Nr3  rB   r   s   Python rl   s
   The Winnerr4  )rì   rŠ  r¯   r5  r6  r'   r7  r4  r5  rd   r   r8  r&   rÿ   r=   rœ   r:   r9  rU   rs   r  ÚclearrJ   r}   r,  r1   rn   r2  rq   r:  r   r   r   Útest_subprocess_interactiveÙ  s*    þ



(z0SubprocessTestsMixin.test_subprocess_interactivec                 C   sÀ   | j  t t| j ¡d¡}| j  |¡\}}|  |t¡ | j  |j¡ | d¡ 	¡  | j  |j
¡ |  d|j¡ |  tdd„ |j ¡ D ƒƒ¡ |  |jd  d¡d¡ |  |jd d	¡ | 	¡  d S )
Nzecho Pythonr   c                 s   s   | ]}|  ¡ V  qd S r   )r>   )re   r=  r   r   r   Ú	<genexpr>ÿ  ri   z=SubprocessTestsMixin.test_subprocess_shell.<locals>.<genexpr>rl   s   
s   Pythonrm   ri   )r'   Úsubprocess_shellr4  r5  rd   r&   rÿ   r=   r9  r1   rn   rœ   rq   r„   Úallrp   ÚvaluesrJ   Úrstrip©r*   rI  r<  rR  r   r   r   Útest_subprocess_shellô  s    þz*SubprocessTestsMixin.test_subprocess_shellc                 C   sd   | j jt t| j ¡dd d d d}| j  |¡\}}|  |t¡ | j  |j¡ |  d|j	¡ | 
¡  d S )Núexit 7©r=  ÚstdoutÚstderré   ©r'   rB  r4  r5  rd   r&   rÿ   rn   rœ   rq   r1   rF  r   r   r   Útest_subprocess_exitcode  s    þz-SubprocessTestsMixin.test_subprocess_exitcodec                 C   sš   | j jt t| j ¡dd d d d}| j  |¡\}}|  |t¡ |  | d¡¡ |  | d¡¡ |  | d¡¡ | j  |j	¡ |  
d|j¡ |  | ¡ ¡ d S )NrH  rI  r   rl   rm   rL  )r'   rB  r4  r5  rd   r&   rÿ   r­  r9  rn   rœ   rq   r1   rF  r   r   r   Ú"test_subprocess_close_after_finish  s    þz7SubprocessTestsMixin.test_subprocess_close_after_finishc                 C   sŠ   t j t j t¡d¡}| j t t	| j¡t
j|¡}| j |¡\}}|  |t	¡ | j |j¡ | ¡  | j |j¡ |  |j¡ | ¡  d S ©Nr3  )rì   rŠ  r¯   r5  r6  r'   r7  r4  r5  rd   r   r8  r&   rÿ   r=   rí   rn   r2  rq   r1   ©r*   r;  rI  r<  rR  r   r   r   Útest_subprocess_kill  s    þz)SubprocessTestsMixin.test_subprocess_killc                 C   sŠ   t j t j t¡d¡}| j t t	| j¡t
j|¡}| j |¡\}}|  |t	¡ | j |j¡ | ¡  | j |j¡ |  |j¡ | ¡  d S rP  )rì   rŠ  r¯   r5  r6  r'   r7  r4  r5  rd   r   r8  r&   rÿ   r=   Ú	terminatern   r1  rq   r1   rQ  r   r   r   Útest_subprocess_terminate,  s    þz.SubprocessTestsMixin.test_subprocess_terminater   zDon't have SIGHUPc              
   C   sÈ   t   t jt j¡}z¢tj tj t¡d¡}| j 	t
 t| j¡tj|¡}| j |¡\}}|  |t¡ | j |j¡ | t j¡ | j |j¡ |  t j |j¡ | ¡  W t   t j|¡ nt   t j|¡ 0 d S rP  )ré   ÚSIGHUPÚSIG_DFLrì   rŠ  r¯   r5  r6  r'   r7  r4  r5  rd   r   r8  r&   rÿ   r=   Úsend_signalrn   rœ   rq   r1   )r*   Zold_handlerr;  rI  r<  rR  r   r   r   Útest_subprocess_send_signal<  s    þ
z0SubprocessTestsMixin.test_subprocess_send_signalc                 C   sÈ   t j t j t¡d¡}| j t t	| j¡t
j|¡}| j |¡\}}|  |t	¡ | j |j¡ | d¡}| d¡ | j |j¡ | ¡  |  d|jd ¡ |  |jd  d¡|jd ¡ |  d|j¡ d S )Núecho2.pyr   ó   testó   OUT:testrl   rm   s   ERR:test)rì   rŠ  r¯   r5  r6  r'   r7  r4  r5  rd   r   r8  r&   rÿ   r=   r9  rU   rn   r1   rœ   rJ   r„   r   rq   r:  r   r   r   Útest_subprocess_stderrT  s    þ

z+SubprocessTestsMixin.test_subprocess_stderrc                 C   sî   t j t j t¡d¡}| jjt t	| j¡t
j|tjd}| j |¡\}}|  |t	¡ | j |j¡ | d¡}|  | d¡¡ |  | d¡¡ | d¡ | j |j¡ |  |jd  d¡|jd ¡ |  d|jd ¡ | ¡  |  d|j¡ d S )	NrY  )rK  r   rl   rm   rZ  s   OUT:testERR:testri   )rì   rŠ  r¯   r5  r6  r'   r7  r4  r5  rd   r   r8  Ú
subprocessÚSTDOUTr&   rÿ   r=   r9  r  r­  rU   rn   r„   rJ   r   rœ   r1   rq   r:  r   r   r   Ú)test_subprocess_stderr_redirect_to_stdouti  s&    
þ

ÿz>SubprocessTestsMixin.test_subprocess_stderr_redirect_to_stdoutc                 C   s\  t j t j t¡d¡}| j t t	| j¡t
j|¡}| j |¡\}}|  |t	¡ | j |j¡ | d¡}| d¡}| d¡ | j |jd  ¡ ¡ |  d|jd ¡ | ¡  | j |jd ¡ | d¡ | j |jd  ¡ ¡ t
jdkrú|  d	|jd ¡ n|  d
|jd ¡ t ¡  | ¡  W d   ƒ n1 s40    Y  | j |j¡ |  |j¡ d S )Nzecho3.pyr   rl   rZ  r[  r  rm   r   s   ERR:BrokenPipeErrors   ERR:OSError)rì   rŠ  r¯   r5  r6  r'   r7  r4  r5  rd   r   r8  r&   rÿ   r=   r9  rU   rs   r  rœ   rJ   r1   rp   r   r}   r,  rn   r2  rq   )r*   r;  rI  r<  rR  r=  rJ  r   r   r   Ú#test_subprocess_close_client_stream  s0    þ





(z8SubprocessTestsMixin.test_subprocess_close_client_streamc                 C   sf   | j jt t| j ¡dd d d dd}| j  |¡\}}|  |t¡ | j  |j¡ |  d|j	¡ | 
¡  d S )NrH  T)r=  rJ  rK  Ústart_new_sessionrL  rM  rF  r   r   r   Ú"test_subprocess_wait_no_same_group¢  s    ýz7SubprocessTestsMixin.test_subprocess_wait_no_same_groupc                    sÄ   ‡ fdd„}ˆ   t¡" ˆ j |dd¡ W d   ƒ n1 s>0    Y  ˆ   t¡" ˆ j |dd¡ W d   ƒ n1 sz0    Y  ˆ   t¡" ˆ j |dd¡ W d   ƒ n1 s¶0    Y  d S )Nc                  ›   s"   ˆ j jtjdfi | ¤ŽI d H  d S ©NÚpwd)r'   r7  r   ÚSubprocessProtocol)ro  r0   r   r   rI  ¯  s    þþzGSubprocessTestsMixin.test_subprocess_exec_invalid_args.<locals>.connectT©Úuniversal_newlinesé   ©Úbufsize©Úshell©r‰   rè   r'   r&   ©r*   rI  r   r0   r   Ú!test_subprocess_exec_invalid_args®  s    00z6SubprocessTestsMixin.test_subprocess_exec_invalid_argsc                    s  d‡ fdd„	}ˆ   t¡$ ˆ j |ddgƒ¡ W d   ƒ n1 sB0    Y  ˆ   t¡" ˆ j |dd¡ W d   ƒ n1 s~0    Y  ˆ   t¡" ˆ j |dd¡ W d   ƒ n1 sº0    Y  ˆ   t¡" ˆ j |d	d
¡ W d   ƒ n1 sö0    Y  d S )Nc                 ›   s*   | sd} ˆ j jtj| fi |¤ŽI d H  d S rc  )r'   rB  r   re  )Úcmdro  r0   r   r   rI  ½  s    þþzHSubprocessTestsMixin.test_subprocess_shell_invalid_args.<locals>.connectZlsz-lTrf  rh  ri  Frk  )Nrm  rn  r   r0   r   Ú"test_subprocess_shell_invalid_args»  s    200z7SubprocessTestsMixin.test_subprocess_shell_invalid_argsN)r3   r4   r5   r1  r2  r>  r@  rG  rN  rO  rR  rT  r_  r,  r   r   rX  r\  r_  r`  rb  ro  rq  r   r   r   r   r.  µ  s"   
!r.  c                   @   s   e Zd Zdd„ ZdS )ÚSelectEventLoopTestsc                 C   s   t  ¡ S r   )r   ÚSelectorEventLoopr0   r   r   r   r{   Ó  s    ú&SelectEventLoopTests.create_event_loopN©r3   r4   r5   r{   r   r   r   r   rr  Ð  s   rr  c                   @   s<   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ ZdS )ÚProactorEventLoopTestsc                 C   s   t  ¡ S r   )r   ZProactorEventLoopr0   r   r   r   r{   Ú  s    z(ProactorEventLoopTests.create_event_loopc                 C   s   t  d¡‚d S ©Nz(IocpEventLoop does not have add_reader()©r_  r`  r0   r   r   r   rØ   Ý  s    z+ProactorEventLoopTests.test_reader_callbackc                 C   s   t  d¡‚d S rw  rx  r0   r   r   r   Útest_reader_callback_cancelà  s    z2ProactorEventLoopTests.test_reader_callback_cancelc                 C   s   t  d¡‚d S ©Nz(IocpEventLoop does not have add_writer()rx  r0   r   r   r   rÞ   ã  s    z+ProactorEventLoopTests.test_writer_callbackc                 C   s   t  d¡‚d S rz  rx  r0   r   r   r   Útest_writer_callback_cancelæ  s    z2ProactorEventLoopTests.test_writer_callback_cancelc                 C   s   t  d¡‚d S rw  rx  r0   r   r   r   r  é  s    z4ProactorEventLoopTests.test_remove_fds_after_closingN)	r3   r4   r5   r{   rØ   ry  rÞ   r{  r  r   r   r   r   rv  Ö  s   rv  c                       s(   e Zd Z‡ fdd„Z‡ fdd„Z‡  ZS )ÚUnixEventLoopTestsMixinc                    s,   t ƒ  ¡  t ¡ }| | j¡ t |¡ d S r   )rT   rz   r   ÚSafeChildWatcherÚattach_loopr'   Úset_child_watcher©r*   ZwatcherrV   r   r   rz   ï  s    
zUnixEventLoopTestsMixin.setUpc                    s   t  d ¡ tƒ  ¡  d S r   )r   r  rT   r€   r0   rV   r   r   r€   õ  s    
z UnixEventLoopTestsMixin.tearDown)r3   r4   r5   rz   r€   rY   r   r   rV   r   r|  î  s   r|  ÚKqueueSelectorc                       s\   e Zd Zdd„ Ze dd¡e ej	 
d¡d¡‡ fdd„ƒƒZe dd¡‡ fd	d
„ƒZ‡  ZS )ÚKqueueEventLoopTestsc                 C   s   t  t ¡ ¡S r   )r   rs  Ú	selectorsr  r0   r   r   r   r{   ÿ  s    ÿz&KqueueEventLoopTests.create_event_loopr   é	   Zopenbsdztest hangs on OpenBSDc                    s   t ƒ  ¡  d S r   )rT   rö  r0   rV   r   r   rö    s    z)KqueueEventLoopTests.test_read_pty_outputc                    s   t ƒ  ¡  d S r   )rT   r  r0   rV   r   r   r    s    z#KqueueEventLoopTests.test_write_pty)r3   r4   r5   r{   r	   r-  r_  r,  r   r   r   rö  r  rY   r   r   rV   r   r‚  û  s   
ÿ
r‚  ÚEpollSelectorc                   @   s   e Zd Zdd„ ZdS )ÚEPollEventLoopTestsc                 C   s   t  t ¡ ¡S r   )r   rs  rƒ  r…  r0   r   r   r   r{     s    z%EPollEventLoopTests.create_event_loopNru  r   r   r   r   r†    s   r†  ÚPollSelectorc                   @   s   e Zd Zdd„ ZdS )ÚPollEventLoopTestsc                 C   s   t  t ¡ ¡S r   )r   rs  rƒ  r‡  r0   r   r   r   r{      s    z$PollEventLoopTests.create_event_loopNru  r   r   r   r   rˆ    s   rˆ  c                   @   s   e Zd Zdd„ ZdS )rr  c                 C   s   t  t ¡ ¡S r   )r   rs  rƒ  ÚSelectSelectorr0   r   r   r   r{   (  s    rt  Nru  r   r   r   r   rr  $  s   c                  O   s   d S r   r   )r»   r  r   r   r   Únoop,  s    rŠ  c                       sh   e Zd Z‡ fdd„Zdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ Zdd„ Z	e
 eejdƒd¡dd„ ƒZ‡  ZS )ÚHandleTestsc                    s"   t ƒ  ¡  t ¡ | _d| jj_d S r¹   )rT   rz   r   rv  r'   Ú	get_debugÚreturn_valuer0   rV   r   r   rz   2  s    

zHandleTests.setUpc                 C   s`   dd„ }d}t  ||| j¡}|  |j|¡ |  |j|¡ |  | ¡ ¡ | ¡  |  	| ¡ ¡ d S )Nc                  W   s   | S r   r   rº   r   r   r   r™   8  s    z)HandleTests.test_handle.<locals>.callbackr   )
r   ÚHandler'   r  Ú	_callbackÚ_argsr¿   r  r¾   r„   )r*   r™   r»   Úhr   r   r   Útest_handle7  s    zHandleTests.test_handlec                 C   s\   dd„ }t  ¡ | _t  ¡ | j_t |d| j¡}| ¡  | jj t 	d¡t j
||jdœ¡ d S )Nc                   S   s
   t ƒ ‚d S r   )rè   r   r   r   r   r™   E  s    z:HandleTests.test_callback_with_exception.<locals>.callbackr   zException in callback.*)rN  r-  ÚhandleZsource_traceback)r   rv  r'   r¦  r   rŽ  Z_runÚassert_called_withr}   ZMockPatternÚANYÚ_source_traceback)r*   r™   r‘  r   r   r   Útest_callback_with_exceptionD  s    
üz(HandleTests.test_callback_with_exceptionc                 C   s(   t  ¡ }t dd„ d| j¡}||d< d S )Nc                   S   s   d S r   r   r   r   r   r   rÏ   W  ri   z1HandleTests.test_handle_weakref.<locals>.<lambda>r   r‘  )ÚweakrefÚWeakValueDictionaryr   rŽ  r'   )r*   Zwdr‘  r   r   r   Útest_handle_weakrefU  s    zHandleTests.test_handle_weakrefc                 C   s¢  d| j j_t td| j ¡}t t¡\}}|  t	|ƒd||f ¡ | 
¡  |  t	|ƒd¡ |  t¡ t t¡}W d   ƒ n1 s‚0    Y  t |d| j ¡}|  t	|ƒd||f ¡ t tdd¡}t |d	| j ¡}d
t |¡|f }|  t	|ƒ|¡ tjtdd}t |d| j ¡}dt |¡|f }|  t	|ƒ|¡ tjdkržtj}t |¡}t |¡\}}t |d| j ¡}d}d| }d|t |¡|f }|  t	|ƒ|¡ d S )NFrk   z<Handle noop(1, 2) at %s:%s>z<Handle cancelled>r   z<Handle noop() at %s:%s>rl   rm   )rj   z%^<Handle noop\(1, 2\)\(3\) at %s:%s>$)Úx)rm   rj   z'^<Handle noop\(x=1\)\(2, 3\) at %s:%s>$)rj   é   z*<function HandleTests.test_handle_repr .*>z%functools.partialmethod\(%s, , \)\(\)z^<Handle %s at %s:%s>$)r'   rŒ  r  r   rŽ  rŠ  r}   Úget_function_sourcerœ   rð  r¾   ZassertWarnsÚDeprecationWarningÚ	coroutiner4  r5  ÚreÚescapeZassertRegexr   r]  r‹  Útest_handle_reprÚpartialmethod)r*   r‘  ÚfilenameÚlinenor’   ZregexÚmethodZcb_regexr   r   r   r¢  Z  sV    

ÿÿ
ÿ(
ÿÿÿÿ
ÿzHandleTests.test_handle_reprc                 C   s¢   d| j j_t}t ¡ jd }t t	d| j ¡}t
 t	¡\}}|  t|ƒd||||f ¡ | ¡  |  t|ƒd||||f ¡ | ¡  |  t|ƒd||||f ¡ d S )NTrl   rk   z-<Handle noop(1, 2) at %s:%s created at %s:%s>z7<Handle cancelled noop(1, 2) at %s:%s created at %s:%s>)r'   rŒ  r  r6  r   Ú	_getframeÚf_linenor   rŽ  rŠ  r}   r  rœ   rð  r¾   ©r*   Zcreate_filenameZcreate_linenor‘  r¤  r¥  r   r   r   Útest_handle_repr_debugŒ  s0    


ÿÿ
ÿþ
ÿþz"HandleTests.test_handle_repr_debugc                    s|   t  ¡  ¡ }| d¡ ˆ  |¡ ‡ fdd„}| t¡}||ƒ | t¡}||ƒ | dt¡}||ƒ | dt¡}||ƒ d S )NTc                    sB   t  d¡jd }ˆ  | jt¡ ˆ  | jd d d… t|df¡ d S )Nrl   rä   rj   Útest_handle_source_traceback)r   r§  r¨  rÿ   r–  Úlistrœ   r6  )r‘  r¥  r0   r   r   Úcheck_source_traceback«  s    þÿzHHandleTests.test_handle_source_traceback.<locals>.check_source_tracebackr   )	r   Úget_event_loop_policyr$   Ú	set_debugr%   r    rŠ  r¤   rš   )r*   r'   r­  r‘  r   r0   r   r«  ¦  s    

	

z(HandleTests.test_handle_source_tracebackÚ	CoroutinezNo collections.abc.Coroutinec                 C   sÂ   t ƒ }d|_|  t |¡¡ |  t |¡d¡ d|_|  t |¡d¡ d|_	|  t |¡d¡ d  |_|_|  t |¡d¡ t ƒ }d|_|  t |¡d	¡ t ƒ }d|_d |_
|  t |¡d¡ d S )
NZAAAzAAA()ZBBBzBBB()TzBBB() runningz%<CoroLike without __name__>() runningr)   z
CoroLike())r)   r3   r„   r   Ziscoroutinerœ   r   Z_format_coroutiner5   Ú
cr_runningÚcr_code)r*   re  r   r   r   Ú+test_coroutine_like_object_debug_formattingÃ  s&    ÿz7HandleTests.test_coroutine_like_object_debug_formatting)r3   r4   r5   rz   r’  r—  rš  r¢  rª  r«  r_  r+  r)  ÚcollectionsÚabcr³  rY   r   r   rV   r   r‹  0  s   2ÿr‹  c                       sL   e Zd Z‡ fdd„Zdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ Zdd„ Z	‡  Z
S )Ú
TimerTestsc                    s   t ƒ  ¡  t ¡ | _d S r   )rT   rz   r   rv  r'   r0   rV   r   r   rz   ç  s    
zTimerTests.setUpc                 C   s8   t  ¡ }t |dd„ dt ¡ ¡}|  t|ƒt|ƒ¡ d S )Nc                   S   s   dS r$  r   r   r   r   r   rÏ   í  ri   z&TimerTests.test_hash.<locals>.<lambda>r   )r   r  r   ÚTimerHandler   rv  rœ   Úhash©r*   Úwhenr‘  r   r   r   Ú	test_hashë  s
    ÿzTimerTests.test_hashc                 C   s4   t  ¡ }t |dd„ dt ¡ ¡}|  || ¡ ¡ d S )Nc                   S   s   dS r$  r   r   r   r   r   rÏ   ó  ri   z&TimerTests.test_when.<locals>.<lambda>r   )r   r  r   r·  r   rv  rœ   rº  r¹  r   r   r   Ú	test_whenñ  s
    ÿzTimerTests.test_whenc                 C   sœ   dd„ }d}t  ¡ }t |||t ¡ ¡}|  |j|¡ |  |j|¡ |  	| 
¡ ¡ | ¡  |  | 
¡ ¡ |  |j¡ |  |j¡ |  ttjd ||| j¡ d S )Nc                  W   s   | S r   r   rº   r   r   r   r™   ø  s    z'TimerTests.test_timer.<locals>.callback)rl   rm   rj   )r   r  r   r·  r   rv  r  r  r  r¿   r  r¾   r„   r­  r‰   ÚAssertionErrorr'   )r*   r™   r»   rº  r‘  r   r   r   Ú
test_timer÷  s    
þzTimerTests.test_timerc                 C   sV   d| j j_t dtd| j ¡}t t¡}|  t	|ƒd| ¡ | 
¡  |  t	|ƒd¡ d S )NFé{   r   z&<TimerHandle when=123 noop() at %s:%s>z <TimerHandle cancelled when=123>)r'   rŒ  r  r   r·  rŠ  r}   r  rœ   rð  r¾   )r*   r‘  Úsrcr   r   r   Útest_timer_repr	  s    


ÿ
ÿzTimerTests.test_timer_reprc                 C   s€   d| j j_t}t ¡ jd }t dt	d| j ¡}t
 t	¡\}}|  t|ƒd||||f ¡ | ¡  |  t|ƒd||||f ¡ d S )NTrl   r¿  r   z7<TimerHandle when=123 noop() at %s:%s created at %s:%s>zA<TimerHandle cancelled when=123 noop() at %s:%s created at %s:%s>)r'   rŒ  r  r6  r   r§  r¨  r   r·  rŠ  r}   r  rœ   rð  r¾   r©  r   r   r   Útest_timer_repr_debug	  s     


þÿ

þÿz TimerTests.test_timer_repr_debugc                 C   s:  dd„ }t  ¡ }t ||d| j¡}t ||d| j¡}|  ||k ¡ |  ||k ¡ |  ||k¡ |  ||k¡ |  ||k¡ |  ||k¡ |  ||k¡ |  ||k¡ |  ||k¡ |  ||k¡ | ¡  |  ||k¡ t ||d| j¡}t |d |d| j¡}|  ||k ¡ |  ||k ¡ |  ||k¡ |  ||k¡ |  ||k¡ |  ||k¡ |  ||k¡ |  ||k¡ |  ||k¡ |  ||k¡ t |d| j¡}|  	t
| |¡¡ |  	t
| |¡¡ |  t¡ |dk  W d   ƒ n1 sè0    Y  |  t¡ |dk W d   ƒ n1 s0    Y  |  t¡ |dk W d   ƒ n1 sP0    Y  |  t¡ |dk W d   ƒ n1 s„0    Y  |  |dk¡ |  |dk¡ |  |tk¡ |  |tk¡ |  |tk ¡ |  |tk¡ |  |tk¡ |  |tk¡ |  |tk ¡ |  |tk¡ |  |tk¡ |  |tk¡ d S )Nc                  W   s   | S r   r   rº   r   r   r   r™   1	  s    z2TimerTests.test_timer_comparison.<locals>.callbackr   g      $@)r   r  r   r·  r'   r¿   r„   r¾   rŽ  r  ÚNotImplementedÚ__eq__Ú__ne__r‰   rå   r   r   r   )r*   r™   rº  Zh1Zh2Zh3r   r   r   Útest_timer_comparison0	  sf    ((((z TimerTests.test_timer_comparison)r3   r4   r5   rz   r»  r¼  r¾  rÁ  rÂ  rÆ  rY   r   r   rV   r   r¶  å  s   r¶  c                   @   s   e Zd Zdd„ Zdd„ ZdS )ÚAbstractEventLoopTestsc                 C   s   t  ¡ }t ¡ }|  t|j¡ |  t|jd ¡ |  t|j¡ |  t|j	¡ |  t|j
¡ |  t|j¡ |  t|jd ¡ |  t|jd d ¡ |  t|j||¡ |  t|jd ¡ |  t|j¡ |  t|jd ¡ |  t|j|¡ |  t|jd|¡ |  t|jd¡ |  t|jd|¡ |  t|jd¡ |  t|jd|¡ |  t|jd¡ |  t|jd¡ |  t|j|¡ |  t|j|¡ |  t|j|¡ |  t|j¡ |  t|j|¡ d S rà   )r   rv  r   ÚAbstractEventLoopr‰   ÚNotImplementedErrorr›   r&   r‘   r…   r|   r1   rn  rš   r%  r    r   r¤   Zset_default_executorrÕ   rÆ   rÛ   rÜ   ræ   rç   Zset_exception_handlerZdefault_exception_handlerr¦  rŒ  r¯  )r*   r=  r'   r   r   r   Útest_not_implementedq	  sš    ÿÿÿÿÿÿÿ
ÿ
ÿÿÿÿÿ
ÿÿ
ÿÿ
ÿÿÿÿÿÿÿÿz+AbstractEventLoopTests.test_not_implementedc                    s,   ‡ fdd„}t  ¡ }| |ƒ ¡ | ¡  d S )Nc                  “   s(  t  ¡ } t ¡ }ˆ  t¡" | | | ¡I d H  W d   ƒ n1 sB0    Y  ˆ  t¡" | dd¡I d H  W d   ƒ n1 s~0    Y  ˆ  t¡  | d¡I d H  W d   ƒ n1 s¸0    Y  ˆ  t¡  | 	| ¡I d H  W d   ƒ n1 sò0    Y  ˆ  t¡  | 
| ¡I d H  W d   ƒ n1 s.0    Y  ˆ  t¡  | | ¡I d H  W d   ƒ n1 sj0    Y  ˆ  t¡" | | d¡I d H  W d   ƒ n1 s¨0    Y  ˆ  t¡" | | d¡I d H  W d   ƒ n1 sæ0    Y  ˆ  t¡" | | d¡I d H  W d   ƒ n1 s$0    Y  ˆ  t¡" | | | ¡I d H  W d   ƒ n1 sb0    Y  ˆ  t¡  | | ¡I d H  W d   ƒ n1 sž0    Y  ˆ  t¡" | | | ¡I d H  W d   ƒ n1 sÜ0    Y  ˆ  t¡" | | | ¡I d H  W d   ƒ n1 s0    Y  ˆ  t¡& | | t jj¡I d H  W d   ƒ n1 s\0    Y  ˆ  t¡& | | t jj¡I d H  W d   ƒ n1 sž0    Y  ˆ  t¡$ | | t j¡I d H  W d   ƒ n1 sÞ0    Y  ˆ  t¡  | | ¡I d H  W d   ƒ n1 s0    Y  d S )Nr·  é  )r·  rË  r   )r   rv  r   rÈ  r‰   rÉ  rµ   rm  rÌ  r  rS  rË  rÿ  Zsock_recv_intoZsock_sendallZsock_connectZsock_acceptZsock_sendfileÚsendfilerÙ  Úsentinelrâ  rì  rB  r7  )r=  r'   r0   r   r   Úinner©	  sH    00..002222022664z@AbstractEventLoopTests.test_not_implemented_async.<locals>.inner)r   r$   r&   r1   )r*   rÎ  r'   r   r0   r   Útest_not_implemented_async§	  s    'z1AbstractEventLoopTests.test_not_implemented_asyncN)r3   r4   r5   rÊ  rÏ  r   r   r   r   rÇ  o	  s   6rÇ  c                   @   s^   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Ze d	¡d
d„ ƒZ	dd„ Z
dd„ Zdd„ Zdd„ ZdS )ÚPolicyTestsc                 C   sZ   t  ¡ }|  t|j¡ |  t|jtƒ ¡ |  t|j¡ |  t|j¡ |  t|j	tƒ ¡ d S r   )
r   ÚAbstractEventLoopPolicyr‰   rÉ  Úget_event_loopr%   r¬  r$   Zget_child_watcherr  ©r*   Úpolicyr   r   r   Útest_event_loop_policy×	  s    
ÿz"PolicyTests.test_event_loop_policyc                 C   sX   t  ¡ }|  |jj¡ | ¡ }|  |t j¡ |  |jj|¡ |  || ¡ ¡ | 	¡  d S r   )
r   ÚDefaultEventLoopPolicyr­  Ú_localZ_looprÒ  rÿ   rÈ  r  r1   ©r*   rÔ  r'   r   r   r   Útest_get_event_loopà	  s    zPolicyTests.test_get_event_loopc                 C   sZ   t  ¡ }tjj|d|jd"}| ¡ }| |¡ W d   ƒ n1 sD0    Y  | ¡  d S )Nr%   )Úwraps)	r   rÖ  r   r*  r¬  r%   rÒ  r”  r1   )r*   rÔ  Zm_set_event_loopr'   r   r   r   Ú(test_get_event_loop_calls_set_event_loopë	  s    þ(z4PolicyTests.test_get_event_loop_calls_set_event_loopc                 C   s$   t  ¡ }| d ¡ |  t|j¡ d S r   )r   rÖ  r%   r‰   rŠ   rÒ  rÓ  r   r   r   Ú"test_get_event_loop_after_set_noneû	  s    
z.PolicyTests.test_get_event_loop_after_set_nonez'asyncio.events.threading.current_threadc                    s,   ‡ fdd„}t j|d}| ¡  | ¡  d S )Nc                     s   t  ¡ } ˆ  t| j¡ d S r   )r   rÖ  r‰   rŠ   rÒ  )rÔ  r0   r   r   r=  
  s    z1PolicyTests.test_get_event_loop_thread.<locals>.fr¨   )rª   r­   r®   r¯   )r*   Zm_current_threadr=  Úthr   r0   r   Útest_get_event_loop_thread 
  s    z&PolicyTests.test_get_event_loop_threadc                 C   s*   t  ¡ }| ¡ }|  |t j¡ | ¡  d S r   )r   rÖ  r$   rÿ   rÈ  r1   rØ  r   r   r   Útest_new_event_loop
  s    zPolicyTests.test_new_event_loopc                 C   sh   t  ¡ }| ¡ }|  t|jtƒ ¡ | ¡ }| |¡ |  || ¡ ¡ |  	|| ¡ ¡ | 
¡  | 
¡  d S r   )r   rÖ  rÒ  r‰   r½  r%   r¬  r$   r  ÚassertIsNotr1   )r*   rÔ  Zold_loopr'   r   r   r   Útest_set_event_loop
  s    
zPolicyTests.test_set_event_loopc                 C   s*   t  ¡ }|  |t j¡ |  |t  ¡ ¡ d S r   )r   r®  rÿ   rÑ  r  rÓ  r   r   r   Útest_get_event_loop_policy
  s    z&PolicyTests.test_get_event_loop_policyc                 C   sL   |   ttjtƒ ¡ t ¡ }t ¡ }t |¡ |  |t ¡ ¡ |  ||¡ d S r   )	r‰   r½  r   r   r¬  r®  rÖ  r  rà  )r*   Ú
old_policyrÔ  r   r   r   Útest_set_event_loop_policy$
  s    
ÿ
z&PolicyTests.test_set_event_loop_policyN)r3   r4   r5   rÕ  rÙ  rÛ  rÜ  r   r*  rÞ  rß  rá  râ  rä  r   r   r   r   rÐ  Õ	  s   	

rÐ  c                       sR   e Zd ZdZdZdZdZ‡ fdd„Z‡ fdd„Ze	j
dkrBdd„ Zd	d
„ Z‡  ZS )ÚGetEventLoopTestsMixinNc                    sÌ   t j| _t j| _t j| _t j| _t	| ƒj
t _t	| ƒjt _t	| ƒjt _t	| ƒjt _t	| ƒj
t_t	| ƒjt_t	| ƒjt_t	| ƒjt_tƒ  ¡  t ¡ | _t | j¡ tjdkrÈt ¡ }| | j¡ t |¡ d S r/  )r   Ú_get_running_loopÚ_get_running_loop_savedÚ_set_running_loopÚ_set_running_loop_savedÚget_running_loopÚget_running_loop_savedrÒ  Úget_event_loop_savedrÒ  Ú_get_running_loop_implÚ_set_running_loop_implÚget_running_loop_implÚget_event_loop_implr   rT   rz   r$   r'   r%   r   r   r}  r~  r  r€  rV   r   r   rz   7
  s&    


zGetEventLoopTestsMixin.setUpc              	      sÒ   zvt jdkrt d ¡ tƒ  ¡  W | j ¡  t d ¡ | j	t
_| jt
_| jt
_| jt
_| j	t_| jt_| jt_| jt_nV| j ¡  t d ¡ | j	t
_| jt
_| jt
_| jt
_| j	t_| jt_| jt_| jt_0 d S r/  )r   r   r   r  rT   r€   r'   r1   r%   rç  r   ræ  ré  rè  rë  rê  rì  rÒ  r0   rV   r   r   r€   Q
  s0    




õ

zGetEventLoopTestsMixin.tearDownr   c                    s.   t  ¡  ‡ fdd„}ˆ  ˆ j |ƒ ¡d¡ d S )Nc                  “   s*   t j ¡ } ˆ j | t¡I d H }|  ¡  |S r   )Ú
concurrentÚfuturesÚProcessPoolExecutorr'   rµ   r(   Úshutdown)Úpoolr  r0   r   r   r  m
  s    
ÿ
zDGetEventLoopTestsMixin.test_get_event_loop_new_process.<locals>.mainr"   )r	   Z*skip_if_broken_multiprocessing_synchronizerœ   r'   r&   )r*   r  r   r0   r   Útest_get_event_loop_new_processg
  s    þz6GetEventLoopTestsMixin.test_get_event_loop_new_processc              	      s&  G dd„ dt ƒ‰ G ‡ fdd„dtjƒ}t ¡ }z„t |ƒ ¡ t ¡ ‰ˆ ˆ ¡ t ¡  W d   ƒ n1 sn0    Y  t d ¡ ˆ ˆ ¡ t ¡  W d   ƒ n1 sª0    Y  ˆ 	t
d¡  ˆ t ¡ d ¡ W d   ƒ n1 sæ0    Y  ˆ t ¡ d ¡ ‡‡fdd„}ˆ |ƒ ¡ t ˆ¡ ˆ ˆ ¡ t ¡  W d   ƒ n1 sN0    Y  t d ¡ ˆ ˆ ¡ t ¡  W d   ƒ n1 sŒ0    Y  W t |¡ ˆd urÔˆ ¡  nt |¡ ˆd urÒˆ ¡  0 ˆ 	t
d¡  ˆ t ¡ d ¡ W d   ƒ n1 s0    Y  ˆ t ¡ d ¡ d S )Nc                   @   s   e Zd ZdS )zRGetEventLoopTestsMixin.test_get_event_loop_returns_running_loop.<locals>.TestErrorN)r3   r4   r5   r   r   r   r   Ú	TestErrory
  s   r÷  c                       s   e Zd Z‡ fdd„ZdS )zOGetEventLoopTestsMixin.test_get_event_loop_returns_running_loop.<locals>.Policyc                    s   ˆ ‚d S r   r   r0   ©r÷  r   r   rÒ  }
  s    z^GetEventLoopTestsMixin.test_get_event_loop_returns_running_loop.<locals>.Policy.get_event_loopN)r3   r4   r5   rÒ  r   rø  r   r   ÚPolicy|
  s   rù  z
no runningc                   “   s4   ˆ  t ¡ ˆ ¡ ˆ  t ¡ ˆ ¡ ˆ  t ¡ ˆ ¡ d S r   )r  r   rÒ  rê  ræ  r   )r'   r*   r   r   r(  
  s    zMGetEventLoopTestsMixin.test_get_event_loop_returns_running_loop.<locals>.func)rK  r   rÖ  r®  r   r$   r‰   rÒ  r%   rc  rŠ   r  rê  ræ  r&   r1   )r*   rù  rã  r(  r   )r÷  r'   r*   r   Ú(test_get_event_loop_returns_running_loopx
  s>    &
&.
(
*


þ


0z?GetEventLoopTestsMixin.test_get_event_loop_returns_running_loop)r3   r4   r5   rí  rî  rï  rð  rz   r€   r   r   rö  rú  rY   r   r   rV   r   rå  0
  s   
rå  c                   @   s$   e Zd ZejZejZejZ	ej
ZdS )ÚTestPyGetEventLoopN)r3   r4   r5   r   Z_py__get_running_looprí  Z_py__set_running_looprî  Z_py_get_running_looprï  Z_py_get_event_looprð  r   r   r   r   rû  ©
  s   rû  c                   @   s$   e Zd ZejZejZejZ	ej
ZdS )ÚTestCGetEventLoopN)r3   r4   r5   r   Z_c__get_running_looprí  Z_c__set_running_looprî  Z_c_get_running_looprï  Z_c_get_event_looprð  r   r   r   r   rü  ·
  s   rü  c                   @   s   e Zd Zdd„ ZdS )Ú
TestServerc                    sb   t  ¡ }|  |j¡ t|ƒ‰ | | ‡ fdd„dd¡¡}|  | ¡ |¡ | ¡  | | 	¡ ¡ d S )Nc                      s   ˆ S r   r   r   rQ  r   r   rÏ   Å
  ri   z*TestServer.test_get_loop.<locals>.<lambda>r€  r   )
r   r$   rb  r1   rS   r&   rS  rœ   Úget_loopÚwait_closed)r*   r'   ry  r   rQ  r   Útest_get_loopÁ
  s    zTestServer.test_get_loopN)r3   r4   r5   r   r   r   r   r   rý  ¿
  s   rý  c                   @   s$   e Zd Zdd„ Zdd„ Zdd„ ZdS )ÚTestAbstractServerc                 C   s:   |   t¡ t ¡  ¡  W d   ƒ n1 s,0    Y  d S r   )r‰   rÉ  r   ÚAbstractServerr1   r0   r   r   r   r*  Í
  s    zTestAbstractServer.test_closec                 C   sT   t  ¡ }|  |j¡ |  t¡" | t ¡  	¡ ¡ W d   ƒ n1 sF0    Y  d S r   )
r   r$   rb  r1   r‰   rÉ  r&   r   r  rÿ  r?   r   r   r   Útest_wait_closedÑ
  s    z#TestAbstractServer.test_wait_closedc                 C   s:   |   t¡ t ¡  ¡  W d   ƒ n1 s,0    Y  d S r   )r‰   rÉ  r   r  rþ  r0   r   r   r   r   Ø
  s    z TestAbstractServer.test_get_loopN)r3   r4   r5   r*  r  r   r   r   r   r   r  Ë
  s   r  Ú__main__)KÚcollections.abcr´  Úconcurrent.futuresrñ  r4  rã  rì   r   r   ré   rÑ   r  ÚImportErrorr]  r   rª   r   r@  r_  r   r˜  r	  r   r   r   r   r   Ztest.test_asyncior   r}   r#  r	   Ztest.supportr
   r   r   r   r   r    r(   r)   r  r6   rS   ZDatagramProtocolrZ   ra   ZBaseProtocolrc   re  rd   ry   r.  ZTestCaserr  rv  rƒ  r|  r)  r‚  r†  rˆ  rŠ  r‹  r¶  rÇ  rÐ  rå  rû  Z_asynciorü  rý  r  r3   r  r   r   r   r   Ú<module>   sÎ   

	" )           Q  ÿþþþþþ 6 f[y
