Sindbad~EG File Manager

Current Path : /usr/local/lib/python3.12/test/test_asyncio/__pycache__/
Upload File :
Current File : //usr/local/lib/python3.12/test/test_asyncio/__pycache__/test_events.cpython-312.pyc

�

(Μga�����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���:/usr/local/lib/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�x��B�� 2� 2� 4�4�x�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'dad&�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��Z6dbd7�Z7dbd8�Z8dbd9�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�ZJdK�ZKej"eLj�dLk7dM�dN��ZNej"eLj�dLk7dM�dO��ZOej"eLj�dLk7dM�ej"eePdP�dQ�dR���ZQej"eLj�dLk7dM�dS��ZRej"eLj�dLk7dM�dT��ZSej"eLj�dLk7dM�ej"eePdP�dQ�eTj�dUdV�dW����ZVej"eLj�dLk7dM�ej"eePdP�dQ�eTj�dUdV�dX����ZWdY�ZXdZ�ZYd[�ZZd\�Z[d]�Z\d^�Z]�xZ^S)c�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_nestingsW���	#�	2��
"�
"��.�
�
����d�i�i�:�:�E�G�
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�	�T�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�rrrrz<EventLoopTestsMixin.test_run_in_executor_cancel.<locals>.run�s���J�J�t�rg�������?)r2r�cancelr1�shutdown_default_executorrAr�r�r�r��assertFalse)r7rrrrs    @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�0Drsdefc� ��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�)rgr7r8s ��r�writerz8EventLoopTestsMixin.test_writer_callback.<locals>.writer�s���
�F�F�4�L��I�I�N�N�rsxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxr�)r2r3r4r2�
add_writerr'r�r��
remove_writerrrAr#rer�)r7r)r<rg�readr8s`    @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����SrrrEs�rr.z=EventLoopTestsMixin.test_add_signal_handler.<locals>.<lambda>�s���r)r��	TypeErrorr2�add_signal_handler�remove_signal_handler�
ValueError�signal�NSIGr�rAr�SIGINT�os�kill�getpidr�r7r�r��	getsignal�default_int_handler�r7rGrFs  @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�yrD)r2r�)rFr7s��rrGzLEventLoopTestsMixin.test_signal_handling_while_selecting.<locals>.my_handler�s����a�K�F��I�I�N�N�r�{�G�z�?�<r��
r2rLrOrYrZ�ITIMER_REALr�r�r�r�rWs` @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�yrD)r�r2r�)rrFr7�	some_argss ���rrGzAEventLoopTestsMixin.test_signal_handling_args.<locals>.my_handlers*����a�K�F����T�9�-��I�I�N�N�rr�r^r�r_)r7rGrFres` @@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�addressrt)r7�httpd�conn_futs`  r�test_create_connectionz*EventLoopTestsMixin.test_create_connectionsR���
�
'�
'�
)�U�2�t�y�y�2�2�/�A�27�-�-�A�H��,�,�X�6�*�
)�
)�s�<A�A$c����t�}tj�5}�jj	�fd�|j
�}�j
||�ddd�y#1swYyxYw)Nc�0��t�j��Srwryr@s�rr.zAEventLoopTestsMixin.test_create_unix_connection.<locals>.<lambda>*rzr)r(r��run_test_unix_serverr2�create_unix_connectionr}rt)r7rqr~rs`   r�test_create_unix_connectionz/EventLoopTestsMixin.test_create_unix_connection"sX���5�6�6��
�
,�
,�
.�%��y�y�7�7�/����@�H��,�,�X�~�F�/�
.�
.�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)Nrh�peername�peercert�cipherr�rr�r��
ssl_object�compression)rmrnr�rir#re�strr%r�r��getpeercert)r7�clientrqr�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)r2r1rirrjrkr�rurD�lowerr�rQrorNrA)r7rprqr�rrrss      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|rqr�rr��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�FG�,��6���4�4�X�~�5=�?�� � ����q�1�C��
�
�s�|�|�
,��(�T�2�H��*�*�,��4�4�X�~�5=�?�-�-�	
������,�,�.I�J�!C�C��-�,��-�
,�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��Srwryr@s�rr.z@EventLoopTestsMixin.test_create_ssl_connection.<locals>.<lambda>�rzr�r�)r�r{�	functools�partialr2r|r}r�)r7r~r|s`  r�test_create_ssl_connectionz.EventLoopTestsMixin.test_create_ssl_connection~sp���
�
'�
'��
5�� )� 1� 1��	�	�+�+�/�! ����! ��
�,�,�U�4E�6;�m�m�
-�
E�6�
5�
5�s�AA8�8Bc�$��t�}tjd��5}tj�j
j�fd�|jd��}�j||||j��ddd�y#1swYyxYw)NTr�c�0��t�j��Srwryr@s�rr.zEEventLoopTestsMixin.test_create_ssl_unix_connection.<locals>.<lambda>�rzr�	127.0.0.1)�server_hostnamer�)	r(r�r�r�r�r2r�r}r�)r7rqr~r|s`   r�test_create_ssl_unix_connectionz3EventLoopTestsMixin.test_create_ssl_unix_connection�s{���
5�6�6��
�
,�
,�T�
:�e� )� 1� 1��	�	�0�0�/���� +�!-��

�,�,�U�4E�-;�6;�m�m�
-�
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��Srwryr@s�rr.zGEventLoopTestsMixin.test_create_connection_local_addr.<locals>.<lambda>�rzr�
local_addrrrhr�)r�r{r�find_unused_portr2r|r}r1rLrnr�rA)r7r~�port�frrrsrYs`      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)r2�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��Srwryr@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�)r2r�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��Srwryr@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��Srwryr@s�rr.zNEventLoopTestsMixin.test_create_connection_local_addr_in_use.<locals>.<lambda>�rzrr�)r�r{r2r|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����
�
'�
'�
)�U�+��	�	�+�+�/�:����:�+0�=�=�:�A��"�"�7�+�r��	�	�,�,�Q�/�,����R�\�\�/�/��1A�1A�B��M�M�#�e�m�m�,�b�l�l�.C�.C�D�*�
)�,�+��	*�
)�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)r2�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��daemonrxc����Srr��protos�rr.zBEventLoopTestsMixin.test_connect_accepted_socket.<locals>.<lambda>s���rr�rm)r2rHr2�
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)r2�
addCleanuprAr2r�rqr�LOOPBACK_TIMEOUT�assertRaisesRegexrNr1)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�(�(��.�E�E�E�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)Nr1r�r)r2r�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�Srryr@s�rr.zBEventLoopTestsMixin.create_server_multiple_hosts.<locals>.<lambda>6s���G�D�I�I�,>r)r�r2r��
getsockbynamer�r2r�r�Mock�_start_serving�
_stop_servingr�r1rrA�socketsr�)r7r�hosts�	mock_sockr�unique_hostsr�r��serverr�server_hostsr�s``         @r�create_server_multiple_hostsz0EventLoopTestsMixin.create_server_multiple_hosts s>���	Q�	E��5�z���V�^�^�#�'3�<5�'3�t��r�
�|�<5�I����,�,�8�.:�<;�-9�T��r�1�a� �\�<;�I����,�,�8� 0��	�	��#'�9�9�;��	�	� �"&�)�)�+��	�	���I�I�#�#�$>��r�J�����-�-�a�0��������%�<B�N�N�K�N�D��*�*�,�Q�/�N��K�����|�4��<5��<;��Ls�E8�!
E=�	Fc�H�|jtjgd��y)N)�1.2.3.4z5.6.7.8r*)r(r2r�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(r2r�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����Er�0.0.0.0rr�r��xxxr]c�"���jdkDSr��rNr�s�rr.z8EventLoopTestsMixin.test_create_server.<locals>.<lambda>S�������q�0@rr�rhr�rm)rqr2r�r1r�rer"r�r2r�r�rPrMr�r7rNrmrLrnrArQ)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>jr0rr1rr�TF)rqr2r�r1r�rer"rir�trsock�TransportSocketr��duprrAr2r�get_inheritabler�rN�
settimeout�
gettimeoutr4)r7r�r&rr�r�r;r�s       @r�test_create_server_trsockz-EventLoopTestsMixin.test_create_server_trsockhsr�����	�	�"���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>�����Err1rr�c����Srrr�s�rr.zCEventLoopTestsMixin.test_create_server_reuse_port.<locals>.<lambda>�rCrT)�
reuse_port)rqr2r�r1r�rer"r�
getsockoptr2�
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)rR�path�exists�unlink)rKs�rr.z7EventLoopTestsMixin._make_unix_server.<locals>.<lambda>�s"��������t� 4� H����4�� Hr)r��gen_unix_socket_pathrr2�create_unix_serverr1)r7�factoryr�r�r&rKs     @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)	Nrxc����Srrr�s�rr.z=EventLoopTestsMixin.test_create_unix_server.<locals>.<lambda>�s���err�r2r]c�"���jdkDSr�r4r�s�rr.z=EventLoopTestsMixin.test_create_unix_server.<locals>.<lambda>�r5rr�rm)rqr2rQr�rer"r2�AF_UNIXr�r�r1rPrMr�r7rNrLrArQ)r7r&rKr�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�;�;�/�	����	���rrUzNo UNIX Socketsc�V��t|j���tj�}|5|jj�fd�d|��}|j	t
d�5|jj
|�ddd�ddd�y#1swY�xYw#1swYyxYw)Nrxc����Srrr�s�rr.zOEventLoopTestsMixin.test_create_unix_server_path_socket_error.<locals>.<lambda>�s���Urz/test�rz3path and sock can not be specified at the same time)rqr2r2rOrrNr1)r7rr�r�s   @r�)test_create_unix_server_path_socket_errorz=EventLoopTestsMixin.test_create_unix_server_path_socket_error�s�����T�Y�Y�'���}�}���
��	�	�,�,�]�G�$�,�O�A��'�'�
�);�<��	�	�,�,�Q�/�<��T�<�<���T�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�)rdr2r�r1r"r�r�)
r7rPrarbrcr�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�)rdrQ)r7rPrarbrcs     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)
Nrxc����Srrr�s�rr.z<EventLoopTestsMixin.test_create_server_ssl.<locals>.<lambda>�rCrr�r2r]c�"���jdkDSr�r4r�s�rr.z<EventLoopTestsMixin.test_create_server_ssl.<locals>.<lambda>�r5rr�r�rm)rqr2rfr��ONLYCERT�ONLYKEYr|rHr�r1rtrPr�rMr7rNr�rLrArQ)r7r&r�r��f_cr�rsr�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)
Nrxc����Srrr�s�rr.zAEventLoopTestsMixin.test_create_unix_server_ssl.<locals>.<lambda>rCrr��r�r�r2r]c�"���jdkDSr�r4r�s�rr.zAEventLoopTestsMixin.test_create_unix_server_ssl.<locals>.<lambda>r5rr�rm)rqr2rhr�rlrmr�rHr�r1rtrPr�rMr7rNrLrArQ)r7r&rKrnr�rsr�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)Nrxc����Srrr�s�rr.zJEventLoopTestsMixin.test_create_server_ssl_verify_failed.<locals>.<lambda>!rCr�check_hostnameTr��call_exception_handler�(?i)certificate.verify.failed)rqr2rfr��SIGNED_CERTFILEr�r\�PROTOCOL_TLS_CLIENTr^r_�
CERT_REQUIRED�verify_moder�rwr|rr��objectr�rr�r1r��assertIsNonerLrA)r7r&r�r��sslcontext_clientrnr�s      @r�$test_create_server_ssl_verify_failedz8EventLoopTestsMixin.test_create_server_ssl_verify_failedsY����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��*�*�,��+�+�C�L�L�,K�M��I�I�0�0��5�M�-�
�"�"�4�9�9�-�D�	
���%�/�/�*�����M�M��-�,��D�
C�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)	Nrxc����Srrr�s�rr.zOEventLoopTestsMixin.test_create_unix_server_ssl_verify_failed.<locals>.<lambda>?rCrrwT�invalidrrrxry)rqr2rhr�rzr�r\r{r^r_r|r}r�rwr�rr�r~r�rr�r1r�rrLrA)r7r&rKr�rnr�s     @r�)test_create_unix_server_ssl_verify_failedz=EventLoopTestsMixin.test_create_unix_server_ssl_verify_failed:s[����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��*�*�,��+�+�C�L�L�,K�M��I�I�0�0��5�M�-�
�"�"�4�9�9�-�D�	
���%�/�/�*�����M�M��-�,��D�
C�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$dt"j&�}t(j*j-|jd�5tj.�5|j1t
j2|�5|jj5|�ddd�ddd�ddd�|j7�j8�|j;�y#1swY�ExYw#1swY�IxYw#1swY�MxYw)	Nrxc����Srrr�s�rr.zIEventLoopTestsMixin.test_create_server_ssl_match_failed.<locals>.<lambda>\rCr�r�rwTr�z�(
            IP address mismatch, certificate is not valid for '127.0.0.1'   # OpenSSL
            |
            CERTIFICATE_VERIFY_FAILED                                       # AWS-LC
        )rx)rqr2rfr�rzr�r\r{r^r_r|r}�load_verify_locations�
SIGNING_CAr�rwr|�re�compile�Xrr�r~r�r�CertificateErrorr1rrLrA)r7r&r�r�r�rn�regexr�s       @r�#test_create_server_ssl_match_failedz7EventLoopTestsMixin.test_create_server_ssl_match_failedXs|����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���
�
�
��d�d�	��
�Z�Z�
�
�t�y�y�*B�
C��*�*�,��+�+�C�,@�,@�%�H��I�I�0�0��5�I�-�D�	
���%�/�/�*�����
I�H��-�,��D�
C�s<�>G,�!G �4G�G �G,�G�G � G)	�%G,�,G5c�$��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)Nrxc����Srrr�s�rr.zJEventLoopTestsMixin.test_create_unix_server_ssl_verified.<locals>.<lambda>rCrr�rwTr�rr)rqr2rhr�rzr�r\r{r^r_r|r}r�r�r�rwr�r1rPrLrArQ)r7r&rKr�rnr�rsr�s       @r�$test_create_unix_server_ssl_verifiedz8EventLoopTestsMixin.test_create_unix_server_ssl_verifiedzs)����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)	Nrxc����Srrr�s�rr.zEEventLoopTestsMixin.test_create_server_ssl_verified.<locals>.<lambda>�rCrr�rwTr�rr)r�r�)rqr2rfr�rzr�r\r{r^r_r|r}r�r�r�rwr|r1rPr��PEERCERTrLrArQ)	r7r&r�r�r�rnr�rsr�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��r1rrYrr1r�r2)
r2rOrqr2r�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�rYr�r�r�)r2r�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�r2r�)r2rOrqrr�r�r1r�r�r�r�r2r�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)Nr1rr�r2)r2r�rqr1r"r�r2r�r9rAr��ConnectionRefusedError)r7r�r&rr�r�r�s       r�test_server_closez%EventLoopTestsMixin.test_server_closes����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��yrw)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�rrhrc�0��t�j��Srw�rzr2r@s�rr.zDEventLoopTestsMixin._test_create_datagram_endpoint.<locals>.<lambda>+����O����3r)�remote_addrr2c����jSrr4)r&s�rr.zDEventLoopTestsMixin._test_create_datagram_endpoint.<locals>.<lambda>5�	����
�
rr�c����jSrr4)r�s�rr.zDEventLoopTestsMixin._test_create_datagram_endpoint.<locals>.<lambda>7r�r�rm)rzr2�create_datagram_endpointr1rnr2�getnameinfo�NI_NUMERICHOST�NI_NUMERICSERVrirrjr�rMrlrLr�r�r7rNrmrArQ)r7r�rr�r�s_transportrhr�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�r2r�r@s r�test_create_datagram_endpointz1EventLoopTestsMixin.test_create_datagram_endpointEs���+�+�,<�f�n�n�Mrc�D�|jdtj�y)N)r�r)r�r2r�r@s r�"test_create_datagram_endpoint_ipv6z6EventLoopTestsMixin.test_create_datagram_endpoint_ipv6Hs���+�+�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��Srwr�r@s�rr.zHEventLoopTestsMixin.test_create_datagram_endpoint_sock.<locals>.<lambda>_r�rrY)r2r1r�r2�
SOCK_DGRAMr4�bind�failr�rirrjrzrArQ)r7r�
local_address�infosrr�r��cnamer}r�rrrss`           r�"test_create_datagram_endpoint_sockz6EventLoopTestsMixin.test_create_datagram_endpoint_sockLs(�����(�
��	�	�,�,�!�D�I�I�!�!��
8�%+�%6�%6�
8�9��49�/�F�D�%���
��}�}�F��U�K��� � ��'��	�	�'�"��49�
�I�I�.�/��I�I�.�.�3�$�
/�
@�����-�-�a�0���B����b�'�"3�"3�4����b�/�2�
���
��	�	�$�$�R�W�W�-��
��s�:E
�
Ec���|j�G�fd�dtj�}d�}|�}�j�j	||���\}}|j�}|�}�j�j	||���\}}	|j�}
|�}�j�j	||���\}}
|j�}|j
�|jd|
��|j�j|	j��d�|jd|��|j�j|j��d�|jd|���jtjd	��|jd
|��|j�j|j��d
�|j�|j�y)Nc�"��eZdZdZd�Z�fd�Zy)�QEventLoopTestsMixin.test_datagram_send_to_non_listening_address.<locals>.ProtocolNc�:�|jj|�yr)�_received_datagramr_r�s   rr�zcEventLoopTestsMixin.test_datagram_send_to_non_listening_address.<locals>.Protocol.datagram_receivedts���'�'�2�2�4�8rc���K��j�|_tj|jd��d{���}d|_|S7�
�w)Nr)rOr�r�wait_for)r7�resultr2s  �r�wait_for_datagram_receivedzlEventLoopTestsMixin.test_datagram_send_to_non_listening_address.<locals>.Protocol.wait_for_datagram_receivedwsF�����*.�*<�*<�*>��'�&�/�/��0G�0G��L�L��*.��'��
�M�s�9A�A
�A)rDrErFr�r�r�rxs�rrkr�ps���!%��
9�
rrkc��tjtjtj�}|jd�|j	d�|S)NFr�)r2r�r�r4r�rYs r�
create_socketzVEventLoopTestsMixin.test_datagram_send_to_non_listening_address.<locals>.create_socket}s<���=�=�����1B�1B�C�D����U�#��I�I�&�'��KrrY�a)r��b�cr�d)r2r�DatagramProtocolr1r�r��abortr�r�r�r�rA)r7rkr��socket_1�transport_1�
protocol_1�addr_1�socket_2�transport_2�
protocol_2�addr_2�socket_3�transport_3�
protocol_3�addr_3r2s               @r�+test_datagram_send_to_non_listening_addressz?EventLoopTestsMixin.test_datagram_send_to_non_listening_addressfs�����y�y��	�w�/�/�	�	�!�?��"&�"9�"9��)�)�(��)�B�#
���Z��%�%�'�� �?��"&�"9�"9��)�)�(��)�B�#
���Z��%�%�'��!�?��"&�"9�"9��)�)�(��)�B�#
���Z��%�%�'���������4�f��-�����0�0��1�1�3�
��	�	���4�f��-�����0�0��1�1�3�
��	�
	���4�f��-�����
