HEX
Server: Microsoft-IIS/10.0
System: Windows NT ITPWINWEBSVR22 10.0 build 20348 (Windows Server 2022) AMD64
User: www.conferencesearch.co.uk (0)
PHP: 8.3.30
Disabled: NONE
Upload Files
File: D:/Python311/Lib/test/test_asyncio/__pycache__/test_base_events.cpython-311.pyc
�

��Vc�>��8�dZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl	m
Z
ddlZddlmZddlm
Z
ddlmZddlmZddlmZdd	lmZdd
lmZddlZe
jZd�Zd�Zd
�ZGd�dej��ZGd�dej��Z Gd�dej!��Z"Gd�dej#��Z$Gd�dej��Z%Gd�de	j��Z&Gd�dej��Z'Gd�dej��Z(e)dkre	j*��dSdS)zTests for base_events.py�N)�mock)�base_events)�	constants)�utils)�support)�assert_python_ok)�	os_helper)�
socket_helperc�.�tjd��dS�N)�asyncio�set_event_loop_policy���6D:\Python311\Lib\test\test_asyncio\test_base_events.py�tearDownModulers���!�$�'�'�'�'�'rc	�B�tjt���}dD]L}tt|��r%t	||tt|�����<t
||���Mtj��|_tj��|j_	|S)N)�spec)
�AF_INET�AF_INET6�	AF_UNSPEC�IPPROTO_TCP�IPPROTO_UDP�SOCK_STREAM�
SOCK_DGRAM�
SOL_SOCKET�SO_REUSEADDR�	inet_pton)
r�	MagicMock�socket�hasattr�setattr�getattr�delattr�
test_utils�mock_nonblocking_socket�return_value)�m_socket�names  r�mock_socket_moduler*s����~�6�*�*�*�H��$�$���6�4� � �	$��H�d�G�F�D�$9�$9�:�:�:�:��H�d�#�#�#�#��n�&�&�H�O�#-�#E�#G�#G�H�O� ��Orc�J�tjdt���|��S)Nzasyncio.base_events.socket)�new_callable)r�patchr*)�fs r�patch_socketr//s2��7�4�:�2�#5�7�7�7�78�:�:�:rc�0�eZdZd�Zd�Zed���ZdS)�BaseEventTestsc
�2�tj}tj}tj}tj}tj}tj}tj}|�|||ddftj
dd|||����|�|||ddftj
dd|||����|�|||ddftj
dd|||����|�|||ddftj
dd|||����|�|||ddftj
dd||d����|�|||ddftj
dd||d����|�tj
dd|dd����tj
r�|�tj
dd|||����|�|||ddftj
dd|||����|�|||ddftj
dd|||����|�tj
dd|||����|�tj
d	d|||����dSdS)
N���1.2.3.4�r5r6s1.2.3.4r)�::3r6rrr7z::3%lo0)r rrrrrrr�assertEqualr�_ipaddr_info�assertIsNoner
�IPV6_ENABLED)�self�UNSPEC�INET�INET6�STREAM�DGRAM�TCP�UDPs        r�test_ipaddr_infozBaseEventTests.test_ipaddr_info6s0���!���~������#���!��� ��� �����
�6�3��N�3��$�Y��4���E�E�	G�	G�	G�	
���
�6�3��N�3��$�Z��D�&�#�F�F�	H�	H�	H�	
���
�6�3��N�3��$�Y��6�6�3�G�G�	I�	I�	I�	
���
�5�#�r�>�2��$�Y��6�5�#�F�F�	H�	H�	H�
	
���
�6�3��N�3��$�Y��6�6�1�E�E�	G�	G�	G�
	
���
�5�#�r�>�2��$�Y��6�5�!�D�D�	F�	F�	F�
	
����$�Y��6�1�a�@�@�	B�	B�	B��%�	L�����(��A�u�f�c�J�J�
L�
L�
L�
������R�)9�:��(���5�&�#�F�F�
H�
H�
H�
������R�)9�:��(���6�6�3�G�G�
I�
I�
I�

����(���4���E�E�
G�
G�
G�
����(��A�u�f�c�J�J�
L�
L�
L�
L�
L�%	L�	Lrc
�8�tj}tj}tj}|�|||ddftjdd|||����|�|||ddftjdd|||����|�|||ddftjdd|||����|�|||ddftjdd|||����|�|||ddftjdd|||����dS)Nr3�r5rr5rr4�1�1)r rrrr8rr9)r<r>r@rBs    r�test_port_parameter_typesz(BaseEventTests.test_port_parameter_typesrsh���~���#��� �����
�6�3��N�3��$�Y��d�F�C�H�H�	J�	J�	J�	
���
�6�3��N�3��$�Y��T�6�3�G�G�	I�	I�	I�	
���
�6�3��N�3��$�Y��D�&�#�F�F�	H�	H�	H�	
���
�6�3��N�3��$�Y��T�6�3�G�G�	I�	I�	I�	
���
�6�3��N�3��$�Y��d�F�C�H�H�	J�	J�	J�	J�	Jrc	��|`|�tjddtjtjtj����dS)Nr5r6)rr:rr9r rrr�r<r(s  r�test_ipaddr_info_no_inet_ptonz,BaseEventTests.test_ipaddr_info_no_inet_pton�sU�������+�2�9�a�39�>�39�3E�39�3E�G�G�	H�	H�	H�	H�	HrN)�__name__�
__module__�__qualname__rDrIr/rLrrrr1r14sY������:L�:L�:L�xJ�J�J�4�H�H��\�H�H�Hrr1c� ��eZdZ�fd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z!d �Z"d!�Z#d"�Z$d#�Z%d$�Z&d%�Z'd&�Z(d'�Z)d(�Z*d)�Z+d*�Z,d+�Z-d,�Z.�xZ/S)-�BaseEventLoopTestsc���t�����tj��|_tj��|j_d|jjj_	|�
|j��dS�Nr)�super�setUpr�
BaseEventLoop�loopr�Mock�	_selector�selectr'�set_event_loop�r<�	__class__s �rrUzBaseEventLoopTests.setUp�s`���
���
�
�����-�/�/��	�"�i�k�k��	��24��	��"�/����D�I�&�&�&�&�&rc	��tj��}|�t|jj||��|�t|jj||||��|�t|jj||��|�t|jjg��|�t|jj	��|�t|jj
||��|�t|jj||��|j�|||||||��}|�t��5|�
d��ddd��dS#1swxYwYdSr)rrX�assertRaises�NotImplementedErrorrW�_make_socket_transport�_make_ssl_transport�_make_datagram_transport�_process_events�_write_to_self�_make_read_pipe_transport�_make_write_pipe_transport�_make_subprocess_transport�send)r<�m�gens   r�test_not_implementedz'BaseEventLoopTests.test_not_implemented�s����I�K�K�������I�,�a��	4�	4�	4�	
�����I�)�1�a��A�	7�	7�	7�	
�����I�.��1�	6�	6�	6�	
������!:�B�	@�	@�	@�������!9�	;�	;�	;������I�/��A�	7�	7�	7�	
�����I�0�!�Q�	8�	8�	8��i�2�2�1�a��A�q�!�Q�G�G��
�
�
�2�
3�
3�	�	��H�H�T�N�N�N�	�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	�	s�F�F�Fc��|�|j�����|j���|�|j�����|j���|j���|j���}|�t|jj��|�t|jj	|��dSr)
�assertFalserW�	is_closed�close�
assertTrue�
create_futurer_�RuntimeError�run_forever�run_until_complete)r<r.s  r�
test_closezBaseEventLoopTests.test_close�s��������,�,�.�.�/�/�/��	����������	�+�+�-�-�.�.�.�	
�	�������	������
�I�#�#�%�%�����,��	�(=�>�>�>����,��	�(D�a�H�H�H�H�Hrc���tjd�d|jd��}|j�|��|�|jj��|�||jj��dS)Nc��dS�NFrrrr�<lambda>z>BaseEventLoopTests.test__add_callback_handle.<locals>.<lambda>����5�rr)r
�HandlerW�
_add_callbackrn�
_scheduled�assertIn�_ready�r<�hs  r�test__add_callback_handlez,BaseEventLoopTests.test__add_callback_handle�si���N�=�=�"�d�i��>�>���	����"�"�"������-�.�.�.��
�
�a���)�*�*�*�*�*rc��tjd�d|jd��}|���|j�|��|�|jj��|�|jj��dS)Nc��dSryrrrrrzzHBaseEventLoopTests.test__add_callback_cancelled_handle.<locals>.<lambda>�r{rr)r
r|rW�cancelr}rnr~r�r�s  r�#test__add_callback_cancelled_handlez6BaseEventLoopTests.test__add_callback_cancelled_handle�sv���N�=�=�"�d�i��>�>��	���
�
�
��	����"�"�"������-�.�.�.������)�*�*�*�*�*rc�<�Gd�dtjj��}tj��|j_tj��|j_|��}|j�|��|�	||jj
��dS)Nc��eZdZd�ZdS)�CBaseEventLoopTests.test_set_default_executor.<locals>.DummyExecutorc� �td���)Nz#cannot submit into a dummy executor)r`)r<�fn�args�kwargss    r�submitzJBaseEventLoopTests.test_set_default_executor.<locals>.DummyExecutor.submit�s��)�9�;�;�;rN)rMrNrOr�rrr�
DummyExecutorr��s#������
;�
;�
;�
;�
;rr�)�
concurrent�futures�ThreadPoolExecutorrrXrWrdre�set_default_executor�assertIs�_default_executor)r<r��executors   r�test_set_default_executorz,BaseEventLoopTests.test_set_default_executor�s���	;�	;�	;�	;�	;�J�.�A�	;�	;�	;�
%)�I�K�K��	�!�#'�9�;�;��	� � �=�?�?���	�&�&�x�0�0�0��
�
�h��	� ;�<�<�<�<�<rc��tj��}d}|�t|��5|j�|��ddd��n#1swxYwY|�|jj��dS)Nz,executor must be ThreadPoolExecutor instance)rrX�assertRaisesRegex�	TypeErrorrWr�r:r�)r<r��msgs   r�test_set_default_executor_errorz2BaseEventLoopTests.test_set_default_executor_error�s����9�;�;��<��
�
#�
#�I�s�
3�
3�	5�	5��I�*�*�8�4�4�4�	5�	5�	5�	5�	5�	5�	5�	5�	5�	5�	5����	5�	5�	5�	5�	
���$�)�5�6�6�6�6�6s�A�A�Ac��d�}|j�|��}|�|j|��|�|t
j��|�||jj��dS)Nc��dSrrrrr�cbz-BaseEventLoopTests.test_call_soon.<locals>.cb�����Dr)	rW�	call_soonr8�	_callback�assertIsInstancer
r|rr��r<r�r�s   r�test_call_soonz!BaseEventLoopTests.test_call_soon�sw��	�	�	�
�I����#�#�������b�)�)�)����a���0�0�0��
�
�a���)�*�*�*�*�*rc���|j�d��|�td��5|j�d��ddd��dS#1swxYwYdS)NTza callable objectr6)rW�	set_debugr�r�r��r<s r�test_call_soon_non_callablez.BaseEventLoopTests.test_call_soon_non_callable�s����	���D�!�!�!�
�
#�
#�I�/B�
C�
C�	#�	#��I����"�"�"�	#�	#�	#�	#�	#�	#�	#�	#�	#�	#�	#�	#����	#�	#�	#�	#�	#�	#s�A�A"�%A"c��d�}|j�d|��}|�|tj��|�||jj��|�||jj��|�	td���5|j�d|��ddd��dS#1swxYwYdS)Nc��dSrrrrrr�z.BaseEventLoopTests.test_call_later.<locals>.cb�r�r�$@zdelay must not be None�r�)rW�
call_laterr�r
�TimerHandlerr~�assertNotInr�r_r�r�s   r�test_call_laterz"BaseEventLoopTests.test_call_later�s
��	�	�	�
�I� � ��r�*�*�����a��!4�5�5�5��
�
�a���-�.�.�.�����D�I�,�-�-�-�
�
�
�y�.F�
�
G�
G�	+�	+��I� � ��r�*�*�*�	+�	+�	+�	+�	+�	+�	+�	+�	+�	+�	+�	+����	+�	+�	+�	+�	+�	+s�C�C�Cc�"��g��fd�}tj��|j_|j�d|d��|j�d|d��tj|j��|��ddg��dS)Nc�2����|��dSr)�append)�arg�callss �rr�z>BaseEventLoopTests.test_call_later_negative_delays.<locals>.cbs����L�L������r����a����b)rrXrWrdr�r%�run_brieflyr8)r<r�r�s  @r�test_call_later_negative_delaysz2BaseEventLoopTests.test_call_later_negative_delayss������	�	�	�	�	�%)�I�K�K��	�!��	���R��S�)�)�)��	���R��S�)�)�)���t�y�)�)�)������c�
�+�+�+�+�+rc�\���fd�}tj���j_d}�j���|z}�j�||���j���}�j����j���|z
}��||dz
|����|d|����	td���5�j�d|��ddd��dS#1swxYwYdS)Nc�:���j���dSr�rW�stopr�s�rr�z4BaseEventLoopTests.test_time_and_call_at.<locals>.cbs����I�N�N�����r皙�����?g�������?g�������?zwhen cannot be Noner�)rrXrWrd�time�call_atrt�assertGreaterEqual�assertLessEqualr_r�)r<r��delay�when�t0�dts`     r�test_time_and_call_atz(BaseEventLoopTests.test_time_and_call_atsj���	�	�	�	�	�%)�I�K�K��	�!����y�~�~���%�'���	���$��#�#�#�
�Y�^�^�
�
���	������
�Y�^�^�
�
��
"��	
����E�E�M�2�6�6�6�	
���R��b�)�)�)�
�
�
�y�.C�
�
D�
D�	(�	(��I���d�B�'�'�'�	(�	(�	(�	(�	(�	(�	(�	(�	(�	(�	(�	(����	(�	(�	(�	(�	(�	(s�8D!�!D%�(D%c���d�}|�|��|r�d}|�t|��5|�|��ddd��n#1swxYwY|�t|��5|�d|��ddd��n#1swxYwY|�t|��5|�|���dz|��ddd��dS#1swxYwYdS|�|��|�d|��|�|���dz|��dS)Nc��dSrrrrrr�z+BaseEventLoopTests.check_thread.<locals>.cb%r�rzMNon-thread-safe operation invoked on an event loop other than the current one�<)r�r�rsr�r�r�r�)r<rW�debugr�r�s     r�check_threadzBaseEventLoopTests.check_thread$s��	�	�	�	
���u�����	/�*�C��'�'��c�:�:�
#�
#����r�"�"�"�
#�
#�
#�
#�
#�
#�
#�
#�
#�
#�
#����
#�
#�
#�
#��'�'��c�:�:�
(�
(�����B�'�'�'�
(�
(�
(�
(�
(�
(�
(�
(�
(�
(�
(����
(�
(�
(�
(��'�'��c�:�:�
3�
3����T�Y�Y�[�[�2�-�r�2�2�2�
3�
3�
3�
3�
3�
3�
3�
3�
3�
3�
3�
3����
3�
3�
3�
3�
3�
3�
�N�N�2�����O�O�B��#�#�#��L�L������r�)�2�.�.�.�.�.s5�A�A�!A�B#�#B'�*B'�	,D�D�	Dc�$����fd��d�fd�	}tj���j_tj���j_|�jd��|�jd��|�jdd���|�jdd���dS)Nc�&��|���	|r�tj��}	tj|����||��tjd��|���nC#tjd��|���wxYw��||��|�|jd��dS#t$r&}|�|j
|��Yd}~dSd}~wwxYwr)�waitrrVr
r[r�rp�call_soon_threadsafe�
set_result�	Exception�
set_exception)rW�eventr��create_loop�fut�loop2�excr<s       �r�check_in_threadz=BaseEventLoopTests.test_check_thread.<locals>.check_in_thread8s$����J�J�L�L�L�
@��	3�'�5�7�7�E�&��.�u�5�5�5��)�)�$��6�6�6��.�t�4�4�4����
�
�
�
�� �.�t�4�4�4����
�
�
�
�����%�%�d�E�2�2�2��)�)�#�.�$�?�?�?�?�?���
B�
B�
B��)�)�#�*;�S�A�A�A�A�A�A�A�A�A�����
B���s.�C �*B�)C �*B*�*C � 
D�*D�DFc�>��tj��}|���}|�|j��|||||f}tj�|���}|���|�|��|���dS)N)�targetr�)	�	threading�Eventrrr��set�Thread�startru�join)rWr�r�r�r�r��threadr�s       �r�test_threadz9BaseEventLoopTests.test_check_thread.<locals>.test_threadLs�����O�%�%�E��$�$�&�&�C��N�N�5�9�%�%�%��%���S�9�D��%�_�4�H�H�H�F��L�L�N�N�N��#�#�C�(�(�(��K�K�M�M�M�M�MrT)r��F)rrXrWrdre)r<r�r�s` @r�test_check_threadz$BaseEventLoopTests.test_check_thread7s�����	@�	@�	@�	@�	@�(	�	�	�	�	�	�%)�I�K�K��	�!�#'�9�;�;��	� �	��D�I�t�$�$�$�	��D�I�u�%�%�%�	��D�I�t��6�6�6�6�	��D�I�u�$�7�7�7�7�7�7rc���tjtj��dzd�d|jd��}tjtj��dzd�d|jd��}|���t
j��|j_|jj	�
|��|jj	�
|��|j���|jjj
jdd}|�d|cxkodknc|��|�|g|jj	��|�|jjj��dS)	Ng@c��dS�NTrrrrrzz3BaseEventLoopTests.test__run_once.<locals>.<lambda>gs���rrr�c��dSr�rrrrrzz3BaseEventLoopTests.test__run_once.<locals>.<lambda>is��$�rrg#@g%@)r
r�r��	monotonicrWr�rrXrdr~r��	_run_oncerYrZ�	call_argsrqr8�called)r<�h1�h2�ts    r�test__run_oncez!BaseEventLoopTests.test__run_oncefsB��
�
 ���!1�!1�C�!7���r�!%��D�2�2��
�
 ���!1�!1�D�!8�,�,��!%��D�2�2��	�	�	����$(�I�K�K��	�!��	��#�#�B�'�'�'��	��#�#�B�'�'�'��	�������I��&�0��3�A�6������a�����$������*�*�*����"��t�y�3�4�4�4�����	�1�8�9�9�9�9�9rc��|j�d��|�|j�����|j�d��|�|j�����dS)NTF)rWr�rq�	get_debugrnr�s r�test_set_debugz!BaseEventLoopTests.test_set_debugxsv���	���D�!�!�!�����	�+�+�-�-�.�.�.��	���E�"�"�"������,�,�.�.�/�/�/�/�/rc����d�d���fd�}tjtj��dz
||jf|jd��}tj��|j_|jj�	|��|j�
��|����|��gt|jj����dS)NFc�8��d�|�d����dS)NTc��dSr�rrrrrzzOBaseEventLoopTests.test__run_once_schedule_handle.<locals>.cb.<locals>.<lambda>�s��D�r)r�)rW�handle�	processeds ��rr�z=BaseEventLoopTests.test__run_once_schedule_handle.<locals>.cb�s����I��^�^�L�L�1�1�F�F�Frr6)r
r�r�r�rWrrXrdr~r�r�rqr8�listr�)r<r�r�r�r�s   @@r�test__run_once_schedule_handlez1BaseEventLoopTests.test__run_once_schedule_handle~s��������	�	2�	2�	2�	2�	2�	2�

���� 0� 0�1� 4�b�4�9�,� $�	�4�
1�
1��%)�I�K�K��	�!��	��#�#�A�&�&�&��	���������	�"�"�"����&��4��	�(8�#9�#9�:�:�:�:�:rc�F�tj��|j_|�dt
jcxkodknc��d�}d}|j�d|��d}td��D]1}|j�d|��}|�	���2|dz
}td��D]1}|j�d|��}|�	���2|�
||zt
j��|�|jj
|��|j���|dz}|�|jj
|��|�t|jj��||z��t#t%jt
jt
jz����dz}t)t
j|z
d��}||z
}t|��D]}|j�d|���||z
}t|��D]1}|j�d|��}|�	���2|�t|jj��||z��|j���|�t|jj��|��|�t+d	�|jjD������dS)
Nrg�?c��dSrrrrrr�zEBaseEventLoopTests.test__run_once_cancelled_event_cleanup.<locals>.cb�r�rr6��i�dc��g|]
}|j��Sr)�
_cancelled)�.0�xs  r�
<listcomp>zMBaseEventLoopTests.test__run_once_cancelled_event_cleanup.<locals>.<listcomp>�s��L�L�L�!���-�L�L�Lr)rrXrWrdrqr�%_MIN_CANCELLED_TIMER_HANDLES_FRACTIONr��ranger�r��_MIN_SCHEDULED_TIMER_HANDLESr8�_timer_cancelled_countr��lenr~�int�math�ceil�max�all)r<r��not_cancelled_count�cancelled_countrr��add_cancel_count�add_not_cancel_counts        r�&test__run_once_cancelled_event_cleanupz9BaseEventLoopTests.test__run_once_cancelled_event_cleanup�sA��$(�I�K�K��	�!����
��A�G�G�G�G�C�G�G�G�G�	I�	I�	I�	�	�	� ���	���T�2�&�&�&�
���q���	�	�A��	�$�$�T�2�.�.�A�
�H�H�J�J�J�J�	�1����q���	�	�A��	�$�$�S�"�-�-�A�
�H�H�J�J�J�J�	
���_�/B�B��4�	6�	6�	6�	
�����9�?�K�K�K��	�������1��������9�?�K�K�K�����T�Y�1�2�2��1�1�	3�	3�	3�
�t�y��4��=�
>� ?� ?�@�@�BC�D�� #�;�#K��$�� !� !��	�3�3���+�,�,�	+�	+�A��I� � ��r�*�*�*�*�	�+�+���'�(�(�	�	�A��	�$�$�T�2�.�.�A�
�H�H�J�J�J�J�	
����T�Y�1�2�2��1�1�	3�	3�	3�	
�	������	
����T�Y�1�2�2�4G�H�H�H�	
����L�L�t�y�7K�L�L�L�M�M�N�N�N�N�Nrc�R�|�t|jjd��dS)N�blah)r_r�rWrur�s r�"test_run_until_complete_type_errorz5BaseEventLoopTests.test_run_until_complete_type_error�s0�����)��I�(�&�	2�	2�	2�	2�	2rc���|j���}|���}|�|j��|�t|j|��dSr)rWrr�
new_test_loop�
addCleanuprpr_�
ValueErrorru)r<�task�
other_loops   r�test_run_until_complete_loopz/BaseEventLoopTests.test_run_until_complete_loop�sg���y�&�&�(�(���'�'�)�)�
����
�(�)�)�)����*��)�4�	1�	1�	1�	1�	1rc���Gd�dt���d�}�fd�}tj��|j_|j�|��|����5|j�|d����ddd��n#1swxYwY|j�|d����dS)Nc��eZdZdS)�]BaseEventLoopTests.test_run_until_complete_loop_orphan_future_close_loop.<locals>.ShowStopperN�rMrNrOrrr�ShowStopperr%���������Drr'c��>K�tj|���d{V��dSr�r
�sleep)r�s r�foozUBaseEventLoopTests.test_run_until_complete_loop_orphan_future_close_loop.<locals>.foo�s.�����-��&�&�&�&�&�&�&�&�&�&�&rc�����rr)r's�r�throwzWBaseEventLoopTests.test_run_until_complete_loop_orphan_future_close_loop.<locals>.throw�s	����rr�g�������?)�
SystemExitrrXrWrdr�r_ru)r<r,r.r's   @r�5test_run_until_complete_loop_orphan_future_close_loopzHBaseEventLoopTests.test_run_until_complete_loop_orphan_future_close_loop�s*���	�	�	�	�	�*�	�	�	�	'�	'�	'�	�	�	�	�	�%)�I�K�K��	�!��	���E�"�"�"�
�
�
�{�
+�
+�	3�	3��I�(�(���S���2�2�2�	3�	3�	3�	3�	3�	3�	3�	3�	3�	3�	3����	3�	3�	3�	3�
	
�	�$�$�S�S��X�X�.�.�.�.�.s�)$B�B� Bc���tjddg}|�t|jj|jjtj��|�t|jj|jjtj|��|�t|jj|jjtjtjd��|jt|jj|jjtjg|�Rddi�|jt|jj|jjtjg|�Rddi�|jt|jj|jjtjg|�Rddi�dS)	N�-c�pass�{�universal_newlinesT�shell�bufsize�)	�sys�
executabler_r�rWru�subprocess_execr
�SubprocessProtocol)r<r�s  r�!test_subprocess_exec_invalid_argsz4BaseEventLoopTests.test_subprocess_exec_invalid_args�s������f�-��	
���)��I�(�$�)�*C��&�	(�	(�	(�
	
���)��I�(�$�)�*C��&��	.�	.�	.�
	
���)��I�(�$�)�*C��&����	=�	=�	=�
	���)��	�$�d�i�&?��&�	H�)-�	H�	H�	H�BF�	H�	H�	H�	���)��I�(�$�)�*C��&�	;�)-�	;�	;�	;�59�	;�	;�	;�	���)��I�(�$�)�*C��&�	=�)-�	=�	=�	=�7;�	=�	=�	=�	=�	=rc	��|�t|jj|jjt
jd��|�t|jj|jjt
jtjddg��|�t|jj|jjt
jdd���|�t|jj|jjt
jdd���|�t|jj|jjt
jdd�	��dS)
Nr4r2r3zexit 0T)r5)r6r8)r7)	r_r�rWru�subprocess_shellr
r<r9r:r�s r�"test_subprocess_shell_invalid_argsz5BaseEventLoopTests.test_subprocess_shell_invalid_argss2�����)��I�(�$�)�*D��&��	-�	-�	-�	
���)��I�(�$�)�*D��&����v�(F�	H�	H�	H�
	
���)��I�(�$�)�*D��&��T�	�	K�	K�	K�	
���)��I�(�$�)�*D��&���	�	>�	>�	>�	
���)��I�(�$�)�*D��&��$�	�	@�	@�	@�	@�	@rc���tj���j_d�}tjd��5}�j���}�j�||��|��fd����j���|j	�
tjd��tttf���ddd��n#1swxYwYtjd��5}�j���}�j�d||��|��fd����j���|j	�
tjd��tttf���ddd��dS#1swxYwYdS)Nc�:�|�d��ddzdS)NTr6r)r��r�s r�
zero_errorzHBaseEventLoopTests.test_default_exc_handler_callback.<locals>.zero_error/s!���N�N�4� � � �
�a�C�C�C�Cr�asyncio.base_events.loggerc�6���j���Srr��r�r<s �rrzzFBaseEventLoopTests.test_default_exc_handler_callback.<locals>.<lambda>7����d�i�n�n�.>�.>�r�Exception in callback.*zero��exc_info�{�G�z�?c�6���j���Srr�rGs �rrzzFBaseEventLoopTests.test_default_exc_handler_callback.<locals>.<lambda>ArHr)rrXrWrdr-rrr��add_done_callbackrt�error�assert_called_withr%�MockPattern�ZeroDivisionError�MOCK_ANYr�)r<rD�logr�s`   r�!test_default_exc_handler_callbackz4BaseEventLoopTests.test_default_exc_handler_callback,sP���$(�I�K�K��	�!�	�	�	�
�Z�4�
5�
5�	B���)�)�)�+�+�C��I���
�C�0�0�0��!�!�">�">�">�">�?�?�?��I�!�!�#�#�#��I�(�(��&�'D�E�E�+�X�x�@�
)�
B�
B�
B�	B�	B�	B�	B�	B�	B�	B�	B�	B�	B�	B����	B�	B�	B�	B��Z�4�
5�
5�	B���)�)�)�+�+�C��I� � ��z�3�7�7�7��!�!�">�">�">�">�?�?�?��I�!�!�#�#�#��I�(�(��&�'D�E�E�+�X�x�@�
)�
B�
B�
B�	B�	B�	B�	B�	B�	B�	B�	B�	B�	B�	B�	B����	B�	B�	B�	B�	B�	Bs%�B&C(�(C,�/C,�B'F;�;F?�F?c����tj���j_d�}tjd��5}tj|���j���}|��fd����j���d}tj
��|j�tjd��tt t f���ddd��dS#1swxYwYdS)Nc��HK�tjd���d{V��ddzdS)NrLr6rr*rrr�zero_error_corozIBaseEventLoopTests.test_default_exc_handler_coro.<locals>.zero_error_coroJs5�����-��%�%�%�%�%�%�%�%�%�
�a�C�C�C�CrrE�rWc�6���j���Srr�)r�r<s �rrzzBBaseEventLoopTests.test_default_exc_handler_coro.<locals>.<lambda>Qs����	���0@�0@�rz.*exception was never retrievedrJ)rrXrWrdr-r
�
ensure_futurerNrtr�
gc_collectrOrPr%rQrRrS)r<rXrTr�s`   r�test_default_exc_handler_coroz0BaseEventLoopTests.test_default_exc_handler_coroGsI���$(�I�K�K��	�!�	�	�	�
�Z�4�
5�
5�		B���'���(9�(9��	�J�J�J�C��!�!�"@�"@�"@�"@�A�A�A��I�!�!�#�#�#��C��� � � ��I�(�(��&�'H�I�I�+�X�x�@�
)�
B�
B�
B�		B�		B�		B�		B�		B�		B�		B�		B�		B�		B�		B�		B����		B�		B�		B�		B�		B�		Bs�B*C-�-C1�4C1c��|�td��5|j�d��ddd��dS#1swxYwYdS)NzA callable object or None�spam)r�r�rW�set_exception_handlerr�s r�test_set_exc_handler_invalidz/BaseEventLoopTests.test_set_exc_handler_invalidZs���
�
#�
#�I�/J�
K�
K�	4�	4��I�+�+�F�3�3�3�	4�	4�	4�	4�	4�	4�	4�	4�	4�	4�	4�	4����	4�	4�	4�	4�	4�	4s�A�A�Ac����d����fd�}�j�d��tj���j_���j�����tj��}�j�|�����j���|��|��}|�	�jttjd��||j
d���|����j�d��tjd��5}|��|j�	tjd��t"ttf���ddd��n#1swxYwY��|j��dS)	Nc��ddzdS�Nr6rrrrrrDzBBaseEventLoopTests.test_set_exc_handler_custom.<locals>.zero_error_s��
�a�C�C�C�Crc�n���j����}�j���|Sr�rWr�r�)r�r<rDs ��r�run_loopz@BaseEventLoopTests.test_set_exc_handler_custom.<locals>.run_loopbs1����Y�(�(��4�4�F��I���!�!�!��MrTz!Exception in callback.*zero_error)�	exception�messager��source_tracebackrErIrJ)rWr�rrXrdr:�get_exception_handlerr`r�rPrSr%rQ�_source_traceback�
reset_mockr-rOrRrnr�)r<rg�mock_handlerr�rTrDs`    @r�test_set_exc_handler_customz.BaseEventLoopTests.test_set_exc_handler_custom^s����	�	�	�	�	�	�	�	�	�
	
�	���D�!�!�!�$(�I�K�K��	�!����$�)�9�9�;�;�<�<�<��y�{�{���	�'�'��5�5�5��
�
�d�i�5�5�7�7��F�F�F�������'�'��	�!�!�-� C�E�E�� &� 8�4
�4
�	�	�	�	���!�!�!��	�'�'��-�-�-�
�Z�4�
5�
5�	J���H�J�J�J��I�(�(�"�.� =�?�?�"3�X�x�!H�
)�
J�
J�
J�	J�	J�	J�	J�	J�	J�	J�	J�	J�	J�	J����	J�	J�	J�	J�	
����,�-�-�-�-�-s�AF(�(F,�/F,c�t���fd�}d�}tj���j_�j�|��tjd��5}|��|j�tj	d��tttf���ddd��dS#1swxYwYdS)Nc�t��d�}�j�|���j���dS)Nc��ddzdSrdrrrrrDzTBaseEventLoopTests.test_set_exc_handler_broken.<locals>.run_loop.<locals>.zero_error�����!����rrf)rDr<s �rrgz@BaseEventLoopTests.test_set_exc_handler_broken.<locals>.run_loop�sB���
�
�
��I���
�+�+�+��I���!�!�!�!�!rc� �td����Nr_)�AttributeError�rW�contexts  r�handlerz?BaseEventLoopTests.test_set_exc_handler_broken.<locals>.handler�s�� ��(�(�(rrEz$Unhandled error in exception handlerrJ)rrXrWrdr`r-rOrPr%rQrvrS)r<rgryrTs`   r�test_set_exc_handler_brokenz.BaseEventLoopTests.test_set_exc_handler_broken�s���	"�	"�	"�	"�	"�	)�	)�	)�%)�I�K�K��	�!��	�'�'��0�0�0�
�Z�4�
5�
5�	?���H�J�J�J��I�(�(��&�:�<�<�(�(�H�=�
)�
?�
?�
?�	?�	?�	?�	?�	?�	?�	?�	?�	?�	?�	?�	?����	?�	?�	?�	?�	?�	?s�AB-�-B1�4B1c�����d�G�fd�dtj��}|���|��j��t	j����fd�}t
jd��5}|��|j�	dd���ddd��n#1swxYwYd�}d���
|��t
jd��5}|��|j�	tjd	��d���|�
d
���|�t�d
d��t ��ddd��dS#1swxYwYdS)Nc�V��eZdZej��Zej��Z�fd�ZdS)�@BaseEventLoopTests.test_default_exc_handler_broken.<locals>.Loopc�&��|�td���ru�r)r<rx�_contexts  �r�default_exception_handlerzZBaseEventLoopTests.test_default_exc_handler_broken.<locals>.Loop.default_exception_handler�s���"�� ��(�(�(rN)rMrNrOrrXrYrdr�)r�s�r�Loopr}�sH�������!��	���I�'�d�i�k�k�O�
)�
)�
)�
)�
)�
)�
)rr�c�`��d�}��|������dS)Nc��ddzdSrdrrrrrDzXBaseEventLoopTests.test_default_exc_handler_broken.<locals>.run_loop.<locals>.zero_error�rsr)r�r�)rDrWs �rrgzDBaseEventLoopTests.test_default_exc_handler_broken.<locals>.run_loop�s:���
�
�
��N�N�:�&�&�&��N�N�����rrEz&Exception in default exception handlerTrJc� �td���)N�hamrrws  r�custom_handlerzJBaseEventLoopTests.test_default_exc_handler_broken.<locals>.custom_handler�s���U�#�#�#rz9Exception in default exception.*while handling.*in customrxrh)rrVrrpr
r[rr-rOrPr`r%rQrr��typerR)r<r�rgrTr�r�rWs     @@r�test_default_exc_handler_brokenz2BaseEventLoopTests.test_default_exc_handler_broken�sD������		)�		)�		)�		)�		)�		)�		)�;�,�		)�		)�		)��t�v�v������
�#�#�#���t�$�$�$�	�	�	�	�	��Z�4�
5�
5�	���H�J�J�J��I�(�(�8��
)�
�
�
�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	$�	$�	$����"�"�>�2�2�2�
�Z�4�
5�
5�	-���H�J�J�J��I�(�(��&�(C�D�D��
)�
�
�
�
�M�M�)�X�.�.�.��M�M�$�x�	�2�;�?�@�@�+�
-�
-�
-�	-�	-�	-�	-�	-�	-�	-�	-�	-�	-�	-�	-����	-�	-�	-�	-�	-�	-s%�0'B#�#B'�*B'�BE,�,E0�3E0c��|�td��5|j�d��ddd��n#1swxYwY|�|j�����dS)Nz'task factory must be a callable or Noner6)r�r�rW�set_task_factoryr:�get_task_factoryr�s r�test_set_task_factory_invalidz0BaseEventLoopTests.test_set_task_factory_invalid�s���
�
#�
#��@�B�B�	*�	*�
�I�&�&�q�)�)�)�	*�	*�	*�	*�	*�	*�	*�	*�	*�	*�	*����	*�	*�	*�	*�
	
���$�)�4�4�6�6�7�7�7�7�7s�A�A�
Ac����tj��|j_Gd�dtj���d�}�fd�}|�|j�����|j�|��|�	|j���|��|j�
|����}|�t|�����|j�
|��|j�d��|�|j�����|j�
|����}|�t|tj����|�t|�����|j�
|��dS)Nc��eZdZdS)�8BaseEventLoopTests.test_set_task_factory.<locals>.MyTaskNr&rrr�MyTaskr��r(rr�c��
K�dSrrrrr�coroz6BaseEventLoopTests.test_set_task_factory.<locals>.coro�������Drc����||���S�NrYr)rWr�r�s  �rrzz:BaseEventLoopTests.test_set_task_factory.<locals>.<lambda>�s���V�V�D�t�%<�%<�%<�r)rrXrWrdr
�Taskr:r�r�r��create_taskrq�
isinstancerurn)r<r��factoryr r�s    @r�test_set_task_factoryz(BaseEventLoopTests.test_set_task_factory�s����$(�I�K�K��	�!�	�	�	�	�	�W�\�	�	�	�	�	�	�=�<�<�<�����$�)�4�4�6�6�7�7�7��	�"�"�7�+�+�+��
�
�d�i�0�0�2�2�G�<�<�<��y�$�$�T�T�V�V�,�,�����
�4��0�0�1�1�1��	�$�$�T�*�*�*��	�"�"�4�(�(�(����$�)�4�4�6�6�7�7�7��y�$�$�T�T�V�V�,�,�����
�4���6�6�7�7�7�����D�&�1�1�2�2�2��	�$�$�T�*�*�*�*�*rc��d�d��}tdd|��\}}}|�|���d��td|dd���\}}}|�|���d��td|dd���\}}}|�|���d	��tdd|d�
��\}}}|�|���d��tdddd|��\}}}|�|���d	��dS)
N�
)zimport asynciozloop = asyncio.get_event_loop()zprint(loop.get_debug())z-Er2sFalser3)�PYTHONASYNCIODEBUG�
PYTHONDEVMODErGsTrue)r�z-X�dev)r�rr8�rstrip)r<�code�sts�stdout�stderrs     r�test_env_var_debugz%BaseEventLoopTests.test_env_var_debug�sn���y�y�'�(�(��/�t�T�4�@�@���V�V���������(�3�3�3�.�t�T�BD�=?�A�A�A���V�V�	
��������(�3�3�3�.�t�T�BE�=?�A�A�A���V�V�	
��������'�2�2�2�.�t�T�4�BE�G�G�G���V�V���������(�3�3�3�/�t�T�5�/3�T�;�;���V�V���������'�2�2�2�2�2rc�V���Gd�dtj���d�}G��fd�dtj��}|���|����|��}tj|����}|�|���d|_|���dS)Nc��eZdZdS)�3BaseEventLoopTests.test_create_task.<locals>.MyTaskNr&rrrr�r�	r(rr�c��
K�dSrrrrr�testz1BaseEventLoopTests.test_create_task.<locals>.testr�rc���eZdZ��fd�ZdS)�6BaseEventLoopTests.test_create_task.<locals>.EventLoopc����|����Sr�r)r<r�r�rWs  ��rr�zBBaseEventLoopTests.test_create_task.<locals>.EventLoop.create_tasks����v�d��.�.�.�.rN)rMrNrOr�)r�rWs��r�	EventLoopr�s3�������
/�
/�
/�
/�
/�
/�
/�
/rr�rYF)	r
r�rrVr[r[r��_log_destroy_pendingrp)r<r�r�r�r r�rWs     @@r�test_create_taskz#BaseEventLoopTests.test_create_tasks�����	�	�	�	�	�W�\�	�	�	�	�	�	�	/�	/�	/�	/�	/�	/�	/�	/��1�	/�	/�	/��y�{�{�����D�!�!�!��t�v�v���$�T��5�5�5�����d�F�+�+�+�%*��!��
�
�����rc��d�}tj��}|���tjd���5}|�t��5tj|��|���ddd��n#1swxYwY|�t|��d��ddd��dS#1swxYwYdS)Nc��
K�dSrrrrrr�zCBaseEventLoopTests.test_create_task_error_closes_coro.<locals>.testr�rT)�recordrYr)
r
�new_event_looprp�warnings�catch_warningsr_rsr[r8r)r<r�rW�ws    r�"test_create_task_error_closes_coroz5BaseEventLoopTests.test_create_task_error_closes_corosB��	�	�	��%�'�'���
�
����
�
$�D�
1�
1�
1�	(�Q��"�"�<�0�0�
9�
9��%�d�d�f�f�4�8�8�8�8�
9�
9�
9�
9�
9�
9�
9�
9�
9�
9�
9����
9�
9�
9�
9����S��V�V�Q�'�'�'�	(�	(�	(�	(�	(�	(�	(�	(�	(�	(�	(�	(����	(�	(�	(�	(�	(�	(s6�C�B�:C�B
	�
C�
B
	�&C�C�Cc�p�d�}tj��}|�|��d���}	|�|���d��|�|��|���dS#|�|��|���wxYw)Nc��
K�dSrrrrrr�zLBaseEventLoopTests.test_create_named_task_with_default_factory.<locals>.test*r�r�	test_task�r))r
r�r�r8�get_namerurp)r<r�rWr s    r�+test_create_named_task_with_default_factoryz>BaseEventLoopTests.test_create_named_task_with_default_factory)s���	�	�	��%�'�'���������[��9�9��	����T�]�]�_�_�k�:�:�:��#�#�D�)�)�)��J�J�L�L�L�L�L��
�#�#�D�)�)�)��J�J�L�L�L�L���s�(B
�
+B5c��d�}d�}tj��}|�|��|�|��d���}	|�|���d��|�|��|���dS#|�|��|���wxYw)Nc�.�tj||���Sr�)r
r�)rWr�s  r�task_factoryzSBaseEventLoopTests.test_create_named_task_with_custom_factory.<locals>.task_factory6s���<��4�0�0�0�0rc��
K�dSrrrrrr�zKBaseEventLoopTests.test_create_named_task_with_custom_factory.<locals>.test9r�rr�r�)r
r�r�r�r8r�rurp)r<r�r�rWr s     r�*test_create_named_task_with_custom_factoryz=BaseEventLoopTests.test_create_named_task_with_custom_factory5s���	1�	1�	1�	�	�	��%�'�'�����l�+�+�+��������[��9�9��	����T�]�]�_�_�k�:�:�:��#�#�D�)�)�)��J�J�L�L�L�L�L��
�#�#�D�)�)�)��J�J�L�L�L�L���s�(B"�"+C
c��d�}tj��|j_tj��|j_	|j�|����n#t$rYnwxYw|j���tj	��|�
|jjj��dS)Nc��K�t�r��KeyboardInterruptrrr�raise_keyboard_interruptzXBaseEventLoopTests.test_run_forever_keyboard_interrupt.<locals>.raise_keyboard_interruptI�����#�#r)rrXrWrd�call_exception_handlerrur�rprr\rnr�)r<r�s  r�#test_run_forever_keyboard_interruptz6BaseEventLoopTests.test_run_forever_keyboard_interruptEs���	$�	$�	$�%)�I�K�K��	�!�+/�9�;�;��	�(�	��I�(�(�)A�)A�)C�)C�D�D�D�D�� �	�	�	��D�	�����	����������������9�@�A�A�A�A�As�"A"�"
A/�.A/c����d�}tj���j_	�j�|����n#t
$rYnwxYw��fd��d�_	�j�����j���n#t
$rYnwxYw��	�j��dS)Nc��K�t�rr�rrrr�zZBaseEventLoopTests.test_run_until_complete_baseexception.<locals>.raise_keyboard_interrupt[r�rc�H���j���d�_dSr�)rWr�r�)�funcr<s��rr�zFBaseEventLoopTests.test_run_until_complete_baseexception.<locals>.funces ����I�N�N�����D�K�K�KrF)
rrXrWrdrur�r�r�rtrq)r<r�r�s` @r�%test_run_until_complete_baseexceptionz8BaseEventLoopTests.test_run_until_complete_baseexceptionXs����	$�	$�	$�%)�I�K�K��	�!�	��I�(�(�)A�)A�)C�)C�D�D�D�D�� �	�	�	��D�	����	�	�	�	�	�	����	��I����%�%�%��I�!�!�#�#�#�#�� �	�	�	��D�	���������$�$�$�$�$s#�"A�
A�A�%3B�
B&�%B&c���������t���d�d�����fd�}���fd����fd��|�j_�f�jjj_t
dd��D]�}��d|z��5�j��jj	���j�
�����d��ddd��n#1swxYwY��dS)Nrc�H���|vr�j�����dSdSr�rWr�)�
event_list�do_event�doer�event_sentinelr<s ����r�proc_eventszZBaseEventLoopTests.test_single_selecter_event_callback_after_stopping.<locals>.proc_eventsws3�����+�
5��y�*�*�8�4�4����
5�
5rc�F���dz
��j����dS�Nr6r�)�	callcount�clear_selectorr<s���rr�zWBaseEventLoopTests.test_single_selecter_event_callback_after_stopping.<locals>.do_event|s(�����N�I��I����/�/�/�/�/rc�\������d�jjj_dSrS)r�rWrYrZr')r�r<s��rr�z]BaseEventLoopTests.test_single_selecter_event_callback_after_stopping.<locals>.clear_selector�s&����K�K�M�M�M�68�D�I��&�3�3�3rr6�z	Loop %d/2)�objectrWrdrYrZr'r�subTestr�r�rtr8)r<r��ir�r�r�r�r�s`  @@@@@r�2test_single_selecter_event_callback_after_stoppingzEBaseEventLoopTests.test_single_selecter_event_callback_after_stoppingpsv�������� �����	���	5�	5�	5�	5�	5�	5�	5�	5�
	0�	0�	0�	0�	0�	0�	0�
	9�	9�	9�	9�	9�	9�%0��	�!�3A�2C��	��"�/��q�!���	/�	/�A����k�A�o�.�.�
/�
/��	�#�#�D�I�N�3�3�3��	�%�%�'�'�'�� � ��A�.�.�.�
/�
/�
/�
/�
/�
/�
/�
/�
/�
/�
/����
/�
/�
/�
/��	/�	/s�;AC�C	�"C	c����d��fd�}tj��|j_|j�|��tj|j��|��d��dS)Nrc����dz
�dSr�r)�counts�r�callbackz2BaseEventLoopTests.test_run_once.<locals>.callback�s����Q�J�E�E�Err6)rrXrWrdr�r%�run_oncer8)r<r�r�s  @r�
test_run_oncez BaseEventLoopTests.test_run_once�sz���
��	�	�	�	�	�%)�I�K�K��	�!��	���H�%�%�%���D�I�&�&�&������"�"�"�"�"rc���tj��|j_|j���|j���|jjj�d��dS�Nr)	rrXrWrdr�rtrYrZ�assert_called_once_withr�s r�test_run_forever_pre_stoppedz/BaseEventLoopTests.test_run_forever_pre_stopped�sZ��$(�I�K�K��	�!��	�������	�������	��"�:�:�1�=�=�=�=�=rc�����K�dddd���fd�}|��}|�������fd��tj������S)NF)�started�stopped�	finalizedc�L�K�d�d<	dD]}|WV��	d�d<dS#d�d<wxYw)NTr�)�ZERO�ONE�TWO�THREE�FOURr�r)�item�statuss �r�agenz;BaseEventLoopTests.leave_unfinalized_asyncgen.<locals>.agen�s_����� $�F�9��
+�C���D��J�J�J�J�J��'+��{�#�#�#��d��{�#�*�*�*�*s�
�#c���K�	�����d{V��}n#t$rYdSwxYw|dkrd�d<dStj�����dS)Nr�Tr�)�	__anext__�StopAsyncIterationr
r�)r��ai�iter_oner�s ���rr�z?BaseEventLoopTests.leave_unfinalized_asyncgen.<locals>.iter_one�s������
��\�\�^�^�+�+�+�+�+�+����%�
�
�
����
�����w��
�$(��y�!�������
�
�+�+�+�+�+s� �
.�.)�	__aiter__r
r�)r<r��agr�r�r�s   @@@r�leave_unfinalized_asyncgenz-BaseEventLoopTests.leave_unfinalized_asyncgen�s��������#�"�$�&�&��	+�	+�	+�	+�	+��T�V�V��
�\�\�^�^��	,�	,�	,�	,�	,�	,�	,�	��H�H�J�J�'�'�'��
rc��tj��|j_tj��|j_tj��5|j�|�����}|ds!tj
|j��|d�!|�|d��|�|d��|�|d��tj
��tj
|j��|�|d��ddd��dS#1swxYwYdS)Nr�r�r�)rrXrWrdrer�
disable_gcrurr%r�rqrnr\�r<r�s  r� test_asyncgen_finalization_by_gcz3BaseEventLoopTests.test_asyncgen_finalization_by_gc�se��$(�I�K�K��	�!�#'�9�;�;��	� �
�
�
!�
!�		1�		1��Y�1�1�$�2Q�2Q�2S�2S�T�T�F��Y�'�
2��&�t�y�1�1�1��Y�'�
2��O�O�F�9�-�.�.�.��O�O�F�9�-�.�.�.����V�K�0�1�1�1��� � � ��"�4�9�-�-�-��O�O�F�;�/�0�0�0�		1�		1�		1�		1�		1�		1�		1�		1�		1�		1�		1�		1����		1�		1�		1�		1�		1�		1s�C.E	�	E
�E
c�4�tj��|j_tj��|j_|j�d��t
j��5|j�|�	����}|ds!tj|j��|d�!|�|d��|�|d��|�
|d��|j�|j�dtj����tj|j��|�|d��ddd��dS#1swxYwYdS)NTr�r�r�)rrXrWrdrer�rrrurr%r�rqrn�run_in_executorr\rs  r�0test_asyncgen_finalization_by_gc_in_other_threadzCBaseEventLoopTests.test_asyncgen_finalization_by_gc_in_other_thread�s���%)�I�K�K��	�!�#'�9�;�;��	� ��	���D�!�!�!�
�
�
!�
!�
	1�
	1��Y�1�1�$�2Q�2Q�2S�2S�T�T�F��Y�'�
2��&�t�y�1�1�1��Y�'�
2��O�O�F�9�-�.�.�.��O�O�F�9�-�.�.�.����V�K�0�1�1�1��I�(�(��	�)�)�$��0B�C�C�
E�
E�
E��"�4�9�-�-�-��O�O�F�;�/�0�0�0�
	1�
	1�
	1�
	1�
	1�
	1�
	1�
	1�
	1�
	1�
	1�
	1����
	1�
	1�
	1�
	1�
	1�
	1s�(DF
�
F�F)0rMrNrOrUrlrvr�r�r�r�r�r�r�r�r�r�r�r�r�r�rrr"r0r=r@rUr]rarorzr�r�r�r�r�r�r�r�r�r�r�r�r�rrr	�
__classcell__�r]s@rrQrQ�s��������'�'�'�'�'����2I�I�I�+�+�+�+�+�+�=�=�=�7�7�7�+�+�+�#�#�#�
	+�	+�	+�
,�
,�
,�(�(�(�*/�/�/�&-8�-8�-8�^:�:�:�$0�0�0�;�;�;�&JO�JO�JO�X2�2�2�1�1�1�/�/�/�&=�=�=�:@�@�@�(B�B�B�6B�B�B�&4�4�4�".�".�".�H?�?�?�*.-�.-�.-�`8�8�8�+�+�+�63�3�3�<���,(�(�(�
�
�
���� B�B�B�&%�%�%�0/�/�/�<#�#�#� >�>�>� � � �D
1�
1�
1�1�1�1�1�1�1�1rrQc�8�eZdZdZd	d�Zd�Zd�Zd�Zd�Zd�Z	dS)
�MyProtoNFc�~�d|_d|_|r,tj�����|_dSdS�N�INITIALr)�state�nbytesr
�get_running_looprr�done)r<rrs  r�__init__zMyProto.__init__�sE����
�����	C��0�2�2�@�@�B�B�D�I�I�I�	C�	Crc�L�|j|vrtd|j�d|�����dS�Nzstate: z, expected: �r�AssertionError�r<�expecteds  r�
_assert_statezMyProto._assert_state�s?���:�X�%�	S� �!Q�4�:�!Q�!Q�X�!Q�!Q�R�R�R�	S�	Src�v�||_|�d��d|_|�d��dS)Nr�	CONNECTEDs%GET / HTTP/1.0
Host: example.com

)�	transportrr�write�r<rs  r�connection_madezMyProto.connection_made�s=��"������9�%�%�%� ��
����F�G�G�G�G�Grc�j�|�d��|xjt|��z
c_dS)Nr�rrr�r<�datas  r�
data_receivedzMyProto.data_received�s0�����;�'�'�'����s�4�y�y� ����rc�>�|�d��d|_dS)Nr�EOF)rrr�s r�eof_receivedzMyProto.eof_receiveds!�����;�'�'�'���
�
�
rc��|�dd��d|_|jr|j�d��dSdS)Nrr)�CLOSED�rrrr��r<r�s  r�connection_lostzMyProto.connection_lostsO�����;��.�.�.���
��9�	'��I� � ��&�&�&�&�&�	'�	'rr�)
rMrNrOrrrr"r'r*r/rrrr
r
�s��������D�C�C�C�C�S�S�S�H�H�H�!�!�!����'�'�'�'�'rr
c�8�eZdZdZd	d�Zd�Zd�Zd�Zd�Zd�Z	dS)
�MyDatagramProtoNFc�\�d|_d|_|r|���|_dSdSr)rrrrr)r<rrrWs   rrzMyDatagramProto.__init__s9����
�����	-��*�*�,�,�D�I�I�I�	-�	-rc�P�|j|krtd|j�d|�����dSrrrs  rrzMyDatagramProto._assert_states?���:��!�	S� �!Q�4�:�!Q�!Q�X�!Q�!Q�R�R�R�	S�	Src�L�||_|�d��d|_dS)Nr�INITIALIZED)rrrr!s  rr"zMyDatagramProto.connection_mades(��"������9�%�%�%�"��
�
�
rc�j�|�d��|xjt|��z
c_dS�Nr5r$)r<r&�addrs   r�datagram_receivedz!MyDatagramProto.datagram_receiveds0�����=�)�)�)����s�4�y�y� ����rc�0�|�d��dSr7)rr.s  r�error_receivedzMyDatagramProto.error_received"s�����=�)�)�)�)�)rc��|�d��d|_|jr|j�d��dSdS)Nr5r,r-r.s  rr/zMyDatagramProto.connection_lost%sM�����=�)�)�)���
��9�	'��I� � ��&�&�&�&�&�	'�	'r)FN)
rMrNrOrrrr"r9r;r/rrrr1r1s{�������D�-�-�-�-�S�S�S�#�#�#�
!�!�!�*�*�*�'�'�'�'�'rr1c����eZdZ�fd�Zejd��d���Zed���Zed���Z	d�Z
d�Zd�Zd	�Z
ejeed
��d��d���Zejejd
��d���Zd�Zd�Zd�Zd�Zd�Zed���Zd�Zejejd
��ejej� d��d��ed�������Z!ed���Z"ed���Z#ed���Z$d�Z%ed���Z&d�Z'd�Z(d �Z)d!�Z*d"�Z+d#�Z,d$�Z-d%�Z.ed&���Z/ed'���Z0ed(���Z1ed)���Z2d*�Z3d+�Z4d,�Z5ed-���Z6ejejd.��d/���Z7ed0���Z8d1�Z9ed2���Z:d3�Z;ejeed4��d5��d6���Z<ej=d7���Z>d8�Z?ejejd9kd:��d;���Z@ed<���ZAed=���ZBd>�ZCejd?��d@���ZDdA�ZEejd?��dB���ZF�xZGS)C�BaseEventLoopWithSelectorTestsc���t�����tj��|_|�|j��dSr)rTrUr
�SelectorEventLooprWr[r\s �rrUz$BaseEventLoopWithSelectorTests.setUp.s@���
���
�
�����-�/�/��	����D�I�&�&�&�&�&rzsocket.getnameinfoc��d�|_|j�|j�d����}|�|d��dS)Nc��dS)N�*r)r�s rrzzABaseEventLoopWithSelectorTests.test_getnameinfo.<locals>.<lambda>5s��"�r)�abcr4rC)�side_effectrWru�getnameinfor8)r<�m_gai�rs   r�test_getnameinfoz/BaseEventLoopWithSelectorTests.test_getnameinfo3sN��,�,����I�(�(���)>�)>�|�)L�)L�M�M������B�����rc�����	�Gd�dtj��}d����fd�}d�	ddg���	fd�}||_|�j_�j�|d	d
��}��t��5}�j�|��ddd��n#1swxYwY��	t|j��d��dS)Nc��eZdZdS)�VBaseEventLoopWithSelectorTests.test_create_connection_multiple_errors.<locals>.MyProtoNr&rrrr
rL<r(rr
c��K�ddgS�N�rr6�r3)z107.6.106.82�Pr�r��kws  r�getaddrinfozZBaseEventLoopWithSelectorTests.test_create_connection_multiple_errors.<locals>.getaddrinfo?s����7�7�9�
9rc�D���j��|i|����Sr�rWr��r��kwdsrTr<s  ��r�getaddrinfo_taskz_BaseEventLoopWithSelectorTests.test_create_connection_multiple_errors.<locals>.getaddrinfo_taskC�(����9�(�(���d�)C�d�)C�)C�D�D�Drr��err1�err2c�8���dz
�t�����r�)�OSError)r�rS�errors�idxs  ��r�_socketzVBaseEventLoopWithSelectorTests.test_create_connection_multiple_errors.<locals>._socketIs����1�H�C��&��+�&�&�&r�example.comrQzMultiple exceptions: err1, err2)r
�Protocolr rWrT�create_connectionr_r^rur8�strrh)
r<r(r
rYrar��cmr_rTr`s
`      @@@r�&test_create_connection_multiple_errorszEBaseEventLoopWithSelectorTests.test_create_connection_multiple_errors9sf������	�	�	�	�	�g�&�	�	�	�	9�	9�	9�	E�	E�	E�	E�	E�	E����&�!��	'�	'�	'�	'�	'�	'�
"��� 0��	���y�*�*�7�M�2�F�F��
�
�
�w�
'�
'�	/�2��I�(�(��.�.�.�	/�	/�	/�	/�	/�	/�	/�	/�	/�	/�	/����	/�	/�	/�	/�	
����R�\�*�*�,M�N�N�N�N�Ns�;B"�"B&�)B&c���tj��}||j_�fd�}|�j_tj��jdtj	���5�j�
tdd��}��tj	��5�j�
|��ddd��n#1swxYwY��|jj��ddd��dS#1swxYwYdS)Nc����j���}tjtjdddf}|�|g��|S)Nrr3)�	127.0.0.1rQ)rWrrr rrr�)r�rSr�r8r<s    �rrTzRBaseEventLoopWithSelectorTests.test_create_connection_timeout.<locals>.getaddrinfo^sG����)�)�)�+�+�C��N�F�$6��2�%�'�D��N�N�D�6�"�"�"��Jr�sock_connect)rErjrQ)rrXr r'rWrTr-r�r
�TimeoutErrorrdr
r_rurqrpr�)r<r(�sockrTr�s`    r�test_create_connection_timeoutz=BaseEventLoopWithSelectorTests.test_create_connection_timeoutXs�����y�{�{��'+���$�	�	�	�	�	�!,��	��
�Z�
�
�t�y�.�+2�+?��A�A�	/�	/��9�.�.�w��R�H�H�D��"�"�7�#7�8�8�
3�
3��	�,�,�T�2�2�2�
3�
3�
3�
3�
3�
3�
3�
3�
3�
3�
3����
3�
3�
3�
3��O�O�D�J�-�.�.�.�	/�	/�	/�	/�	/�	/�	/�	/�	/�	/�	/�	/����	/�	/�	/�	/�	/�	/s7�#AD�$C�?D�C	�D�C	�"D�D�	Dc��|j�tddt�����}|�t
|jj|��dS)NrbrQ�rm)rWrdr
r�r_rru�r<r�s  r�%test_create_connection_host_port_sockzDBaseEventLoopWithSelectorTests.test_create_connection_host_port_sockmsN���y�*�*��]�B�V�X�X�+�7�7�����*�d�i�&B�D�I�I�I�I�Irc�j�tjtjtj��}|5|j�t
|���}|�td��5|j�|��ddd��n#1swxYwYddd��dS#1swxYwYdS�NrpzA Stream Socket was expected)	r rrrWrdr
r�rru�r<rmr�s   r�!test_create_connection_wrong_sockz@BaseEventLoopWithSelectorTests.test_create_connection_wrong_sockrs$���}�V�^�V�->�?�?��
�	3�	3��9�.�.�w�T�.�B�B�D��'�'�
�(F�H�H�
3�
3��	�,�,�T�2�2�2�
3�
3�
3�
3�
3�
3�
3�
3�
3�
3�
3����
3�
3�
3�
3�	3�	3�	3�	3�	3�	3�	3�	3�	3�	3�	3�	3����	3�	3�	3�	3�	3�	3�5�=B(�)B�B(�B	�B(�B	�B(�(B,�/B,c�j�tjtjtj��}|5|j�t
|���}|�td��5|j�|��ddd��n#1swxYwYddd��dS#1swxYwYdSrt)	r rrrW�
create_serverr
r�rrurus   r�test_create_server_wrong_sockz<BaseEventLoopWithSelectorTests.test_create_server_wrong_sockzs$���}�V�^�V�->�?�?��
�	3�	3��9�*�*�7��*�>�>�D��'�'�
�(F�H�H�
3�
3��	�,�,�T�2�2�2�
3�
3�
3�
3�
3�
3�
3�
3�
3�
3�
3����
3�
3�
3�
3�	3�	3�	3�	3�	3�	3�	3�	3�	3�	3�	3�	3����	3�	3�	3�	3�	3�	3rwc���|j�tddd���}|�td��5|j�|��ddd��dS#1swxYwYdS�NrbrQr6)�ssl_handshake_timeoutz1ssl_handshake_timeout is only meaningful with ssl)rWryr
r�rrurqs  r�/test_create_server_ssl_timeout_for_plain_socketzNBaseEventLoopWithSelectorTests.test_create_server_ssl_timeout_for_plain_socket�s����y�&�&��]�B�a�'�A�A��
�
#�
#��C�E�E�	/�	/�
�I�(�(��.�.�.�	/�	/�	/�	/�	/�	/�	/�	/�	/�	/�	/�	/����	/�	/�	/�	/�	/�	/��A'�'A+�.A+�
SOCK_NONBLOCKz$no socket.SOCK_NONBLOCK (linux only)c��tjtjtjtjz��}|5|j�d�|���}|j�|��}|���|j�|�����ddd��dS#1swxYwYdS)Nc��dSrrrrrrzzRBaseEventLoopWithSelectorTests.test_create_server_stream_bittype.<locals>.<lambda>�s��4�rrp)	r rrr�rWryrurp�wait_closed)r<rmr��srvs    r�!test_create_server_stream_bittypez@BaseEventLoopWithSelectorTests.test_create_server_stream_bittype�s����}��N�F�.��1E�E�G�G��
�	<�	<��9�*�*�<�<�d�*�C�C�D��)�.�.�t�4�4�C��I�I�K�K�K��I�(�(����):�):�;�;�;�		<�	<�	<�	<�	<�	<�	<�	<�	<�	<�	<�	<����	<�	<�	<�	<�	<�	<s�A8B>�>C�Czno IPv6 supportc�
���fd�}	�j�|����dS#t$rL}ttd��r+|jtjkr��d��n�Yd}~dSd}~wwxYw)Nc��Z�K�tjd�dd���d{V��}	��t|j��d��|���|����d{V��dS#|���|����d{V��wxYw)Nc��dSrrrrrrzzVBaseEventLoopWithSelectorTests.test_create_server_ipv6.<locals>.main.<locals>.<lambda>�s��T�r�::1r)r
�start_server�
assertGreaterr�socketsrpr�)r�r<s �r�mainzDBaseEventLoopWithSelectorTests.test_create_server_ipv6.<locals>.main�s�������,�\�\�5�!�D�D�D�D�D�D�D�D�C�
(��"�"�3�s�{�#3�#3�Q�7�7�7��	�	�����o�o�'�'�'�'�'�'�'�'�'�'�'���	�	�����o�o�'�'�'�'�'�'�'�'�'�'���s�(A:�:0B*�
EADDRNOTAVAILzfailed to bind to ::1)rWrur^r!�errnor��skipTest)r<r��exs`  r�test_create_server_ipv6z6BaseEventLoopWithSelectorTests.test_create_server_ipv6�s����	(�	(�	(�	(�	(�	��I�(�(�����0�0�0�0�0���	�	�	����/�/�
��H�� 3�3�
��
�
�5�6�6�6�6��7�6�6�6�6�6�����	���s�",�
B�AA=�=Bc�T�tjtj��}|5|j�t|���}|�td��5|j�|��ddd��n#1swxYwYddd��dS#1swxYwYdS)NrpzA UDP Socket was expected)r rrW�create_datagram_endpointr
r�rrurus   r�(test_create_datagram_endpoint_wrong_sockzGBaseEventLoopWithSelectorTests.test_create_datagram_endpoint_wrong_sock�s���}�V�^�,�,��
�	3�	3��9�5�5�g�D�5�I�I�D��'�'�
�(C�E�E�
3�
3��	�,�,�T�2�2�2�
3�
3�
3�
3�
3�
3�
3�
3�
3�
3�
3����
3�
3�
3�
3�	3�	3�	3�	3�	3�	3�	3�	3�	3�	3�	3�	3����	3�	3�	3�	3�	3�	3s5�=B�B�9B�B		�	B�B		�
B�B!�$B!c��|j�t��}|�t|jj|��dSr�rWrdr
r_rrurqs  r�(test_create_connection_no_host_port_sockzGBaseEventLoopWithSelectorTests.test_create_connection_no_host_port_sock�s:���y�*�*�7�3�3�����*�d�i�&B�D�I�I�I�I�Irc�����d����fd�}|�j_�j�tdd��}��t
�jj|��dS)Nc��
K�gSrrrRs  rrTzYBaseEventLoopWithSelectorTests.test_create_connection_no_getaddrinfo.<locals>.getaddrinfo�s�����Irc�D���j��|i|����SrrVrWs  ��rrYz^BaseEventLoopWithSelectorTests.test_create_connection_no_getaddrinfo.<locals>.getaddrinfo_task�rZrrbrQ)rWrTrdr
r_r^ru�r<rYr�rTs`  @r�%test_create_connection_no_getaddrinfozDBaseEventLoopWithSelectorTests.test_create_connection_no_getaddrinfo�s�����	�	�	�	E�	E�	E�	E�	E�	E�!1��	���y�*�*�7�M�2�F�F������T�Y�1�4�	9�	9�	9�	9�	9rc�(���d����fd�}|�j_tj���j_t
�jj_�j�tdd��}��	t
�jj
|��dS)Nc��K�dgSrNrrRs  rrTzVBaseEventLoopWithSelectorTests.test_create_connection_connect_err.<locals>.getaddrinfo�s����7�8�8rc�D���j��|i|����SrrVrWs  ��rrYz[BaseEventLoopWithSelectorTests.test_create_connection_connect_err.<locals>.getaddrinfo_task�rZrrbrQ)rWrTrrXrkr^rErdr
r_rur�s`  @r�"test_create_connection_connect_errzABaseEventLoopWithSelectorTests.test_create_connection_connect_err�s�����	9�	9�	9�	E�	E�	E�	E�	E�	E�!1��	��!%�����	��-4��	��*��y�*�*�7�M�2�F�F������T�Y�1�4�	9�	9�	9�	9�	9rc����d����fd�}|�j_tj���j_t
�jj_�j�tddtj
���}��t
��5�j�|��ddd��dS#1swxYwYdS)Nc��K�ddgS�N)rr6rPr3)�0.0.0.1rQ)rr6rPr3)z0.0.0.2rQrrRs  rrTzSBaseEventLoopWithSelectorTests.test_create_connection_multiple.<locals>.getaddrinfo������2�2�4�
4rc�D���j��|i|����SrrVrWs  ��rrYzXBaseEventLoopWithSelectorTests.test_create_connection_multiple.<locals>.getaddrinfo_task�rZrrbrQ��family)
rWrTrrXrkr^rErdr
r rr_rur�s`  @r�test_create_connection_multiplez>BaseEventLoopWithSelectorTests.test_create_connection_multiple�s����	4�	4�	4�	E�	E�	E�	E�	E�	E�!1��	��!%�����	��-4��	��*��y�*�*��]�B�v�~�+�?�?��
�
�
�w�
'�
'�	/�	/��I�(�(��.�.�.�	/�	/�	/�	/�	/�	/�	/�	/�	/�	/�	/�	/����	/�	/�	/�	/�	/�	/s�B:�:B>�B>c����d�}||jj_d����fd�}|�j_tj���j_td���jj_	�j�
tddtjd���}��
t��5}�j�|��ddd��n#1swxYwY��t!|j���d	������|jjjj��dS)
Nc�N�|ddkrtd��}d|_|�dS)Nrr��Err)r^�strerror)r8�errs  r�bindz^BaseEventLoopWithSelectorTests.test_create_connection_multiple_errors_local_addr.<locals>.bind�s4���A�w�)�#�
��e�n�n��$����	�
�
rc��K�ddgSr�rrRs  rrTzeBaseEventLoopWithSelectorTests.test_create_connection_multiple_errors_local_addr.<locals>.getaddrinfo�r�rc�D���j��|i|����SrrVrWs  ��rrYzjBaseEventLoopWithSelectorTests.test_create_connection_multiple_errors_local_addr.<locals>.getaddrinfo_task�rZr�Err2rbrQ�Ni��r��
local_addrzMultiple exceptions: )r r'r�rWrTrrXrkr^rErdr
rr_rurqrerh�
startswithrpr�)r<r(r�rYr�rfrTs`     @r�1test_create_connection_multiple_errors_local_addrzPBaseEventLoopWithSelectorTests.test_create_connection_multiple_errors_local_addr�s|����	�	�	�-1���$�)�	4�	4�	4�	E�	E�	E�	E�	E�	E�!1��	��!%�����	��-4�V�_�_��	��*��y�*�*��]�B�v�~�#�+�%�%���
�
�w�
'�
'�	/�2��I�(�(��.�.�.�	/�	/�	/�	/�	/�	/�	/�	/�	/�	/�	/����	/�	/�	/�	/�	
����B�L�)�)�4�4�5L�M�M�N�N�N������4�:�A�B�B�B�B�Bs�/C�C�Cc��|s|`tj|_|jj}t	j��|j_t	j��|j_|j�	tjdd��}|j�|��\}}	|j
�d��|jj\}}|�|d|j��|�|d|j��|���t)j|j��n2#|���t)j|j��wxYwt,j�rTtj|_|j�	tjdd��}|j�|��\}}	|j
jd\}	|	dd�\}
}|�|
d	��|�|d��|jj\}}|�|d|j��|�|d|j��|���t)j|j��dS#|���t)j|j��wxYwdS)
Nr5rQ�r5rQr�r�r�rrz	::(0\.)*1)rr rTr'rrXrW�_add_reader�_add_writerrdr
rcru�connectrPr�r8rrrpr%r�r
r;rr��assertRegex)r<r(�allow_inet_ptonrmr�r��p�_r��address�host�ports            r�_test_create_connection_ip_addrz>BaseEventLoopWithSelectorTests._test_create_connection_ip_addr�sj���	#��"�%�1�����+�� $�	����	�� $�	����	���y�*�*�7�+;�Y��K�K���y�+�+�D�1�1���1�	.��L�+�+�O�<�<�<� ��1�I�A�v����V�H�-�x�/?�@�@�@����V�F�^�X�-A�B�B�B�
�G�G�I�I�I��"�4�9�-�-�-�-��
�G�G�I�I�I��"�4�9�-�-�-�-�����%�	2� �/�D�K��9�.�.�w�/?���K�K�D��9�/�/��5�5�D�A�q�

2�!�L�2�1�5�	��$�R�a�R�[�
��d�� � ��|�4�4�4�� � ��r�*�*�*�$�O�5�	��6�� � ���!1�8�3D�E�E�E�� � �����1E�F�F�F����	�	�	��&�t�y�1�1�1�1�1�����	�	�	��&�t�y�1�1�1�1����#	2�	2s� A+D9�9/E(�
BJ�/K	�aixzDbpo-25545: IPv6 scope id and getaddrinfo() behave differently on AIXc���tj|_|jj}tj|_tj��|j_tj��|j_	|j�
tjdd��}|j�
|��\}}	|j�d��|jj\}}|�|d|j��|�|d|j��|���t)j|j��dS#|���t)j|j��wxYw)Nz	fe80::1%1rQ)zfe80::1rQrr6r�r�)r rTr'rr�rrXrWr�r�rdr
rcrur�rPr�r8rrpr%r�)r<r(rmr�r�r�r�r�s        r�!test_create_connection_ipv6_scopez@BaseEventLoopWithSelectorTests.test_create_connection_ipv6_scope(s+��
 &�1�����+���o��� $�	����	�� $�	����	���y�*�*�7�+;�[�"�M�M���y�+�+�D�1�1���1�	.��L�+�+�,A�B�B�B� ��1�I�A�v����V�H�-�x�/@�A�A�A����V�F�^�X�-A�B�B�B�
�G�G�I�I�I��"�4�9�-�-�-�-�-��
�G�G�I�I�I��"�4�9�-�-�-�-���s
�-A+E�/E6c�2�|�|d��dSr��r�rKs  r�test_create_connection_ip_addrz=BaseEventLoopWithSelectorTests.test_create_connection_ip_addr?s���,�,�X�t�<�<�<�<�<rc�2�|�|d��dSryr�rKs  r�#test_create_connection_no_inet_ptonzBBaseEventLoopWithSelectorTests.test_create_connection_no_inet_ptonCs���,�,�X�u�=�=�=�=�=rc���tj|_|jj}tj��|j_tj��|j_dD�]\}}|j�tj
d|��}|j�|��\}}	|j�
d|f��|jj\}}	|�|	d|j��|�|	d|j��|���t'j|j����#|���t'j|j��wxYwdD]t}|j�tj
d|��}|�t,��5|j�|��ddd��n#1swxYwY�udS)N))�httprQ)shttprQrjr�r�)�nonsensesnonsense)r rTr'rrXrWr�r�rdr
rcrur�rPr�r8rrrpr%r�r_r^)
r<r(rm�servicer�r�r�r�r�r�s
          r�#test_create_connection_service_namezBBaseEventLoopWithSelectorTests.test_create_connection_service_nameGs���%�1�����+�� $�	����	�� $�	����	��8�	2�	2�M�G�T��9�.�.�w�/?�/:�G�E�E�D��9�/�/��5�5�D�A�q�
2���/�/��d�0C�D�D�D�$�O�5�	��6�� � ���!1�8�3C�D�D�D�� � �����1E�F�F�F����	�	�	��&�t�y�1�1�1�1�����	�	�	��&�t�y�1�1�1�1����.�	3�	3�G��9�.�.�w�/?�/:�G�E�E�D��"�"�7�+�+�
3�
3��	�,�,�T�2�2�2�
3�
3�
3�
3�
3�
3�
3�
3�
3�
3�
3����
3�
3�
3�
3��		3�	3s�$A-D?�?/E.�5G�G 	�#G 	c�����d����fd�}|�j_�j�tddtjd���}��t�jj|��dS)Nc��K�|dkrddgSgS)NrbrOr)r�r�rSs   rrTzXBaseEventLoopWithSelectorTests.test_create_connection_no_local_addr.<locals>.getaddrinfoes*�����}�$�
�;�;�=�=��	rc�D���j��|i|����SrrVrWs  ��rrYz]BaseEventLoopWithSelectorTests.test_create_connection_no_local_addr.<locals>.getaddrinfo_tasklrZrrbrQr�r�)	rWrTrdr
r rr_r^rur�s`  @r�$test_create_connection_no_local_addrzCBaseEventLoopWithSelectorTests.test_create_connection_no_local_addrds�����	�	�	�	E�	E�	E�	E�	E�	E� 0��	���y�*�*��]�B�v�~�#�+�%�%��	
����T�Y�1�4�	9�	9�	9�	9�	9rc����d���fd�}||_|���}�j�|���}�j�|��dS)N)z00:01:02:03:04:05r6c�H����||f���dddd�dffgS)Ni�r6r3)r8)r�r�r�rSr8r<s    ��rrTzTBaseEventLoopWithSelectorTests.test_create_connection_bluetooth.<locals>.getaddrinfo|s5������d�D�\�4�0�0�0��!�S�"�t�Q�i�0�1�1r)rTr rWrkru)r<r(rTrmr�r8s`    @r� test_create_connection_bluetoothz?BaseEventLoopWithSelectorTests.test_create_connection_bluetoothvsu����(��	2�	2�	2�	2�	2�	2� +������ � ���y�%�%�d�D�1�1���	�$�$�T�*�*�*�*�*rc
���	�tj���j_�fd�}|�jj_tj���j_�j����jj_�jjj�d��tj���j_	Gd�d���	�	fd�}|�jj	_tj
}t��}t��}�jj	����j�
tddd||���}�j�|��\}}|����jj	�||||d	d||�
���jj	����j�
tdddd||���}�j�|��\}}|����jj	�||||d	d||�
���jj	����j�
tdddd
||���}�j�|��\}}|����jj	�||||d	d
||�
��dS)Nc����j���}|�tjtjtjddfg��|S)Nr3r�)rWrrr�r rr�SOL_TCP)r�rXr.r<s   �r�mock_getaddrinfozkBaseEventLoopWithSelectorTests.test_create_connection_ssl_server_hostname_default.<locals>.mock_getaddrinfo�sR����	�'�'�)�)�A�
�L�L�6�>�6�+=�!�>�2��@�A�
B�
B�
B��Hrc��eZdZdZd�Zd�ZdS)�qBaseEventLoopWithSelectorTests.test_create_connection_ssl_server_hostname_default.<locals>._SelectorTransportMockNc�(�tj��Sr)rrX)r<�keys  r�get_extra_infoz�BaseEventLoopWithSelectorTests.test_create_connection_ssl_server_hostname_default.<locals>._SelectorTransportMock.get_extra_info�s���y�{�{�"rc�8�|j���dSr)�_sockrpr�s rrpzwBaseEventLoopWithSelectorTests.test_create_connection_ssl_server_hostname_default.<locals>._SelectorTransportMock.close�s���
� � �"�"�"�"�"r)rMrNrOr�r�rprrr�_SelectorTransportMockr��s7�������E�
#�
#�
#�
#�
#�
#�
#�
#rr�c�T��|�d�����}||_|Sr)r�r�)rm�protocol�
sslcontext�waiterrXrr�s      �r�mock_make_ssl_transportzrBaseEventLoopWithSelectorTests.test_create_connection_ssl_server_hostname_default.<locals>.mock_make_ssl_transport�s2������d�#�#�#�.�.�0�0�I�"�I�O��r�
python.orgrQT)�sslr}�ssl_shutdown_timeoutF)�server_side�server_hostnamer}r�zperl.com)r�r�r}r�r3)rrXrWrTrErkrrr'r�rb�ANYr�rmrdr
rurprP)
r<r�r�r��handshake_timeout�shutdown_timeoutr�rr�r�s
`        @r�2test_create_connection_ssl_server_hostname_defaultzQBaseEventLoopWithSelectorTests.test_create_connection_ssl_server_hostname_default�s����� $�	����	��	�	�	�	�	�-=��	��)�!%�����	��.2�i�.E�.E�.G�.G��	��+��	��+�6�6�t�<�<�<�(,�	����	�%�	#�	#�	#�	#�	#�	#�	#�	#�	�	�	�	�	�5L��	�%�1��h��"�H�H��!�8�8���	�%�0�0�2�2�2��y�*�*���r�t�&7�%5�+�7�7���y�3�3�D�9�9��	�1��������	�%�8�8���c�3��(�"3�!1�	9�	3�	3�	3�	
�	�%�0�0�2�2�2��y�*�*���r�t� *�&7�%5�	+�7�7��
�y�3�3�D�9�9��	�1��������	�%�8�8���c�3��&�"3�!1�	9�	3�	3�	3�	
�	�%�0�0�2�2�2��y�*�*���r�t� "�&7�%5�	+�7�7��
�y�3�3�D�9�9��	�1��������	�%�8�8��S�#�s�!� "�&7�%5�	9�	7�	7�	7�	7�	7rc�*�|j�tddd���}|�t|jj|��|j�tddd���}|�t|jj|��dS)Nr�rQr3)r�r�rqs  r�4test_create_connection_no_ssl_server_hostname_errorszSBaseEventLoopWithSelectorTests.test_create_connection_no_ssl_server_hostname_errors�s����y�*�*�7�L�"�;=�+�?�?�����*�d�i�&B�D�I�I�I��y�*�*�7�L�"�;G�+�I�I�����*�d�i�&B�D�I�I�I�I�Irc��|j�tddd���}|�t|jj|��|j�tddd���}|�t|jj|��t
j��}|j�tddd|���}|�|j��|�t|jj|��dS)Nr3rQT)r�)r�rm)	rWrdr
r_rrur rrp)r<r�rms   r�1test_create_connection_ssl_server_hostname_errorszPBaseEventLoopWithSelectorTests.test_create_connection_ssl_server_hostname_errors�s����y�*�*�7�B���*�E�E�����*�d�i�&B�D�I�I�I��y�*�*�7�D�"�$�*�G�G�����*�d�i�&B�D�I�I�I��}�����y�*�*�7�D�$�/3�$�+�@�@������
�#�#�#����*�d�i�&B�D�I�I�I�I�Irc���|j�tddd���}|�td��5|j�|��ddd��dS#1swxYwYdSr|)rWrdr
r�rrurqs  r�3test_create_connection_ssl_timeout_for_plain_socketzRBaseEventLoopWithSelectorTests.test_create_connection_ssl_timeout_for_plain_socket�s����y�*�*��]�B�a�+�A�A��
�
#�
#��C�E�E�	/�	/�
�I�(�(��.�.�.�	/�	/�	/�	/�	/�	/�	/�	/�	/�	/�	/�	/����	/�	/�	/�	/�	/�	/rc�����t����fd����fd�}|�j_�j�tdd��}��t�jj|�������dS)Nc���K�|d�gSr�r)r�rSr�s  �rrTzQBaseEventLoopWithSelectorTests.test_create_server_empty_host.<locals>.getaddrinfo�s�������7�D��Irc�D���j��|i|����SrrVrWs  ��rrYzVBaseEventLoopWithSelectorTests.test_create_server_empty_host.<locals>.getaddrinfo_task�rZrr3r)	r�rWrTryr
r_r^rur:)r<rYr�rTr�s`  @@r�test_create_server_empty_hostz<BaseEventLoopWithSelectorTests.test_create_server_empty_host�s�������x�x��	�	�	�	�	�
	E�	E�	E�	E�	E�	E�!1��	���i�%�%�g�r�1�5�5�����'�4�9�#?��E�E�E����$�����rc��|j�tddt�����}|�t
|jj|��dS)N�0.0.0.0rrp)rWryr
r�r_rru�r<r�s  r�!test_create_server_host_port_sockz@BaseEventLoopWithSelectorTests.test_create_server_host_port_socksN���i�%�%��Y�����&�2�2�����*�d�i�&B�C�H�H�H�H�Hrc��|j�t��}|�t|jj|��dSr)rWryr
r_rrurs  r�$test_create_server_no_host_port_sockzCBaseEventLoopWithSelectorTests.test_create_server_no_host_port_socks:���i�%�%�g�.�.�����*�d�i�&B�C�H�H�H�H�Hrc�B�tj��x}|j_|j���|_|j�d��|j�tdd��}|�	t|jj|��dS)Nr�r)rrXrWrTrrr'r�ryr
r_r^ru)r<rTr.s   r�!test_create_server_no_getaddrinfoz@BaseEventLoopWithSelectorTests.test_create_server_no_getaddrinfos���.2�i�k�k�9��d�i�+�#'�9�#:�#:�#<�#<�� �� �+�+�D�1�1�1��I�#�#�G�\�1�=�=�����'�4�9�#?��C�C�C�C�Crc��tj|_|`tj��|j_|j�tddd���}|�	t|jj|��dS)Nr�rT��
reuse_port)r rT�SO_REUSEPORTrrXr'rWryr
r_rru�r<r(r.s   r� test_create_server_nosoreuseportz?BaseEventLoopWithSelectorTests.test_create_server_nosoreuseportsm��%�1����!�'+�y�{�{���$��I�#�#��Y��d�
$�
4�
4��	
���*�d�i�&B�A�F�F�F�F�Frc��tj|_tj��|j_d|_|j�tddd���}|�	t|jj|��dS)Nr�r�rTr)r rTrrXr'r	rWryr
r_rrur
s   r�+test_create_server_soreuseport_only_definedzJBaseEventLoopWithSelectorTests.test_create_server_soreuseport_only_definedso��%�1���'+�y�{�{���$� "����I�#�#��Y��d�
$�
4�
4��	
���*�d�i�&B�A�F�F�F�F�Frc�h�Gd�dt��}dg|j_tj��x}|j_||j_|j�	tdd��}|�t|jj|��|�
|jj��dS)Nc��eZdZdZdS)�HBaseEventLoopWithSelectorTests.test_create_server_cant_bind.<locals>.ErrrON)rMrNrOr�rrrr�r-s�������H�H�Hrr�)rr6rPr3)rjit'r�r)r^rTr'rrXr r�rErWryr
r_rurqrpr��r<r(r��m_sockr�s     r�test_create_server_cant_bindz;BaseEventLoopWithSelectorTests.test_create_server_cant_bind*s���	�	�	�	�	�'�	�	�	�
0�-1���)�04�	���;����-�"%�����i�%�%�g�y�!�<�<�����'�4�9�#?��E�E�E������+�,�,�,�,�,rc��g|j_|j�td���}|�t|jj|��dS)N)�	localhostr�r�)rTr'rWr�r1r_r^ru�r<r(r�s   r�)test_create_datagram_endpoint_no_addrinfozHBaseEventLoopWithSelectorTests.test_create_datagram_endpoint_no_addrinfo9s]��,.���)��y�1�1��(8�2�:�:������T�Y�1�4�	9�	9�	9�	9�	9rc�"�|j�td���}|�t|jj|��|j�td���}|�t|jj|��dS)Nrr)rr6rr�)rWr�r1r_r�rurqs  r�(test_create_datagram_endpoint_addr_errorzGBaseEventLoopWithSelectorTests.test_create_datagram_endpoint_addr_errorBs����y�1�1���2�5�5������t�y�3�T�	;�	;�	;��y�1�1��(>�2�@�@������t�y�3�T�	;�	;�	;�	;�	;rc��tj��|j_t|jj_|j�tjd���}|�	t|jj
|��dS)N�rjr)�remote_addr)rrXrWrkr^rEr�r
�DatagramProtocolr_rurqs  r�)test_create_datagram_endpoint_connect_errzHBaseEventLoopWithSelectorTests.test_create_datagram_endpoint_connect_errLst��!%�����	��-4��	��*��y�1�1��$�2B�2�D�D������T�Y�1�4�	9�	9�	9�	9�	9rc����td|j����tj��x|j_}g|_|j��fd�dd���}|j�|��\}}|�|j	��|�
��|j��j��|�d�j
��dS)NT�rrrWc����Srr)r�s�rrzz^BaseEventLoopWithSelectorTests.test_create_datagram_endpoint_allow_broadcast.<locals>.<lambda>[s���H�rr)r�allow_broadcastr,)r1rWrrXrkr'r�rurnr�rprr8r)r<rkr�rr�r�s     @r�-test_create_datagram_endpoint_allow_broadcastzLBaseEventLoopWithSelectorTests.test_create_datagram_endpoint_allow_broadcastUs����"��D�I�F�F�F��04�	���;��	���$&��!��y�1�1�����(� �2�"�"��
�y�3�3�D�9�9��	�1�����,�-�-�-��������	�$�$�X�]�3�3�3�����8�>�2�2�2�2�2rc��tj|_t|j_|j�tjtj���}|�	t|jj
|��|j�tjd���}|�	t|jj
|��dS)Nr�rr)r rTr^rErWr�r
rrr_rurs   r�(test_create_datagram_endpoint_socket_errzGBaseEventLoopWithSelectorTests.test_create_datagram_endpoint_socket_errfs���%�1���&-���#��y�1�1��$�V�^�2�=�=������T�Y�1�4�	9�	9�	9��y�1�1��$�1A�2�C�C������T�Y�1�4�	9�	9�	9�	9�	9rzIPv6 not supported or enabledc��|j�tjdd���}|�t
|jj|��dS)Nr)r�r)rr��rWr�r
rr_rrurqs  r�0test_create_datagram_endpoint_no_matching_familyzOBaseEventLoopWithSelectorTests.test_create_datagram_endpoint_no_matching_familyus[���y�1�1��$�(�Z�2�A�A��	
�����	�4�d�	<�	<�	<�	<�	<rc�:�t|jjj_|j�tjtj	���}|�
t|jj|��|�|jjj
j��dS)Nr�)r^r r'�setblockingrErWr�r
rrr_rurqrpr�rs   r�(test_create_datagram_endpoint_setblk_errzGBaseEventLoopWithSelectorTests.test_create_datagram_endpoint_setblk_err}s���?F���$�0�<��y�1�1��$�V�^�2�=�=������T�Y�1�4�	9�	9�	9�����O�(�.�5�	7�	7�	7�	7�	7rc��|j�tj��}|�t
|jj|��dSrr(rqs  r�-test_create_datagram_endpoint_noaddr_nofamilyzLBaseEventLoopWithSelectorTests.test_create_datagram_endpoint_noaddr_nofamily�sB���y�1�1��$�&�&�����*�d�i�&B�D�I�I�I�I�Irc�|�Gd�dt��}tj|_tj��x}|j_||j_|j�	tdtj���}|�||jj
|��|�|jj��dS)Nc��eZdZdS)�SBaseEventLoopWithSelectorTests.test_create_datagram_endpoint_cant_bind.<locals>.ErrNr&rrrr�r1�r(rr�r)r�r�)r^r rTrrXr'r�rErWr�r1rr_rurqrpr�rs     r�'test_create_datagram_endpoint_cant_bindzFBaseEventLoopWithSelectorTests.test_create_datagram_endpoint_cant_bind�s���	�	�	�	�	�'�	�	�	� &�1���04�	���;����-�"%�����i�0�0��'���1�@�@��	
���#�t�y�;�S�A�A�A������+�,�,�,�,�,rc���tjtjtj��}|�d���j��fd�|���}�j�|��\}}|����j�|j����	d|j
��dS)Nrc�0��td�j���S�NTr!�r1rWr�s�rrzzSBaseEventLoopWithSelectorTests.test_create_datagram_endpoint_sock.<locals>.<lambda>�����O�$�T�Y�G�G�G�rrpr,)r rrr�rWr�rurprr8r)r<rmr�rr�s`    r�"test_create_datagram_endpoint_sockzABaseEventLoopWithSelectorTests.test_create_datagram_endpoint_sock�s�����}�V�^�V�->�?�?���	�	�"�#�#�#��i�0�0�G�G�G�G��1����#�i�:�:�3�?�?��	�8��������	�$�$�X�]�3�3�3�����8�>�2�2�2�2�2r�AF_UNIXzNo UNIX Socketsc����j��fd�tj���}�j�|��\}}��|jjtj��|����j�|j	����d|j
��dS)Nc�0��td�j���Sr5r6r�s�rrzzXBaseEventLoopWithSelectorTests.test_create_datagram_endpoint_sock_unix.<locals>.<lambda>�r7rr�r,)rWr�r r9rur8r�r�rprr)r<r�rr�s`   r�'test_create_datagram_endpoint_sock_unixzFBaseEventLoopWithSelectorTests.test_create_datagram_endpoint_sock_unix�s�����i�0�0�G�G�G�G��>�1�#�#��#�i�:�:�3�?�?��	�8������/���@�@�@��������	�$�$�X�]�3�3�3�����8�>�2�2�2�2�2rc���tj��5}tjtjtj���}|�|��|����j��fd�|tj���}�j�	|��\}}|����j�	|j
��ddd��dS#1swxYwYdS)N)r�c�0��td�j���Sr5r6r�s�rrzzaBaseEventLoopWithSelectorTests.test_create_datagram_endpoint_existing_sock_unix.<locals>.<lambda>�s����d���K�K�K�rr�)r%�unix_socket_pathr r9rr�rprWr�rur)r<�pathrmr�rr�s`     r�0test_create_datagram_endpoint_existing_sock_unixzOBaseEventLoopWithSelectorTests.test_create_datagram_endpoint_existing_sock_unix�s���
�
(�
*�
*�
	8�d��=���f�6G�H�H�H�D��I�I�d�O�O�O��J�J�L�L�L��9�5�5�K�K�K�K��V�^�6�-�-�D�#'�)�">�">�t�"D�"D��I�x��O�O�����I�(�(���7�7�7�
	8�
	8�
	8�
	8�
	8�
	8�
	8�
	8�
	8�
	8�
	8�
	8����
	8�
	8�
	8�
	8�
	8�
	8s�CC0�0C4�7C4c��Gd�d��}|j�td|�����}|�t|jj|��|j�td|�����}|�t|jj|��|j�td|�����}|�t|jj|��|j�td|�����}|�t|jj|��|j�td|���	��}|�t|jj|��|j�td
|�����}|�t|jj|��|j�td
|�����}|�t|jj|��dS)
Nc��eZdZejZdS)�\BaseEventLoopWithSelectorTests.test_create_datagram_endpoint_sock_sockopts.<locals>.FakeSockN)rMrNrOr rr�rrr�FakeSockrD�s�������$�D�D�DrrEr)r�rm)rrmr6)r�rm)�protorm)�flagsrmT)rrm)r#rm)rWr�r1r_rru)r<rEr�s   r�+test_create_datagram_endpoint_sock_sockoptszJBaseEventLoopWithSelectorTests.test_create_datagram_endpoint_sock_sockopts�s$��	%�	%�	%�	%�	%�	%�	%�	%��i�0�0��(8�x�x�z�z�1�K�K�����*�d�i�&B�C�H�H�H��i�0�0��)9���
�
�1�L�L�����*�d�i�&B�C�H�H�H��i�0�0��A�H�H�J�J�1�8�8�����*�d�i�&B�C�H�H�H��i�0�0��1�8�8�:�:�1�7�7�����*�d�i�&B�C�H�H�H��i�0�0��1�8�8�:�:�1�7�7�����*�d�i�&B�C�H�H�H��i�0�0���8�8�:�:�1�?�?�����*�d�i�&B�C�H�H�H��i�0�0��T���
�
�1�D�D�����*�d�i�&B�C�H�H�H�H�Hr�vxworksz-SO_BROADCAST is enabled by default on VxWorksc����j��fd�d���}�j�|��\}}|�d��}t	t
d��}|r=��|�t
jt
j	������|�t
jt
j
����|����j�|j����
d|j���j��fd�d|d�	��}�j�|��\}}|�d��}��|�t
jt
j����|r=��|�t
jt
j	������|�t
jt
j
����|����j�|j����
d|j��dS)
Nc�0��td�j���Sr5r6r�s�rrzzWBaseEventLoopWithSelectorTests.test_create_datagram_endpoint_sockopts.<locals>.<lambda>�r7rrrr r	r,c�0��td�j���Sr5r6r�s�rrzzWBaseEventLoopWithSelectorTests.test_create_datagram_endpoint_sockopts.<locals>.<lambda>�r7rT)r�rr#)rWr�rur�r!r rn�
getsockoptrr	�SO_BROADCASTrprr8rrrq)r<r�rr�rm�reuseport_supporteds`     r�&test_create_datagram_endpoint_sockoptszEBaseEventLoopWithSelectorTests.test_create_datagram_endpoint_sockopts�so����y�1�1�G�G�G�G�'�2�)�)��#�i�:�:�4�@�@��	�8��'�'��1�1��%�f�n�=�=���	=��������%�v�':�<�<�
=�
=�
=�	
����O�O��!�6�#6�
8�
8�	9�	9�	9�	�������	�$�$�X�]�3�3�3�����8�>�2�2�2��y�1�1�G�G�G�G�'�*� �	2�"�"��
#�i�:�:�4�@�@��	�8��'�'��1�1������O�O��!�6�#6�
8�
8�	9�	9�	9��	=��O�O�����%�v�':�<�<�
=�
=�
=�	
����O�O��!�6�#6�
8�
8�	9�	9�	9�	�������	�$�$�X�]�3�3�3�����8�>�2�2�2�2�2rc����|`tj��|j_�j��fd�dd���}��t�jj	|��dS)Nc�.��t�j���Sr�r6r�s�rrzz\BaseEventLoopWithSelectorTests.test_create_datagram_endpoint_nosoreuseport.<locals>.<lambda>����O���3�3�3�rrT�r�r)
r	rrXr r'rWr�r_rrurs`  r�+test_create_datagram_endpoint_nosoreuseportzJBaseEventLoopWithSelectorTests.test_create_datagram_endpoint_nosoreuseportsl����!�'+�y�{�{���$��y�1�1�3�3�3�3�'��2����
	
���*�d�i�&B�D�I�I�I�I�Irc����fd�}||_tj��x|jj_}tj���j_ttd��}�j�	�fd�d|���}�j�
|��\}}	|�d��|j�|j|j
|j���|���t!j�j��dS#|���t!j�j��wxYw)Nc�2����d��dS)Nz"should not have called getaddrinfo)�fail)r�rSr<s  �rrTzYBaseEventLoopWithSelectorTests.test_create_datagram_endpoint_ip_addr.<locals>.getaddrinfos����I�I�:�;�;�;�;�;rr	c�.��t�j���Sr�r6r�s�rrzzVBaseEventLoopWithSelectorTests.test_create_datagram_endpoint_ip_addr.<locals>.<lambda>(rSrrFrT)r�rFr�)rTrrXr r'r�rWr�r!r�rurPrrrrpr%r�)r<r(rTr�rOr�r�r�s`       r�%test_create_datagram_endpoint_ip_addrzDBaseEventLoopWithSelectorTests.test_create_datagram_endpoint_ip_addrsD���	<�	<�	<�	<�	<� +���37�9�;�;�>���$�)�D� $�	����	��%�f�n�=�=���y�1�1�3�3�3�3�%�*�2�,�,��
�y�+�+�D�1�1���1�	.��#�#�N�3�3�3��O�.�.�h�6F�5=�5I�4<�4G�
/�
I�
I�
I�
�G�G�I�I�I��"�4�9�-�-�-�-�-��
�G�G�I�I�I��"�4�9�-�-�-�-���s
�"AD�/Ec���tj��}t��|j_|j�t|��|�|j	j
��dSr)rrX�BlockingIOError�acceptrErW�_accept_connectionr
rnrpr��r<rms  r�test_accept_connection_retryz;BaseEventLoopWithSelectorTests.test_accept_connection_retry6sT���y�{�{��"1�"3�"3�����	�$�$�W�d�3�3�3������*�+�+�+�+�+rrEc��tj��}d|j_t	t
jd��|j_tj��|j	_
tj��|j	_|j	�t|��|�|jj��|�|jj��|j	j
�d��|j	j�t(jtjt|ddtjtjtj�	�	dS)N�
zToo many open files)rrX�filenor'r^r��EMFILEr]rErW�_remove_readerr�r^r
rqrOr�rnrprPr�ACCEPT_RETRY_DELAYr�)r<�m_logrms   r� test_accept_connection_exceptionz?BaseEventLoopWithSelectorTests.test_accept_connection_exception=s����y�{�{��#%��� �")�%�,�8M�"N�"N����#'�9�;�;��	� �#�y�{�{��	���	�$�$�W�d�3�3�3������*�+�+�+������*�+�+�+��	� �3�3�B�7�7�7��	��/�/��(��H��T�4��t�x���4�8�		E�	E�	E�	E�	Erc��d�}|j�d��|}|��}|�|j��||fD�]�}|�t
��5|j�|��ddd��n#1swxYwY|�t
��5|j�|��ddd��n#1swxYwY|�t
��5|j�d|��ddd��n#1swxYwY|�t
��5|j�	|j�
��dz|��ddd��n#1swxYwY|�t
��5|j�|j�d|����ddd��n#1swxYwY���dS)Nc��
K�dSrrrrr�simple_coroutinezLBaseEventLoopWithSelectorTests.test_call_coroutine.<locals>.simple_coroutinePr�rTr�)
rWr�rrpr_r�r�r�r�r�r�rur)r<rk�	coro_func�coro_objr�s     r�test_call_coroutinez2BaseEventLoopWithSelectorTests.test_call_coroutineOs��	�	�	�	
�	���D�!�!�!�$�	��9�;�;�������'�'�'���)�	;�	;�D��"�"�9�-�-�
*�
*��	�#�#�D�)�)�)�
*�
*�
*�
*�
*�
*�
*�
*�
*�
*�
*����
*�
*�
*�
*��"�"�9�-�-�
5�
5��	�.�.�t�4�4�4�
5�
5�
5�
5�
5�
5�
5�
5�
5�
5�
5����
5�
5�
5�
5��"�"�9�-�-�
/�
/��	�$�$�R��.�.�.�
/�
/�
/�
/�
/�
/�
/�
/�
/�
/�
/����
/�
/�
/�
/��"�"�9�-�-�
?�
?��	�!�!�$�)�.�.�"2�"2�R�"7��>�>�>�
?�
?�
?�
?�
?�
?�
?�
?�
?�
?�
?����
?�
?�
?�
?��"�"�9�-�-�
;�
;��	�,�,��I�-�-�d�D�9�9�;�;�;�
;�
;�
;�
;�
;�
;�
;�
;�
;�
;�
;����
;�
;�
;�
;��	;�	;sZ�%B�B	�B	�1C�C	�C	�=D%�%D)	�,D)	�
6F�F	�F	�14G1�1G5	�8G5	c�n�d�}d�}tj|j��|j�d��d|j_|j�||j��|j���|jjd^}}|�	|t|��zd��tj||j��|j���|j���|jjd^}}|�	|t|��zd��dS)	Nc�.�|���dSr�r�rYs r�stop_loop_cbzLBaseEventLoopWithSelectorTests.test_log_slow_callbacks.<locals>.stop_loop_cbfs���I�I�K�K�K�K�Krc��2K�|���dSrrqrYs r�stop_loop_corozNBaseEventLoopWithSelectorTests.test_log_slow_callbacks.<locals>.stop_loop_corois�����I�I�K�K�K�K�KrTgrz4^Executing <Handle.*stop_loop_cb.*> took .* seconds$rYz4^Executing <Task.*stop_loop_coro.*> took .* seconds$)r
r[rWr��slow_callback_durationr�rt�warningr�r��tupler[)r<�m_loggerrrrt�fmtr�s      r�test_log_slow_callbacksz6BaseEventLoopWithSelectorTests.test_log_slow_callbacksdsE��	�	�	�	�	�	�	��t�y�)�)�)��	���D�!�!�!�+.��	�(�	
�	���L�$�)�4�4�4��	�������%�/��2�
��d�����u�T�{�{�*�,�	-�	-�	-�
	��n�n�T�Y�7�7�d�i�H�H�H�H��	�������%�/��2�
��d�����u�T�{�{�*�,�	-�	-�	-�	-�	-r)HrMrNrOrUrr-rIr/rgrnrrrvrzr~�unittest�
skipUnlessr!r r�r
r;r�r�r�r�r�r�r�r��skipIfr9�platformr�r�r�r�r�r�r�r�r�r�r�r�rrrrr
rrrrr$r&r)r,r.r2r8r<�skip_unless_bind_unix_socketrArHrPrUrZr`rhrnrzr
rs@rr>r>,s��������'�'�'�'�'�
�T�Z�$�%�%� � �&�%� �
�O�O��\�O�<�/�/��\�/�(J�J�J�
3�3�3�3�3�3�/�/�/��X������9�9�?�A�A�<�<�A�A�<��X���3�5F�G�G���H�G��$3�3�3�J�J�J�
9�
9�
9�
9�
9�
9�/�/�/�"�C�C��\�C�<'2�'2�'2�R�X���3�5F�G�G��X�_�S�\�,�,�U�3�3�Z�\�\��.�.��\�\�\�H�G�.�&�=�=��\�=��>�>��\�>��3�3��\�3�89�9�9�$�+�+��\�+�N7�N7�N7�`J�J�J�
J�
J�
J�/�/�/� � � �"I�I�I�
I�I�I�D�D�D��G�G��\�G��G�G��\�G��-�-��\�-��9�9��\�9�;�;�;�9�9�9�3�3�3�"�9�9��\�9��X���3�5T�U�U�<�<�V�U�<��7�7��\�7�J�J�J�
�-�-��\�-�	3�	3�	3��X������3�3�5F�G�G�3�3�H�G�3��/�8�8�0�/�8�I�I�I�@�X�_�S�\�Y�.�C�E�E�-3�-3�E�E�-3�^�	J�	J��\�	J��.�.��\�.�0,�,�,��T�Z�,�-�-�E�E�.�-�E�";�;�;�*�T�Z�,�-�-�-�-�.�-�-�-�-�-�-rr>c��eZdZd�ZdS)�RunningLoopTestsc��d�}tj��}tj��}	|�td��5|�||����ddd��n#1swxYwY|���|���dS#|���|���wxYw)Nc��2K�|���dSr)rtrYs r�runnerz@RunningLoopTests.test_running_loop_within_a_loop.<locals>.runner�s�����������rzwhile another loop is running)r
r�r�rsrurp)r<r�rW�
outer_loops    r�test_running_loop_within_a_loopz0RunningLoopTests.test_running_loop_within_a_loop�s��	�	�	��%�'�'���+�-�-�
�	��'�'��(G�I�I�
<�
<��-�-�f�f�T�l�l�;�;�;�
<�
<�
<�
<�
<�
<�
<�
<�
<�
<�
<����
<�
<�
<�
<�
�J�J�L�L�L����������
�J�J�L�L�L����������s/�B&�A1�%B&�1A5�5B&�8A5�9B&�&*CN)rMrNrOr�rrrr�r��s#����������rr�c����eZdZddzZGd�dej��Ze�fd���Ze�fd���Z	�fd�Z
dd	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z�xZS)�BaseLoopSockSendfileTestss�12345abcde12345abcde12345abcde12345abcde12345abcde12345abcde12345abcde12345abcde12345abcde12345abcde12345abcde12345abcde12345abcde12345abcde12345abcde12345abcdeic�,�eZdZd�Zd�Zd�Zd�Zd�ZdS)�!BaseLoopSockSendfileTests.MyProtoc��d|_d|_t��|_|���|_d|_dSry)r��closed�	bytearrayr&rrr�r)r<rWs  rrz*BaseLoopSockSendfileTests.MyProto.__init__�s9�� �D�L��D�K�!���D�I��)�)�+�+�D�H�!�D�N�N�Nrc�"�d|_||_dSr�)r�rr!s  rr"z1BaseLoopSockSendfileTests.MyProto.connection_made�s���D�L�&�D�N�N�Nrc�:�|j�|��dSr)r&�extendr%s  rr'z/BaseLoopSockSendfileTests.MyProto.data_received�s���I���T�"�"�"�"�"rc�V�d|_|j�d��d|_dSr�)r�r�r�rr.s  rr/z1BaseLoopSockSendfileTests.MyProto.connection_lost�s*���D�K��H����%�%�%�!�D�N�N�Nrc��$K�|j�d{V��dSrrCr�s rr�z-BaseLoopSockSendfileTests.MyProto.wait_closed�s�����(�N�N�N�N�N�N�N�N�NrN)rMrNrOrr"r'r/r�rrrr
r��s_������	"�	"�	"�	'�	'�	'�	#�	#�	#�	"�	"�	"�
	�	�	�	�	rr
c���tj|_dt_ttjd��5}|�|j��ddd��n#1swxYwYt���	��dS)Ni@�wb)
r�!SENDFILE_FALLBACK_READBUFFER_SIZE�'_BaseLoopSockSendfileTests__old_bufsize�openr	�TESTFNr �DATArT�
setUpClass)�cls�fpr]s  �rr�z$BaseLoopSockSendfileTests.setUpClass�s����%�G���6?�	�3�
�)�"�D�
)�
)�	�R��H�H�S�X����	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�
���������s�A � A$�'A$c���|jt_tjtj��t
�����dSr)r�rr�r	�unlinkr�rT�
tearDownClass)r�r]s �rr�z'BaseLoopSockSendfileTests.tearDownClass�s>���69�6G�	�3����)�*�*�*�
���������rc�"��ddlm}|��|_|�|j��t	t
jd��|_|�|jj	��t�����dS)Nr)�BaseSelectorEventLoop�rb)�asyncio.selector_eventsr�rWr[r�r	r��filerrprTrU)r<r�r]s  �rrUzBaseLoopSockSendfileTests.setUp�sz���A�A�A�A�A�A�)�)�+�+��	����D�I�&�&�&���)�4�0�0��	�����	��(�(�(�
���
�
�����rFc��tjtjtj��}|�|��|�|j��|Sr)r rrr+rrp)r<�blockingrms   r�make_socketz%BaseLoopSockSendfileTests.make_socket�sE���}�V�^�V�-?�@�@������"�"�"�����
�#�#�#��rc�6�|j�|��Sr)rWrurqs  rrgz"BaseLoopSockSendfileTests.run_loop�s���y�+�+�D�1�1�1rc���������������j������j��fd�t
jdtj�������j	d�
��}td��D]i}	���j��|����ne#t$r*��tjd����Y�fwxYw���j��|��������fd�}��|����fS)Nc����Srr)rFs�rrzz3BaseLoopSockSendfileTests.prepare.<locals>.<lambda>�s���E�rrr�rbg�?c�8�������������������j�B�j�����������dSdSr)rprgr�r)rFr<�serverrms����r�cleanupz2BaseLoopSockSendfileTests.prepare.<locals>.cleanup�s�����L�L�N�N�N��M�M�&�,�,�.�.�/�/�/��J�J�L�L�L���
3���%�%�'�'�'��
�
�e�/�/�1�1�2�2�2�2�2�
3�
3r)r�r
rWrgryr
�HOSTr rr��getsocknamerrkr^r
r+r)r<r8r�r�rFr�rms`   @@@r�preparez!BaseLoopSockSendfileTests.prepare�su���������!�!�����T�Y�'�'�����t�y�6�6��M�M�M�=�-�q��� 7� I� I�J�J���~�a� �,�,�.�.���r���
	>�
	>�A�
��
�
�d�i�4�4�T�4�@�@�A�A�A�
���	�
�
�
��
�
�g�m�C�0�0�1�1�1���
����
�M�M�$�)�0�0��t�<�<�=�=�=�	3�	3�	3�	3�	3�	3�	3�	3�	
���� � � ��U�{�s�,.C�1D�Dc	��|���\}}|�tjd��5|�|j�||jdd����ddd��n#1swxYwY|�|j	d��|�|j�
��d��dS)N�sendfile is not availablerr)r�r�r
�SendfileNotAvailableErrorrgrW�_sock_sendfile_nativer�r8r&�tell�r<rmrFs   r�"test__sock_sendfile_native_failurez<BaseLoopSockSendfileTests.test__sock_sendfile_native_failure�s���l�l�n�n���e�
�
#�
#�G�$E�$?�A�A�	D�	D��M�M�$�)�9�9�$��	�:;�T�C�C�
D�
D�
D�	D�	D�	D�	D�	D�	D�	D�	D�	D�	D�	D����	D�	D�	D�	D�
	
�����S�)�)�)��������)�)�1�-�-�-�-�-��6A:�:A>�A>c��|���\}}|�tjd��5|�|j�||jd�����ddd��n#1swxYwY|�|j�	��d��|�|j
d��dS)Nr�F)�fallbackrr)r�r�r
r�rgrW�
sock_sendfiler�r8r�r&r�s   r�test_sock_sendfile_no_fallbackz8BaseLoopSockSendfileTests.test_sock_sendfile_no_fallback�s���l�l�n�n���e�
�
#�
#�G�$E�$?�A�A�	C�	C��M�M�$�)�1�1�$��	�;@�2�B�B�
C�
C�
C�	C�	C�	C�	C�	C�	C�	C�	C�	C�	C�	C����	C�	C�	C�	C�
	
�������)�)�1�-�-�-������S�)�)�)�)�)r�c��|���\}}|�|j�||j����}|���|�|�����|�|t|j	����|�|j�
��t|j	����|�|j|j	��dSr)r�rgrWr�r�rpr�r8rr�r�r&�r<rmrF�rets    r�test_sock_sendfile_fallbackz5BaseLoopSockSendfileTests.test_sock_sendfile_fallbacks����l�l�n�n���e��m�m�D�I�3�3�D�$�)�D�D�E�E���
�
�����
�
�e�'�'�)�)�*�*�*�����c�$�)�n�n�-�-�-��������)�)�3�t�y�>�>�:�:�:������T�Y�/�/�/�/�/rc���|���\}}|�|j�||jdd����}|���|�|�����|�|d��|�|j���d��|�|j	|j
dd���dS)Ni�i�r)r�rgrWr�r�rpr�r8r�r&r�r�s    r�,test_sock_sendfile_fallback_offset_and_countzFBaseLoopSockSendfileTests.test_sock_sendfile_fallback_offset_and_counts����l�l�n�n���e��m�m�D�I�3�3�D�$�)�48�$�@�@�A�A���
�
�����
�
�e�'�'�)�)�*�*�*�����d�#�#�#��������)�)�4�0�0�0������T�Y�t�D�y�%9�:�:�:�:�:rc�4�|j�d��|�d���}|�td��5|�|j�||j����ddd��dS#1swxYwYdS)NT)r�zmust be non-blocking)rWr�r�r�rrgr�r�r_s  r�test_blocking_socketz.BaseLoopSockSendfileTests.test_blocking_sockets����	���D�!�!�!������.�.��
�
#�
#�J�0F�
G�
G�	D�	D��M�M�$�)�1�1�$��	�B�B�C�C�C�	D�	D�	D�	D�	D�	D�	D�	D�	D�	D�	D�	D����	D�	D�	D�	D�	D�	Ds�4B
�
B�Bc�X�|���}ttjd���5}|�t
d��5|�|j�||����ddd��n#1swxYwYddd��dS#1swxYwYdS)Nzutf-8)�encodingzbinary mode)	r�r�r	r�r�rrgrWr�)r<rmr.s   r�test_nonbinary_filez-BaseLoopSockSendfileTests.test_nonbinary_file s=�����!�!��
�)�"�W�
5�
5�
5�	@���'�'�
�M�B�B�
@�
@��
�
�d�i�5�5�d�A�>�>�?�?�?�
@�
@�
@�
@�
@�
@�
@�
@�
@�
@�
@����
@�
@�
@�
@�	@�	@�	@�	@�	@�	@�	@�	@�	@�	@�	@�	@����	@�	@�	@�	@�	@�	@s5�B�/B�;B�B	�B�B	�B�B#�&B#c��tjtjtj��}|�d��|�|j��|�td��5|�|j	�
||j����ddd��dS#1swxYwYdS)NFzonly SOCK_STREAM type)r rrr+rrpr�rrgrWr�r�r_s  r�test_nonstream_socketz/BaseLoopSockSendfileTests.test_nonstream_socket&s����}�V�^�V�->�?�?�������������
�#�#�#�
�
#�
#�J�0G�
H�
H�	D�	D��M�M�$�)�1�1�$��	�B�B�C�C�C�	D�	D�	D�	D�	D�	D�	D�	D�	D�	D�	D�	D����	D�	D�	D�	D�	D�	Ds�44B5�5B9�<B9c	��|���}|�td��5|�|j�||jdd����ddd��dS#1swxYwYdS)N� count must be a positive integerrr��r�r�r�rgrWr�r�r_s  r�test_notint_countz+BaseLoopSockSendfileTests.test_notint_count-s������!�!��
�
#�
#�I�$F�H�H�	P�	P��M�M�$�)�1�1�$��	�1�g�N�N�O�O�O�	P�	P�	P�	P�	P�	P�	P�	P�	P�	P�	P�	P����	P�	P�	P�	P�	P�	P��6A3�3A7�:A7c	��|���}|�td��5|�|j�||jdd����ddd��dS#1swxYwYdS)Nr�rr��r�r�rrgrWr�r�r_s  r�test_negative_countz-BaseLoopSockSendfileTests.test_negative_count3s������!�!��
�
#�
#�J�$F�H�H�	K�	K��M�M�$�)�1�1�$��	�1�b�I�I�J�J�J�	K�	K�	K�	K�	K�	K�	K�	K�	K�	K�	K�	K����	K�	K�	K�	K�	K�	Kr�c��|���}|�td��5|�|j�||jd����ddd��dS#1swxYwYdS)N�%offset must be a non-negative integer�offsetr�r_s  r�test_notint_offsetz,BaseLoopSockSendfileTests.test_notint_offset9s������!�!��
�
#�
#�I�$K�M�M�	N�	N��M�M�$�)�1�1�$��	�8�L�L�M�M�M�	N�	N�	N�	N�	N�	N�	N�	N�	N�	N�	N�	N����	N�	N�	N�	N�	N�	N��5A2�2A6�9A6c��|���}|�td��5|�|j�||jd����ddd��dS#1swxYwYdS)Nr�r�r�r_s  r�test_negative_offsetz.BaseLoopSockSendfileTests.test_negative_offset?s������!�!��
�
#�
#�J�$K�M�M�	H�	H��M�M�$�)�1�1�$��	�2�F�F�G�G�G�	H�	H�	H�	H�	H�	H�	H�	H�	H�	H�	H�	H����	H�	H�	H�	H�	H�	Hr�r�)rMrNrOr�r
rcr
�classmethodr�r�rUr�rgr�r�r�r�r�r�r�r�r�r�r�r�r
rs@rr�r��s����������$�D������'�"����0������[��� � � � ��[� �
���������2�2�2����>	.�	.�	.�	*�	*�	*�	0�	0�	0�
;�
;�
;�D�D�D�@�@�@�D�D�D�P�P�P�K�K�K�N�N�N�H�H�H�H�H�H�Hrr�c�\�eZdZd�Zejeed��d��d���ZdS)�TestSelectorUtilsc�*�|�tjtj��}|�|��tj|��|�tjtj��}|�|��dSr)rMr r�TCP_NODELAYrnr�_set_nodelayrq)r<rm�opts   r�check_set_nodelayz#TestSelectorUtils.check_set_nodelayGsq���o�o�f�0�&�2D�E�E���������� ��&�&�&��o�o�f�0�&�2D�E�E����������rr�zneed socket.TCP_NODELAYc���tjtjtjtj���}|5|�|��ddd��n#1swxYwYtjtjtjtj���}|5|�d��|�|��ddd��dS#1swxYwYdS)N)r�r�rFF)r rrrr�r+r_s  r�test_set_nodelayz"TestSelectorUtils.test_set_nodelayPsQ���}�F�N��9K�#)�#5�7�7�7��
�	)�	)��"�"�4�(�(�(�	)�	)�	)�	)�	)�	)�	)�	)�	)�	)�	)����	)�	)�	)�	)��}�F�N��9K�#)�#5�7�7�7��
�	)�	)����U�#�#�#��"�"�4�(�(�(�	)�	)�	)�	)�	)�	)�	)�	)�	)�	)�	)�	)����	)�	)�	)�	)�	)�	)s#�A�A�!A�+C�C�CN)	rMrNrOr�r{r|r!r r�rrrr�r�Fsa����������X������7�7�2�4�4�
)�
)�4�4�
)�
)�
)rr��__main__)+�__doc__�concurrent.futuresr�r�rr r9r�r�r{rr
rr�test.test_asynciorr%r�r�test.support.script_helperr�test.supportr	r
r�r�rSrr*r/�TestCaser1rQrcr
rr1r>r�r�r�rMr�rrr�<module>r�s�����������������
�
�
�
�
�
�
�
�����������������������������������1�1�1�1�1�1�������7�7�7�7�7�7�"�"�"�"�"�"�&�&�&�&�&�&������8��(�(�(����":�:�:�
^H�^H�^H�^H�^H�Z�(�^H�^H�^H�BR
1�R
1�R
1�R
1�R
1��,�R
1�R
1�R
1�j'�'�'�'�'�g��'�'�'�D'�'�'�'�'�g�.�'�'�'�@R
-�R
-�R
-�R
-�R
-�Z�%8�R
-�R
-�R
-�j�����x�(����"qH�qH�qH�qH�qH�
� 3�qH�qH�qH�h)�)�)�)�)�
�+�)�)�)�4�z����H�M�O�O�O�O�O��r