HEX
Server: Apache
System: Linux bd12.noc223.com 4.18.0-553.121.1.lve.el8.x86_64 #1 SMP Thu Apr 30 16:40:41 UTC 2026 x86_64
User: handcraf (1693)
PHP: 8.1.28
Disabled: NONE
Upload Files
File: //opt/alt/python312/lib64/python3.12/test/test_asyncio/__pycache__/test_events.cpython-312.pyc
�

}h�e�����dZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZ	ddl
Z
ddlZddlZddlZddlZddlZddlZddlZddlmZddlZddlZejdvrddlZddlZddlmZddlmZddlmZddlmZ dd	l!m"Z#dd
l$m%Z%ddl&m'Z'ddl&m(Z(dd
l&m)Z)m*Z*m+Z+d�Z,d�Z-d�Z.Gd�d�Z/Gd�dej`�Z1Gd�de1�Z2Gd�dejf�Z4Gd�dej`�Z5Gd�dejl�Z7Gd�dejp�Z9Gd�d �Z:Gd!�d"�Z;ejd#k(r.Gd$�d%e:e#jx�Z=Gd&�d'e:e;e#jx�Z>n�ddl?Z?Gd(�d)e:�Z@eAe?d*�rGd+�d,e@e;e#jx�ZBeAe?d-�rGd.�d/e@e;e#jx�ZCeAe?d0�rGd1�d2e@e;e#jx�ZDGd3�d%e@e;e#jx�Z=d4�ZEGd5�d6e#jx�ZFGd7�d8ejx�ZGGd9�d:ejx�ZHGd;�d<ejx�ZIGd=�d>�ZJGd?�d@eJejx�ZK	ddlLZLGdA�dBeJejx�ZMGdC�dDejx�ZNGdE�dFejx�ZOePdGk(rej��yy#e$rdZ
Y���wxYw#e$rY�WwxYw)HzTests for events.py.�N)�mock)�win32�vxworks)�
coroutines)�events)�selector_events)�_cleanup_tests)�utils)�support)�
socket_helper)�threading_helper)�	ALWAYS_EQ�LARGEST�SMALLESTc�.�tjd�y�N)�asyncio�set_event_loop_policy���D/opt/alt/python312/lib64/python3.12/test/test_asyncio/test_events.py�tearDownModuler*s���!�!�$�'rc���tjjd�rytjdk7rytj�d}t	tt|jd���}|dkS)z4Return True if the platform is Mac OS 10.4 or older.�aixT�darwinFr�.)�
�)�sys�platform�
startswith�mac_ver�tuple�map�int�split)�versions r�broken_unix_getsocknamer(.s^��
�|�|���u�%��	����	!����� ��#�G��C��W�]�]�3�/�0�1�G��W��rc��d�}tj�}tj|�|j|��S)Nc��K�y�w�N�hellorrrr�doitz8_test_get_event_loop_new_process__sub_proc.<locals>.doit:s	�������)r�new_event_loop�set_event_loop�run_until_complete)r-�loops  r�*_test_get_event_loop_new_process__sub_procr39s8����!�!�#�D����4� ��"�"�4�6�*�*rc�$�eZdZd�Zd�Zd�Zd�Zy)�CoroLikec��yrr)�self�vs  r�sendz
CoroLike.sendC���rc��yrr�r7�excs  r�throwzCoroLike.throwFr:rc��yrr�r7s r�closezCoroLike.closeIr:rc��yrrr@s r�	__await__zCoroLike.__await__Lr:rN)�__name__�
__module__�__qualname__r9r>rArCrrrr5r5Bs��
�
�
�
rr5c�:�eZdZdZdZdd�Zd�Zd�Zd�Zd�Z	d�Z
y)	�MyBaseProtoNc��d|_d|_d|_|�+|j�|_|j�|_yy�N�INITIALr)�	transport�state�nbytes�
create_future�	connected�done�r7r2s  r�__init__zMyBaseProto.__init__TsB�������
������!�/�/�1�D�N��*�*�,�D�I�rc�V�|j|vrtd|j�d|����y�Nzstate: z, expected: �rM�AssertionError�r7�expecteds  r�
_assert_statezMyBaseProto._assert_state\s/���:�:�X�%� �7�4�:�:�.��X�L�!Q�R�R�&rc��||_|jd�d|_|jr|jj	d�yy�NrK�	CONNECTED�rLrZrMrP�
set_result�r7rLs  r�connection_madezMyBaseProto.connection_made`s<��"������9�%� ��
��>�>��N�N�%�%�d�+�rc�b�|jd�|xjt|�z
c_y�Nr]�rZrN�len�r7�datas  r�
data_receivedzMyBaseProto.data_receivedgs"�����;�'����s�4�y� �rc�4�|jd�d|_y)Nr]�EOF)rZrMr@s r�eof_receivedzMyBaseProto.eof_receivedks�����;�'���
rc��|jdd�d|_|jr|jjd�yy)Nr]rj�CLOSED�rZrMrQr_r<s  r�connection_lostzMyBaseProto.connection_lostos7�����;��.���
��9�9��I�I� � ��&�rr)rDrErFrPrQrSrZrarhrkrorrrrHrHPs+���I��D�-�S�,�!��'rrHc���eZdZ�fd�Z�xZS)�MyProtoc�F��t�|�|�|jd�y)Ns%GET / HTTP/1.0
Host: example.com

)�superra�write)r7rL�	__class__s  �rrazMyProto.connection_madews���
���	�*����F�Gr�rDrErFra�
__classcell__�rus@rrqrqvs���H�Hrrqc�6�eZdZdZdd�Zd�Zd�Zd�Zd�Zd�Z	y)	�MyDatagramProtoNc�P�d|_d|_|�|j�|_yyrJ)rMrNrOrQrRs  rrSzMyDatagramProto.__init__s+����
�������*�*�,�D�I�rc�X�|j|k7rtd|j�d|����yrUrVrXs  rrZzMyDatagramProto._assert_state��/���:�:��!� �7�4�:�:�.��X�L�!Q�R�R�"rc�B�||_|jd�d|_y)NrK�INITIALIZED�rLrZrMr`s  rrazMyDatagramProto.connection_made�s��"������9�%�"��
rc�b�|jd�|xjt|�z
c_y�Nrrd)r7rg�addrs   r�datagram_receivedz!MyDatagramProto.datagram_received�s"�����=�)����s�4�y� �rc�&�|jd�yr�)rZr<s  r�error_receivedzMyDatagramProto.error_received�s�����=�)rc��|jd�d|_|jr|jjd�yy)Nrrmrnr<s  rrozMyDatagramProto.connection_lost�s5�����=�)���
��9�9��I�I� � ��&�rr)
rDrErFrQrSrZrar�r�rorrrrzrz|s&���D�-�S�#�
!�*�'rrzc�6�eZdZdZdd�Zd�Zd�Zd�Zd�Zd�Z	y)	�MyReadPipeProtoNc�`�dg|_d|_d|_|�|j�|_yyrJ)rMrNrLrOrQrRs  rrSzMyReadPipeProto.__init__�s4���[��
����������*�*�,�D�I�rc�X�|j|k7rtd|j�d|����yrUrVrXs  rrZzMyReadPipeProto._assert_state�r}rc�l�||_|jdg�|jjd�yr\)rLrZrM�appendr`s  rrazMyReadPipeProto.connection_made�s+��"������I�;�'��
�
���+�&rc�f�|jddg�|xjt|�z
c_yr\rdrfs  rrhzMyReadPipeProto.data_received�s'�����I�{�3�4����s�4�y� �rc�`�|jddg�|jjd�y)NrKr]rj)rZrMr�r@s rrkzMyReadPipeProto.eof_received�s'�����I�{�3�4��
�
���%� rc��d|jvr|jjd�|jgd��|jjd�|jr|jj	d�yy)Nrj)rKr]rjrm)rMr�rZrQr_r<s  rrozMyReadPipeProto.connection_lost�s_����
�
�"��J�J���e�$����:�;��
�
���(�#��9�9��I�I� � ��&�rr)
rDrErFrQrSrZrarhrkrorrrr�r��s&���D�-�S�'�
!�!�'rr�c�*�eZdZdZdd�Zd�Zd�Zd�Zy)�MyWritePipeProtoNc�P�d|_d|_|�|j�|_yy)NrK)rMrLrOrQrRs  rrSzMyWritePipeProto.__init__�s+����
�������*�*�,�D�I�rc�X�|j|k7rtd|j�d|����yrUrVrXs  rrZzMyWritePipeProto._assert_state�r}rc�B�||_|jd�d|_yr\r�r`s  rraz MyWritePipeProto.connection_made�s��"������9�%� ��
rc��|jd�d|_|jr|jjd�yy�Nr]rmrnr<s  rroz MyWritePipeProto.connection_lost�s5�����;�'���
��9�9��I�I� � ��&�rr)rDrErFrQrSrZrarorrrr�r��s���D�-�S�!�
'rr�c�6�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	y)	�MySubprocessProtocolc�V�d|_d|_|j�|_|j�|_td�D�cic]}||j���c}|_ddd�|_d|_tj�tj�d�|_ycc}w)NrK�r���)rMrLrOrP�	completed�range�disconnectsrg�
returncoder�Event�got_data)r7r2�fds   rrSzMySubprocessProtocol.__init__�s�����
�����+�+�-����+�+�-���?D�Q�x�H��B�� 2� 2� 4�4�H�����$��	����#�M�M�O�#�M�M�O�-��
��Is�B&c�X�|j|k7rtd|j�d|����yrUrVrXs  rrZz"MySubprocessProtocol._assert_state�r}rc�x�||_|jd�d|_|jj	d�yr\r^r`s  rraz$MySubprocessProtocol.connection_made�s0��"������9�%� ��
����!�!�$�'rc�j�|jd�d|_|jjd�yr�)rZrMr�r_r<s  rroz$MySubprocessProtocol.connection_lost�s)�����;�'���
����!�!�$�'rc��|jd�|j|xx|z
cc<|j|j�yrc)rZrgr��set)r7r�rgs   r�pipe_data_receivedz'MySubprocessProtocol.pipe_data_received�s7�����;�'��	�	�"�
���
��
�
�b����rc��|jd�|r|j|j|�y|j|j|�yrc)rZr��
set_exceptionr_)r7r�r=s   r�pipe_connection_lostz)MySubprocessProtocol.pipe_connection_lost�sE�����;�'�����R� �.�.�s�3����R� �+�+�C�0rc�d�|jd�|jj�|_yrc)rZrL�get_returncoder�r@s r�process_exitedz#MySubprocessProtocol.process_exiteds$�����;�'��.�.�7�7�9��rN)
rDrErFrSrZraror�r�r�rrrr�r��s&��	-�S�(�(�
 �
1�:rr�c�
��eZdZ�fd�Z�fd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zej"eed�d�d��Zej"eed�d�ej"eed�d�d���Zej"eed�d�ej"eed�d�d���Zd^d�Zd�Zej4d��Zddifd�Z		d_d�Z	d_d�Zej>e dud�d ��Z!ej4ej>e dud�d!���Z"d"�Z#ejHd#��Z%ejHd$��Z&d%�Z'd`d&�Z(ej>e dud�d'��Z)d(�Z*e+jXd)�d*��Z-d+�Z.d,�Z/d-�Z0d.�Z1ej"ee2d/�d0�d1��Z3d2�Z4ej4d3��Z5ej"ee2d4�d5�d6��Z6dad7�Z7dad8�Z8dad9�Z9ej>e dud�d:��Z:ej4ej>e dud�d;���Z;ej>e dud�d<��Z<ej4ej>e dud�d=���Z=ej>e dud�d>��Z>ej4ej>e dud�d?���Z?ej>e dud�d@��Z@dA�ZAdB�ZBej"ej�dC�dD��ZDejHdE��ZEdF�ZFdG�ZGej"ej�dC�dH��ZHdI�ZIdJ�ZJej"eKj�dKk7dL�dM��ZMej"eKj�dKk7dL�dN��ZNej"eKj�dKk7dL�ej"eeOdO�dP�dQ���ZPej"eKj�dKk7dL�dR��ZQej"eKj�dKk7dL�dS��ZRej"eKj�dKk7dL�ej"eeOdO�dP�eSj�dTdU�dV����ZUej"eKj�dKk7dL�ej"eeOdO�dP�eSj�dTdU�dW����ZVdX�ZWdY�ZXdZ�ZYd[�ZZd\�Z[d]�Z\�xZ]S)b�EventLoopTestsMixinc���t�|��|j�|_|j	|j�yr)rs�setUp�create_event_loopr2r0�r7rus �rr�zEventLoopTestsMixin.setUps.���
��
���*�*�,��	����D�I�I�&rc����|jj�stj|j�|j	�tj�t�|�!�yr)	r2�	is_closed�
test_utils�run_briefly�
doCleanupsr�
gc_collectrs�tearDownr�s �rr�zEventLoopTestsMixin.tearDown
sF����y�y�"�"�$��"�"�4�9�9�-���������
���rc�����d����fd�}�jtd�5�jt�jj
|��ddd�y#1swYyxYw)Nc��JK�tjd��d{���y7��w�Nr�r�sleeprrr�coro1zBEventLoopTestsMixin.test_run_until_complete_nesting.<locals>.coro1s�����-�-��"�"�"�s�#�!�#c���K��j�jj���jj���y�wr)�
assertTruer2�
is_runningr1)r�r7s��r�coro2zBEventLoopTestsMixin.test_run_until_complete_nesting.<locals>.coro2s4������O�O�D�I�I�0�0�2�3��I�I�(�(���1�s�AAzcoroutine \S+ was never awaited)�assertWarnsRegex�RuntimeWarning�assertRaises�RuntimeErrorr2r1)r7r�r�s` @r�test_run_until_complete_nestingz3EventLoopTestsMixin.test_run_until_complete_nestings`���	#�	2��
"�
"��.�
�	E�
����d�i�i�:�:�E�G�
E�		E�	E�	E�s�1A�A%c��d}|jj�}|jjtj|��|jj�|z
}|j||tjz
�y�N皙�����?)r2�timer1rr��assertGreaterEqualr��	CLOCK_RES)r7�delay�t0�dts    r�test_run_until_completez+EventLoopTestsMixin.test_run_until_complete(sb����
�Y�Y�^�^�
���	�	�$�$�W�]�]�5�%9�:�
�Y�Y�^�^�
��
"������E�J�,@�,@�$@�Arc�t���fd�}|�}�jt�jj|�y)Nc���K��jj�tjd��d{���y7��wr�)r2�stoprr�r@s�r�cbz?EventLoopTestsMixin.test_run_until_complete_stopped.<locals>.cb1s'������I�I�N�N���-�-��$�$�$�s�3>�<�>)r�r�r2r1)r7r��tasks`  r�test_run_until_complete_stoppedz3EventLoopTestsMixin.test_run_until_complete_stopped/s0���	%��t�����,��)�)�6�6��	>rc����g���fd�}�jjd|d��jj��j�dg�y)Nc�\���j|��jj�yr�r�r2r���arg�resultsr7s ��r�callbackz5EventLoopTestsMixin.test_call_later.<locals>.callback;s����N�N�3���I�I�N�N�rr�zhello world)r2�
call_later�run_forever�assertEqual�r7r�r�s` @r�test_call_laterz#EventLoopTestsMixin.test_call_later8sG�����	�	
�	�	���S�(�M�:��	�	��������=�/�2rc����g���fd�}�jj|dd��jj��j�dg�y)Nc�`���j||f��jj�yrr�)�arg1�arg2r�r7s  ��rr�z4EventLoopTestsMixin.test_call_soon.<locals>.callbackFs!����N�N�D�$�<�(��I�I�N�N�rr,�world)r,r�)r2�	call_soonr�r�r�s` @r�test_call_soonz"EventLoopTestsMixin.test_call_soonCsI�����	�	
�	�	���H�g�w�7��	�	��������#5�"6�7rc������g�tj����fd�����fd�}�j�tj|��}|j	��5�j
j
�d��j
j�ddd�|j��j�ddg�y#1swY�.xYw)Nc�z���j|�t��dk\r�jj�yy�Nr��r�rer2r�r�s ��rr�z?EventLoopTestsMixin.test_call_soon_threadsafe.<locals>.callbackR�.����N�N�3���7�|�q� ��	�	��� �!rc�^���jj�d��j�yr+)r2�call_soon_threadsafe�release)r��lockr7s���r�
run_in_threadzDEventLoopTestsMixin.test_call_soon_threadsafe.<locals>.run_in_threadWs ����I�I�*�*�8�W�=��L�L�Nr��targetr�r,)
�	threading�Lock�acquire�Thread�startr2r�r��joinr�)r7r��tr�r�r�s`  @@@r�test_call_soon_threadsafez-EventLoopTestsMixin.test_call_soon_threadsafeNs�������~�~���	!�
	�	
�������M�2��	���	�
�	$��I�I����'�2��I�I�!�!�#�	$�	
��������7�G�"4�5�		$�	$�s� 7C�C
c�����g���fd�}�jj|d��jj|d��jj��j	�ddg�y)Nc�z���j|�t��dk\r�jj�yyr�r�r�s ��rr�zKEventLoopTestsMixin.test_call_soon_threadsafe_same_thread.<locals>.callbackhr�rr,r�)r2r�r�r�r�r�s` @r�%test_call_soon_threadsafe_same_threadz9EventLoopTestsMixin.test_call_soon_threadsafe_same_threades\�����	!�
	
�	�	�&�&�x��9��	�	���H�g�.��	�	��������7�G�"4�5rc���d�}|jjd|d�}|jj|�\}}|j|d�|j	|tj��y)Nc�.�|tj�fSr)r��	get_ident)r�s r�runz5EventLoopTestsMixin.test_run_in_executor.<locals>.runss����,�,�.�/�/r�yo)r2�run_in_executorr1r��assertNotEqualr�r
)r7r�f2�res�	thread_ids     r�test_run_in_executorz(EventLoopTestsMixin.test_run_in_executorrs`��	0�
�Y�Y�
&�
&�t�S�$�
7�����5�5�b�9���Y�����d�#����I�y�':�':�'<�=rc���d��fd�}d�}|jjd|�}|j�|jj|jj	��|jj�||j_||j_tjd�|j��y)NFc�
��d�y�NTr)�args�calleds �r�patched_call_soonzJEventLoopTestsMixin.test_run_in_executor_cancel.<locals>.patched_call_soon}s����Frc�.�tjd�y)Ng�������?)r�r�rrrrz<EventLoopTestsMixin.test_run_in_executor_cancel.<locals>.run�s���J�J�t�rg�������?)r2r
�cancelr1�shutdown_default_executorrAr�r�r�r��assertFalse)r7rrrrs    @r�test_run_in_executor_cancelz/EventLoopTestsMixin.test_run_in_executor_cancelzs������	�	��Y�Y�
&�
&�t�S�
1��
�	�	���	�	�$�$��	�	�3�3�5�	7��	�	����/��	�	��):��	�	�&��
�
�3������ rc������tj�\�}�jd�t�����fd�}�jj�j
�|��jj|jd�tj�j�fd���jj|jd�tj�j�fd���jj|j��jj�jj��jj��j�d�y)NFc���	�jd�}|r�j|�y�j�jj�j
����j�y#t$rYywxYw�N�)�recv�BlockingIOError�extendr�r2�
remove_reader�filenorA)rg�
bytes_read�rr7s ���r�readerz8EventLoopTestsMixin.test_reader_callback.<locals>.reader�sh���
��v�v�d�|��
��!�!�$�'�����	�	� 7� 7����
� C�D����	��#�
��
�s�A1�1	A=�<A=sabcc� ��t��dk\S)Nr��re�r's�r�<lambda>z:EventLoopTestsMixin.test_reader_callback.<locals>.<lambda>������J��1�0D�rsdefc� ��t��dk\S)N�r+r,s�rr-z:EventLoopTestsMixin.test_reader_callback.<locals>.<lambda>�r.rsabcdef)�socket�
socketpair�setblocking�	bytearrayr2�
add_readerr&r�r9r��	run_untilrAr�r�r�)r7�wr)r'r(s`  @@r�test_reader_callbackz(EventLoopTestsMixin.test_reader_callback�s����� � �"���1�	�
�
�e���[�
�	�	
�	�	���Q�X�X�Z��0��	�	���A�F�F�F�+����T�Y�Y�(D�E��	�	���A�F�F�F�+����T�Y�Y�(D�E��	�	���A�G�G�$��	�	���D�I�I�N�N�+��	�	��������Y�/rc�p���tj�\}��jd���fd�}d}�jj	�j�||��jj
��j�jj�j����j�jj�j����j�|jt|�dz�}|j��j||�y)NFc�\���j|��jj�yr)r9r2r�)rgr7r7s ��r�writerz8EventLoopTestsMixin.test_writer_callback.<locals>.writer�s���
�F�F�4�L��I�I�N�N�rsxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxr�)r1r2r3r2�
add_writerr&r�r��
remove_writerrrAr"rer�)r7r(r;rg�readr7s`    @r�test_writer_callbackz(EventLoopTestsMixin.test_writer_callback�s����� � �"���1�	�
�
�e��	����	�	���Q�X�X�Z���6��	�	��������	�	�/�/����
�;�<�������0�0�����<�=�	���	��v�v�c�$�i�!�m�$��	���	�����t�$r�SIGKILLz
No SIGKILLc�\��d��fd�}|jt|jjd|�|jt|jjd�|jt
|jjtjdz|�|jt
|jjtjdz�|jt
|jjd|�|jt
|jjd�|jt
|jjd|�|jt
|jjd�|jt|jjtj|�|j|jj	tj��|jjtj|�tjtj�tj�tj |j�fd��|j#|jj	tj��|j%t
j&tj�tj(�|j|jj	tj��y)Nrc����dz
�y�Nr�r��caughts�r�
my_handlerz?EventLoopTestsMixin.test_add_signal_handler.<locals>.my_handler�s����a�K�Fr�boomr����c����SrrrDs�rr-z=EventLoopTestsMixin.test_add_signal_handler.<locals>.<lambda>�s����r)r��	TypeErrorr2�add_signal_handler�remove_signal_handler�
ValueError�signal�NSIGr�r@r�SIGINT�os�kill�getpidr�r6r�r��	getsignal�default_int_handler�r7rFrEs  @r�test_add_signal_handlerz+EventLoopTestsMixin.test_add_signal_handler�s �����	�
	
����t�y�y�3�3�V�Z�	I�����t�y�y�6�6��	@������	�	�4�4�f�k�k�!�m��	�	
�����	�	�7�7����Q��	H������	�	�4�4�a��	E������	�	�7�7��	<������	�	�4�4�b�*�	F������	�	�7�7��	=�����$�)�)�6�6�����	�	
������8�8����H�I��	�	�$�$�V�]�]�J�?�
����	�	��V�]�]�+����T�Y�Y��7�	
����	�	�7�7��
�
�F�G�����)�)�&�-�-�8��3�3�	5�	
������8�8����G�Hr�SIGALRMz
No SIGALRM�	setitimerzneed signal.setitimer()c�n���d���fd�}�jjtj|�tjtj
dd��jj
d�jj��jj��j�d�y)Nrc�D���dz
��jj�yrC)r2r�)rEr7s��rrFzLEventLoopTestsMixin.test_signal_handling_while_selecting.<locals>.my_handler�s����a�K�F��I�I�N�N�r�{�G�z�?�<r��
r2rKrNrXrY�ITIMER_REALr�r�r�r�rVs` @r�$test_signal_handling_while_selectingz8EventLoopTestsMixin.test_signal_handling_while_selecting�s}���
��	�
	
�	�	�$�$�V�^�^�Z�@�����+�+�T�1�5��	�	���R������0��	�	���������#rc�z����d�d����fd�}�jjtj|g����tjtj
dd��jj
d�jj��jj��j�d�y)N)�*rc�h���dz
��j|���jj�yrC)r�r2r�)rrEr7�	some_argss ���rrFzAEventLoopTestsMixin.test_signal_handling_args.<locals>.my_handlers*����a�K�F����T�9�-��I�I�N�N�rr�r]r�r^)r7rFrErds` @@r�test_signal_handling_argsz-EventLoopTestsMixin.test_signal_handling_args�s�����	���	�	%��	�	�$�$�V�^�^�Z�L�)�L�����+�+�S�!�4��	�	���R������0��	�	���������#rTc���|jj|�\}}|j|tj�|j|tj
�|j
|j|�|r |j|jd��|jj|j�|j|jd�|j�y)N�socknamer)r2r1�assertIsInstancer�	Transport�Protocol�assertIsrL�assertIsNotNone�get_extra_inforQ�
assertGreaterrNrA)r7�connection_fut�check_sockname�tr�prs     r�_basetest_create_connectionz/EventLoopTestsMixin._basetest_create_connections������-�-�n�=���B����b�'�"3�"3�4����b�'�"2�"2�3��
�
�b�l�l�B�'��� � ��!2�!2�:�!>�?��	�	�$�$�R�W�W�-����2�9�9�a�(�
���
rc����tj�5}�jj�fd�g|j���}�j|�ddd�y#1swYyxYw)Nc�0��t�j��S�N�r2�rqr2r@s�rr-z<EventLoopTestsMixin.test_create_connection.<locals>.<lambda>�����T�Y�Y�/�r)r��run_test_serverr2�create_connection�addressrs)r7�httpd�conn_futs`  r�test_create_connectionz*EventLoopTestsMixin.test_create_connections[���
�
'�
'�
)�	7�U�2�t�y�y�2�2�/�A�27�-�-�A�H��,�,�X�6�	7�	7�	7�s�<A�A$c����t�}tj�5}�jj	�fd�|j
�}�j
||�ddd�y#1swYyxYw)Nc�0��t�j��Srvrxr@s�rr-zAEventLoopTestsMixin.test_create_unix_connection.<locals>.<lambda>*ryr)r(r��run_test_unix_serverr2�create_unix_connectionr|rs)r7rpr}r~s`   r�test_create_unix_connectionz/EventLoopTestsMixin.test_create_unix_connection"se���5�6�6��
�
,�
,�
.�	G�%��y�y�7�7�/����@�H��,�,�X�~�F�	G�	G�	G�s�<A&�&A/Nc���|r |j|jd��|r"|j||jd��n |j|jd��|j||jd��|jd�}|j|t�|jt|�d|�|j|dt�|j|dt�|j|dt�|jd	�}|j|�|j|j�|jd
��|j|j�|jd��|j|j�|jd��|j|j�|jd
��y)Nrg�peername�peercert�cipherr�rr�r��
ssl_object�compression)rlrmr�rhr#re�strr%r�r��getpeercert)r7�clientrpr�r�r��sslobjs       r�check_ssl_extra_infoz(EventLoopTestsMixin.check_ssl_extra_info-s����� � ��!6�!6�z�!B�C�����X�#�2�2�:�>�
@�
� � ��!6�!6�z�!B�C������.�.�z�:�	<��&�&�x�0�����f�e�,�����V��a��0����f�Q�i��-����f�Q�i��-����f�Q�i��-��&�&�|�4�����V�$�����+�+�-��.�.�}�=�	?���������.�.�x�8�	:�����+�+�-��.�.�z�:�	<�����+�+�-��.�.�}�=�	?rc���|jj|�\}}|j|tj�|j|tj
�|j
d|jjj�v�|j|||�|jj|j�|j|jd�|j�y)N�sslr)r2r1rhrrirjr�rurD�lowerr�rQrnrNrA)r7rorpr�rqrrs      r�_basetest_create_ssl_connectionz3EventLoopTestsMixin._basetest_create_ssl_connectionMs������-�-�n�=���B����b�'�"3�"3�4����b�'�"2�"2�3��������!6�!6�!<�!<�!>�>�?��!�!�"�n�h�?��	�	�$�$�R�W�W�-����2�9�9�a�(�
���
rc����|tj���}�j|||�ttd�r|tj
jfdddd��fd�}tjd|��5}|d��}�j|||��j|jd�ddd��jtj�5}|d��}tj�5�j|||�ddd�ddd��jjjd	�y#1swY��xYw#1swY�DxYw#1swY�HxYw)
N�r��Purpose)�cafile�capath�cadatac����j|tjj�t	j
�S)z�
                A ssl.create_default_context() replacement that doesn't enable
                cert validation.
                )r�r�r��SERVER_AUTHr��dummy_ssl_context)�purposer�r�r�r7s    �r�_dummy_ssl_create_contextzREventLoopTestsMixin._test_create_ssl_connection.<locals>._dummy_ssl_create_contextas.���� � ��#�+�+�*A�*A�B�!�3�3�5�5rzssl.create_default_context)�side_effectTr��CERTIFICATE_VERIFY_FAILED)r�r�r��hasattrr�r�r�r�patchr��
call_countr��SSLError�disable_logger�	exception�reason)	r7r}r{rpr�r~r��m�cms	`        r�_test_create_ssl_connectionz/EventLoopTestsMixin._test_create_ssl_connectionYs>���$��)E�)E�)G�H���,�,�X�~�-5�	7��3�	�"�25�+�+�2I�2I�
6�15�d�15�
6����8�(A�C�
2�FG�,��6���4�4�X�~�5=�?�� � ����q�1�
2��
�
�s�|�|�
,�	?��(�T�2�H��*�*�,�
?��4�4�X�~�5=�?�
?�	?�	
������,�,�.I�J�!
2�
2��
?�
?��	?�	?�s0�;9E�E�9E�
E�E
�E	�E�E%z
No ssl modulec���tjd��5}tj�jj
�fd�g|j���}�j|||j��ddd�y#1swYyxYw)NT��use_sslc�0��t�j��Srvrxr@s�rr-z@EventLoopTestsMixin.test_create_ssl_connection.<locals>.<lambda>�ryr�r�)r�rz�	functools�partialr2r{r|r�)r7r}r{s`  r�test_create_ssl_connectionz.EventLoopTestsMixin.test_create_ssl_connection~s}���
�
'�
'��
5�	E�� )� 1� 1��	�	�+�+�/�! ����! ��
�,�,�U�4E�6;�m�m�
-�
E�	E�	E�	E�s�AA8�8Bc�$��t�}tjd��5}tj�j
j�fd�|jd��}�j||||j��ddd�y#1swYyxYw)NTr�c�0��t�j��Srvrxr@s�rr-zEEventLoopTestsMixin.test_create_ssl_unix_connection.<locals>.<lambda>�ryr�	127.0.0.1)�server_hostnamer�)	r(r�r�r�r�r2r�r|r�)r7rpr}r{s`   r�test_create_ssl_unix_connectionz3EventLoopTestsMixin.test_create_ssl_unix_connection�s����
5�6�6��
�
,�
,�T�
:�	E�e� )� 1� 1��	�	�0�0�/���� +�!-��

�,�,�U�4E�-;�6;�m�m�
-�
E�
	E�	E�	E�s�AB�Bc���tj�5}tj�}�jj
�fd�g|j��d|jd|fi�}�jj|�\}}|jjd�d}�j||�|j�ddd�y#1swYyxYw)Nc�0��t�j��Srvrxr@s�rr-zGEventLoopTestsMixin.test_create_connection_local_addr.<locals>.<lambda>�ryr�
local_addrrrgr�)r�rzr�find_unused_portr2r{r|r1rLrmr�rA)r7r}�port�frqrrrYs`      r�!test_create_connection_local_addrz5EventLoopTestsMixin.test_create_connection_local_addr�s����
�
'�
'�
)�	�U� �1�1�3�D�+��	�	�+�+�/�E����E�,1�M�M�!�,<�d�+C�E�A��Y�Y�1�1�!�4�F�B���|�|�2�2�:�>�q�A�H����T�8�,��H�H�J�	�	�	�s�B/C�Cc�����tj�}tj���jj���fd�}|�j_�jj	�fd�d|d�f��}�jt�5�jj|�ddd�y#1swYyxYw)Nc����K�|�k(rFtjtjdddftjtjdddfgS�||g|��i|���d{���S7��w)Nr���::1rrr�r�r)r1�AF_INET6�SOCK_STREAM�AF_INET��hostr�r�kwargs�getaddrinfo_orig�port2s    ��r�getaddrinfoz`EventLoopTestsMixin.test_create_connection_local_addr_skip_different_family.<locals>.getaddrinfo�si������u�}����&�*<�*<�a��EU�V�����);�);�Q��DT�U�W�W�)�$��F�t�F�v�F�F�F�F�s�AA&�A$� A&c�0��t�j��Srvrxr@s�rr-z]EventLoopTestsMixin.test_create_connection_local_addr_skip_different_family.<locals>.<lambda>�����G����+�r�	localhost�r��rr�r2r�r{r��OSErrorr1�r7�port1r�r�r�r�s`   @@r�7test_create_connection_local_addr_skip_different_familyzKEventLoopTestsMixin.test_create_connection_local_addr_skip_different_family�s�����.�.�0���.�.�0���9�9�0�0��	G�!,��	�	���I�I�'�'�+���K��+?�
(�
A���
�
�w�
'�	,��I�I�(�(��+�	,�	,�	,���B7�7Cc�����tj�}tj���jj���fd�}|�j_�jj	�fd�d|d�f��}�jt�5�jj|�ddd�y#1swYyxYw)Nc���K�|�k(r$tjtjdddfgS�||g|��i|���d{���S7��w)Nrr�r�)r1r�r�r�s    ��rr�zYEventLoopTestsMixin.test_create_connection_local_addr_nomatch_family.<locals>.getaddrinfo�sJ������u�}����&�*<�*<�a��EU�V�W�W�)�$��F�t�F�v�F�F�F�F�s�:A�A�Ac�0��t�j��Srvrxr@s�rr-zVEventLoopTestsMixin.test_create_connection_local_addr_nomatch_family.<locals>.<lambda>�r�rr�r�r�r�s`   @@r�0test_create_connection_local_addr_nomatch_familyzDEventLoopTestsMixin.test_create_connection_local_addr_nomatch_family�s�����.�.�0���.�.�0���9�9�0�0��	G�
!,��	�	���I�I�'�'�+���K��+?�
(�
A���
�
�w�
'�	,��I�I�(�(��+�	,�	,�	,�r�c�*��tj�5}�jj�fd�g|j��d|ji�}�jt�5}�jj|�ddd��jjjtj��jt|j�|jj�ddd�y#1swY�xYw#1swYyxYw)Nc�0��t�j��Srvrxr@s�rr-zNEventLoopTestsMixin.test_create_connection_local_addr_in_use.<locals>.<lambda>�ryrr�)r�rzr2r{r|r�r�r1r�r��errno�
EADDRINUSE�assertInr��strerror)r7r}r�r�s`   r�(test_create_connection_local_addr_in_usez<EventLoopTestsMixin.test_create_connection_local_addr_in_use�s����
�
'�
'�
)�	E�U�+��	�	�+�+�/�:����:�+0�=�=�:�A��"�"�7�+�
0�r��	�	�,�,�Q�/�
0����R�\�\�/�/��1A�1A�B��M�M�#�e�m�m�,�b�l�l�.C�.C�D�	E�	E�
0�
0��		E�	E�s%�A
D	�#C=�?A5D	�=D	�D	�	Dc���	�
���
��|j�G�
�fd�dt�}tjdd��}|j	��	d�d�d�
�	���fd�}tj|d	�
�}|j�|j�\}}|����
��
_�j�j�
fd�||�
���j��
jj�|j�tj|�|j!|j#��|j%�
j&d�|j%�
j(t+���|j%��
�y)Nc�.���eZdZ��fd�Z��fd�Z�xZS)�AEventLoopTestsMixin.test_connect_accepted_socket.<locals>.MyProtoc�Z��t�|�|��j�j�yr)rsror�r�)r7r=rur2s  ��rrozQEventLoopTestsMixin.test_connect_accepted_socket.<locals>.MyProto.connection_lost�s �����'��,����t�y�y�)rc�Z��t�|�|�|jj��yr)rsrhrLrt)r7rgru�expected_responses  ��rrhzOEventLoopTestsMixin.test_connect_accepted_socket.<locals>.MyProto.data_received�s#�����%�d�+����$�$�%6�7r)rDrErFrorhrw)rur�r2s@��rrqr��s���
*�
8�
8rrqr�r�)�backlogs	test datasrogerc� ��	tj�}���j|�}|j��|j��|j	d��|j�y#t$r}td|�Yd}~yd}~wwxYw)N�cz8Failure in client thread in test_connect_accepted_socket)r1�wrap_socket�connect�sendallr"rA�	Exception�print)�csockr=r��
client_ssl�message�responses  ����rr�z@EventLoopTestsMixin.test_connect_accepted_socket.<locals>.client�sz���
��
�
����)�&�2�2�5�9�E��
�
�d�#��
�
�g�&� �:�:�b�>�����
���
��N�����
�s�A*A.�.	B
�7B�B
T)r��daemonrwc����Srr��protos�rr-zBEventLoopTestsMixin.test_connect_accepted_socket.<locals>.<lambda>s����rr�rm)r2rHr1�
create_server�getsocknamer�rr�acceptr1�connect_accepted_socketr�rLrAr
�join_threadr�is_aliver�rMrNre)r7�
server_sslr�rq�lsockr��thread�conn�_r�r�r2r�r�r�s  `      @@@@@@r�test_connect_accepted_socketz0EventLoopTestsMixin.test_connect_accepted_socket�s<����y�y��	8�k�	8��$�$�%5�q�A��� � �"������$��
	��!�!���=�������,�,�.���a��T�"����
�����(�(���:�
)�
7�	8�	
����
������
���
��$�$�V�,�������*�+�������h�/�������s�7�|�4�����#4�5rc�x�tj�}tj�}|j||�yr)r��simple_server_sslcontext�simple_client_sslcontextr)r7�server_context�client_contexts   r� test_ssl_connect_accepted_socketz4EventLoopTestsMixin.test_ssl_connect_accepted_sockets.��#�<�<�>��#�<�<�>���)�)�.�.�Irc�N�tj�}|j|j�|jj	t
|tj��}|jtd�5|jj|�ddd�y#1swYyxYw)N)�ssl_handshake_timeoutz1ssl_handshake_timeout is only meaningful with ssl)r1�
addCleanuprAr2r�rqr�LOOPBACK_TIMEOUT�assertRaisesRegexrMr1)r7�sock�coros   r�9test_connect_accepted_socket_ssl_timeout_for_plain_socketzMEventLoopTestsMixin.test_connect_accepted_socket_ssl_timeout_for_plain_sockets����}�}�������
�
�#��y�y�0�0��T��1I�1I�1�K��
�
#�
#��C�E�	/�
�I�I�(�(��.�	/�	/�	/�s�6B�B$zasyncio.base_events.socketc������fd����fd�}t|�}�tjk(r0|D�cgc]}|df��c}|j�j_n1|D�cgc]}|dddf��
c}|j�j_|�j
_tj��j
_	tj��j
_
�j
j�fd�|d�}�j
j|�}�j|j�|jD�	chc]}	|	j�d��}
}	�j!|
|�ycc}wcc}wcc}	w)Nc���K��tjk(r�tjdd||ffgS�tjdd||ddffgS�w)Nr0r�r)r1r�r�)r�r�r�kw�familys    �rr�zEEventLoopTestsMixin.create_server_multiple_hosts.<locals>.getaddrinfo"sT���������'���!3�!3�Q��T�4�L�I�J�J���!3�!3�Q��T�4��A�<N�O�P�P�s�AA	c�F���jj�|i|���Sr)r2�create_task)r�kwdsr�r7s  ��r�getaddrinfo_taskzJEventLoopTestsMixin.create_server_multiple_hosts.<locals>.getaddrinfo_task(s"����9�9�(�(��d�)C�d�)C�D�Dr�Prc�.��t�j�Srrxr@s�rr-zBEventLoopTestsMixin.create_server_multiple_hosts.<locals>.<lambda>6s���G�D�I�I�,>�r)r�r1r��
getsockbynamer�r2r�r�Mock�_start_serving�
_stop_servingr�r1r
rA�socketsr�)r7r�hosts�	mock_sockr�unique_hostsr�r��serverr�server_hostsr�s``         @r�create_server_multiple_hostsz0EventLoopTestsMixin.create_server_multiple_hosts s5���	Q�	E��5�z���V�^�^�#�'3�<5�#��r�
�<5�I����,�,�8�.:�<;�%)��r�1�a� �<;�I����,�,�8� 0��	�	��#'�9�9�;��	�	� �"&�)�)�+��	�	���I�I�#�#�$>��r�J�����-�-�a�0��������%�<B�N�N�K�D��*�*�,�Q�/�K��K�����|�4��<5��<;��Ls�E8�!
E=�	Fc�H�|jtjgd��y)N)�1.2.3.4z5.6.7.8r))r'r1r�r@s r�&test_create_server_multiple_hosts_ipv4z:EventLoopTestsMixin.test_create_server_multiple_hosts_ipv4<s���)�)�&�.�.�*K�	Mrc�H�|jtjgd��y)N)r�z::2r�)r'r1r�r@s r�&test_create_server_multiple_hosts_ipv6z:EventLoopTestsMixin.test_create_server_multiple_hosts_ipv6@s���)�)�&�/�/�*?�	Arc�n��t|j��|jj�fd�dd�}|jj|�}|j	t|j�d�|jd}|j�\}}|j	|d�tj�}|jd|f�|jd�|jj�j�|j	d�j�tj|j�fd��|j	d	�j�|j!�j"j%d
��|j	d�j"j%d�d��j"j'�|jj�j(�|j	d�j�|j'�|j'�y)
Nc����Srrr�s�rr-z8EventLoopTestsMixin.test_create_server.<locals>.<lambda>F����E�r�0.0.0.0rr�r��xxxr]c�"���jdkDSr��rNr�s�rr-z8EventLoopTestsMixin.test_create_server.<locals>.<lambda>S�������q�0@�rr�rgr�rm)rqr2r�r1r�rer!r�r1r�r�rPrMr�r6rNrlrLrmrArQ)r7r�r%rr�r�r�r�s       @r�test_create_serverz&EventLoopTestsMixin.test_create_serverDs������	�	�"���I�I�#�#�M�9�a�@�����-�-�a�0������V�^�^�,�a�0��~�~�a� ���%�%�'�
��d�����y�)����������T�*�+����v���	�	�$�$�U�_�_�5�����e�k�k�2����T�Y�Y�(@�A�����E�L�L�)�	
���U�_�_�;�;�J�G�H��������7�7�
�C�A�F�	H�	�������	�	�$�$�U�Z�Z�0�����5�;�;�/�	����	���rc���t|j��|jj�fd�dd�}|jj|�}|j	t|j�d�|jd}|j|tjj�|j�\}}|j	|d�|j�}|j|j�|j|tj�|j!|j#��|j%t&�5|j)d�ddd�|j)d�|j	|j+�d�|j%t&�5|j-d�ddd�|j-d�|j�y#1swY��xYw#1swY�7xYw)Nc����Srrr�s�rr-z?EventLoopTestsMixin.test_create_server_trsock.<locals>.<lambda>jr/rr0rr�TF)rqr2r�r1r�rer!rhr�trsock�TransportSocketr��dupr
rAr1r�get_inheritabler�rM�
settimeout�
gettimeoutr3)r7r�r%rr�r�r:r�s       @r�test_create_server_trsockz-EventLoopTestsMixin.test_create_server_trsockhs������	�	�"���I�I�#�#�M�9�a�@�����-�-�a�0������V�^�^�,�a�0��~�~�a� �����d�G�N�N�$B�$B�C��%�%�'�
��d�����y�)��h�h�j������	�	�"����c�6�=�=�1�����-�-�/�0�
�
�
�z�
*�	��O�O�A��	������������*�A�.�
�
�
�z�
*�	#����T�"�	#����������	�	��	#�	#�s�G0�4G<�0G9�<H�SO_REUSEPORTzNo SO_REUSEPORTc���t|j��|jj�fd�dd�}|jj|�}|j	t|j�d�|jd}|j|jtjtj��|j�tj|j�t|j��|jj�fd�ddd��}|jj|�}|j	t|j�d�|jd}|j|jtjtj��|j�y)Nc����Srrr�s�rr-zCEventLoopTestsMixin.test_create_server_reuse_port.<locals>.<lambda>�����E�rr0rr�c����Srrr�s�rr-zCEventLoopTestsMixin.test_create_server_reuse_port.<locals>.<lambda>�rBrT)�
reuse_port)rqr2r�r1r�rer!r�
getsockoptr1�
SOL_SOCKETr?rAr�r�r�)r7r�r%rr�s    @r�test_create_server_reuse_portz1EventLoopTestsMixin.test_create_server_reuse_portsN�����	�	�"���I�I�#�#��9�a�
)�����-�-�a�0������V�^�^�,�a�0��~�~�a� ������O�O��!�!�6�#6�#6�
8�	9�	�������t�y�y�)���	�	�"���I�I�#�#��9�a�D�
$�
:�����-�-�a�0������V�^�^�,�a�0��~�~�a� ������O�O��!�!�6�#6�#6�
8�	9�	���rc����tj��|j�fd��|jj|�fi|��}|jj|�}|�fS)Nc�p��tjj��xrtj��Sr)rQ�path�exists�unlink)rJs�rr-z7EventLoopTestsMixin._make_unix_server.<locals>.<lambda>�s!��������t� 4� H����4��r)r��gen_unix_socket_pathr
r2�create_unix_serverr1)r7�factoryr�r�r%rJs     @r�_make_unix_serverz%EventLoopTestsMixin._make_unix_server�sY����.�.�0�����H�I�(�D�I�I�(�(��$�A�&�A�����-�-�a�0���t�|�rc�*��t|j���|j�fd��\}}|jt	|j
�d�t
jtj�}|j|�|jd�|jj�j�|jd�j�tj|j�fd��|jd�j��j j#�|jj�j$�|jd�j�|j#�|j#�y)	Nrwc����Srrr�s�rr-z=EventLoopTestsMixin.test_create_unix_server.<locals>.<lambda>�s���e�rr�r1r]c�"���jdkDSr�r3r�s�rr-z=EventLoopTestsMixin.test_create_unix_server.<locals>.<lambda>�r4rr�rm)rqr2rPr�rer!r1�AF_UNIXr�r�r1rPrMr�r6rNrLrArQ)r7r%rJr�r�s    @r�test_create_unix_serverz+EventLoopTestsMixin.test_create_unix_server�s
����T�Y�Y�'���-�-�m�<��������V�^�^�,�a�0����v�~�~�.�����t�����v���	�	�$�$�U�_�_�5�����e�k�k�2����T�Y�Y�(@�A�����E�L�L�)�	�������	�	�$�$�U�Z�Z�0�����5�;�;�/�	����	���rrTzNo UNIX Socketsc�V��t|j���tj�}|5|jj�fd�d|��}|j	t
d�5|jj
|�ddd�ddd�y#1swY�xYw#1swYyxYw)Nrwc����Srrr�s�rr-zOEventLoopTestsMixin.test_create_unix_server_path_socket_error.<locals>.<lambda>�s���U�rz/test�rz3path and sock can not be specified at the same time)rqr2r1rNrrMr1)r7rr�r�s   @r�)test_create_unix_server_path_socket_errorz=EventLoopTestsMixin.test_create_unix_server_path_socket_error�s�����T�Y�Y�'���}�}���
�	0��	�	�,�,�]�G�$�,�O�A��'�'�
�);�<�
0��	�	�,�,�Q�/�
0�	0�	0�
0�
0��	0�	0�s#�8B�&B�B�B	�B�B(c��tjtj�}|xjtjzc_|j||�|Sr)r��
SSLContext�PROTOCOL_TLS_SERVER�options�OP_NO_SSLv2�load_cert_chain)r7�certfile�keyfile�
sslcontexts    r�_create_ssl_contextz'EventLoopTestsMixin._create_ssl_context�sA���^�^�C�$;�$;�<�
����c�o�o�-���"�"�8�W�5��rc��|j||�}|jj|dd|��}|jj|�}|jd}|j�\}}	|j
|d�|||	fS)Nr�rr�)rcr2r�r1r!r�r�)
r7rOr`rarbr�r%rr�r�s
          r�_make_ssl_serverz$EventLoopTestsMixin._make_ssl_server�s����-�-�h��@�
��I�I�#�#�G�[�!��#�L�����-�-�a�0���~�~�a� ���%�%�'�
��d�����{�+��t�T�!�!rc�L�|j||�}|j||��S)Nr�)rcrP)r7rOr`rarbs     r�_make_ssl_unix_serverz)EventLoopTestsMixin._make_ssl_unix_server�s*���-�-�h��@�
��%�%�g�:�%�>�>rc���t|j���|j�fd�tjtj
�\}}}|jj
t||tj���}|jj|�\}}|jd�|jj�j�|jd�j�tj|j�fd��|jd�j�|j!|||f���j"j%�|jj�j&�|jd	�j�|j%�|j%�y)
Nrwc����Srrr�s�rr-z<EventLoopTestsMixin.test_create_server_ssl.<locals>.<lambda>�rBrr�r1r]c�"���jdkDSr�r3r�s�rr-z<EventLoopTestsMixin.test_create_server_ssl.<locals>.<lambda>�r4rr�r�rm)rqr2rer��ONLYCERT�ONLYKEYr{rHr�r1rtrPr�rMr6rNr�rLrArQ)r7r%r�r��f_cr�rrr�s       @r�test_create_server_sslz*EventLoopTestsMixin.test_create_server_ssl�sL����T�Y�Y�'��!�2�2��:�.�.�
�0B�0B�D����d��i�i�)�)�+�t�T�.8�.J�.J�.L�*�N���Y�Y�1�1�#�6�
������V���	�	�$�$�U�_�_�5�����e�k�k�2����T�Y�Y�(@�A�����E�L�L�)�	
�!�!�&�D�$�<�!�@�	�������	�	�$�$�U�Z�Z�0�����5�;�;�/�	����	���rc�Z��t|j���|j�fd�tjtj
�\}}|jj
t|tj�d��}|jj|�\}}|jd�|jj�j�|jd�j�tj|j�fd��|jd�j��j j#�|jj�j$�|jd	�j�|j#�|j#�y)
Nrwc����Srrr�s�rr-zAEventLoopTestsMixin.test_create_unix_server_ssl.<locals>.<lambda>rBrr��r�r�r1r]c�"���jdkDSr�r3r�s�rr-zAEventLoopTestsMixin.test_create_unix_server_ssl.<locals>.<lambda>r4rr�rm)rqr2rgr�rkrlr�rHr�r1rtrPr�rMr6rNrLrArQ)r7r%rJrmr�rrr�s      @r�test_create_unix_server_sslz/EventLoopTestsMixin.test_create_unix_server_ssl�s4����T�Y�Y�'���1�1��:�.�.�
�0B�0B�D�����i�i�.�.���:�#?�#?�#A��/� ���Y�Y�1�1�#�6�
������V���	�	�$�$�U�_�_�5�����e�k�k�2����T�Y�Y�(@�A�����E�L�L�)�	�������	�	�$�$�U�Z�Z�0�����5�;�;�/�	����	���rc���t|j���|j�fd�tj�\}}}tjt
j�}|xjt
jzc_t
j|_t|d�rd|_
|jjt|||��}tj j#|jd�5tj$�5|j't
j(d�5|jj+|�ddd�ddd�tj,|j�ddd�|j/�j0�|j3�y#1swY�dxYw#1swY�hxYw#1swY�MxYw)Nrwc����Srrr�s�rr-zJEventLoopTestsMixin.test_create_server_ssl_verify_failed.<locals>.<lambda>!rBr�check_hostnameTr��call_exception_handler�(?i)certificate.verify.failed)rqr2rer��SIGNED_CERTFILEr�r[�PROTOCOL_TLS_CLIENTr]r^�
CERT_REQUIRED�verify_moder�rvr{rr��objectr�rr�r1r��assertIsNonerLrA�r7r%r�r��sslcontext_clientrmr�s      @r�$test_create_server_ssl_verify_failedz8EventLoopTestsMixin.test_create_server_ssl_verify_failedsg����T�Y�Y�'��!�2�2��:�5�5�7����d� �N�N�3�+B�+B�C���!�!�S�_�_�4�!�(+�(9�(9��%��$�&6�7�/3��,��i�i�)�)�'�4��.?�*�A��
�Z�Z�
�
�t�y�y�*B�
C�	.��*�*�,�
6��+�+�C�L�L�,K�M�6��I�I�0�0��5�6�
6�
�"�"�4�9�9�-�	.�	
���%�/�/�*�����6�6��
6�
6��	.�	.�s<�:G�!F;�0F/�F;�'G�/F8�4F;�;G	�G�Gc���t|j���|j�fd�tj�\}}tjt
j�}|xjt
jzc_t
j|_t|d�rd|_
|jjt||d��}tj j#|jd�5tj$�5|j't
j(d�5|jj+|�ddd�ddd�tj,|j�ddd�|j/�j0�|j3�y#1swY�dxYw#1swY�hxYw#1swY�MxYw)	Nrwc����Srrr�s�rr-zOEventLoopTestsMixin.test_create_unix_server_ssl_verify_failed.<locals>.<lambda>?rBrrvT�invalidrqrwrx)rqr2rgr�ryr�r[rzr]r^r{r|r�rvr�rr�r}r�rr�r1r�r~rLrA)r7r%rJr�rmr�s     @r�)test_create_unix_server_ssl_verify_failedz=EventLoopTestsMixin.test_create_unix_server_ssl_verify_failed:si����T�Y�Y�'���1�1��:�5�5�7���� �N�N�3�+B�+B�C���!�!�S�_�_�4�!�(+�(9�(9��%��$�&6�7�/3��,��i�i�.�.�w��3D�?H�/�J���Z�Z�
�
�t�y�y�*B�
C�	.��*�*�,�
6��+�+�C�L�L�,K�M�6��I�I�0�0��5�6�
6�
�"�"�4�9�9�-�	.�	
���%�/�/�*�����6�6��
6�
6��	.�	.�s<�9G�!F:�/F.�F:�'G�.F7�3F:�:G	�?G�Gc���t|j���|j�fd�tj�\}}}tjt
j�}|xjt
jzc_t
j|_|jtj��t|d�rd|_|jj!t|||��}t"j$j'|jd�5tj(�5|j+t
j,d�5|jj/|�ddd�ddd�ddd�|j1�j2�|j5�y#1swY�ExYw#1swY�IxYw#1swY�MxYw)	Nrwc����Srrr�s�rr-zIEventLoopTestsMixin.test_create_server_ssl_match_failed.<locals>.<lambda>\rBr�r�rvTr�rwz=IP address mismatch, certificate is not valid for '127.0.0.1')rqr2rer�ryr�r[rzr]r^r{r|�load_verify_locations�
SIGNING_CAr�rvr{rr�r}r�r�CertificateErrorr1r~rLrArs      @r�#test_create_server_ssl_match_failedz7EventLoopTestsMixin.test_create_server_ssl_match_failedXsu����T�Y�Y�'��!�2�2��:�5�5�7����d� �N�N�3�+B�+B�C���!�!�S�_�_�4�!�(+�(9�(9��%��/�/��(�(�	0�	*��$�&6�7�/3��,��i�i�)�)�'�4��.?�*�A��
�Z�Z�
�
�t�y�y�*B�
C�	6��*�*�,�
6��+�+��,�,�&�'�6��I�I�0�0��5�	6�
6�	6�	
���%�/�/�*�����6�6��
6�
6��	6�	6�s<�G�/!F<�F0�,F<�4G�0F9�5F<�<G	�G�Gc�$��t|j���|j�fd�tj�\}}tjt
j�}|xjt
jzc_t
j|_|jtj��t|d�rd|_|jj!t||d��}|jj#|�\}}|jj#�j$��j&j)�|j)�|j)�|jj#�j*�y)Nrwc����Srrr�s�rr-zJEventLoopTestsMixin.test_create_unix_server_ssl_verified.<locals>.<lambda>{rBrr�rvTr�rq)rqr2rgr�ryr�r[rzr]r^r{r|r�r�r�rvr�r1rPrLrArQ)r7r%rJr�rmr�rrr�s       @r�$test_create_unix_server_ssl_verifiedz8EventLoopTestsMixin.test_create_unix_server_ssl_verifiedvs)����T�Y�Y�'���1�1��:�5�5�7���� �N�N�3�+B�+B�C���!�!�S�_�_�4�!�(+�(9�(9��%��/�/�z�7L�7L�/�M��$�&6�7�/3��,��i�i�.�.�w��3D�?J�/�L���Y�Y�1�1�#�6�
����	�	�$�$�U�_�_�5�	���������������	�	�$�$�U�Z�Z�0rc�p��t|j���|j�fd�tj�\}}}tjt
j�}|xjt
jzc_t
j|_|jtj��t|d�rd|_|jj!t|||d��}|jj#|�\}}|jj#�j$�|j'|||ftj(���j*j-�|j-�|j-�|jj#�j.�y)	Nrwc����Srrr�s�rr-zEEventLoopTestsMixin.test_create_server_ssl_verified.<locals>.<lambda>�rBrr�rvTr�rq)r�r�)rqr2rer�ryr�r[rzr]r^r{r|r�r�r�rvr{r1rPr��PEERCERTrLrArQ)	r7r%r�r�r�rmr�rrr�s	        @r�test_create_server_ssl_verifiedz3EventLoopTestsMixin.test_create_server_ssl_verified�sS����T�Y�Y�'��!�2�2��:�5�5�7����d� �N�N�3�+B�+B�C���!�!�S�_�_�4�!�(+�(9�(9��%��/�/�z�7L�7L�/�M��$�&6�7�/3��,��i�i�)�)�'�4��.?�:E�*�G���Y�Y�1�1�#�6�
����	�	�$�$�U�_�_�5�	
�!�!�&�D�$�<�+5�+>�+>�	"�	@�	���������������	�	�$�$�U�Z�Z�0rc�j�	�|jj��	G�	fd�dt�}tjd�}|jj	||��}|jj|�}|jd}|j|j�|j��|j�\}}|j|d�tj�}|jd|f�|jd�|j�|j�y)	Nc�"���eZdZ��fd�Z�xZS)�@EventLoopTestsMixin.test_create_server_sock.<locals>.TestMyProtoc�F��t�|�|��j|�yr�rsrar_)r7rLrur�s  ��rrazPEventLoopTestsMixin.test_create_server_sock.<locals>.TestMyProto.connection_made�s�����'�	�2�� � ��&rrv)rur�s@�r�TestMyProtor��s
���
'�
'rr��r0rrXrr0r�r1)
r2rOrqr1r�r1r!r�r&r�r�r9rA)
r7r��sock_obr�r%rr�r�r�r�s
         @r�test_create_server_sockz+EventLoopTestsMixin.test_create_server_sock�s�����	�	�'�'�)��	'�'�	'�
�&�&�~�6���I�I�#�#�K�g�#�>�����-�-�a�0���~�~�a� ������������(8�9��%�%�'�
��d�����y�)����������T�*�+����F���������rc�@�tjd�}|jjt|��}|jj	|�}|j
d}|j
�\}}|jjt||��}|jt�5}|jj	|�ddd�|jjjtj�|j�y#1swY�NxYw)Nr�rXr�r�r�)r1r�r2rqr1r!r�r�r�r�r�r�r�rA)r7r�r�r%rr�r�r�s        r�test_create_server_addr_in_usez2EventLoopTestsMixin.test_create_server_addr_in_use�s����&�&�~�6���I�I�#�#�G�'�#�:�����-�-�a�0���~�~�a� ���%�%�'�
��d��I�I�#�#�G�$�T�#�B��
�
�
�w�
'�	,�2��I�I�(�(��+�	,�������+�+�U�-=�-=�>�����		,�	,�s�+D�DzIPv6 not supported or enabledc��	�|jj��	G�	fd�dt�}d}		tj�}|jj|d|��}|jj
|�}	tj�}|jd|f�|jd�|jj
�	�}|jj�|j�|jj��	tjtj �}|jd	|f�|jd�|jj
�	�}|jj�|j�|j�y#t$r@}|jtjk(r|dz
}|jd|�Yd}~��ǂd}~wwxYw)
Nc�"���eZdZ��fd�Z�xZS)�FEventLoopTestsMixin.test_create_server_dual_stack.<locals>.TestMyProtoc�F��t�|�|��j|�yrr�)r7rLru�f_protos  ��rrazVEventLoopTestsMixin.test_create_server_dual_stack.<locals>.TestMyProto.connection_made�s�����'�	�2��"�"�4�(rrv)rur�s@�rr�r��s
���
)�
)rr�rr�r�rr�r1r�)r2rOrqrr�r�r1r�r�r�r�r1r�r9rLrAr�)
r7r��	try_countr�r�r%�exr�r�r�s
         @r�test_create_server_dual_stackz1EventLoopTestsMixin.test_create_server_dual_stack�s�����)�)�)�)�+��	)�'�	)�
�	��
�$�5�5�7���I�I�+�+�K�d��+�N�����5�5�a�8������������T�*�+����F���	�	�,�,�W�5��
�����������)�)�)�)�+�����v���/������t�}�%����F���	�	�,�,�W�5��
���������������1�
��8�8�u�/�/�/���N�I��+�+�A�y�9����

�s�A
F3�3	G<�<4G7�6G7�7G<c��|jjtdd�}|jj|�}|jd}|j�\}}t
j�}|jd|f�|jd�|j�|j�t
j�}|jt|jd|f�|j�y)Nr0rr�r1)r2r�rqr1r!r�r1r�r9rAr��ConnectionRefusedError)r7r�r%rr�r�r�s       r�test_server_closez%EventLoopTestsMixin.test_server_close�s����I�I�#�#�G�Y��:�����-�-�a�0���~�~�a� ���%�%�'�
��d����������T�*�+����F������������������"�F�N�N�[�$�4G�	I����rc���
��G�fd�dt�}�jj|||��}�jj|�\}�|j	d�}tj|t
jt
jz�\}}�j|tj��j�|��jd�j��j�j|��jj�fd�||f��}�jj|�\}	�
�j|	tj��j�
t��jd�
j��j�
j|	�|	j!d�t#j$�j�fd	���jd
�j&�t#j$�j�
fd���jd�
j&��j)|	j	d��|	j+��jj�
j,��jd
�
j��jj+�y)Nc�,���eZdZ��fd�Z�fd�Z�xZS)�OEventLoopTestsMixin._test_create_datagram_endpoint.<locals>.TestMyDatagramProtoc�:��t�|��j��yrv)rsrSr2)�
inner_selfrur7s ��rrSzXEventLoopTestsMixin._test_create_datagram_endpoint.<locals>.TestMyDatagramProto.__init__s����� �d�i�i� �0rc�d��t�|�||�|jjd|z|�y)Nsresp:)rsr�rL�sendto)r7rgr�rus   �rr�zaEventLoopTestsMixin._test_create_datagram_endpoint.<locals>.TestMyDatagramProto.datagram_receiveds*�����)�$��5����%�%�h�t�m�T�:r)rDrErFrSr�rw)rur7s@�r�TestMyDatagramProtor�s���
1�
;�
;rr�)r�rrgrc�0��t�j��Srv�rzr2r@s�rr-zDEventLoopTestsMixin._test_create_datagram_endpoint.<locals>.<lambda>'����O����3�r)�remote_addrr1c����jSrr3)r%s�rr-zDEventLoopTestsMixin._test_create_datagram_endpoint.<locals>.<lambda>1�����
�
�rr�c����jSrr3)r�s�rr-zDEventLoopTestsMixin._test_create_datagram_endpoint.<locals>.<lambda>3r�r�rm)rzr2�create_datagram_endpointr1rmr1�getnameinfo�NI_NUMERICHOST�NI_NUMERICSERVrhrrir�rMrkrLr�r�r6rNrlrArQ)r7r�rr�r�s_transportrgr�r�rLr�r%s`         @@r�_test_create_datagram_endpointz2EventLoopTestsMixin._test_create_datagram_endpoints(���	;�/�	;��y�y�1�1��J�v�2�G��"�i�i�:�:�4�@���V��-�-�j�9���'�'��f�+�+�F�,A�,A�A�C�
��d�	
���k�7�+<�+<�=����f�&9�:��������5��
�
�f�&�&��4��y�y�1�1�3��t��2�&��!�I�I�8�8��>��	�6����i��):�):�;����f�o�6��������5��
�
�f�&�&�	�2����� ����T�Y�Y�(=�>�����F�M�M�*����T�Y�Y�(=�>�	
����F�M�M�*�	
���Y�5�5�j�A�B�	�����	�	�$�$�V�[�[�1�����6�<�<�0������ rc�D�|jdtj�y)Nr�)r�r1r�r@s r�test_create_datagram_endpointz1EventLoopTestsMixin.test_create_datagram_endpointAs���+�+�,<�f�n�n�Mrc�D�|jdtj�y)N)r�r)r�r1r�r@s r�"test_create_datagram_endpoint_ipv6z6EventLoopTestsMixin.test_create_datagram_endpoint_ipv6Ds���+�+�J����Hrc���d}d}�jj�jj|dtji��}|D]D\}}}}}	tj|||��}|jd�|j
|�n�jd��jj�fd�|��}	�jj|	�\}
}�j|
tj��j|t�|
j��jj|j�y#Y��xYw)Nr��type)rr�r�FzCan not create socket.c�0��t�j��Srvr�r@s�rr-zHEventLoopTestsMixin.test_create_datagram_endpoint_sock.<locals>.<lambda>[r�rrX)r2r1r�r1�
SOCK_DGRAMr3�bind�failr�rhrrirzrArQ)r7r�
local_address�infosrr�r��cnamer|r�rqrrs`           r�"test_create_datagram_endpoint_sockz6EventLoopTestsMixin.test_create_datagram_endpoint_sockHs-�����(�
��	�	�,�,�!�D�I�I�!�!��
8�%+�%6�%6�
8�9��49�
	0�/�F�D�%���
��}�}�F��U�K��� � ��'��	�	�'�"��
	0�
�I�I�.�/��I�I�.�.�3�$�
/�
@�����-�-�a�0���B����b�'�"3�"3�4����b�/�2�
���
��	�	�$�$�R�W�W�-��
��s�:E
�
Ec��|j�}t|tj�s!|j	�|jd�|j
d|j�|j	�|j
d|j�|j|j�|j|j�y)Nz#loop is not a BaseSelectorEventLoopr�r)r��
isinstancer�BaseSelectorEventLooprA�skipTestr��
_internal_fdsr~�_csock�_ssockrRs  r�test_internal_fdsz%EventLoopTestsMixin.test_internal_fdsbs����%�%�'���$�� E� E�F��J�J�L��M�M�?�@�����D�.�.�/��
�
������D�.�.�/����$�+�+�&����$�+�+�&rrzDon't support pipes for Windowsc�t����t�j���tj�\}}t	j
|dd�����fd�}�jj
|��tj|d�tj�j�fd���jd�j�tj|d�tj�j�fd	���jd
dg�j��jd�j�tj|��jj
�j��jgd
��j��j�j j#d��y)Nrw�rbr!c��6�K��jj�fd����d{���\}}�j|���j|�j��j	ddg�j
��j	d�j�y7�p�w)Nc����Srrr�s�rr-zEEventLoopTestsMixin.test_read_pipe.<locals>.connect.<locals>.<lambda>xs����rrKr]r�r2�connect_read_piperkrLr�rMrN)r�p�pipeobjr�r7s  ���rr�z3EventLoopTestsMixin.test_read_pipe.<locals>.connectvs{��������4�4��w�(�(�D�A�q��M�M�!�U�#��M�M�!�U�_�_�-����i��5�u�{�{�C����Q����-�(���#B�B�A1B�1c�"���jdk\SrCr3r�s�rr-z4EventLoopTestsMixin.test_read_pipe.<locals>.<lambda>���������0A�rr��2345c�"���jdk\S�Nrr3r�s�rr-z4EventLoopTestsMixin.test_read_pipe.<locals>.<lambda>�r�rrKr]r�rKr]rjrm�pipe)r�r2rQr��io�openr1rtr�r6r�rNrMrArQrlrLrm)r7�rpipe�wpiper�r�r�s`   @@r�test_read_pipez"EventLoopTestsMixin.test_read_pipens.��� �T�Y�Y�/���w�w�y���u��'�'�%��t�,��	.�	
�	�	�$�$�W�Y�/�
���������T�Y�Y�(A�B�����E�L�L�)�
����� ����T�Y�Y�(A�B����)�[�1�5�;�;�?�����E�L�L�)�
������	�	�$�$�U�Z�Z�0����5�u�{�{�	D�	
���U�_�_�;�;�F�C�Drc�����	�
�|j��t����t����
tj�\}}tj|dd��tj|ddd���	����	�
fd�}�j|��\}}�j�|jdt|��|jdt|���j��	j�d|_d|_y)	Nrwr�r!r7zutf-8)�encodingc���K��j�fd����d{���\}}�j�fd����d{���\}}||fS7�+7�
�w)Nc����Srr��
read_protos�rr-zSEventLoopTestsMixin.test_unclosed_pipe_transport.<locals>.connect.<locals>.<lambda>�s���
�rc����Srr��write_protos�rr-zSEventLoopTestsMixin.test_unclosed_pipe_transport.<locals>.connect.<locals>.<lambda>�s����r)r��connect_write_pipe)�read_transportr�write_transportr2r��rpipeobj�wpipeobjr�s   �����rr�zAEventLoopTestsMixin.test_unclosed_pipe_transport.<locals>.connect�s[�����&*�&<�&<�"�H�'.�!.��N�A�'+�'>�'>�#�X�(/�"/��O�Q�!�?�2�2�	!.��"/�s�A�A�A�A
�A�
Ar�)r�r�r�rQr�r�r�r1rAr��repr�_pipe)r7r�r�r�r�r�r2r�r�r�r�s      @@@@@r�test_unclosed_pipe_transportz0EventLoopTestsMixin.test_unclosed_pipe_transport�s�����%�%�'��$�$�/�
�&�D�1���w�w�y���u��7�7�5�$��-���7�7�5�#�t�g�>��	3�	3�+/�*A�*A�'�)�*L�'����
�
��	
�
�
�f�d�>�2�3��
�
�f�d�?�3�4�	��������#��� $��r�openptyzneed os.openpty()c�����t�j���tj�\}}t	j
|dd�����fd�}�jj
|��tj|d�tj�j�fd���jd�j�tj|d�tj�j�fd	���jd
dg�j��jd�j�tj|��jj��jj
�j��jgd
��j��j!�jj#d��y)Nrwr�rc��6�K��jj�fd����d{���\}}�j|���j|�j��j	ddg�j
��j	d�j�y7�p�w)Nc����Srrr�s�rr-zKEventLoopTestsMixin.test_read_pty_output.<locals>.connect.<locals>.<lambda>�s���U�rrKr]rr�)rr��master_read_objr�r7s  ���rr�z9EventLoopTestsMixin.test_read_pty_output.<locals>.connect�s~��������4�4�]�5D�F�F�D�A�q��M�M�!�U�#��M�M�!�U�_�_�-����i��5�u�{�{�C����Q����-�F�r�r�c����jSrr3r�s�rr-z:EventLoopTestsMixin.test_read_pty_output.<locals>.<lambda>�s������rr�r�c�"���jdk\Sr�r3r�s�rr-z:EventLoopTestsMixin.test_read_pty_output.<locals>.<lambda>�r�rrKr]rr�r�)r�r2rQr�r�r�r1rtr�r6r�rNrMrArLrQrlrm)r7�master�slaver�rr�s`   @@r�test_read_pty_outputz(EventLoopTestsMixin.test_read_pty_output�s>��� �T�Y�Y�/���
�
��
����'�'�&�$��2��	.�	
�	�	�$�$�W�Y�/�
���������T�Y�Y�(<�=�����E�L�L�)�
����� ����T�Y�Y�(A�B����)�[�1�5�;�;�?�����E�L�L�)�
�����
�������	�	�$�$�U�Z�Z�0����5�u�{�{�	D�	
���U�_�_�;�;�F�C�Drc�H����	�tj�\�	}tj|dd�}t	|j
���|j
j
�fd�|�}|j
j|�\}}|j|��|j|�j�|jd�j�|jd�t���	fd��tj|j
��fd��|jd��|jd	�tj|j
��fd
��|jd��|jd�j�tj �	�|j#�jj%d���jj!�|j
j�j&�|jd
�j�y)N�wbr!rwc����Srrr�s�rr-z5EventLoopTestsMixin.test_write_pipe.<locals>.<lambda>�����u�rr]r�c�P��tj�d�}||z
}t|�Sr �rQr>re)rg�chunkr�s  �rr)z3EventLoopTestsMixin.test_write_pipe.<locals>.reader�s&����G�G�E�4�(�E��E�M�D��t�9�rc������dk\SrCr�rgr)s��rr-z5EventLoopTestsMixin.test_write_pipe.<locals>.<lambda>������t���0A�rr�c������dk\Sr�rrs��rr-z5EventLoopTestsMixin.test_write_pipe.<locals>.<lambda>�rr�12345r�rm)rQr�r�r�r�r2r�r1rkrLr�rMrtr4r�r6rArlrmrQ)
r7r�r�r�rLr�rgr�r)r�s
      @@@@r�test_write_pipez#EventLoopTestsMixin.test_write_pipe�s�����w�w�y���u��'�'�%��t�,�� �d�i�i�0���)�)�.�.�}�g�F���y�y�3�3�G�<��	�1��
�
�a����
�
�i����1�����e�k�k�2�������{��	�
	���T�Y�Y�(A�B�����t�$����� ����T�Y�Y�(A�B�����4�(�����e�k�k�2�
�����	
���U�_�_�;�;�F�C�D�	�������	�	�$�$�U�Z�Z�0�����5�;�;�/rc�,��tj�\}}|jd�tj|j�dd�}t
|j���|jj�fd�|�}|jj|�\}}|j|��|j|�j�|jd�j�|jd�|jj|jj|d��}|jd|�|j!�|jj�j"�|jd�j�y)	NFr	r!rwc����Srrr�s�rr-zIEventLoopTestsMixin.test_write_pipe_disconnect_on_close.<locals>.<lambda>rrr]r�rm)r1r2r3r�r��detachr�r2r�r1rkrLr�rMrt�	sock_recvrArQ)	r7�rsock�wsockr�r�rLr�rgr�s	        @r�#test_write_pipe_disconnect_on_closez7EventLoopTestsMixin.test_write_pipe_disconnect_on_close�s!����(�(�*���u�
���%� ��'�'�%�,�,�.�$��5�� �d�i�i�0���)�)�.�.�}�g�F���y�y�3�3�G�<��	�1��
�
�a����
�
�i����1�����e�k�k�2�������y�y�+�+�D�I�I�,?�,?��t�,L�M������t�$�
���
��	�	�$�$�U�Z�Z�0�����5�;�;�/rrr0c�����	�tj�\�}tj|dd�}t	|j
���|j
j
�fd�|�}|j
j|�\}}|j|��|j|�j�|jd�j�|jd�t���fd��	tj|j
��	fd�t j"�	�|jd��|jd
�tj|j
��	fd�t j"�	�|jd��|jd�j�tj$��|j'�jj)d
���jj%�|j
j�j*�|jd�j�y)Nr	rrwc����Srrr�s�rr-z4EventLoopTestsMixin.test_write_pty.<locals>.<lambda>rrr]r�c�P��tj�d�}||z
}t|�Sr r
�rgrrs  �rr)z2EventLoopTestsMixin.test_write_pty.<locals>.reader(�&����G�G�F�D�)�E��E�M�D��t�9�rc������dk\SrCrrs��rr-z4EventLoopTestsMixin.test_write_pty.<locals>.<lambda>-rr��timeoutr�c������dk\Sr�rrs��rr-z4EventLoopTestsMixin.test_write_pty.<locals>.<lambda>2rrrr�rm)rQr�r�r�r�r2r�r1rkrLr�rMrtr4r�r6r�
SHORT_TIMEOUTrArlrmrQ)
r7r�slave_write_objr�rLr�rgrr�r)s
      @@@@r�test_write_ptyz"EventLoopTestsMixin.test_write_ptys�����
�
��
����'�'�%��q�1�� �d�i�i�0���)�)�.�.�}�o�N���y�y�3�3�G�<��	�1��
�
�a����
�
�i����1�����e�k�k�2�������{��	�
	���T�Y�Y�(A�%,�%:�%:�	<�����t�$����� ����T�Y�Y�(A�%,�%:�%:�	<�����4�(�����e�k�k�2�
�����	
���U�_�_�;�;�F�C�D�	�������	�	�$�$�U�Z�Z�0�����5�;�;�/rc��	�
���
��tj�\�}tj|�}tj|�tj|dd�}t|j���|jj�fd�|�}|jj|�\}}|j|��|j|�j�|jddg�j�|jd�j�tj|dd�}t!|j���|jj#�fd�|�}|jj|�\}	}|j|��|j|	�j�|jd�j�t%��
�fd	��
|	j'd
�t)j*|j�
�
fd�t,j.��|jd
�
�|jddg�j�|jd�j�tj&�d
�t)j*|j�fd�t,j.��|jddg�j�|jd�j�|jd�j�|	j'd�t)j*|j�
�
fd�t,j.��|jd�
�|jddg�j�|jd�j�tj&�d�t)j*|j�fd�t,j.��|jddg�j�|jd�j�|jd�j�tj0��|j1�|jj�j2�|jgd��j�|	j1�|jj�j2�|jd�j�y)Nr�rrwc����Srrr�s�rr-z<EventLoopTestsMixin.test_bidirectional_pty.<locals>.<lambda>Ns���:�rrKr]r	c����Srrr�s�rr-z<EventLoopTestsMixin.test_bidirectional_pty.<locals>.<lambda>Ys���[�rc�P��tj�d�}||z
}t|�Sr r
rs  �rr)z:EventLoopTestsMixin.test_bidirectional_pty.<locals>.readerar rr�c������dk\SrCrrs��rr-z<EventLoopTestsMixin.test_bidirectional_pty.<locals>.<lambda>grrr"�ac�"���jdk\SrCr3r�s�rr-z<EventLoopTestsMixin.test_bidirectional_pty.<locals>.<lambda>n����
�0A�0A�Q�0F�rr�r�c������dk\Sr�rrs��rr-z<EventLoopTestsMixin.test_bidirectional_pty.<locals>.<lambda>urrrsbcdec�"���jdk\Sr�r3r�s�rr-z<EventLoopTestsMixin.test_bidirectional_pty.<locals>.<lambda>|r/rrr�rm)rQr�r:�tty�setrawr�r�r�r2r�r1rkrLr�rMrNr�r�r4rtr�r6rr%rArQ)r7�
read_slave�write_slave�slave_read_obj�read_connectr�r�r&�
write_connectr�rgrr�r)r�s          @@@@@r�test_bidirectional_ptyz*EventLoopTestsMixin.test_bidirectional_ptyAs���� �Z�Z�\���
��f�f�Z�(���
�
�:������T�1�5��$�$�)�)�4�
��y�y�2�2�3E�3A�C�� �I�I�8�8��F�����
�
�a��$��
�
�n�j�&:�&:�;����)�[�1�:�3C�3C�D�����J�-�-�.��'�'�+�t�Q�7��&�D�I�I�6���	�	�4�4�5H�5D�F�
�!�Y�Y�9�9�-�H�����
�
�a��%��
�
�o�{�'<�'<�=�����k�&7�&7�8��{��	�
	���d�#����T�Y�Y�(A�%,�%:�%:�	<�����t�$����)�[�1�:�3C�3C�D�����k�&7�&7�8�
���������T�Y�Y�(F�%,�%:�%:�	<����)�[�1�:�3C�3C�D�����J�-�-�.�����k�&7�&7�8����g�&����T�Y�Y�(A�%,�%:�%:�	<�����4�(����)�[�1�:�3C�3C�D�����k�&7�&7�8�
�����!����T�Y�Y�(F�%,�%:�%:�	<����)�[�1�:�3C�3C�D�����J�-�-�.�����k�&7�&7�8�
����������	�	�$�$�Z�_�_�5����5�z�7G�7G�	I�	�����	�	�$�$�[�%5�%5�6�����;�#4�#4�5rc�����tj�\}}|jd��jj	�jj|d���t
�dd�}|��j|j���fd�}�jj	|��}�jj��j|j�d��jtj�j�|��j|j��jj!|�|j#�|j#�y)NFr��ovc�� �K�	�jj�j���d{���d}�jj�|S7�"#tj$rd}Y�5wxYw#�jj�wxYw�w)N�	cancelled)r2r�rr�CancelledErrorr�)rr�r7s ��r�mainz:EventLoopTestsMixin.test_prompt_cancellation.<locals>.main�sr�����
!��	�	�#�#�A�H�H�-�������	�	��� ��J����)�)�
"�!��
"��
�	�	��� �sH�B�*A�A�A�A/�B�A�A,�)A/�+A,�,A/�/B�Br=)r1r2r3r2rr�getattrr��pendingr�r��resultr�rr>rr rA)r7r(r7r;r?rr�s`     @r�test_prompt_cancellationz,EventLoopTestsMixin.test_prompt_cancellation�s���� � �"���1�	�
�
�e���I�I�!�!�$�)�)�"5�"5�a��";�<��
�Q��d�
#��
�>��O�O�B�J�J�'�
	�
�I�I�!�!�$�&�)���	�	�����������[�1����'�0�0�!�(�(�;�
�>����R�Z�Z�(��	�	����"�	���	�	���	rc������fd�}�jj�d�j_|�j_d�}�jj|���j	�jjd�jj
�jjjjd��y)Nc�R���jxjdz
c_��yrC)r2�_run_once_counter)�
orig_run_oncer7s��r�	_run_oncez<EventLoopTestsMixin.test_timeout_rounding.<locals>._run_once�s����I�I�'�'�1�,�'��Orrc��BK�tjd��d{���tjd��d{���tjd��d{���tjd��d{���tjd��d{���y7�y7�^7�C7�(7�
�w)Nr\g-C��6?g���ư>g:�0�yE>g�����|�=r�rrr�waitz7EventLoopTestsMixin.test_timeout_rounding.<locals>.wait�su�����-�-��%�%�%��-�-��%�%�%��-�-��%�%�%��-�-��%�%�%��-�-��&�&�&�	
&��%��%��%��&�sU�B�B�B�B�B�B�B�2B�3B�B�B�B�B�B�B�)�clock_resolution�selector)	r2rHrFr1�assertLessEqual�_clock_resolution�	_selectorrurD)r7rHrJrGs`  @r�test_timeout_roundingz)EventLoopTestsMixin.test_timeout_rounding�s����	��	�	�+�+�
�&'��	�	�#�'��	�	��	'�	
�	�	�$�$�T�V�,�
	
���T�Y�Y�8�8�"�!%���!<�!<����,�,�6�6�?�?�
A�	Brc��|j�}d�}tj�\}}|j|j�|j|j�|j||�|j
||�|j	�|j|j|��|j|j|��y)Nc��yrrrrrr-zCEventLoopTestsMixin.test_remove_fds_after_closing.<locals>.<lambda>���r)
r�r1r2r
rAr5r<rr%r=�r7r2r�r(r7s     r�test_remove_fds_after_closingz1EventLoopTestsMixin.test_remove_fds_after_closing�s����%�%�'����� � �"���1������� ������� �����8�$�����8�$��
�
������+�+�A�.�/�����+�+�A�.�/rc���|j�}d�}tj�\}}|j|j�|j|j�|j	�|jt�5|j||�ddd�|jt�5|j||�ddd�y#1swY�:xYw#1swYyxYw)Nc��yrrrrrr-z@EventLoopTestsMixin.test_add_fds_after_closing.<locals>.<lambda>�rTr)	r�r1r2r
rAr�r�r5r<rUs     r�test_add_fds_after_closingz.EventLoopTestsMixin.test_add_fds_after_closing�s����%�%�'����� � �"���1������� ������� ��
�
��
�
�
�|�
,�	)��O�O�A�x�(�	)�
�
�
�|�
,�	)��O�O�A�x�(�	)�	)�	)�	)��	)�	)�s�C�6C�C�C'c����fd�}|�j�}�jt�5�jj|�ddd�y#1swYyxYw)Nc��B�K��jj�y�wr)r2rA�r2r7s �r�
close_loopzEEventLoopTestsMixin.test_close_running_event_loop.<locals>.close_loop�s������I�I�O�O��s�)r2r�r�r1)r7r]rs`  r�test_close_running_event_loopz1EventLoopTestsMixin.test_close_running_event_loop�sM���	��$�)�)�$��
�
�
�|�
,�	/��I�I�(�(��.�	/�	/�	/�s�A�Ac�,�|jj�d�}d�}|�}|j|j�|jt�5|jj�ddd�|jt�5|jj
�}|jj|�ddd�|jt�5|jj|�ddd�|jt�5|jj|�ddd�|jt�5|jjd|�ddd�|jt�5|jj|jj�dz|�ddd�|jt�5|jj|�ddd�|jt�5|jjtj |�ddd�|jt�5|jj#d|�j%�}t'|�ddd�y#1swY��3xYw#1swY���xYw#1swY���xYw#1swY���xYw#1swY��hxYw#1swY�� xYw#1swY��xYw#1swY��xYw#1swYyxYw)Nc��K�y�wrrrrr�testz,EventLoopTestsMixin.test_close.<locals>.test�s	�����r.c��y�NFrrrrr-z0EventLoopTestsMixin.test_close.<locals>.<lambda>�rTrg�?g)r2rAr
r�r�r�rOr1r�r�r��call_atr�rrKrN�SIGTERMr
rC�next)r7ra�funcr�fut�its      r�
test_closezEventLoopTestsMixin.test_close�sY���	�	����	����v������
�
�#��
�
�|�
,�	$��I�I�!�!�#�	$�
�
�
�|�
,�	.��)�)�)�)�+�C��I�I�(�(��-�	.��
�
�|�
,�	&��I�I����%�	&�
�
�
�|�
,�	1��I�I�*�*�4�0�	1�
�
�
�|�
,�	,��I�I� � ��d�+�	,�
�
�
�|�
,�	;��I�I���d�i�i�n�n�.��3�T�:�	;�
�
�
�|�
,�	(��I�I�!�!�$�'�	(�
�
�
�|�
,�	?��I�I�(�(�����>�	?��
�
�|�
,�	����*�*�4��6�@�@�B�B���H�	�	�+	$�	$��	.�	.��	&�	&��	1�	1��	,�	,��	;�	;��	(�	(��	?�	?��	�	�sl�J$�6J1�#J>�K�K�8K%�$K2�+K>�%6L
�$J.�1J;�>K�K�K"�%K/�2K;�>L�
L)T)TN)NNr)^rDrErFr�r�r�r�r�r�r�rrrrr8r?�unittest�
skipUnlessr�rNrWr`rersrr�skip_unless_bind_unix_socketr�r�r�r��skipIfr�r�r�r��skip_if_tcp_blackholer�r�r�rr
rrr�r'r*r,r5r>r1rGrPrUrYrcrergrnrsr�r�r�r�r�r�r��IPV6_ENABLEDr�r�r�r�r�r�r�rr r�r�rQrrrr�requires_mac_verr'r9rCrQrVrYr^rjrwrxs@rr�r�s����'�
�
E�$B�>�	3�	8�6�.6�>�!�(0�8%�(�X������3�\�B�)I�C�)I�V�X������3�\�B��X������5�2�4�$�4�C�$� �X������3�\�B��X������5�2�4�$�4�C�$�"	�7��/�/�G�0�G�;?�&*�R�?�B8<�15�
�CG�#K�J�X�_�_�S�D�[�/�2�E�3�E��/�/��X�_�_�S�D�[�/�2�
E�3�0�
E�	��(�(�,�)�,�*�(�(�,�)�,�(E�46�l�X�_�_�S�D�[�/�2�J�3�J�/��T�Z�Z�,�-�5�.�5�6M�A�"�H�.�X������8�:K�L��M��2��/�/��0��6�X������3�5F�G�0�H�0��	"�?��X�_�_�S�D�[�/�2��3��>�/�/��X�_�_�S�D�[�/�2��3�0��:�X�_�_�S�D�[�/�2��3��8�/�/��X�_�_�S�D�[�/�2��3�0��8�X�_�_�S�D�[�/�2��3��:�/�/��X�_�_�S�D�[�/�2�1�3�0�1�2�X�_�_�S�D�[�/�2�1�3�1�:�.
��X����3�3�5T�U�&�V�&�P�(�(��)��$.!�`N��X����3�3�5T�U�I�V�I�.�4
'��X�������0�:�<�E�<�E�@�X�������0�:�<�%�<�%�@�X�������0�:�<��X�����Y�/�1D�E�E�F�<�E�B�X�������0�:�<�#0�<�#0�J�X�������0�:�<�0�<�0�*�X�������0�:�<��X�����Y�/�1D�E��W���b�!�$�%0�%�F�<�%0�N�X�������0�:�<��X�����Y�/�1D�E��W���b�!�$�D6�%�F�<�D6�L�@B�2
0�
)�/�"rr�c��eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zejejd
k(d�d��Zd
�Zd�Zd�Zd�Zd�Zd�Zy)�SubprocessTestsMixinc��tjdk(r|j|t�y|j	t
j|�y�Nr)rr rhr%r�rNre�r7r�s  r�check_terminatedz%SubprocessTestsMixin.check_terminated
�6���<�<�7�"��!�!�*�c�2�
���f�n�n�_�j�9rc��tjdk(r|j|t�y|j	t
j|�yru)rr rhr%r�rNr@rvs  r�check_killedz!SubprocessTestsMixin.check_killedrxrc���tjjtjjt�d�}|j
j
tjt|j
�tj|�}|j
j|�\}}|j|t�|j
j|j�|jd|j �|j#d�}|j%d�|j
j|j&dj)��t+j,�5|j/�ddd�|j
j|j0�|j3|j4�|jd|j6d�y#1swY�ixYw)N�echo.pyr]r�Python The Winnerr�)rQrJr�dirname�__file__r2�subprocess_execr�r�r�r�
executabler1rhrPr�rM�get_pipe_transportrtr�rJr�r�rAr�rzr�rg�r7�progr��transpr��stdins      r�test_subprocess_execz)SubprocessTestsMixin.test_subprocess_execsX���w�w�|�|�B�G�G�O�O�H�5�y�A���)�)�+�+�!�)�)�*>��	�	�J�����.���	�	�4�4�W�=�
������e�%9�:��	�	�$�$�U�_�_�5�����e�k�k�2��)�)�!�,��
���(�)��	�	�$�$�U�^�^�A�%6�%;�%;�%=�>�
�
&�
&�
(�	��L�L�N�	��	�	�$�$�U�_�_�5����%�*�*�+����-�u�z�z�!�}�=�		�	�s�0G)�)G2c���tjjtjjt�d�}|j
j
tjt|j
�tj|�}|j
j|�\}}|j|t�|j
j|j�|jd|j �|j#d�}|j%d�|j
j|j&dj)��|j&dj+�|jd|j,d�|j%d�|j
j|j&dj)��|jd|j,d�t/j0�5|j3�ddd�|j
j|j4�|j7|j8�y#1swY�JxYw)Nr|r]rsPython r�s
The Winnerr})rQrJrr~rr2r�r�r�r�rr�r1rhrPr�rMr�rtr�rJ�clearrgr�r�rAr�rzr�r�s      r�test_subprocess_interactivez0SubprocessTestsMixin.test_subprocess_interactive0s����w�w�|�|�B�G�G�O�O�H�5�y�A���)�)�+�+�!�)�)�*>��	�	�J�����.���	�	�4�4�W�=�
������e�%9�:��	�	�$�$�U�_�_�5�����e�k�k�2��)�)�!�,��
���J���	�	�$�$�U�^�^�A�%6�%;�%;�%=�>�
���q����!�����U�Z�Z��]�3�
���M�"��	�	�$�$�U�^�^�A�%6�%;�%;�%=�>����-�u�z�z�!�}�=�
�
&�
&�
(�	��L�L�N�	��	�	�$�$�U�_�_�5����%�*�*�+�	�	�s�I,�,I5c��|jjtjt|j�d�}|jj|�\}}|j
|t�|jj|j�|jd�j�|jj|j�|jd|j�|jtd�|jj!�D���|j|j"dj%d�d�|j|j"dd�|j�y)	Nzecho Pythonrc3�<K�|]}|j����y�wr)rQ)�.0r�s  r�	<genexpr>z=SubprocessTestsMixin.test_subprocess_shell.<locals>.<genexpr>Vs����I��A�F�F�H�I�s�r�s
sPythonr�r)r2�subprocess_shellr�r�r�r1rhrPr�rAr�r�r�r��allr��valuesrg�rstrip�r7r�r�r�s    r�test_subprocess_shellz*SubprocessTestsMixin.test_subprocess_shellKs���)�)�,�,�!�)�)�*>��	�	�J�%�'���	�	�4�4�W�=�
������e�%9�:��	�	�$�$�U�_�_�5��!�!�!�$�*�*�,��	�	�$�$�U�_�_�5�����E�,�,�-�����I�e�.?�.?�.F�.F�.H�I�I�J�������A��-�-�g�6�	�B�������A���,����rc��|jjtjt|j�dddd��}|jj|�\}}|j
|t�|jj|j�|jd|j�|j�y)N�exit 7�r��stdout�stderr��r2r�r�r�r�r1rhr�r�r�rAr�s    r�test_subprocess_exitcodez-SubprocessTestsMixin.test_subprocess_exitcode[s����)�)�,�,�!�)�)�*>��	�	�J� ��T�$�-�H���	�	�4�4�W�=�
������e�%9�:��	�	�$�$�U�_�_�5�����E�,�,�-����rc�p�|jjtjt|j�dddd��}|jj|�\}}|j
|t�|j|jd��|j|jd��|j|jd��|jj|j�|jd|j�|j|j��y)Nr�r�rr�r�r�)
r2r�r�r�r�r1rhr~r�r�r�r�rAr�s    r�"test_subprocess_close_after_finishz7SubprocessTestsMixin.test_subprocess_close_after_finishfs����)�)�,�,�!�)�)�*>��	�	�J� ��T�$�-�H���	�	�4�4�W�=�
������e�%9�:����&�3�3�A�6�7����&�3�3�A�6�7����&�3�3�A�6�7��	�	�$�$�U�_�_�5�����E�,�,�-����&�,�,�.�)rc��tjjtjjt�d�}|j
j
tjt|j
�tj|�}|j
j|�\}}|j|t�|j
j|j�|j�|j
j|j �|j#|j$�|j'�y�Nr|)rQrJrr~rr2r�r�r�r�rr�r1rhrPrRr�rzr�rA�r7r�r�r�r�s     r�test_subprocess_killz)SubprocessTestsMixin.test_subprocess_killts����w�w�|�|�B�G�G�O�O�H�5�y�A���)�)�+�+�!�)�)�*>��	�	�J�����.���	�	�4�4�W�=�
������e�%9�:��	�	�$�$�U�_�_�5����
��	�	�$�$�U�_�_�5����%�*�*�+����rc��tjjtjjt�d�}|j
j
tjt|j
�tj|�}|j
j|�\}}|j|t�|j
j|j�|j�|j
j|j �|j#|j$�|j'�yr�)rQrJrr~rr2r�r�r�r�rr�r1rhrP�	terminater�rwr�rAr�s     r�test_subprocess_terminatez.SubprocessTestsMixin.test_subprocess_terminate�s����w�w�|�|�B�G�G�O�O�H�5�y�A���)�)�+�+�!�)�)�*>��	�	�J�����.���	�	�4�4�W�=�
������e�%9�:��	�	�$�$�U�_�_�5������	�	�$�$�U�_�_�5����e�.�.�/����rrzDon't have SIGHUPc���tjtjtj�}	tjjtjj
t�d�}|jjtjt|j�tj|�}|jj|�\}}|j!|t�|jj|j"�|j%tj�|jj|j&�|j)tj|j*�|j-�tjtj|�y#tjtj|�wxYwr�)rN�SIGHUP�SIG_DFLrQrJrr~rr2r�r�r�r�rr�r1rhrP�send_signalr�r�r�rA)r7�old_handlerr�r�r�r�s      r�test_subprocess_send_signalz0SubprocessTestsMixin.test_subprocess_send_signal�s'��
�m�m�F�M�M�6�>�>�B��	6��7�7�<�<������� 9�9�E�D��i�i�/�/�%�-�-�.B�D�I�I�N��N�N�D�2�G�
!�I�I�8�8��A�M�F�E��!�!�%�)=�>��I�I�(�(����9����v�}�}�-��I�I�(�(����9����f�m�m�^�U�-=�-=�>��L�L�N��M�M�&�-�-��5��F�M�M�&�-�-��5�s�E&F?�?&G%c�l�tjjtjjt�d�}|j
j
tjt|j
�tj|�}|j
j|�\}}|j|t�|j
j|j�|jd�}|j!d�|j
j|j"�|j%�|j'd|j(d�|j+|j(dj-d�|j(d�|j'd|j.�y)N�echo2.pyr�test�OUT:testr�r�sERR:test)rQrJrr~rr2r�r�r�r�rr�r1rhrPr�rtr�rAr�rgr�r!r�r�s      r�test_subprocess_stderrz+SubprocessTestsMixin.test_subprocess_stderr�s(���w�w�|�|�B�G�G�O�O�H�5�z�B���)�)�+�+�!�)�)�*>��	�	�J�����.���	�	�4�4�W�=�
������e�%9�:��	�	�$�$�U�_�_�5��)�)�!�,��
���G���	�	�$�$�U�_�_�5���������e�j�j��m�4�����
�
�1�
�0�0��=�u�z�z�!�}�M�����E�,�,�-rc��tjjtjjt�d�}|j
j
tjt|j
�tj|tj��}|j
j|�\}}|j|t�|j
j|j �|j#d�}|j%|j#d��|j'|j#d��|j)d�|j
j|j*�|j-|j.dj1d�|j.d�|j3d|j.d�|j5�|j3d|j6�y)	Nr�)r�rr�r�r�sOUT:testERR:testr)rQrJrr~rr2r�r�r�r�rr��
subprocess�STDOUTr1rhrPr�rlr~rtr�r�rgr!r�rAr�r�s      r�)test_subprocess_stderr_redirect_to_stdoutz>SubprocessTestsMixin.test_subprocess_stderr_redirect_to_stdout�sl���w�w�|�|�B�G�G�O�O�H�5�z�B���)�)�+�+�!�)�)�*>��	�	�J�����Z�5F�5F�,�H��
�	�	�4�4�W�=�
������e�%9�:��	�	�$�$�U�_�_�5��)�)�!�,�����V�6�6�q�9�:����&�3�3�A�6�7�
���G���	�	�$�$�U�_�_�5�����
�
�1�
�0�0�1D�E��
�
�1�
�	'�����e�j�j��m�,���������E�,�,�-rc�v�tjjtjjt�d�}|j
j
tjt|j
�tj|�}|j
j|�\}}|j|t�|j
j|j�|jd�}|jd�}|j!d�|j
j|j"dj%��|j'd|j(d�|j+�|j
j|j,d�|j!d�|j
j|j"dj%��tj.dk7r |j'd	|j(d�n|j'd
|j(d�t1j2�5|j+�ddd�|j
j|j4�|j7|j8�y#1swY�JxYw)Nzecho3.pyrr�r�r�r1r�rsERR:BrokenPipeErrorsERR:OSError)rQrJrr~rr2r�r�r�r�rr�r1rhrPr�rtr�rJr�rgrAr�r r�r�r�rzr�)r7r�r�r�r�r�r�s       r�#test_subprocess_close_client_streamz8SubprocessTestsMixin.test_subprocess_close_client_stream�s����w�w�|�|�B�G�G�O�O�H�5�z�B���)�)�+�+�!�)�)�*>��	�	�J�����.���	�	�4�4�W�=�
������e�%9�:��	�	�$�$�U�_�_�5��)�)�!�,���*�*�1�-��
���G���	�	�$�$�U�^�^�A�%6�%;�%;�%=�>�����e�j�j��m�4������	�	�$�$�U�%6�%6�q�%9�:�
���F���	�	�$�$�U�^�^�A�%6�%;�%;�%=�>��<�<�7�"����3�U�Z�Z��]�C�
���^�U�Z�Z��]�;�
�
&�
&�
(�	��L�L�N�	��	�	�$�$�U�_�_�5����%�*�*�+�	�	�s�J/�/J8c��|jjtjt|j�ddddd��}|jj|�\}}|j
|t�|jj|j�|jd|j�|j�y)Nr�T)r�r�r��start_new_sessionr�r�r�s    r�"test_subprocess_wait_no_same_groupz7SubprocessTestsMixin.test_subprocess_wait_no_same_group�s����)�)�,�,�!�)�)�*>��	�	�J� ��T�$�*.�-�0���	�	�4�4�W�=�
������e�%9�:��	�	�$�$�U�_�_�5�����E�,�,�-����rc�����fd�}�jt�5�jj|d���ddd��jt�5�jj|d���ddd��jt�5�jj|d���ddd�y#1swY��xYw#1swY�VxYw#1swYyxYw)Nc��z�K��jjtjdfi|���d{���y7��w�N�pwd)r2r�r�SubprocessProtocol)rr7s �rr�zGSubprocessTestsMixin.test_subprocess_exec_invalid_args.<locals>.connect
s9�����+�$�)�)�+�+��*�*�����
�
�s�0;�9�;T��universal_newlines���bufsize��shell�r�rMr2r1�r7r�s` r�!test_subprocess_exec_invalid_argsz6SubprocessTestsMixin.test_subprocess_exec_invalid_args	s����	�
�
�
�z�
*�	K��I�I�(�(��D�)I�J�	K�
�
�
�z�
*�	@��I�I�(�(���)>�?�	@�
�
�
�z�
*�	>��I�I�(�(��t�)<�=�	>�	>�		K�	K��	@�	@��	>�	>�s#�#C�#C�#C �C�C� C)c�t��d
�fd�	}�jt�5�jj|ddg��ddd��jt�5�jj|d���ddd��jt�5�jj|d���ddd��jt�5�jj|d�	��ddd�y#1swY��xYw#1swY��xYw#1swY�bxYw#1swYyxYw)Nc���K�|sd}�jjtj|fi|���d{���y7��wr�)r2r�rr�)�cmdrr7s  �rr�zHSubprocessTestsMixin.test_subprocess_shell_invalid_args.<locals>.connectsA��������,�$�)�)�,�,��*�*�����
�
�s�4?�=�?�lsz-lTr�r�r�Fr�rr�r�s` r�"test_subprocess_shell_invalid_argsz7SubprocessTestsMixin.test_subprocess_shell_invalid_argss���	��
�
�z�
*�	@��I�I�(�(��$���)>�?�	@�
�
�
�z�
*�	K��I�I�(�(��D�)I�J�	K�
�
�
�z�
*�	@��I�I�(�(���)>�?�	@�
�
�
�z�
*�	?��I�I�(�(��u�)=�>�	?�	?�
	@�	@��	K�	K��	@�	@��	?�	?�s/�$D
�#D�#D"�#D.�
D�D�"D+�.D7N)rDrErFrwrzr�r�r�r�r�r�r�rkrnrr r�r�r�r�r�r�r�rrrrsrssz��:�:�>�*,�6� 	�*�� � �X�_�_�S�\�\�W�,�.A�B�6�C�6�0.�*.�2 ,�D
�>�?rrsrc��eZdZd�Zy)�SelectEventLoopTestsc�*�tj�Sr)r�SelectorEventLoopr@s rr�z&SelectEventLoopTests.create_event_loop.����,�,�.�.rN�rDrErFr�rrrr�r�+s��	/rr�c�0�eZdZd�Zd�Zd�Zd�Zd�Zd�Zy)�ProactorEventLoopTestsc�*�tj�Sr)r�ProactorEventLoopr@s rr�z(ProactorEventLoopTests.create_event_loop5r�rc�,�tjd���Nz(IocpEventLoop does not have add_reader()�rk�SkipTestr@s rr8z+ProactorEventLoopTests.test_reader_callback8����#�#�$N�O�Orc�,�tjd��r�r�r@s r�test_reader_callback_cancelz2ProactorEventLoopTests.test_reader_callback_cancel;r�rc�,�tjd���Nz(IocpEventLoop does not have add_writer()r�r@s rr?z+ProactorEventLoopTests.test_writer_callback>r�rc�,�tjd��r�r�r@s r�test_writer_callback_cancelz2ProactorEventLoopTests.test_writer_callback_cancelAr�rc�,�tjd��r�r�r@s rrVz4ProactorEventLoopTests.test_remove_fds_after_closingDr�rN)	rDrErFr�r8r�r?r�rVrrrr�r�1s%��	/�	P�	P�	P�	P�	Prr�c�(��eZdZ�fd�Z�fd�Z�xZS)�UnixEventLoopTestsMixinc�0��t�|��tj�5tjdt
�t
j�}|j|j�t
j|�ddd�y#1swYyxYw�N�ignore)rsr��warnings�catch_warnings�simplefilter�DeprecationWarningr�SafeChildWatcher�attach_loopr2�set_child_watcher�r7�watcherrus  �rr�zUnixEventLoopTestsMixin.setUpJsl����G�M�O��(�(�*�
3��%�%�h�0B�C�!�2�2�4���#�#�D�I�I�.��)�)�'�2�	
3�
3�
3�s�AB�Bc����tj�5tjdt�t	j
d�ddd�t�|��y#1swY�xYwr�)r�r�r�r�rr�rsr�r�s �rr�z UnixEventLoopTestsMixin.tearDownRsP����(�(�*�
0��%�%�h�0B�C��)�)�$�/�
0�
�G���
0�
0�s�0A�A&)rDrErFr�r�rwrxs@rr�r�Is���	3�	�	rr��KqueueSelectorc����eZdZd�Zej
dd�ejejjd�d��fd���Zej
dd��fd��Z�xZ
S)�KqueueEventLoopTestsc�P�tjtj��Sr)rr��	selectorsr�r@s rr�z&KqueueEventLoopTests.create_event_loop^s!���0�0��,�,�.�0�0rr�	�openbsdztest hangs on OpenBSDc�"��t�|��yr)rsrr�s �rrz)KqueueEventLoopTests.test_read_pty_outputds�����,�.rc�"��t�|��yr)rsr'r�s �rr'z#KqueueEventLoopTests.test_write_ptyns�����&�(r)rDrErFr�rrqrkrnrr r!rr'rwrxs@rr�r�Zsw���
0�&�W�
%�
%�b�!�
,��X�_�_�S�\�\�4�4�Y�?�4�6�
/�6�-�

/�
&�W�
%�
%�b�!�
,�
)�-�
)rr��
EpollSelectorc��eZdZd�Zy)�EPollEventLoopTestsc�P�tjtj��Sr)rr�r�r�r@s rr�z%EPollEventLoopTests.create_event_loopws���0�0��1H�1H�1J�K�KrNr�rrrr�r�ss��
Lrr��PollSelectorc��eZdZd�Zy)�PollEventLoopTestsc�P�tjtj��Sr)rr�r�rr@s rr�z$PollEventLoopTests.create_event_loops���0�0��1G�1G�1I�J�JrNr�rrrrr{s��
Krrc��eZdZd�Zy)r�c�P�tjtj��Sr)rr�r��SelectSelectorr@s rr�z&SelectEventLoopTests.create_event_loop�s���,�,�Y�-E�-E�-G�H�HrNr�rrrr�r��s��	Irc��yrr)rr�s  r�noopr�s��rc���eZdZ�fd�Zd�Zd�Zd�Zd�Zd�Zd�Z	e
jee
jd�d	�d
��Z�xZS)�HandleTestsc���t�|��tj�|_d|jj
_yr)rsr�rrr2�	get_debug�return_valuer�s �rr�zHandleTests.setUp�s+���
��
���I�I�K��	�+/��	�	���(rc�\�d�}d}tj|||j�}|j|j|�|j|j
|�|j
|j��|j�|j|j��y)Nc��|Srr�rs rr�z)HandleTests.test_handle.<locals>.callback�����Krr)
r�Handler2rk�	_callback�_argsrr=rr�)r7r�r�hs    r�test_handlezHandleTests.test_handle�sw��	����N�N�8�T�4�9�9�5���
�
�a�k�k�8�,��
�
�a�g�g�t�$��������'�	���
�������
�&rc��d�}tj�|_tj�|j_t	j
|d|j�}|j
�|jjjtjd�tj||jd��y)Nc��t��r)rMrrrr�z:HandleTests.test_callback_with_exception.<locals>.callback�s
���,�rrzException in callback.*)r�r��handle�source_traceback)rrr2rwrr�_run�assert_called_withr��MockPattern�ANY�_source_traceback)r7r�rs   r�test_callback_with_exceptionz(HandleTests.test_callback_with_exception�s���	��I�I�K��	�+/�9�9�;��	�	�(��N�N�8�R����3��	�����	�	�(�(�;�;�!�-�-�.G�H����� !� 3� 3�	=
�	rc�z�tj�}tjd�d|j�}||d<y)Nc��yrrrrrr-z1HandleTests.test_handle_weakref.<locals>.<lambda>�rTrrr)�weakref�WeakValueDictionaryrrr2)r7�wdrs   r�test_handle_weakrefzHandleTests.test_handle_weakref�s/��
�
(�
(�
*���N�N�<��T�Y�Y�7����3�rc��d|jj_tjt
d|j�}t
jt
�\}}|jt|�d|�d|�d��|j�|jt|�d�tjt
�}tj|d|j�}|jt|�d|�d|�d��tjt
d	d
�}tj|d|j�}dtj |��d|�d
�}|j#t|�|�tjt
d	��}tj|d|j�}dtj |��d|�d
�}|j#t|�|�t$j&}tj(|�}t
j|�\}}tj|d|j�}d}d|�d�}d|�dtj |��d|�d
�}|j#t|�|�y)NFr��<Handle noop(1, 2) at �:�>z<Handle cancelled>rz<Handle noop() at r�r�)r�z^<Handle noop\(1, 2\)\(3\) at z>$)�x)r�r�z ^<Handle noop\(x=1\)\(2, 3\) at z*<function HandleTests.test_handle_repr .*>zfunctools.partialmethod\(z
, , \)\(\)z	^<Handle z at )r2rr
rrrr��get_function_sourcer�r�r�types�	coroutiner�r��re�escape�assertRegexr
�test_handle_repr�
partialmethod)r7r�filename�linenor��regex�method�cb_regexs        rr2zHandleTests.test_handle_repr�s��+0��	�	���(�
�N�N�4�����3��%�9�9�$�?���&�����a��#�V�-�	.�
	
���
�����a��,�	.��_�_�T�
"���N�N�2�r�4�9�9�-������a��#�V�-�	.�
�
�
�t�Q��
*���N�N�2�t�T�Y�Y�/���I�I�h�'��1������a��%�(��
�
�t�q�
)���N�N�2�v�t�y�y�1���I�I�h�'��1������a��%�(��-�-��
�
$�
$�V�
,��%�9�9�&�A���&��N�N�2�r�4�9�9�-��@��/��z��D���X�J�d�2�9�9�X�+>�*?�q����K������a��%�(rc�:�d|jj_t}t	j
�jdz}tjtd|j�}tjt�\}}|jt|�d|�d|�d|�d|�d�	�|j�|jt|�d|�d|�d|�d|�d�	�|j�|jt|�d|�d|�d|�d|�d�	�y)	NTr�r�r(r)� created at r*z <Handle cancelled noop(1, 2) at )r2rr
rr�	_getframe�f_linenorrrr�r,r�r�r�r7�create_filename�
create_linenorr4r5s      r�test_handle_repr_debugz"HandleTests.test_handle_repr_debug�s���+/��	�	���(�#���
�
��0�0�1�4�
��N�N�4�����3��%�9�9�$�?���&�����a��#�V�_�m�M�	N�
	
���
������G����-�
A�	B�	
���
������G����-�
A�	Brc���tj�j�}|jd��j	|��fd�}|jt�}||�|jt�}||�|jdt�}||�|jdt�}||�y)NTc����tjd�jdz
}�j|jt
��j
|jdddt|df�y)Nr�rHr��test_handle_source_traceback)rr;r<rhr�listr�r)rr5r7s  �r�check_source_tracebackzHHandleTests.test_handle_source_traceback.<locals>.check_source_traceback	sb����]�]�1�%�.�.��2�F��!�!�!�"5�"5�t�<����Q�0�0��4�R�a�8�&�$�<�>�
?rr)	r�get_event_loop_policyr/�	set_debugr0r�rr�r�)r7r2rErs`   rrCz(HandleTests.test_handle_source_traceback	s�����,�,�.�=�=�?�����t�����D�!�	?�
�N�N�4� ���q�!�
�%�%�d�+���q�!�
�O�O�A�t�$���q�!�
�O�O�A�t�$���q�!r�	CoroutinezNo collections.abc.Coroutinec��t�}d|_|jtj|��|jt
j|�d�d|_|jt
j|�d�d|_	|jt
j|�d�dx|_|_|jt
j|�d�t�}d|_|jt
j|�d	�t�}d|_d|_
|jt
j|�d�y)
N�AAAzAAA()�BBBzBBB()Tz
BBB() runningz%<CoroLike without __name__>() runningr5z
CoroLike())r5rDr�r�iscoroutiner�r�_format_coroutinerF�
cr_running�cr_code)r7rs  r�+test_coroutine_like_object_debug_formattingz7HandleTests.test_coroutine_like_object_debug_formatting	s���z����
�����+�+�D�1�2�����5�5�d�;�W�E�!�������5�5�d�;�W�E��������5�5�d�;�_�M�,0�0��
��)�����5�5�d�;�@�	B��z��&���	
����5�5�d�;�\�J��z��!����������5�5�d�;�W�Er)rDrErFr�rr r&r2r@rCrkrlr��collections�abcrPrwrxs@rr
r
�s[���0�
'��"�
-)�^B�4"�:�X�������+�>�7�9�F�9�Frr
c�B��eZdZ�fd�Zd�Zd�Zd�Zd�Zd�Zd�Z	�xZ
S)�
TimerTestsc�T��t�|��tj�|_yr)rsr�rrr2r�s �rr�zTimerTests.setUpC	s���
��
���I�I�K��	rc���tj�}tj|d�dt	j
��}|j
t|�t|��y)Nc��yrcrrrrr-z&TimerTests.test_hash.<locals>.<lambda>I	rTrr)r��	monotonicr�TimerHandlerrr��hash�r7�whenrs   r�	test_hashzTimerTests.test_hashG	sE���~�~�������m�R� $�	�	��
-������a��$�t�*�-rc���tj�}tj|d�dt	j
��}|j
||j��y)Nc��yrcrrrrr-z&TimerTests.test_when.<locals>.<lambda>O	rTrr)r�rXrrYrrr�r\r[s   r�	test_whenzTimerTests.test_whenM	sC���~�~�������m�R� $�	�	��
-������q�v�v�x�(rc��d�}d}tj�}tj|||t	j
��}|j
|j|�|j
|j|�|j|j��|j�|j|j��|j|j�|j|j�y)Nc��|Srrrs rr�z'TimerTests.test_timer.<locals>.callbackT	rr)r�r�r�)r�rXrrYrrrkrrrr=rr�r~)r7r�rr\rs     r�
test_timerzTimerTests.test_timerS	s���	����~�~�������h��d�i�i�k�B���
�
�a�k�k�8�,��
�
�a�g�g�t�$��������'�	
���
�������
�&����!�+�+�&����!�'�'�"rc�J�d|jj_tjdt
d|j�}t
jt
�}|jt|�d|z�|j�|jt|�d�y)NF�{rz&<TimerHandle when=123 noop() at %s:%s>z <TimerHandle cancelled when=123>)r2rr
rrYrr�r,r�r�r)r7r�srcs   r�test_timer_reprzTimerTests.test_timer_repre	s��+0��	�	���(�
����T�2�t�y�y�9���,�,�T�2������a��@�3�F�	H�	
���
�����a��:�	<rc���d|jj_t}t	j
�jdz}tjdtd|j�}tjt�\}}|jt|�d|�d|�d|�d|�d�	�|j�|jt|�d	|�d|�d|�d|�d�	�y)
NTr�rerz <TimerHandle when=123 noop() at r)r:r*z*<TimerHandle cancelled when=123 noop() at )r2rr
rrr;r<rrYrr�r,r�r�rr=s      r�test_timer_repr_debugz TimerTests.test_timer_repr_debugs	s���+/��	�	���(�#���
�
��0�0�1�4�
�����T�2�t�y�y�9��%�9�9�$�?���&�����a��$�V�_�m�M�	N�	
���
�����a��$�V�_�m�M�	Nrc�6	�d�}tj�}tj||d|j�}tj||d|j�}|j||k�|j||k�|j
||k�|j
||k�|j||kD�|j||kD�|j
||k\�|j
||k\�|j
||k(�|j||k7�|j�|j||k(�tj||d|j�}tj|dz|d|j�}|j
||k�|j||k�|j
||k�|j||k�|j||kD�|j
||kD�|j||k\�|j
||k\�|j||k(�|j
||k7�tj|d|j�}|jt|j|��|jt|j|��|jt�5|dkddd�|jt�5|dkDddd�|jt�5|dkddd�|jt�5|dk\ddd�|j|dk(�|j
|dk7�|j
|tk(�|j|tk7�|j
|t k�|j|t kD�|j
|t k�|j|t k\�|j|t"k�|j
|t"kD�|j|t"k�|j
|t"k\�y#1swY���xYw#1swY��vxYw#1swY��`xYw#1swY��JxYw)Nc��|Srrrs rr�z2TimerTests.test_timer_comparison.<locals>.callback�	rrrg$@)r�rXrrYr2rr�rrrk�NotImplemented�__eq__�__ne__r�rJrrr)r7r�r\�h1�h2�h3s      r�test_timer_comparisonz TimerTests.test_timer_comparison�	s���	��~�~���
�
 �
 ��x��T�Y�Y�
?��
�
 �
 ��x��T�Y�Y�
?������b��!�����b��!�����b��!�����b��!�����b��!�����b��!�����b��!�����b��!�����b��!�����r��"�
�	�	������r��"�
�
 �
 ��x��T�Y�Y�
?��
�
 �
 ����h��D�I�I�
F������R�� �����b��!�����b��!�����r��"�����b��!�����R�� �����r��"�����b��!�����r��"�����b��!�
�^�^�H�b�$�)�)�
4���
�
�n�b�i�i��m�4��
�
�n�b�i�i��m�4�
�
�
�y�
)�	���G�	�
�
�
�y�
)�	���G�	�
�
�
�y�
)�	��"�H�	�
�
�
�y�
)�	��"�H�	�����r��"�����b��!�����i��(�����y��)�����W��%�����g��&�����g�
�&�����w��'�����h��'�����X�
�&�����x��(�����h��'�)	�	��	�	��	�	��	�	�s0�Q'�:Q4�R�R�'Q1�4Q>�R�R)rDrErFr�r]r`rcrgrirrrwrxs@rrTrTA	s'��� �.�)�#�$<�N�*<(rrTc��eZdZd�Zd�Zy)�AbstractEventLoopTestsc���tj�}tj�}|j	t
|j�|j	t
|jd�|j	t
|j�|j	t
|j�|j	t
|j�|j	t
|j�|j	t
|jd�|j	t
|jdd�|j	t
|j||�|j	t
|jd�|j	t
|j �|j	t
|j"d�|j	t
|j$|�|j	t
|j&d|�|j	t
|j(d�|j	t
|j*d|�|j	t
|j,d�|j	t
|j.d|�|j	t
|j0d�|j	t
|j0d�|j	t
|j2|�|j	t
|j4|�|j	t
|j6|�|j	t
|j8�|j	t
|j:|�yrC)rrr�AbstractEventLoopr��NotImplementedErrorr�r1r�r�r�rArr�rdr�r�r��set_default_executorr5r%r<r=rKrL�set_exception_handler�default_exception_handlerrwrrG)r7r�r2s   r�test_not_implementedz+AbstractEventLoopTests.test_not_implemented�	s����I�I�K���(�(�*�������!1�!1�	3������!8�!8�$�	@��������	,��������	2��������	1��������	-������!1�!1�4�	9��������$��	>��������q�!�	5���������	7��������	,������!:�!:�D�	B������!:�!:�A�	?��������!�Q�	8������!3�!3�Q�	8��������!�Q�	8������!3�!3�Q�	8������!8�!8�!�Q�	@������!;�!;�Q�	@������!;�!;�Q�	@������!;�!;�Q�	@������!?�!?��	D������!<�!<�a�	A��������	1���������	4rc����fd�}tj�}|j|��|j�y)Nc��\
�K�tj�}tj�}�j	t
�5|j
||��d{���ddd��j	t
�5|jdd��d{���ddd��j	t
�5|jd��d{���ddd��j	t
�5|j|��d{���ddd��j	t
�5|j|��d{���ddd��j	t
�5|j|��d{���ddd��j	t
�5|j|d��d{���ddd��j	t
�5|j|d��d{���ddd��j	t
�5|j|d��d{���ddd��j	t
�5|j||��d{���ddd��j	t
�5|j!|��d{���ddd��j	t
�5|j#||��d{���ddd��j	t
�5|j%||��d{���ddd��j	t
�5|j'|tj(j*��d{���ddd��j	t
�5|j-|tj(j*��d{���ddd��j	t
�5|j/|tj(��d{���ddd��j	t
�5|j1|��d{���ddd�y7���#1swY���xYw7���#1swY���xYw7��w#1swY��wxYw7��P#1swY��PxYw7��)#1swY��)xYw7��#1swY��xYw7���#1swY���xYw7���#1swY���xYw7���#1swY���xYw7��b#1swY��bxYw7��;#1swY��;xYw7��#1swY��xYw7���#1swY���xYw7���#1swY���xYw7��k#1swY��kxYw7��5#1swY��5xYw7��#1swYyxYw�w)Nr��)r�r~r)rrrrvr�rwr
r�r�r{r�r�r�sock_recv_into�sock_sendall�sock_connect�sock_accept�
sock_sendfile�sendfiler��sentinelr�r�r�r�)r�r2r7s  �r�innerz@AbstractEventLoopTests.test_not_implemented_async.<locals>.inner
sw������	�	��A��,�,�.�D��"�"�#6�7�
1��*�*�1�a�0�0�0�
1��"�"�#6�7�
:��&�&�{�D�9�9�9�
:��"�"�#6�7�
<��&�&�':�;�;�;�
<��"�"�#6�7�
0��,�,�Q�/�/�/�
0��"�"�#6�7�
,��(�(��+�+�+�
,��"�"�#6�7�
7��3�3�A�6�6�6�
7��"�"�#6�7�
,��n�n�Q��+�+�+�
,��"�"�#6�7�
1��)�)�!�R�0�0�0�
1��"�"�#6�7�
/��'�'��2�.�.�.�
/��"�"�#6�7�
.��'�'��1�-�-�-�
.��"�"�#6�7�
*��&�&�q�)�)�)�
*��"�"�#6�7�
/��(�(��A�.�.�.�
/��"�"�#6�7�
*��m�m�A�q�)�)�)�
*��"�"�#6�7�
D��,�,�Q��
�
�0B�0B�C�C�C�
D��"�"�#6�7�
E��-�-�a����1C�1C�D�D�D�
E��"�"�#6�7�
>��+�+�A�t�}�}�=�=�=�
>��"�"�#6�7�
.��*�*�1�-�-�-�
.�
.�?1��
1�
1��:��
:�
:��<��
<�
<��0��
0�
0��,��
,�
,��7��
7�
7��,��
,�
,��1��
1�
1��/��
/�
/��.��
.�
.��*��
*�
*��/��
/�
/��*��
*�
*��D��
D�
D��E��
E�
E��>��
>�
>��.��
.�
.�s��>T,�P �P�P �T,�9P0�P-�P0�T,�1Q�P=�Q�T,�(Q�=Q
�>Q�T,�Q �4Q�5Q �9T,�Q0�+Q-�,Q0�0T,�
R�#Q=�$R�(T,�R�R
�R� T,�=R �R�R �T,�5R0�R-�R0�T,�-S�R=�S�T,�$S�:S
�;S�?T,�S �2S�3S �7T,�.S0�S-�S0�T,�$.T�S=�T�T,�4$T�T
�T�T,�:T �T�T �	T,�P � P*�%T,�-P0�0P:�5T,�=Q�Q
�T,�
Q�Q�T,�Q � Q*�%T,�-Q0�0Q:�5T,�=R�R
�T,�
R�R�T,�R � R*�%T,�-R0�0R:�5T,�=S�S
�T,�
S�S�T,�S � S*�%T,�-S0�0S:�5T,�=T�T
�T,�
T�T�T,�T � T)�%T,)rr/r1rA)r7r�r2s`  r�test_not_implemented_asyncz1AbstractEventLoopTests.test_not_implemented_async�	s2���%	.�N�%�%�'�������(��
�
�rN)rDrErFr{r�rrrrtrt�	s
��44�l+rrtc�l�eZdZd�Zd�Zd�Zd�Zejd�d��Z	d�Z
d�Zd	�Zd
�Z
y)�PolicyTestsc��tj�}|jt|j�|jt|j
t
��|jt|j�|jt|j�|jt|jt
��yr)
r�AbstractEventLoopPolicyr�rw�get_event_loopr0r}r/�get_child_watcherr��r7�policys  r�test_event_loop_policyz"PolicyTests.test_event_loop_policy/
s����0�0�2�����-�v�/D�/D�E����-�v�/D�/D�f�h�O����-�v�/D�/D�E����-�v�/G�/G�H����-�v�/G�/G� �(�	$rc��tj�}|j|jj�|jt�5}|j�}ddd�|jjt�|jtj�|j|jj|�|j||j��|j�y#1swY��xYwr)r�DefaultEventLoopPolicyr~�_local�_loop�assertWarnsr�r�r�r4rrhrvrkrA)r7r�r�r2s    r�test_get_event_loopzPolicyTests.test_get_event_loop8
s����/�/�1�����&�-�-�-�-�.�
�
�
�0�
1�	+�R��(�(�*�D�	+�������h�/����d�G�$=�$=�>��
�
�f�m�m�)�)�4�0��
�
�d�F�1�1�3�4��
�
��	+�	+�s�C?�?Dc���tj�}tjj	|d|j
��5}|j
t�5}|j�}ddd�|jj�|jjt�|j|�ddd�j�y#1swY�nxYw#1swY�&xYw)Nr0)�wraps)rr�rr�r}r0r�r�r�r
rAr�r4rr)r7r��m_set_event_loopr�r2s     r�(test_get_event_loop_calls_set_event_loopz4PolicyTests.test_get_event_loop_calls_set_event_loopD
s����/�/�1��
�Z�Z�
�
��(��+�+��-�	6�0@��!�!�"4�5�
/���,�,�.��
/��O�O�D�J�J�'����R�[�[�(�3�

�/�/��5�	6�	
�
�
��
/�
/��		6�	6�s%�C!�C�(AC!�C	�C!�!C*c��tj�}|jd�|jt|j
�yr)rr�r0r�r�r�r�s  r�"test_get_event_loop_after_set_nonez.PolicyTests.test_get_event_loop_after_set_noneW
s4���/�/�1�����d�#����,��(=�(=�>rz'asyncio.events.threading.current_threadc�|���fd�}tj|��}|j�|j�y)Nc�n��tj�}�jt|j�yr)rr�r�r�r�)r�r7s �rr�z1PolicyTests.test_get_event_loop_thread.<locals>.f_
s'����3�3�5�F����l�F�,A�,A�Brr�)r�rrr)r7�m_current_threadr��ths`   r�test_get_event_loop_threadz&PolicyTests.test_get_event_loop_thread\
s-���	C��
�
�Q�
'��
���
�
���	rc��tj�}|j�}|j|tj�|j�yr)rr�r/rhrvrA)r7r�r2s   r�test_new_event_loopzPolicyTests.test_new_event_loopg
s=���/�/�1���$�$�&�����d�G�$=�$=�>��
�
�rc���tj�}|j�}|j|�|j	t
|jt
��|j�}|j|�|j||j��|j||j��|j�|j�yr)rr�r/r0r�rJr}rkr��assertIsNotrA)r7r��old_loopr2s    r�test_set_event_loopzPolicyTests.test_set_event_loopn
s����/�/�1���(�(�*�����h�'����)�V�%:�%:�F�H�E��$�$�&�����d�#��
�
�d�F�1�1�3�4�����6�#8�#8�#:�;��
�
�����rc��tj�}|j|tj�|j	|tj��yr)rrFrhr�rkr�s  r�test_get_event_loop_policyz&PolicyTests.test_get_event_loop_policy|
s=���.�.�0�����f�g�&E�&E�F��
�
�f�g�;�;�=�>rc�D�|jttjt	��tj
�}tj�}tj|�|j|tj
��|j||�yr)	r�rJrrr}rFr�rkr�)r7�
old_policyr�s   r�test_set_event_loop_policyz&PolicyTests.test_set_event_loop_policy�
ss������w�4�4�f�h�	@��2�2�4�
��/�/�1���%�%�f�-��
�
�f�g�;�;�=�>������,rN)rDrErFr�r�r�r�rr�r�r�r�r�r�rrrr�r�-
sJ��$�
��&?�
�T�Z�Z�9�:��;����?�
	-rr�c�h��eZdZdZdZdZdZ�fd�Z�fd�Ze	jdk7rd�Zd�Zd�Z
�xZS)�GetEventLoopTestsMixinNc�P��tj|_tj|_tj
|_tj|_t|�jt_t|�jt_t|�jt_t|�jt_t|�jt_t|�jt_t|�jt_t|�jt_t�|�A�tj"�|_tj&|j$�t(j*dk7r|t-j.�5t-j0dt2�tj4�}|j7|j$�tj8|�ddd�yy#1swYyxYw�Nrr�)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_implrrsr�r/r2r0rr r�r�r�r�r�r�r�r�s  �rr�zGetEventLoopTestsMixin.setUp�
sl���'-�'?�'?��$�'-�'?�'?��$�&,�&=�&=��#�$*�$9�$9��!�#'��:�#D�#D�� �#'��:�#D�#D�� �"&�t�*�"B�"B��� $�T�
� >� >���$(��J�$E�$E��!�$(��J�$E�$E��!�#'��:�#C�#C�� �!%�d��!?�!?���
��
���*�*�,��	����t�y�y�)��<�<�7�"��(�(�*�
3��%�%�h�0B�C�!�2�2�4���#�#�D�I�I�.��)�)�'�2�	
3�
3�#�
3�
3�s
�3AH�H%c�`��	tjdk7rLtj�5tjdt
�t
jd�ddd�t�|�%�|jj�t
jd�|jt_|j t_|j$t_|j(t_|jt_|j t_|j$t_|j(t_y#1swY��xYw#|jj�t
jd�|jt_|j t_|j$t_|j(t_|jt_|j t_|j$t_|j(t_wxYwr�)rr r�r�r�r�rr�rsr�r2rAr0r�rr�r�r�r�r�r�r�r�s �rr�zGetEventLoopTestsMixin.tearDown�
s|���	?��|�|�w�&��,�,�.�4��)�)�(�4F�G��-�-�d�3�4�
�G����I�I�O�O���"�"�4�(�'+�'C�'C�F�$�'+�'C�'C�F�$�&*�&A�&A�F�#�$(�$=�$=�F�!�(,�(D�(D�G�%�(,�(D�(D�G�%�'+�'B�'B�G�$�%)�%>�%>�G�"�#4�4��
�I�I�O�O���"�"�4�(�'+�'C�'C�F�$�'+�'C�'C�F�$�&*�&A�&A�F�#�$(�$=�$=�F�!�(,�(D�(D�G�%�(,�(D�(D�G�%�'+�'B�'B�G�$�%)�%>�%>�G�"�s#�'E�0E�E�E�
E�CH-rc����tj��jt��fd�}�j	�j
j
|��d�y)Nc��"�K�tj�dk(rtjd�}nd}tjj|��}�jj|t��d{���}|j�|S7��w)N�fork�
forkserver)�
mp_context)
�multiprocessing�get_start_method�get_context�
concurrent�futures�ProcessPoolExecutorr2r
r3�shutdown)r��poolrBr7s   �rr?zDGetEventLoopTestsMixin.test_get_event_loop_new_process.<locals>.main�
s������"�3�3�5��?�!0�!<�!<�\�!J�J�!%�J�!�)�)�=�=�#-�>�/��#�y�y�8�8��D� F�F���
�
���
�F�s�A3B�6B
�7Br,)r�*skip_if_broken_multiprocessing_synchronizer
�multiprocessing_cleanup_testsr�r2r1)r7r?s` r�test_get_event_loop_new_processz6GetEventLoopTestsMixin.test_get_event_loop_new_process�
sJ���
�>�>�@��O�O�9�:�
�
����	�	�,�,�T�V�4��
rc�����Gd�dt��G�fd�dtj�}tj�}	tj|��tj
���j
��5tj�ddd�tjd��j
��5tj�ddd��jtd�5tj�ddd��jtj�d���fd�}�j|��tj���j
��5tj�ddd�tjd��j
��5tj�ddd�tj|����j�	�jtd�5tj�ddd��jtj�d�y#1swY���xYw#1swY���xYw#1swY��jxYw#1swY��xYw#1swY��xYw#tj|����j�wwxYw#1swY��xYw)Nc��eZdZy)�RGetEventLoopTestsMixin.test_get_event_loop_returns_running_loop.<locals>.TestErrorN)rDrErFrrr�	TestErrorr��
s��rr�c���eZdZ�fd�Zy)�OGetEventLoopTestsMixin.test_get_event_loop_returns_running_loop.<locals>.Policyc�����rr)r7r�s �rr�z^GetEventLoopTestsMixin.test_get_event_loop_returns_running_loop.<locals>.Policy.get_event_loop�
s����rN)rDrErFr�)r�s�r�Policyr��
s���
 rr��
no runningc����K��jtj����jtj����jtj���y�wr�rkrr�r�r�r\s��rrgzMGetEventLoopTestsMixin.test_get_event_loop_returns_running_loop.<locals>.func�
�L������
�
�g�4�4�6��=��
�
�g�6�6�8�$�?��
�
�g�7�7�9�4�@���A.A1)r�rr�rFrr/r�r�r0rr�r�rkr�r1rA)r7r�r�rgr�r2s`   @@r�(test_get_event_loop_returns_running_loopz?GetEventLoopTestsMixin.test_get_event_loop_returns_running_loop�
s+���	�	�	�	 �W�3�3�	 ��2�2�4�
�	��)�)�&�(�3��)�)�+�D��"�"�9�-�
)��&�&�(�
)��"�"�4�(��"�"�9�-�
)��&�&�(�
)��'�'��l�C�
+��(�(�*�
+��M�M�'�3�3�5�t�<�
A�

�#�#�D�F�+��"�"�4�(��"�"�9�-�
)��&�&�(�
)��"�"�4�(��"�"�9�-�
)��&�&�(�
)�
�)�)�*�5����
�
��
�
#�
#�L�,�
?�	'��$�$�&�	'�	
�
�
�g�/�/�1�4�8�A
)�
)��
)�
)��
+�
+��
)�
)��
)�
)��
�)�)�*�5����
�
�� ��	'�	'�s��?J�I�.J�I(�J�8I5�
A.J�;J�.J�>J�J�K�I%� J�(I2�-J�5I?�:J�J�J�J�J�*K�Kc����tj�}	tjtj��tj���j�j��jt�5}tj�}ddd��jj��jjt�tjd��jtd�5tj�ddd��jtd�5tj �ddd��j#tj$�d���fd�}�j'|��tj���j#tj���tjd��jtd�5tj�ddd�tj|����j
�	�jtd�5tj �ddd��j#tj$�d�y#1swY��xYw#1swY���xYw#1swY��exYw#1swY��xYw#tj|����j
�wwxYw#1swY��xYw)Nz
no currentr�c����K��jtj����jtj����jtj���y�wrr�r\s��rrgzNGetEventLoopTestsMixin.test_get_event_loop_returns_running_loop2.<locals>.func#r�r�)rrFrr�r/r
rAr�r�r�r�r4rr0rr�r�rkr�r1)r7r�r��loop2rgr2s`    @r�)test_get_event_loop_returns_running_loop2z@GetEventLoopTestsMixin.test_get_event_loop_returns_running_loop2s7����2�2�4�
�"	��)�)�'�*H�*H�*J�K��)�)�+�D��O�O�D�J�J�'��!�!�"4�5�
1���.�.�0��
1��O�O�E�K�K�(����R�[�[�(�3��"�"�4�(��'�'��l�C�
)��&�&�(�
)��'�'��l�C�
+��(�(�*�
+��M�M�'�3�3�5�t�<�
A�

�#�#�D�F�+��"�"�4�(��M�M�'�0�0�2�D�9��"�"�4�(��'�'��l�C�
)��&�&�(�
)�
�)�)�*�5����
�
��
�
#�
#�L�,�
?�	'��$�$�&�	'�	
�
�
�g�/�/�1�4�8�E
1�
1��

)�
)��
+�
+��
)�
)��
�)�)�*�5����
�
�� ��	'�	'�sz�A+K
�J�A.K
�J$�K
�9J1�B,K
�:J>�K
�K7�J!�K
�$J.�)K
�1J;�6K
�>K�K
�
*K4�7L)rDrErFr�r�r�r�r�r�rr r�r�r�rwrxs@rr�r��
sC���!��!�� ����3�8?�,�|�|�w��	�2-9�^)9rr�c�l�eZdZejZejZejZ	ejZy)�TestPyGetEventLoopN)rDrErFr�_py__get_running_loopr��_py__set_running_loopr��_py_get_running_loopr��_py_get_event_loopr�rrrr�r�<s2��#�9�9��#�9�9��"�7�7�� �3�3�rr�c�l�eZdZejZejZejZ	ejZy)�TestCGetEventLoopN)rDrErFr�_c__get_running_loopr��_c__set_running_loopr��_c_get_running_loopr��_c_get_event_loopr�rrrr�r�Js2��!'�!<�!<��!'�!<�!<�� &� :� :��$�6�6�rr�c��eZdZd�Zy)�
TestServerc�b��tj�}|j|j�t	|��|j|j
�fd�dd��}|j|j�|�|j�|j|j��y)Nc����Srrr�s�rr-z*TestServer.test_get_loop.<locals>.<lambda>Xs���E�rr0r)
rr/r
rArqr1r�r��get_loop�wait_closed)r7r2r%r�s   @r�
test_get_loopzTestServer.test_get_loopTs�����%�%�'������
�
�#���
���(�(��);�);�M�9�VW�)X�Y��������*�D�1��������� 2� 2� 4�5rN)rDrErFr�rrrr�r�Rs��6rr�c��eZdZd�Zd�Zd�Zy)�TestAbstractServerc��|jt�5tj�j	�ddd�y#1swYyxYwr)r�rwr�AbstractServerrAr@s rrjzTestAbstractServer.test_close`s;��
�
�
�2�
3�	,��!�!�#�)�)�+�	,�	,�	,���#A�Ac��tj�}|j|j�|j	t
�5|j
tj�j��ddd�y#1swYyxYwr)
rr/r
rAr�rwr1rr�r�rRs  r�test_wait_closedz#TestAbstractServer.test_wait_closeddsh���%�%�'������
�
�#�
�
�
�2�
3�	K��#�#�F�$9�$9�$;�$G�$G�$I�J�	K�	K�	K�s�2B�B	c��|jt�5tj�j	�ddd�y#1swYyxYwr)r�rwrr�r�r@s rr�z TestAbstractServer.test_get_loopks;��
�
�
�2�
3�	/��!�!�#�,�,�.�	/�	/�	/�r�N)rDrErFrjr�r�rrrr�r�^s��,�K�/rr��__main__)R�__doc__�collections.abcrQ�concurrent.futuresr�r�r�r�rQr r/rNr1r��ImportErrorr�rr�r�r-r�rkrr#r�r2rrrr�multiprocessing.utilr	r��test.test_asyncior
r�rar�test.supportrr
rrrrr(r3r5rjrHrq�DatagramProtocolrzr��BaseProtocolr�r�r�r�rs�TestCaser�r�r�r�r�r�r�rrr
rTrtr�r�r��_asyncior�r�r�rDr?rrr�<module>rs������	��	��	�
�
����
����������<�<�+�+�����#�P�1��&�)�5�5�(��+�
�
�#'�'�"�"�#'�LH�k�H�'�g�.�.�'�@!'�g�&�&�!'�H'�w�+�+�'�2*:�7�5�5�*:�ZB�B�J0[?�[?�|�<�<�7��/�2�)�2�2�/�P�!4�!5�!+�!4�!4�P�,�
�"5�
� �y�*�+�	)�#:�#7�#-�#6�#6�	)�0�y�/�*�	L�"9�"6�",�"5�"5�	L��y�.�)�	K�!8�!5�!+�!4�!4�	K�I�6�3�)�2�2�I�	�oF�*�%�%�oF�dC(��"�"�C(�Lc�X�.�.�c�L]-�(�#�#�]-�@l9�l9�^4�/��1B�1B�4�7��
7�2�H�4E�4E�7�	6��"�"�	6�/��*�*�/�$�z���H�M�M�O���C[��
�C���nY�	��	�s#�K�K*�K'�&K'�*K2�1K2