�
�a� 0�1�	���4�f��-�����0�0��1�1�3�
��	�	�������rc��|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_fds�s����%�%�'���$�� 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)Nrx�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>�s���rrKr]r�r2�connect_read_piperlrLr�rMrN)r�p�pipeobjr�r7s  ���rr�z3EventLoopTestsMixin.test_read_pipe.<locals>.connect�s{��������4�4��w�(�(�D�A�q��M�M�!�U�#��M�M�!�U�_�_�-����i��5�u�{�{�C����Q����-�(���#B�B�A1B�1c�"���jdk\SrDr4r�s�rr.z4EventLoopTestsMixin.test_read_pipe.<locals>.<lambda>���������0Arr��2345c�"���jdk\S�Nrr4r�s�rr.z4EventLoopTestsMixin.test_read_pipe.<locals>.<lambda>�rrrKr]r�rKr]rjrm�pipe)r�r2rRr	�io�openr1rtr�r7r�rNrMrArQrmrLrn)r7�rpipe�wpiper�rr�s`   @@r�test_read_pipez"EventLoopTestsMixin.test_read_pipe�s.��� �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)	Nrxr�r"r8zutf-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�wpipeobjrs   �����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�rRr	r
rr1rAr��repr�_pipe)r7rr
r�rrr2rrrrs      @@@@@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)Nrxr�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���UrrKr]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�rrc����jSrr4r�s�rr.z:EventLoopTestsMixin.test_read_pty_output.<locals>.<lambda>s	�����rr�rc�"���jdk\Srr4r�s�rr.z:EventLoopTestsMixin.test_read_pty_output.<locals>.<lambda>rrrKr]rrr	)r�r2rRr r
rr1rtr�r7r�rNrMrArLrQrmrn)r7�master�slaver�r$r�s`   @@r�test_read_pty_outputz(EventLoopTestsMixin.test_read_pty_outputs>��� �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"rxc����Srrr�s�rr.z5EventLoopTestsMixin.test_write_pipe.<locals>.<lambda>+����urr]rc�P��tj�d�}||z
}t|�Sr!�rRr?re)rg�chunkrs  �rr*z3EventLoopTestsMixin.test_write_pipe.<locals>.reader4s&����G�G�E�4�(�E��E�M�D��t�9�rc������dk\SrDr�rgr*s��rr.z5EventLoopTestsMixin.test_write_pipe.<locals>.<lambda>9�����t���0Arrc������dk\Srrr2s��rr.z5EventLoopTestsMixin.test_write_pipe.<locals>.<lambda>=r3r�12345r	rm)rRr	r
rr�r2rr1rlrLr�rMrtr5r�r7rArmrnrQ)
r7r
rr�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"rxc����Srrr�s�rr.zIEventLoopTestsMixin.test_write_pipe_disconnect_on_close.<locals>.<lambda>Sr-rr]rrm)r2r3r4r
r�detachr�r2rr1rlrLr�rMrt�	sock_recvrArQ)	r7�rsock�wsockrr�rLr�rgr�s	        @r�#test_write_pipe_disconnect_on_closez7EventLoopTestsMixin.test_write_pipe_disconnect_on_closeKs!����(�(�*���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�;�;�/rrr1c�����	�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+rrxc����Srrr�s�rr.z4EventLoopTestsMixin.test_write_pty.<locals>.<lambda>mr-rr]rc�P��tj�d�}||z
}t|�Sr!r/�rgr0r's  �rr*z2EventLoopTestsMixin.test_write_pty.<locals>.readerv�&����G�G�F�D�)�E��E�M�D��t�9�rc������dk\SrDrr2s��rr.z4EventLoopTestsMixin.test_write_pty.<locals>.<lambda>{r3r��timeoutrc������dk\Srrr2s��rr.z4EventLoopTestsMixin.test_write_pty.<locals>.<lambda>�r3rr5r	rm)rRr r
rr�r2rr1rlrLr�rMrtr5r�r7r�
SHORT_TIMEOUTrArmrnrQ)
r7r(�slave_write_objr�rLr�rgr'r�r*s
      @@@@r�test_write_ptyz"EventLoopTestsMixin.test_write_ptybs�����
�
��
����'�'�%��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�rrxc����Srrrs�rr.z<EventLoopTestsMixin.test_bidirectional_pty.<locals>.<lambda>�s���:rrKr]r+c����Srrrs�rr.z<EventLoopTestsMixin.test_bidirectional_pty.<locals>.<lambda>�s���[rc�P��tj�d�}||z
}t|�Sr!r/rAs  �rr*z:EventLoopTestsMixin.test_bidirectional_pty.<locals>.reader�rBrrc������dk\SrDrr2s��rr.z<EventLoopTestsMixin.test_bidirectional_pty.<locals>.<lambda>�r3rrDr�c�"���jdk\SrDr4rs�rr.z<EventLoopTestsMixin.test_bidirectional_pty.<locals>.<lambda>�����
�0A�0A�Q�0Frr�rc������dk\Srrr2s��rr.z<EventLoopTestsMixin.test_bidirectional_pty.<locals>.<lambda>�r3rr5sbcdec�"���jdk\Srr4rs�rr.z<EventLoopTestsMixin.test_bidirectional_pty.<locals>.<lambda>�rPrrrrm)rRr r;�tty�setrawr
rr�r2r�r1rlrLr�rMrNr�rr5rtr�r7rrGrArQ)r7�
read_slave�write_slave�slave_read_obj�read_connectrr�rH�
write_connectrrgr'rr*rs          @@@@@r�test_bidirectional_ptyz*EventLoopTestsMixin.test_bidirectional_pty�s���� �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^)r2r3r4r2rr:�getattrr��pendingr�r�r�r�rr_rr!rA)r7r)r8r\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_��yrD)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>.waitsu�����-�-��%�%�%��-�-��%�%�%��-�-��%�%�%��-�-��%�%�%��-�-��&�&�&�	
&��%��%��%��&�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>���4r)
r�r2r3rrAr6r=rr&r>�r7r2r�r)r8s     r�test_remove_fds_after_closingz1EventLoopTestsMixin.test_remove_fds_after_closings����%�%�'����� � �"���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�r2r3rrAr�r�r6r=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,sD���	��$�)�)�$��
�
�
�|�
,��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>.test7s	�����r.c��y�NFrrrrr.z0EventLoopTestsMixin.test_close.<locals>.<lambda>:s��urg�?g)r2rArr�r�r�rOr1r�r�r��call_atr�rrLrO�SIGTERMrrC�next)r7r��funcr�fut�its      r�
test_closezEventLoopTestsMixin.test_close4s���	�	����	����v������
�
�#��
�
�|�
,��I�I�!�!�#�-�
�
�
�|�
,��)�)�)�)�+�C��I�I�(�(��-�-��
�
�|�
,��I�I����%�-�
�
�
�|�
,��I�I�*�*�4�0�-�
�
�
�|�
,��I�I� � ��d�+�-�
�
�
�|�
,��I�I���d�i�i�n�n�.��3�T�:�-�
�
�
�|�
,��I�I�!�!�$�'�-�
�
�
�|�
,��I�I�(�(�����>�-��
�
�|�
,����*�*�4��6�@�@�B�B���H�-�
,�+-�
,��
,�
,��-�
,��
,�
,��
,�
,��
,�
,��
,�
,��
,�
,��-�
,�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�rrrrr9r@�unittest�
skipUnlessr�rOrXrarfrtr�r�skip_unless_bind_unix_socketr�r�r�r��skipIfr�r�r�r��skip_if_tcp_blackholer�r�r�rrrrr�r(r+r-r6r?r2rHrQrVrZrdrfrhrortr�r�r�r�r�r�r��IPV6_ENABLEDr�r�r�r�r�r�r�r�rr rrrRr)r6r=r�requires_mac_verrIrZrcrqrvryr~r�rwrxs@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��B�/�/��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�.�4H�T
'��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 rir%r�rOr��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|�yr�)rr rir%r�rOrAr�s  r�check_killedz!SubprocessTestsMixin.check_killedbr�rc���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�)rRrKr�dirname�__file__r2�subprocess_execr�r�r�r�
executabler1rirPr�rM�get_pipe_transportrtr�rjr�r�rAr�r�r�rg�r7�progr��transpr��stdins      r�test_subprocess_execz)SubprocessTestsMixin.test_subprocess_execisQ���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�)rRrKrr�r�r2r�r�r�r�rr�r1rirPr�rMr�rtr�rj�clearrgr�r�rAr�r�r�r�s      r�test_subprocess_interactivez0SubprocessTestsMixin.test_subprocess_interactive~s����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>�s����I�.H��A�F�F�H�.H�s�r�s
sPythonr�r)r2�subprocess_shellr�r�r�r1rirPr�rAr�r�r�r��allr��valuesrg�rstrip�r7r�r�r�s    r�test_subprocess_shellz*SubprocessTestsMixin.test_subprocess_shell�s���)�)�,�,�!�)�)�*>��	�	�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�r1rir�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�r1rirr�r�r�r�rAr�s    r�"test_subprocess_close_after_finishz7SubprocessTestsMixin.test_subprocess_close_after_finish�s����)�)�,�,�!�)�)�*>��	�	�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�)rRrKrr�r�r2r�r�r�r�rr�r1rirPrSr�r�r�rA�r7r�r�r�r�s     r�test_subprocess_killz)SubprocessTestsMixin.test_subprocess_kill�s����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�)rRrKrr�r�r2r�r�r�r�rr�r1rirP�	terminater�r�r�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�)rO�SIGHUP�SIG_DFLrRrKrr�r�r2r�r�r�r�rr�r1rirP�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)rRrKrr�r�r2r�r�r�r�rr�r1rirPr�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)rRrKrr�r�r2r�r�r�r�rr��
subprocess�STDOUTr1rirPr�rmrrtr�r�rgr!r�rAr�r�s      r�)test_subprocess_stderr_redirect_to_stdoutz>SubprocessTestsMixin.test_subprocess_stderr_redirect_to_stdoutsl���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�r2r�rsERR:BrokenPipeErrorsERR:OSError)rRrKrr�r�r2r�r�r�r�rr�r1rirPr�rtr�rjr�rgrAr�r r�r�r�r�r�)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_groupKs����)�)�,�,�!�)�)�*>��	�	�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>.connectXs9�����+�$�)�)�+�+��*�*�����
�
�s�0;�9�;T��universal_newlines���bufsize��shell�r�rNr2r1�r7r�s` r�!test_subprocess_exec_invalid_argsz6SubprocessTestsMixin.test_subprocess_exec_invalid_argsWs����	�
�
�
�z�
*��I�I�(�(��D�)I�J�+�
�
�
�z�
*��I�I�(�(���)>�?�+�
�
�
�z�
*��I�I�(�(��t�)<�=�+�
*�	+�
*��
*�
*��
*�
*�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>.connectfsA��������,�$�)�)�,�,��*�*�����
�
�s�4?�=�?�lsz-lTr�r�r�Fr�rr�r�s` r�"test_subprocess_shell_invalid_argsz7SubprocessTestsMixin.test_subprocess_shell_invalid_argsds����	��
�
�z�
*��I�I�(�(��$���)>�?�+�
�
�
�z�
*��I�I�(�(��D�)I�J�+�
�
�
�z�
*��I�I�(�(���)>�?�+�
�
�
�z�
*��I�I�(�(��u�)=�>�+�
*�
+�
*��
*�
*��
*�
*��
*�
*�s/�$D
�#D�#D"�#D.�
D�D�"D+�.D7N)rDrErFr�r�r�r�r�r�r�r�r�r�r�rr r�r�r�r�r�r�r�rrrr�r�Ysz��:�:�>�*,�6� 	�*�� � �X�_�_�S�\�\�W�,�.A�B�6�C�6�0.�*.�2 ,�D
�>�?rr�rc��eZdZd�Zy)�SelectEventLoopTestsc�*�tj�Sr)r�SelectorEventLoopr@s rr�z&SelectEventLoopTests.create_event_loop|����,�,�.�.rN�rDrErFr�rrrr�r�ys��	/rr�c�0�eZdZd�Zd�Zd�Zd�Zd�Zd�Zy)�ProactorEventLoopTestsc�*�tj�Sr)r�ProactorEventLoopr@s rr�z(ProactorEventLoopTests.create_event_loop�r�rc�,�tjd���Nz(IocpEventLoop does not have add_reader()�r��SkipTestr@s rr9z+ProactorEventLoopTests.test_reader_callback�����#�#�$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��rr�r@s r�test_writer_callback_cancelz2ProactorEventLoopTests.test_writer_callback_cancel�r�rc�,�tjd��r�r�r@s rrvz4ProactorEventLoopTests.test_remove_fds_after_closing�r�rN)	rDrErFr�r9r�r@rrvrrrr�r�s%��	/�	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.setUp�sc����G�M�O��(�(�*��%�%�h�0B�C�!�2�2�4���#�#�D�I�I�.��)�)�'�2�	+�*�*�s�AB�Bc����tj�5tjdt�t	j
d�ddd�t�|��y#1swY�xYwr)r	r
rrrrrsr�r�s �rr�z UnixEventLoopTestsMixin.tearDown�sI����(�(�*��%�%�h�0B�C��)�)�$�/�+�
�G���+�*�s�0A�A&)rDrErFr�r�rwrxs@rrr�s���	3�	�	rr�KqueueSelectorc����eZdZd�Zej
dd�ejejjd�d��fd���Zej
dd��fd��Z�xZ
S)�KqueueEventLoopTestsc�P�tjtj��Sr)rr��	selectorsrr@s rr�z&KqueueEventLoopTests.create_event_loop�s!���0�0��,�,�.�0�0rr�	�openbsdztest hangs on OpenBSDc�"��t�|��yr)rsr)r�s �rr)z)KqueueEventLoopTests.test_read_pty_output�s�����,�.rc�"��t�|��yr)rsrIr�s �rrIz#KqueueEventLoopTests.test_write_pty�s�����&�(r)rDrErFr�rr�r�r�rr r!r)rIrwrxs@rrr�sw���
0�&�W�
%�
%�b�!�
,��X�_�_�S�\�\�4�4�Y�?�4�6�
/�6�-�

/�
&�W�
%�
%�b�!�
,�
)�-�
)rr�
EpollSelectorc��eZdZd�Zy)�EPollEventLoopTestsc�P�tjtj��Sr)rr�rrr@s rr�z%EPollEventLoopTests.create_event_loop�s���0�0��1H�1H�1J�K�KrNr�rrrrr�s��
Lrr�PollSelectorc��eZdZd�Zy)�PollEventLoopTestsc�P�tjtj��Sr)rr�rr r@s rr�z$PollEventLoopTests.create_event_loop�s���0�0��1G�1G�1I�J�JrNr�rrrr"r"�s��
Krr"c��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�Handler2rl�	_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)rNrrrr�z:HandleTests.test_callback_with_exception.<locals>.callback�s
���,�rrzException in callback.*)r�r��handle�source_traceback)rrr2rxrr2�_run�assert_called_withr��MockPattern�ANY�_source_traceback)r7r�r5s   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>	s��4rrr5)�weakref�WeakValueDictionaryrr2r2)r7�wdr5s   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-rr2r(r��get_function_sourcer�rr�types�	coroutiner�r�r��escape�assertRegexr*�test_handle_repr�
partialmethod)r7r5�filename�linenor�r��method�cb_regexs        rrQzHandleTests.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��@���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�rHrI� created at rJz <Handle cancelled noop(1, 2) at )r2r,r-r�r�	_getframe�f_linenorr2r(r�rLr�rr�r7�create_filename�
create_linenor5rSrTs      r�test_handle_repr_debugz"HandleTests.test_handle_repr_debug6	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�rIr��test_handle_source_traceback)rrYrZrir?�listr�r�)r5rTr7s  �r�check_source_tracebackzHHandleTests.test_handle_source_traceback.<locals>.check_source_tracebackU	sb����]�]�1�%�.�.��2�F��!�!�!�"5�"5�t�<����Q�0�0��4�R�a�8�&�$�<�>�
?rr)	r�get_event_loop_policyr/�	set_debugr0r�r(r�r�)r7r2rcr5s`   rraz(HandleTests.test_handle_source_tracebackP	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_formattingm	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�r6r@rFrQr^rar�r�r��collections�abcrnrwrxs@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.setUp�	s���
��
���I�I�K��	rc���tj�}tj|d�dt	j
��}|j
t|�t|��y)Nc��yr�rrrrr.z&TimerTests.test_hash.<locals>.<lambda>�	���err)r��	monotonicr�TimerHandlerrr��hash�r7�whenr5s   r�	test_hashzTimerTests.test_hash�	sE���~�~�������m�R� $�	�	��
-������a��$�t�*�-rc���tj�}tj|d�dt	j
��}|j
||j��y)Nc��yr�rrrrr.z&TimerTests.test_when.<locals>.<lambda>�	rvrr)r�rwrrxrrr�r{rzs   r�	test_whenzTimerTests.test_when�	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��|Srrr0s rr�z'TimerTests.test_timer.<locals>.callback�	r1r)r�r�r�)r�rwrrxrrrlr3r4rr^rr�r)r7r�rr{r5s     r�
test_timerzTimerTests.test_timer�	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-rrxr(r�rLr�rr)r7r5�srcs   r�test_timer_reprzTimerTests.test_timer_repr�	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�r�rz <TimerHandle when=123 noop() at rIrXrJz*<TimerHandle cancelled when=123 noop() at )r2r,r-r�rrYrZrrxr(r�rLr�rrr[s      r�test_timer_repr_debugz TimerTests.test_timer_repr_debug�	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��|Srrr0s rr�z2TimerTests.test_timer_comparison.<locals>.callback�	r1rrg$@)r�rwrrxr2rr�rr2rl�NotImplemented�__eq__�__ne__r�rKrrr)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|rr�r�r�r�rwrxs@rrrrr�	s'��� �.�)�#�$<�N�*<(rrrc��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:|�yrD)rrr�AbstractEventLoopr��NotImplementedErrorr�r1r�r�r�rArr�r�r�r�r��set_default_executorr6r&r=r>rLrM�set_exception_handler�default_exception_handlerrxr,re)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)rrrr�r�r�rr�r�r|r�r�r:�sock_recv_into�sock_sendall�sock_connect�sock_accept�
sock_sendfile�sendfiler��sentinelr	rr�r�)r�r2r7s  �r�innerz@AbstractEventLoopTests.test_not_implemented_async.<locals>.innerO
s�������	�	��A��,�,�.�D��"�"�#6�7��*�*�1�a�0�0�0�8��"�"�#6�7��&�&�{�D�9�9�9�8��"�"�#6�7��&�&�':�;�;�;�8��"�"�#6�7��,�,�Q�/�/�/�8��"�"�#6�7��(�(��+�+�+�8��"�"�#6�7��3�3�A�6�6�6�8��"�"�#6�7��n�n�Q��+�+�+�8��"�"�#6�7��)�)�!�R�0�0�0�8��"�"�#6�7��'�'��2�.�.�.�8��"�"�#6�7��'�'��1�-�-�-�8��"�"�#6�7��&�&�q�)�)�)�8��"�"�#6�7��(�(��A�.�.�.�8��"�"�#6�7��m�m�A�q�)�)�)�8��"�"�#6�7��,�,�Q��
�
�0B�0B�C�C�C�8��"�"�#6�7��-�-�a����1C�1C�D�D�D�8��"�"�#6�7��+�+�A�t�}�}�=�=�=�8��"�"�#6�7��*�*�1�-�-�-�8�7�?1��8�7��:��8�7��<��8�7��0��8�7��,��8�7��7��8�7��,��8�7��1��8�7��/��8�7��.��8�7��*��8�7��/��8�7��*��8�7��D��8�7��E��8�7��>��8�7��.��8�7�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_asyncM
s2���%	.�N�%�%�'�������(��
�
�rN)rDrErFr�r�rrrr�r�
s
��44�l+rr�c�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�r��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�rSr�rir�rlrA)r7r�r�r2s    r�test_get_event_loopzPolicyTests.test_get_event_loop�
s����/�/�1�����&�-�-�-�-�.�
�
�
�0�
1�R��(�(�*�D�2�������h�/����d�G�$=�$=�>��
�
�f�m�m�)�)�4�0��
�
�d�F�1�1�3�4��
�
��2�
1�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�rrAr�rSr�r<)r7r��m_set_event_loopr�r2s     r�(test_get_event_loop_calls_set_event_loopz4PolicyTests.test_get_event_loop_calls_set_event_loop�
s����/�/�1��
�Z�Z�
�
��(��+�+��-�0@��!�!�"4�5���,�,�.��6��O�O�D�J�J�'����R�[�[�(�3�

�/�/��5�-�	
�
�
��6�5��	-�-�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_none�
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/rir�rA)r7r�r2s   r�test_new_event_loopzPolicyTests.test_new_event_loop�
s=���/�/�1���$�$�&�����d�G�$=�$=�>��
�
�rc���tj�}|j�}|j|�|j	t
|jt
��|j�}|j|�|j||j��|j||j��|j�|j�yr)rr�r/r0r�rKr~rlr��assertIsNotrA)r7r��old_loopr2s    r�test_set_event_loopzPolicyTests.test_set_event_loop�
s����/�/�1���(�(�*�����h�'����)�V�%:�%:�F�H�E��$�$�&�����d�#��
�
�d�F�1�1�3�4�����6�#8�#8�#:�;��
�
�����rc��tj�}|j|tj�|j	|tj��yr)rrdrir�rlr�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�rKrrr~rdr�rlr�)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
rrr
rrrs  �rr�zGetEventLoopTestsMixin.setUp�
sa���'-�'?�'?��$�'-�'?�'?��$�&,�&=�&=��#�$*�$9�$9��!�#'��:�#D�#D�� �#'��:�#D�#D�� �"&�t�*�"B�"B��� $�T�
� >� >���$(��J�$E�$E��!�$(��J�$E�$E��!�#'��:�#C�#C�� �!%�d��!?�!?���
��
���*�*�,��	����t�y�y�)��<�<�7�"��(�(�*��%�%�h�0B�C�!�2�2�4���#�#�D�I�I�.��)�)�'�2�	+�*�#�*�*�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
rrrrrsr�r2rAr0r�rr�r�r�r�r�r�r�r�s �rr�zGetEventLoopTestsMixin.tearDown�
su���	?��|�|�w�&��,�,�.��)�)�(�4F�G��-�-�d�3�/�
�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�"�#/�.��
�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�ProcessPoolExecutorr2rr3�shutdown)r��poolr�r7s   �rr`zDGetEventLoopTestsMixin.test_get_event_loop_new_process.<locals>.mains������"�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_processsJ���
�>�>�@��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�0s��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_loop4s����rN)rDrErFr�)r�s�r�Policyr�3s���
 rr��
no runningc����K��jtj����jtj����jtj���y�wr�rlrr�r�r�r|s��rr�zMGetEventLoopTestsMixin.test_get_event_loop_returns_running_loop.<locals>.funcF�L������
�
�g�4�4�6��=��
�
�g�6�6�8�$�?��
�
�g�7�7�9�4�@���A.A1)r�rr�rdrr/r�r�r0rr�r�rlr�r1rA)r7r�r�r�r�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��(�(�*�D��M�M�'�3�3�5�t�<�
A�

�#�#�D�F�+��"�"�4�(��"�"�9�-��&�&�(�.��"�"�4�(��"�"�9�-��&�&�(�.�
�)�)�*�5����
�
��
�
#�
#�L�,�
?��$�$�&�@�	
�
�
�g�/�/�1�4�8�A.�-��.�-��D�C��.�-��.�-��
�)�)�*�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��rr�zNGetEventLoopTestsMixin.test_get_event_loop_returns_running_loop2.<locals>.funcqr�r�)rrdrr�r/rrAr�rr�r�rSr�r0rr�r�rlr�r1)r7r�r��loop2r�r2s`    @r�)test_get_event_loop_returns_running_loop2z@GetEventLoopTestsMixin.test_get_event_loop_returns_running_loop2^s����2�2�4�
�"	��)�)�'�*H�*H�*J�K��)�)�+�D��O�O�D�J�J�'��!�!�"4�5���.�.�0��6��O�O�E�K�K�(����R�[�[�(�3��"�"�4�(��'�'��l�C��&�&�(�D��'�'��l�C��(�(�*�D��M�M�'�3�3�5�t�<�
A�

�#�#�D�F�+��"�"�4�(��M�M�'�0�0�2�D�9��"�"�4�(��'�'��l�C��&�&�(�D�
�)�)�*�5����
�
��
�
#�
#�L�,�
?��$�$�&�@�	
�
�
�g�/�/�1�4�8�E6�5��
D�C��D�C��D�C��
�)�)�*�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�rrrrr�s2��!'�!<�!<��!'�!<�!<�� &� :� :��$�6�6�rrc��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>�s���Err1r)
rr/rrArqr1r�r��get_loop�wait_closed)r7r2r&r�s   @r�
test_get_loopzTestServer.test_get_loop�s�����%�%�'������
�
�#���
���(�(��);�);�M�9�VW�)X�Y��������*�D�1��������� 2� 2� 4�5rN)rDrErFrrrrrr�s��6rrc��eZdZd�Zd�Zd�Zy)�TestAbstractServerc��|jt�5tj�j	�ddd�y#1swYyxYwr)r�r�r�AbstractServerrAr@s rr�zTestAbstractServer.test_close�s2��
�
�
�2�
3��!�!�#�)�)�+�4�
3�
3���#A�Ac��tj�}|j|j�|j	t
�5|j
tj�j��ddd�y#1swYyxYwr)
rr/rrAr�r�r1rrrrRs  r�test_wait_closedz#TestAbstractServer.test_wait_closed�s[���%�%�'������
�
�#�
�
�
�2�
3��#�#�F�$9�$9�$;�$G�$G�$I�J�4�
3�
3�s�2B�B	c��|jt�5tj�j	�ddd�y#1swYyxYwr)r�r�rrrr@s rrz TestAbstractServer.test_get_loop�s2��
�
�
�2�
3��!�!�#�,�,�.�4�
3�
3�rN)rDrErFr�rrrrrrr�s��,�K�/rr�__main__)R�__doc__�collections.abcro�concurrent.futuresr�r�r
r�rRr r�rOr2r��ImportErrorr�rr�r�rMr�r�rrCr	rSrrrr�multiprocessing.utilr	r��test.test_asyncior
r�r�r�test.supportrr
rrrrr(r3r5rkrHrqr�rzr��BaseProtocolr�r�r�r�r��TestCaser�r�rrr�rrr"r(r*rrr�r�r�r��_asynciorrrrDr`rrr�<module>r$s������	��	��	�
�
����
����������<�<�+�+�����#�P�1��&�)�5�5�(��+�
�
�#'�'�"�"�#'�LH�k�H�'�g�.�.�'�@!'�g�&�&�!'�H'�w�+�+�'�2*:�7�5�5�*:�ZP�P�f2[?�[?�|�<�<�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���J\�	��	�s#�K�K*�K'�&K'�*K2�1K2

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists