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_base_events.cpython-312.pyc

�

(ΜgO>��`�dZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl	m
Z
ddlZddlmZddlm
Z
ddlmZddlmZddlmZdd	lmZdd
lmZddlZe
j2Zd�Zd�Zd
�ZGd�dej<�ZGd�dej<�Z Gd�dejB�Z"Gd�dejF�Z$Gd�dej<�Z%Gd�de	j<�Z&Gd�dej<�Z'Gd�dej<�Z(e)dk(re	jT�yy)zTests for base_events.py�N)�mock)�base_events)�	constants)�utils)�support)�assert_python_ok)�	os_helper)�
socket_helperc�.�tjd�y�N)�asyncio�set_event_loop_policy���?/usr/local/lib/python3.12/test/test_asyncio/test_base_events.py�tearDownModulers���!�!�$�'rc	�0�tjt��}dD]:}tt|�rt	||tt|���/t
||��<tj�|_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*so���~�~�6�*�H����6�4� ��H�d�G�F�D�$9�:��H�d�#���n�n�&�H�O�#-�#E�#E�#G�H�O�O� ��Orc�D�tjdt��|�S)Nzasyncio.base_events.socket)�new_callable)r�patchr*)�fs r�patch_socketr//s%��7�4�:�:�2�#5�7�78�:�:rc�(�eZdZd�Zd�Zed��Zy)�BaseEventTestsc
�&�tj}tj}tj}tj}tj
}tj}tj}|j|||ddftjdd|||��|j|||ddftjdd|||��|j|||ddftjdd|||��|j|||ddftjdd|||��|j|||ddftjdd||d��|j|||ddftjdd||d��|jtjdd|dd��tjr�|jtjdd|||��|j|||ddftjdd|||��|j|||ddftjdd|||��|jtjdd|||��|jtjd	d|||��yy)
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_info6s����!�!���~�~�������#�#���!�!��� � ��� � �����
�6�3��N�3��$�$�Y��4���E�	G�	
���
�6�3��N�3��$�$�Z��D�&�#�F�	H�	
���
�6�3��N�3��$�$�Y��6�6�3�G�	I�	
���
�5�#�r�>�2��$�$�Y��6�5�#�F�	H�
	
���
�6�3��N�3��$�$�Y��6�6�1�E�	G�
	
���
�5�#�r�>�2��$�$�Y��6�5�!�D�	F�
	
����$�$�Y��6�1�a�@�	B��%�%�����(�(��A�u�f�c�J�
L�
������R�)9�:��(�(���5�&�#�F�
H�
������R�)9�:��(�(���6�6�3�G�
I�

����(�(���4���E�
G�
����(�(��A�u�f�c�J�
L�%&rc
�0�tj}tj}tj}|j	|||ddftjdd|||��|j	|||ddftjdd|||��|j	|||ddftjdd|||��|j	|||ddftjdd|||��|j	|||ddftjdd|||��y)Nr3�r5rr5rr4�1�1)r rrrr8rr9)r<r>r@rBs    r�test_port_parameter_typesz(BaseEventTests.test_port_parameter_typesrs(���~�~���#�#��� � �����
�6�3��N�3��$�$�Y��d�F�C�H�	J�	
���
�6�3��N�3��$�$�Y��T�6�3�G�	I�	
���
�6�3��N�3��$�$�Y��D�&�#�F�	H�	
���
�6�3��N�3��$�$�Y��T�6�3�G�	I�	
���
�6�3��N�3��$�$�Y��d�F�C�H�	Jrc	��|`|jtjddtj
tjtj��y)Nr5r6)rr:rr9r rrr�r<r(s  r�test_ipaddr_info_no_inet_ptonz,BaseEventTests.test_ipaddr_info_no_inet_pton�sB�������+�2�2�9�a�39�>�>�39�3E�3E�39�3E�3E�G�	HrN)�__name__�
__module__�__qualname__rDrIr/rLrrrr1r14s%��:L�xJ�4�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.d-�Z/�xZ0S).�BaseEventLoopTestsc���t�|��tj�|_tj�|j_d|jjj_	|j|j�y�Nr)�super�setUpr�
BaseEventLoop�loopr�Mock�	_selector�selectr'�set_event_loop�r<�	__class__s �rrUzBaseEventLoopTests.setUp�sX���
��
���-�-�/��	�"�i�i�k��	�	��24��	�	���"�"�/����D�I�I�&rc	�J�tj�}|jt|jj
||�|jt|jj||||�|jt|jj||�|jt|jjg�|jt|jj�|jt|jj||�|jt|jj||�|jj|||||||�}|jt�5|jd�ddd�y#1swYyxYwr)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�sH���I�I�K�������I�I�,�,�a��	4�	
�����I�I�)�)�1�a��A�	7�	
�����I�I�.�.��1�	6�	
�������!:�!:�B�	@��������!9�!9�	;������I�I�/�/��A�	7�	
�����I�I�0�0�!�Q�	8��i�i�2�2�1�a��A�q�!�Q�G��
�
�
�2�
3��H�H�T�N�4�
3�
3�s�>F�F"c�"�|j|jj��|jj�|j	|jj��|jj�|jj�|jj�}|j
t|jj�|j
t|jj|�yr)
�assertFalserW�	is_closed�close�
assertTrue�
create_futurer_�RuntimeError�run_forever�run_until_complete)r<r.s  r�
test_closezBaseEventLoopTests.test_close�s���������,�,�.�/��	�	��������	�	�+�+�-�.�	
�	�	�����	�	����
�I�I�#�#�%�����,��	�	�(=�(=�>����,��	�	�(D�(D�a�Hrc��tjd�d|jd�}|jj|�|j	|jj
�|j
||jj�y)Nc��y�NFrrrr�<lambda>z>BaseEventLoopTests.test__add_callback_handle.<locals>.<lambda>����5rr)r
�HandlerW�
_add_callbackrn�
_scheduled�assertIn�_ready�r<�hs  r�test__add_callback_handlez,BaseEventLoopTests.test__add_callback_handle�s\���N�N�=�"�d�i�i��>���	�	����"�������-�-�.��
�
�a����)�)�*rc�4�tjd�d|jd�}|j�|jj	|�|j|jj�|j|jj�y)Nc��yryrrrrrzzHBaseEventLoopTests.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�se���N�N�=�"�d�i�i��>��	���
��	�	����"�������-�-�.�������)�)�*rc�f�Gd�dtjj�}tj�|j
_tj�|j
_|�}|j
j|�|j||j
j�y)Nc��eZdZd�Zy)�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�sq��	;�J�.�.�A�A�	;�
%)�I�I�K��	�	�!�#'�9�9�;��	�	� � �?���	�	�&�&�x�0��
�
�h��	�	� ;� ;�<rc��tj�}d}|jt|�5|jj|�ddd�|j
|jj�y#1swY�/xYw)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�9�;��<��
�
#�
#�I�s�
3��I�I�*�*�8�4�4�	
���$�)�)�5�5�6�4�
3�s�A7�7Bc���Gd�dtjj�}tj�|j
_tj�|j
_|�}|j
j|�|jtd�5|j
j|j
jd���ddd�y#1swYyxYw)Nc��eZdZddd�d�Zy)�PBaseEventLoopTests.test_shutdown_default_executor_timeout.<locals>.DummyExecutorF)�cancel_futuresc�4�|rtjd�yy)N皙�����?)�time�sleep)r<�waitr�s   r�shutdownzYBaseEventLoopTests.test_shutdown_default_executor_timeout.<locals>.DummyExecutor.shutdown�s����J�J�s�O�rN)T)rMrNrOr�rrrr�r��s��
$�E�
$rr�z&The executor did not finishing joining�{�G�z�?)�timeout)
r�r�r�rrXrWrdrer��assertWarnsRegex�RuntimeWarningru�shutdown_default_executorr�s   r�&test_shutdown_default_executor_timeoutz9BaseEventLoopTests.test_shutdown_default_executor_timeout�s���	$�J�.�.�A�A�	$�
%)�I�I�K��	�	�!�#'�9�9�;��	�	� � �?���	�	�&�&�x�0�
�
"�
"�>�#K�M��I�I�(�(��	�	�3�3�D�3�A�
C�M�M�M�s�"6C!�!C*c��d�}|jj|�}|j|j|�|j	|t
j�|j||jj�y)Nc��yrrrrr�cbz-BaseEventLoopTests.test_call_soon.<locals>.cb����r)	rW�	call_soonr8�	_callback�assertIsInstancer
r|rr��r<r�r�s   r�test_call_soonz!BaseEventLoopTests.test_call_soon�s]��	�
�I�I����#��������b�)����a����0��
�
�a����)�)�*rc���|jjd�|jtd�5|jj	d�ddd�y#1swYyxYw)NTza callable objectr6)rW�	set_debugr�r�r��r<s r�test_call_soon_non_callablez.BaseEventLoopTests.test_call_soon_non_callablesD���	�	���D�!�
�
#�
#�I�/B�
C��I�I����"�D�
C�
C�s�A�A c��d�}|jjd|�}|j|tj�|j||jj�|j||jj�|jtd��5|jjd|�ddd�y#1swYyxYw)Nc��yr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_laters���	�
�I�I� � ��r�*�����a��!4�!4�5��
�
�a����-�-�.�����D�I�I�,�,�-�
�
�
�y�.F�
�
G��I�I� � ��r�*�H�
G�
G�s�#C	�	Cc�4��g��fd�}tj�|j_|jj	d|d�|jj	d|d�tj|j�|j�ddg�y)Nc�(���j|�yr)�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_delaysss�����	�%)�I�I�K��	�	�!��	�	���R��S�)��	�	���R��S�)����t�y�y�)������c�
�+rc�D���fd�}tj��j_d}�jj	�|z}�jj||��jj	�}�jj
��jj	�|z
}�j||tjz
��jtd��5�jjd|�ddd�y#1swYyxYw)Nc�:���jj�yr�rW�stopr�s�rr�z4BaseEventLoopTests.test_time_and_call_at.<locals>.cb s����I�I�N�N�rr�zwhen cannot be Noner�)rrXrWrdr��call_atrt�assertGreaterEqualr%�	CLOCK_RESr_r�)r<r��delay�when�t0�dts`     r�test_time_and_call_atz(BaseEventLoopTests.test_time_and_call_ats����	�%)�I�I�K��	�	�!����y�y�~�~��%�'���	�	���$��#�
�Y�Y�^�^�
���	�	����
�Y�Y�^�^�
��
"��	
����E�J�,@�,@�$@�A�
�
�
�y�.C�
�
D��I�I���d�B�'�E�
D�
D�s�0D�Dc�P�d�}|j|�|r�d}|jt|�5|j|�ddd�|jt|�5|j	d|�ddd�|jt|�5|j|j
�dz|�ddd�y|j|�|j	d|�|j|j
�dz|�y#1swY��xYw#1swY��xYw#1swYyxYw)Nc��yrrrrrr�z+BaseEventLoopTests.check_thread.<locals>.cb2r�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_thread1s���	�	
���u���*�C��'�'��c�:����r�"�;��'�'��c�:�����B�'�;��'�'��c�:����T�Y�Y�[�2�-�r�2�;�:�
�N�N�2���O�O�B��#��L�L�����r�)�2�.�;�:��:�:��:�:�s#�D�D�$D�D
�D�D%c�J����fd��d�fd�	}tj��j_tj��j_|�jd�|�jd�|�jdd��|�jdd��y)Nc���|j�	|rbtj�}	tj|��j||�tjd�|j
�n�j||�|j|jd�y#tjd�|j
�wxYw#t$r&}|j|j|�Yd}~yd}~wwxYwr)r�rrVr
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_threadEs�����J�J�L�
@��'�5�5�7�E�&��.�.�u�5��)�)�$��6��.�.�t�4����
��%�%�d�E�2��)�)�#�.�.�$�?�� �.�.�t�4����
���
B��)�)�#�*;�*;�S�A�A��
B�s.�C�'B&�8C�&'C
�
C�	C?�C:�:C?Fc�"��tj�}|j�}|j|j�|||||f}tj
�|��}|j
�|j|�|j�y)N)�targetr�)	�	threading�Eventrrr��set�Thread�startru�join)rWr�r�r�r�r��threadr�s       �r�test_threadz9BaseEventLoopTests.test_check_thread.<locals>.test_threadYso����O�O�%�E��$�$�&�C��N�N�5�9�9�%��%���S�9�D��%�%�_�4�H�F��L�L�N��#�#�C�(��K�K�MrT)r��F)rrXrWrdre)r<r�r�s` @r�test_check_threadz$BaseEventLoopTests.test_check_threadDsx���	@�(	�%)�I�I�K��	�	�!�#'�9�9�;��	�	� �	�D�I�I�t�$�	�D�I�I�u�%�	�D�I�I�t��6�	�D�I�I�u�$�7rc�b�tjtj�dzd�d|jd�}tjtj�dzd�d|jd�}|j�t
j�|j_|jjj|�|jjj|�|jj�|jjjjdd}|jd|cxkxrdknc|�|j!|g|jj�|j|jjj"�y)	Ng@c��y�NTrrrrrzz3BaseEventLoopTests.test__run_once.<locals>.<lambda>ts��rrr�c��yr�rrrrrzz3BaseEventLoopTests.test__run_once.<locals>.<lambda>vs��$rrg#@g%@)r
r�r��	monotonicrWr�rrXrdr~r��	_run_oncerYrZ�	call_argsrqr8�called)r<�h1�h2�ts    r�test__run_oncez!BaseEventLoopTests.test__run_oncess(��
�
 �
 ����!1�C�!7��r�!%���D�2��
�
 �
 ����!1�D�!8�,��!%���D�2��	�	�	��$(�I�I�K��	�	�!��	�	���#�#�B�'��	�	���#�#�B�'��	�	�����I�I���&�&�0�0��3�A�6������a��$���*����"��t�y�y�3�3�4�����	�	�1�1�8�8�9rc��|jjd�|j|jj��|jjd�|j	|jj��y)NTF)rWr�rq�	get_debugrnr�s r�test_set_debugz!BaseEventLoopTests.test_set_debug�sZ���	�	���D�!�����	�	�+�+�-�.��	�	���E�"�������,�,�.�/rc�����d�d���fd�}tjtj�dz
||jf|jd�}tj�|j_|jjj|�|jj�|j��|j�gt|jj��y)NFc�.��d�|jd���y)NTc��yr�rrrrrzzOBaseEventLoopTests.test__run_once_schedule_handle.<locals>.cb.<locals>.<lambda>�s��Dr)r�)rW�handle�	processeds ��rr�z=BaseEventLoopTests.test__run_once_schedule_handle.<locals>.cb�s����I��^�^�L�1�Frr6)r
r�r�r�rWrrXrdr~r�r�rqr8�listr�)r<r�r�r
rs   @@r�test__run_once_schedule_handlez1BaseEventLoopTests.test__run_once_schedule_handle�s�������	�	2�

������ 0�1� 4�b�4�9�9�,� $�	�	�4�
1��%)�I�I�K��	�	�!��	�	���#�#�A�&��	�	�������	�"����&��4��	�	�(8�(8�#9�:rc��tj�|j_|j	dt
jcxkxrdknc�d�}d}|jjd|�d}td�D].}|jjd|�}|j��0|dz
}td�D].}|jjd|�}|j��0|j||zt
j�|j|jj|�|jj�|dz}|j|jj|�|jt|jj �||z�t#t%j&t
jt
jz��dz}t)t
j|z
d�}||z
}t|�D]}|jjd|�� ||z
}t|�D].}|jjd|�}|j��0|jt|jj �||z�|jj�|jt|jj �|�|j	t+|jj D�cgc]}|j,��c}��ycc}w)	Nrg�?c��yrrrrrr�zEBaseEventLoopTests.test__run_once_cancelled_event_cleanup.<locals>.cb�r�rr6��i�d)rrXrWrdrqr�%_MIN_CANCELLED_TIMER_HANDLES_FRACTIONr��ranger��assertLessEqual�_MIN_SCHEDULED_TIMER_HANDLESr8�_timer_cancelled_countr��lenr~�int�math�ceil�max�all�
_cancelled)r<r��not_cancelled_count�cancelled_count�xr��add_cancel_count�add_not_cancel_counts        r�&test__run_once_cancelled_event_cleanupz9BaseEventLoopTests.test__run_once_cancelled_event_cleanup�s���$(�I�I�K��	�	�!����
��A�A�G�C�G�	I�	� ���	�	���T�2�&�
���q��A��	�	�$�$�T�2�.�A�
�H�H�J��
	�1����q��A��	�	�$�$�S�"�-�A�
�H�H�J��
	
���_�/B�B��4�4�	6�	
������9�9�?�K��	�	�����1���������9�9�?�K�����T�Y�Y�1�1�2��1�1�	3�
�t�y�y��4�4��=�=�
>� ?�@�BC�D�� #�;�#K�#K��$�� !��	�3�3���+�,�A��I�I� � ��r�*�-�	�+�+���'�(�A��	�	�$�$�T�2�.�A�
�H�H�J�)�
	
����T�Y�Y�1�1�2��1�1�	3�	
�	�	����	
����T�Y�Y�1�1�2�4G�H�	
����t�y�y�7K�7K�L�7K�!����-�7K�L�M�N��Ls�#Mc�Z�|jt|jjd�y)N�blah)r_r�rWrur�s r�"test_run_until_complete_type_errorz5BaseEventLoopTests.test_run_until_complete_type_error�s!�����)��I�I�(�(�&�	2rc���|jj�}|j�}|j|j�|jt|j|�yr)rWrr�
new_test_loop�
addCleanuprpr_�
ValueErrorru)r<�task�
other_loops   r�test_run_until_complete_loopz/BaseEventLoopTests.test_run_until_complete_loop�sO���y�y�&�&�(���'�'�)�
����
�(�(�)����*��)�)�4�	1rc���Gd�dt��d�}�fd�}tj�|j_|jj|�|j
��5|jj|d��ddd�|jj|d��y#1swY�+xYw)Nc��eZdZy)�]BaseEventLoopTests.test_run_until_complete_loop_orphan_future_close_loop.<locals>.ShowStopperN�rMrNrOrrr�ShowStopperr1����rr3c��JK�tj|��d{���y7��wr�r
r�)r�s r�foozUBaseEventLoopTests.test_run_until_complete_loop_orphan_future_close_loop.<locals>.foo�s�����-�-��&�&�&�s�#�!�#c�����rr)r3s�r�throwzWBaseEventLoopTests.test_run_until_complete_loop_orphan_future_close_loop.<locals>.throw�s	����rr�g�������?)�
SystemExitrrXrWrdr�r_ru)r<r7r9r3s   @r�5test_run_until_complete_loop_orphan_future_close_loopzHBaseEventLoopTests.test_run_until_complete_loop_orphan_future_close_loop�s����	�*�	�	'�	�%)�I�I�K��	�	�!��	�	���E�"�
�
�
�{�
+��I�I�(�(��S��2�,�
	
�	�	�$�$�S��X�.�,�
+�s�("B4�4B=c��tjddg}|jt|jj
|jjtj�|jt|jj
|jjtj|�|jt|jj
|jjtjtjd�|jt|jj
|jjtjg|��ddi�|jt|jj
|jjtjg|��ddi�|jt|jj
|jjtjg|��ddi�y)	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_argss�������f�-��	
���)��I�I�(�(�$�)�)�*C�*C��&�&�	(�
	
���)��I�I�(�(�$�)�)�*C�*C��&�&��	.�
	
���)��I�I�(�(�$�)�)�*C�*C��&�&�����	=�
	����)��	�	�$�$�d�i�i�&?�&?��&�&�	H�)-�	H�BF�	H�	����)��I�I�(�(�$�)�)�*C�*C��&�&�	;�)-�	;�59�	;�	����)��I�I�(�(�$�)�)�*C�*C��&�&�	=�)-�	=�7;�	=rc	�H�|jt|jj|jjt
jd�|jt|jj|jjt
jtjddg�|jt|jj|jjt
jdd��|jt|jj|jjt
jdd��|jt|jj|jjt
jdd�	�y)
Nr?r=r>zexit 0T)r@)rArC)rB)	r_r�rWru�subprocess_shellr
rGrDrEr�s r�"test_subprocess_shell_invalid_argsz5BaseEventLoopTests.test_subprocess_shell_invalid_args%s1�����)��I�I�(�(�$�)�)�*D�*D��&�&��	-�	
���)��I�I�(�(�$�)�)�*D�*D��&�&�����v�(F�	H�
	
���)��I�I�(�(�$�)�)�*D�*D��&�&��T�	�	K�	
���)��I�I�(�(�$�)�)�*D�*D��&�&���	�	>�	
���)��I�I�(�(�$�)�)�*D�*D��&�&��$�	�	@rc���tj��j_d�}tjd�5}�jj�}�jj
||�|j�fd���jj�|jjtjd�tttf��ddd�tjd�5}�jj�}�jjd||�|j�fd���jj�|jjtjd�tttf��ddd�y#1swY��xYw#1swYyxYw)Nc�0�|jd�ddzy)NTr6r)r��r�s r�
zero_errorzHBaseEventLoopTests.test_default_exc_handler_callback.<locals>.zero_error<s���N�N�4� �
�a�Cr�asyncio.base_events.loggerc�8���jj�Srr��r�r<s �rrzzFBaseEventLoopTests.test_default_exc_handler_callback.<locals>.<lambda>D����d�i�i�n�n�.>r�Exception in callback.*zero��exc_infor�c�8���jj�Srr�rRs �rrzzFBaseEventLoopTests.test_default_exc_handler_callback.<locals>.<lambda>NrSr)rrXrWrdr-rrr��add_done_callbackrt�error�assert_called_withr%�MockPattern�ZeroDivisionError�MOCK_ANYr�)r<rO�logr�s`   r�!test_default_exc_handler_callbackz4BaseEventLoopTests.test_default_exc_handler_callback9sI���$(�I�I�K��	�	�!�	�
�Z�Z�4�
5���)�)�)�)�+�C��I�I���
�C�0��!�!�">�?��I�I�!�!�#��I�I�(�(��&�&�'D�E�+�X�x�@�
)�
B�6��Z�Z�4�
5���)�)�)�)�+�C��I�I� � ��z�3�7��!�!�">�?��I�I�!�!�#��I�I�(�(��&�&�'D�E�+�X�x�@�
)�
B�6�
5�6�
5��6�
5�s�B$F,�>B%F8�,F5�8Gc���tj��j_d�}tjd�5}tj|��j��}|j�fd���jj�d}tj�|jjtjd�tt t f��ddd�y#1swYyxYw)Nc��TK�tjd��d{���ddzy7�
�w)Nr�r6rr6rrr�zero_error_corozIBaseEventLoopTests.test_default_exc_handler_coro.<locals>.zero_error_coroWs$�����-�-��%�%�%�
�a�C�
&�s�(�&�(rP�rWc�8���jj�Srr�)r�r<s �rrzzBBaseEventLoopTests.test_default_exc_handler_coro.<locals>.<lambda>^s����	�	���0@rz.*exception was never retrievedrU)rrXrWrdr-r
�
ensure_futurerXrtr�
gc_collectrYrZr%r[r\r])r<rbr^r�s`   r�test_default_exc_handler_coroz0BaseEventLoopTests.test_default_exc_handler_coroTs����$(�I�I�K��	�	�!�	�
�Z�Z�4�
5���'�'��(9��	�	�J�C��!�!�"@�A��I�I�!�!�#��C���� ��I�I�(�(��&�&�'H�I�+�X�x�@�
)�
B�6�
5�
5�s�B*C0�0C9c��|jtd�5|jjd�ddd�y#1swYyxYw)NzA callable object or None�spam)r�r�rW�set_exception_handlerr�s r�test_set_exc_handler_invalidz/BaseEventLoopTests.test_set_exc_handler_invalidgs2��
�
#�
#�I�/J�
K��I�I�+�+�F�3�L�
K�
K�s	�<�Ac����d����fd�}�jjd�tj��j_�j�jj
��tj�}�jj|��j�jj
�|�|�}|j�jttjd�||jd��|j��jjd�tjd�5}|�|j jtjd�t"ttf��ddd��j%|j&�y#1swY�%xYw)	Nc��ddzy�Nr6rrrrrrOzBBaseEventLoopTests.test_set_exc_handler_custom.<locals>.zero_errorls	��
�a�Crc�r���jj��}�jj�|Sr�rWr�r�)r
r<rOs ��r�run_loopz@BaseEventLoopTests.test_set_exc_handler_custom.<locals>.run_loopos,����Y�Y�(�(��4�F��I�I���!��MrTz!Exception in callback.*zero_error)�	exception�messager
�source_tracebackrPrTrU)rWr�rrXrdr:�get_exception_handlerrjr�rZr]r%r[�_source_traceback�
reset_mockr-rYr\rnr�)r<rq�mock_handlerr
r^rOs`    @r�test_set_exc_handler_customz.BaseEventLoopTests.test_set_exc_handler_customksR���	�	�
	
�	�	���D�!�$(�I�I�K��	�	�!����$�)�)�9�9�;�<��y�y�{���	�	�'�'��5��
�
�d�i�i�5�5�7��F�����'�'��	�	�!�!�-�-� C�E�� &� 8� 8�4
�	�	���!��	�	�'�'��-�
�Z�Z�4�
5���J��I�I�(�(�"�.�.� =�?�"3�X�x�!H�
)�
J�6�	
����,�,�-�6�
5�s
�AG�G	c�r���fd�}d�}tj��j_�jj	|�tj
d�5}|�|jjtjd�tttf��ddd�y#1swYyxYw)Nc�v��d�}�jj|��jj�y)Nc��ddzyrnrrrrrOzTBaseEventLoopTests.test_set_exc_handler_broken.<locals>.run_loop.<locals>.zero_error��	���!�rrp)rOr<s �rrqz@BaseEventLoopTests.test_set_exc_handler_broken.<locals>.run_loop�s*���
��I�I���
�+��I�I���!rc��td���Nri)�AttributeError�rW�contexts  r�handlerz?BaseEventLoopTests.test_set_exc_handler_broken.<locals>.handler�s
�� ��(�(rrPz$Unhandled error in exception handlerrU)rrXrWrdrjr-rYrZr%r[r�r])r<rqr�r^s`   r�test_set_exc_handler_brokenz.BaseEventLoopTests.test_set_exc_handler_broken�s����	"�	)�%)�I�I�K��	�	�!��	�	�'�'��0�
�Z�Z�4�
5���J��I�I�(�(��&�&�:�<�(�(�H�=�
)�
?�6�
5�
5�s
�AB-�-B6c����d�G�fd�dtj�}|��|j�j�t	j
���fd�}t
jd�5}|�|jjdd��ddd�d�}d��j|�t
jd�5}|�|jjtjd	�d��|jd
��|jt�d
d�t �ddd�y#1swY��xYw#1swYyxYw)Nc�\��eZdZej�Zej�Z�fd�Zy)�@BaseEventLoopTests.test_default_exc_handler_broken.<locals>.Loopc���|�td��r�r+)r<r��_contexts  �r�default_exception_handlerzZBaseEventLoopTests.test_default_exc_handler_broken.<locals>.Loop.default_exception_handler�s���"�� ��(�(rN)rMrNrOrrXrYrdr�)r�s�r�Loopr��s"���!��	�	��I�'�d�i�i�k�O�
)rr�c�N��d�}�j|��j�y)Nc��ddzyrnrrrrrOzXBaseEventLoopTests.test_default_exc_handler_broken.<locals>.run_loop.<locals>.zero_error�r}r)r�r�)rOrWs �rrqzDBaseEventLoopTests.test_default_exc_handler_broken.<locals>.run_loop�s���
��N�N�:�&��N�N�rrPz&Exception in default exception handlerTrUc��td��)N�hamr�r�s  r�custom_handlerzJBaseEventLoopTests.test_default_exc_handler_broken.<locals>.custom_handler�s
���U�#�#rz9Exception in default exception.*while handling.*in customr�rr)rrVr*rpr
r[rr-rYrZrjr%r[rr��typer\)r<r�rqr^r�r�rWs     @@r�test_default_exc_handler_brokenz2BaseEventLoopTests.test_default_exc_handler_broken�s%�����		)�;�,�,�		)��v������
�
�#����t�$�	��Z�Z�4�
5���J��I�I�(�(�8��
)�
�6�	$����"�"�>�2�
�Z�Z�4�
5���J��I�I�(�(��&�&�(C�D��
)�
�
�M�M�)�X�.��M�M�$�x�	�2�;�?�@�+�
-�6�
5�6�
5��6�
5�s�1%E�	A/E
�E
�
Ec���|jtd�5|jjd�ddd�|j	|jj��y#1swY�3xYw)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�
�I�I�&�&�q�)�B�
	
���$�)�)�4�4�6�7�B�B�s�A%�%A.c���tj�|j_Gd�dtj
��d�}�fd�}|j
|jj��|jj|�|j|jj�|�|jj|��}|jt|���|jj|�|jjd�|j
|jj��|jj|��}|jt|tj
��|jt|���|jj|�y)Nc��eZdZy)�8BaseEventLoopTests.test_set_task_factory.<locals>.MyTaskNr2rrr�MyTaskr��r4rr�c��K�y�wrrrrr�coroz6BaseEventLoopTests.test_set_task_factory.<locals>.coro��	�������c����||��S�Nrcr)rWr�r�s  �rrzz:BaseEventLoopTests.test_set_task_factory.<locals>.<lambda>�s���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�s5���$(�I�I�K��	�	�!�	�W�\�\�	�	�=�����$�)�)�4�4�6�7��	�	�"�"�7�+��
�
�d�i�i�0�0�2�G�<��y�y�$�$�T�V�,�����
�4��0�1��	�	�$�$�T�*��	�	�"�"�4�(����$�)�)�4�4�6�7��y�y�$�$�T�V�,�����
�4����6�7�����D�&�1�2��	�	�$�$�T�*rc� �djd�}tdd|�\}}}|j|j�d�td|dd��\}}}|j|j�d�td|dd��\}}}|j|j�d	�tdd|d�
�\}}}|j|j�d�tdddd|�\}}}|j|j�d	�y)
N�
)zimport asynciozloop = asyncio.new_event_loop()zprint(loop.get_debug())z-Er=sFalser3)�PYTHONASYNCIODEBUG�
PYTHONDEVMODErGsTrue)r�z-X�dev)r�rr8�rstrip)r<�code�sts�stdout�stderrs     r�test_env_var_debugz%BaseEventLoopTests.test_env_var_debug�s���y�y�'�(��/�t�T�4�@���V�V��������(�3�.�t�T�BD�=?�A���V�V�	
�������(�3�.�t�T�BE�=?�A���V�V�	
�������'�2�.�t�T�4�BE�G���V�V��������(�3�/�t�T�5�/3�T�;���V�V��������'�2rc�6���Gd�dtj��d�}G��fd�dtj�}|��|j	��|�}tj
|���}|j
|��d|_|j�y)Nc��eZdZy)�3BaseEventLoopTests.test_create_task.<locals>.MyTaskNr2rrrr�r�r4rr�c��K�y�wrrrrr�testz1BaseEventLoopTests.test_create_task.<locals>.testr�r�c���eZdZ��fd�Zy)�6BaseEventLoopTests.test_create_task.<locals>.EventLoopc����|���Sr�r)r<r�r�rWs  ��rr�zBBaseEventLoopTests.test_create_task.<locals>.EventLoop.create_tasks����d��.�.rN)rMrNrOr�)r�rWs��r�	EventLoopr�s���
/rr�rcF)	r
r�rrVr[rer��_log_destroy_pendingrp)r<r�r�r�r,r�rWs     @@r�test_create_taskz#BaseEventLoopTests.test_create_tasks}���	�W�\�\�	�	�	/��1�1�	/��{�����D�!��v���$�$�T��5�����d�F�+�%*��!��
�
�rc�j�d�}tj�}|j�tjd��5}|jt�5tj|�|��ddd�|jt|�d�ddd�y#1swY�-xYw#1swYyxYw)Nc��K�y�wrrrrrr�zCBaseEventLoopTests.test_create_task_error_closes_coro.<locals>.test,r�r�T)�recordrcr)
r
�new_event_looprp�warnings�catch_warningsr_rsrer8r)r<r�rW�ws    r�"test_create_task_error_closes_coroz5BaseEventLoopTests.test_create_task_error_closes_coro+s��	��%�%�'���
�
��
�
$�
$�D�
1�Q��"�"�<�0��%�%�d�f�4�8�1����S��V�Q�'�2�
1�0�0��2�
1�s#�B)�B�1#B)�B&	�"B)�)B2c�2�d�}tj�}|j|�d��}	|j|j	�d�|j|�|j
�y#|j|�|j
�wxYw)Nc��K�y�wrrrrrr�zLBaseEventLoopTests.test_create_named_task_with_default_factory.<locals>.test7r�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_factory6s{��	��%�%�'�������[��9��	����T�]�]�_�k�:��#�#�D�)��J�J�L��
�#�#�D�)��J�J�L�s� A3�3#Bc�Z�d�}d�}tj�}|j|�|j|�d��}	|j	|j�d�|j
|�|j�y#|j
|�|j�wxYw)Nc�0�tj||��Sr�)r
r�)rWr�s  r�task_factoryzSBaseEventLoopTests.test_create_named_task_with_custom_factory.<locals>.task_factoryCs���<�<��4�0�0rc��K�y�wrrrrrr�zKBaseEventLoopTests.test_create_named_task_with_custom_factory.<locals>.testFr�r�r�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_factoryBs���	1�	��%�%�'�����l�+������[��9��	����T�]�]�_�k�:��#�#�D�)��J�J�L��
�#�#�D�)��J�J�L�s� B�#B*c��d�}tj�|j_tj�|j_	|jj|��|jj�tj�|j|jjj�y#t$rY�iwxYw)Nc��K�t��wr��KeyboardInterruptrrr�raise_keyboard_interruptzXBaseEventLoopTests.test_run_forever_keyboard_interrupt.<locals>.raise_keyboard_interruptV�����#�#���	)rrXrWrd�call_exception_handlerrur�rprrfrnr�)r<r�s  r�#test_run_forever_keyboard_interruptz6BaseEventLoopTests.test_run_forever_keyboard_interruptRs���	$�%)�I�I�K��	�	�!�+/�9�9�;��	�	�(�	��I�I�(�(�)A�)C�D�	
�	�	��������������9�9�@�@�A��!�	��	�s� C	�		C�Cc�����d�}tj��j_�j	t
�5�jj
|��ddd���fd��d�_�jj�jj���jj��j�j�y#1swY�|xYw)Nc��K�t��wrr�rrrr�zZBaseEventLoopTests.test_run_until_complete_baseexception.<locals>.raise_keyboard_interrupthr�r�c�H���jj�d�_yr�)rWr�r�)�funcr<s��rr�zFBaseEventLoopTests.test_run_until_complete_baseexception.<locals>.funcps����I�I�N�N���D�KrF)rrXrWrdr_r�rur�r�rtrq)r<r�r�s` @r�%test_run_until_complete_baseexceptionz8BaseEventLoopTests.test_run_until_complete_baseexceptiones����	$�%)�I�I�K��	�	�!�
�
�
�0�
1��I�I�(�(�)A�)C�D�2�	�����	�	���D�I�I�/�/��6��	�	����������$�2�
1�s�!C�C#c���������t��d�d�����fd�}���fd����fd��|�j_�f�jjj_t
dd�D]z}�jd|z�5�jj�jj��jj��j�d�ddd��|y#1swY��xYw)Nrc�F���|vr�jj���yyr�rWr�)�
event_list�do_event�doer�event_sentinelr<s ����r�proc_eventszZBaseEventLoopTests.test_single_selecter_event_callback_after_stopping.<locals>.proc_eventss$�����+��y�y�*�*�8�4��,rc�F���dz
��jj��y�Nr6r�)�	callcount�clear_selectorr<s���rr�zWBaseEventLoopTests.test_single_selecter_event_callback_after_stopping.<locals>.do_event�s�����N�I��I�I����/rc�p���j�d�jjj_yrS)r�rWrYrZr')r�r<s��rr�z]BaseEventLoopTests.test_single_selecter_event_callback_after_stopping.<locals>.clear_selector�s$����K�K�M�68�D�I�I���&�&�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_stoppingxs���� ����	���	5�
	0�
	9�%0��	�	�!�3A�2C��	�	���"�"�/��q�!��A����k�A�o�.��	�	�#�#�D�I�I�N�N�3��	�	�%�%�'�� � ��A�.�/�.��.�.�s
�AC+�+C4	c����d��fd�}tj�|j_|jj	|�tj|j�|j�d�y)Nrc����dz
�yr�r)�counts�r�callbackz2BaseEventLoopTests.test_run_once.<locals>.callback�s����Q�J�Err6)rrXrWrdr�r%�run_oncer8)r<r�r�s  @r�
test_run_oncez BaseEventLoopTests.test_run_once�sW���
��	�%)�I�I�K��	�	�!��	�	���H�%����D�I�I�&������"rc��tj�|j_|jj	�|jj�|jjjjd�y�Nr)	rrXrWrdr�rtrYrZ�assert_called_once_withr�s r�test_run_forever_pre_stoppedz/BaseEventLoopTests.test_run_forever_pre_stopped�sP��$(�I�I�K��	�	�!��	�	�����	�	�����	�	���"�"�:�:�1�=rc�����K�dddd���fd�}|�}|j�����fd��tj����S�w)NF)�started�stopped�	finalizedc�R�K�d�d<	dD]}|����		d�d<y#d�d<wxYw�w)NTr�)�ZERO�ONE�TWO�THREE�FOURr�r)�item�statuss �r�agenz;BaseEventLoopTests.leave_unfinalized_asyncgen.<locals>.agen�s<����� $�F�9��
+�C�D��J�D�'+��{�#��d��{�#�s�'��'�$�'c���K�	�j��d{���}|dk(rd�d<ytj���y7�*#t$rYywxYw�w)NrTr�)�	__anext__�StopAsyncIterationr
r�)r�ai�iter_oners ���rrz?BaseEventLoopTests.leave_unfinalized_asyncgen.<locals>.iter_one�sV�����
��\�\�^�+���w��$(��y�!������
�+�
,��%�
��
�s7�A�A�A�A�&A�A�	A�A�A�A)�	__aiter__r
r�)r<r�agr
rrs   @@@r�leave_unfinalized_asyncgenz-BaseEventLoopTests.leave_unfinalized_asyncgen�sN�����#�"�$�&��	+��V��
�\�\�^��	,�	���H�J�'��
�s�AAc��tj�|j_tj�|j_tj�5|jj|j��}|ds%tj|j�|ds�%|j|d�|j|d�|j|d�tj�tj|j�|j|d�ddd�y#1swYyxYw)Nr�r�r�)rrXrWrdrer�
disable_gcrurr%r�rqrnrf�r<rs  r� test_asyncgen_finalization_by_gcz3BaseEventLoopTests.test_asyncgen_finalization_by_gc�s���$(�I�I�K��	�	�!�#'�9�9�;��	�	� �
�
�
�
!��Y�Y�1�1�$�2Q�2Q�2S�T�F��Y�'��&�&�t�y�y�1��Y�'��O�O�F�9�-�.��O�O�F�9�-�.����V�K�0�1���� ��"�"�4�9�9�-��O�O�F�;�/�0�"�
!�
!�s�AD;�/BD;�;Ec�"�tj�|j_tj�|j_|jjd�t
j�5|jj|j��}|ds%tj|j�|ds�%|j|d�|j|d�|j|d�|jj|jjdtj��tj|j�|j|d�ddd�y#1swYyxYw)NTr�r�r�)rrXrWrdrer�rrrurr%r�rqrn�run_in_executorrfrs  r�0test_asyncgen_finalization_by_gc_in_other_threadzCBaseEventLoopTests.test_asyncgen_finalization_by_gc_in_other_thread�s��%)�I�I�K��	�	�!�#'�9�9�;��	�	� ��	�	���D�!�
�
�
�
!��Y�Y�1�1�$�2Q�2Q�2S�T�F��Y�'��&�&�t�y�y�1��Y�'��O�O�F�9�-�.��O�O�F�9�-�.����V�K�0�1��I�I�(�(��	�	�)�)�$��0B�0B�C�
E��"�"�4�9�9�-��O�O�F�;�/�0�"�
!�
!�s�6AF�
B2F�F)1rMrNrOrUrlrvr�r�r�r�r�r�r�r�r�r�r�r�rrr
r$r'r.r;rHrKr_rgrkryr�r�r�r�r�r�r�r�r�r�r�r�r�r�rrr�
__classcell__�r]s@rrQrQ�s����'��2I�+�+�=�7�C� +�#�
	+�
,�(�$/�&-8�^:�$0�;�&JO�X2�1�/�&=�:@�(B�6B�&4�".�H?�*.-�`8�+�63�<�,(�
�� B�&%�&/�<#� >� �D
1�1rrQc�6�eZdZdZdd�Zd�Zd�Zd�Zd�Zd�Z	y)	�MyProtoNc�t�d|_d|_|r(tj�j	�|_yy�N�INITIALr)�state�nbytesr
�get_running_looprr�done)r<rrs  r�__init__zMyProto.__init__�s1����
������0�0�2�@�@�B�D�I�rc�V�|j|vrtd|j�d|����y�Nzstate: z, expected: �r�AssertionError�r<�expecteds  r�
_assert_statezMyProto._assert_state�s/���:�:�X�%� �7�4�:�:�.��X�L�!Q�R�R�&rc�d�||_|jd�d|_|jd�y)Nr�	CONNECTEDs%GET / HTTP/1.0
Host: example.com

)�	transportr(r�write�r<r+s  r�connection_madezMyProto.connection_made�s+��"������9�%� ��
����F�Grc�b�|jd�|xjt|�z
c_y)Nr*�r(rr�r<�datas  r�
data_receivedzMyProto.data_receiveds"�����;�'����s�4�y� �rc�4�|jd�d|_y)Nr*�EOF)r(rr�s r�eof_receivedzMyProto.eof_received	s�����;�'���
rc��|jdd�d|_|jr|jjd�yy)Nr*r5�CLOSED�r(rr r��r<r�s  r�connection_lostzMyProto.connection_lost
s7�����;��.���
��9�9��I�I� � ��&�rr�)
rMrNrOr r!r(r.r3r6r;rrrrr�s(���D�C�S�H�!��'rrc�6�eZdZdZdd�Zd�Zd�Zd�Zd�Zd�Z	y)	�MyDatagramProtoNc�P�d|_d|_|r|j�|_yyr)rrrrr )r<rrrWs   rr!zMyDatagramProto.__init__s(����
������*�*�,�D�I�rc�X�|j|k7rtd|j�d|����yr#r$r&s  rr(zMyDatagramProto._assert_states/���:�:��!� �7�4�:�:�.��X�L�!Q�R�R�"rc�B�||_|jd�d|_y)Nr�INITIALIZED)r+r(rr-s  rr.zMyDatagramProto.connection_made!s��"������9�%�"��
rc�b�|jd�|xjt|�z
c_y�NrAr0)r<r2�addrs   r�datagram_receivedz!MyDatagramProto.datagram_received&s"�����=�)����s�4�y� �rc�&�|jd�yrC)r(r:s  r�error_receivedzMyDatagramProto.error_received*s�����=�)rc��|jd�d|_|jr|jjd�yy)NrAr8r9r:s  rr;zMyDatagramProto.connection_lost-s5�����=�)���
��9�9��I�I� � ��&�r)FN)
rMrNrOr r!r(r.rErGr;rrrr=r=s&���D�-�S�#�
!�*�'rr=c�z��eZdZ�fd�Zej
d�d��Zed��Zed��Z	d�Z
d�Zd�Zd	�Z
ejeed
�d�d��Zejej(d
�d��Zd�Zd�Zd�Zd�Zd�Zed��Zd�Zejej(d
�ej:ej>jAd�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-��Z6ejej(d.�d/��Z7ed0��Z8d1�Z9ed2��Z:d3�Z;ejeed4�d5�d6��Z<ejzd7��Z>d8�Z?ej:ej>d9k(d:�d;��Z@ed<��ZAed=��ZBd>�ZCej
d?�d@��ZDdA�ZEej
d?�dB��ZF�xZGS)C�BaseEventLoopWithSelectorTestsc���t�|��tj�|_|j|j�yr)rTrUr
�SelectorEventLooprWr[r\s �rrUz$BaseEventLoopWithSelectorTests.setUp6s.���
��
���-�-�/��	����D�I�I�&rzsocket.getnameinfoc��d�|_|jj|jjd��}|j	|d�y)Nc��y)N�*r)r�s rrzzABaseEventLoopWithSelectorTests.test_getnameinfo.<locals>.<lambda>=s��"r)�abcr?rO)�side_effectrWru�getnameinfor8)r<�m_gai�rs   r�test_getnameinfoz/BaseEventLoopWithSelectorTests.test_getnameinfo;s=��,����I�I�(�(����)>�)>�|�)L�M������B�rc����	�
�Gd�dtj�}d��	�	�fd�}d�
ddg���
fd�}||_|�j_�jj|d	d
�}�j
t�5}�jj|�ddd��jtj�d�d�
�jj|d	d
d�
�}�j
t�5}�jj|�ddd��j|jt�|jjD]}�j|t��y#1swY��xYw#1swY�gxYw)Nc��eZdZy)�VBaseEventLoopWithSelectorTests.test_create_connection_multiple_errors.<locals>.MyProtoNr2rrrrrXDr4rrc��K�ddgS�w�N�rr6�r3)z107.6.106.82�Pr�r��kws  r�getaddrinfozZBaseEventLoopWithSelectorTests.test_create_connection_multiple_errors.<locals>.getaddrinfoGs����7�7�9�
9���c�F���jj�|i|���Sr�rWr��r��kwdsr`r<s  ��r�getaddrinfo_taskz_BaseEventLoopWithSelectorTests.test_create_connection_multiple_errors.<locals>.getaddrinfo_taskK�"����9�9�(�(��d�)C�d�)C�D�Drr��err1�err2c�*���dz
�t����r�)�OSError)r�r_�errors�idxs  ��r�_socketzVBaseEventLoopWithSelectorTests.test_create_connection_multiple_errors.<locals>._socketQs����1�H�C��&��+�&�&r�example.comr]zMultiple exceptions: err1, err2T��
all_errors)r
�Protocolr rWr`�create_connectionr_rkrur8�strrr�ExceptionGroupr��
exceptions)r<r(rrfrnr��cm�erlr`rms`       @@@r�&test_create_connection_multiple_errorszEBaseEventLoopWithSelectorTests.test_create_connection_multiple_errorsAs<���	�g�&�&�	�	9�	E����&�!��	'�
"��� 0��	�	���y�y�*�*�7�M�2�F��
�
�
�w�
'�2��I�I�(�(��.�(�	
����R�\�\�*�,M�N����y�y�*�*�7�M�2�RV�*�W��
�
�
�~�
.�"��I�I�(�(��.�/�	
���b�l�l�N�;����(�(�A��!�!�!�W�-�)�(�
'��/�
.�s�=E2�<E>�2E;�>Fc�D��tj�}||j_�fd�}|�j_tjj�jdtj��5�jjtdd�}�jtj�5�jj|�ddd��j|jj �ddd�y#1swY�7xYw#1swYyxYw)Nc����jj�}tjtjdddf}|j|g�|S)Nrr3)�	127.0.0.1r])rWrrr rrr�)r�r_r�rDr<s    �rr`zRBaseEventLoopWithSelectorTests.test_create_connection_timeout.<locals>.getaddrinfoosE����)�)�)�)�+�C��N�N�F�$6�$6��2�%�'�D��N�N�D�6�"��Jr�sock_connect)rQr|r])rrXr r'rWr`r-r�r
�TimeoutErrorrsrr_rurqrpr�)r<r(�sockr`r�s`    r�test_create_connection_timeoutz=BaseEventLoopWithSelectorTests.test_create_connection_timeoutis�����y�y�{��'+����$�	�!,��	�	��
�Z�Z�
�
�t�y�y�.�+2�+?�+?��A��9�9�.�.�w��R�H�D��"�"�7�#7�#7�8��	�	�,�,�T�2�9��O�O�D�J�J�-�-�.�A�A�9�8��A�A�s%�7AD�8D
�-D�
D	�D�Dc��|jjtddt���}|j	t
|jj|�y)Nror]�r)rWrsrr�r_r+ru�r<r�s  r�%test_create_connection_host_port_sockzDBaseEventLoopWithSelectorTests.test_create_connection_host_port_sock~sB���y�y�*�*��]�B�V�X�+�7�����*�d�i�i�&B�&B�D�Irc�d�tjtjtj�}|5|jj	t
|��}|j
td�5|jj|�ddd�ddd�y#1swY�xYw#1swYyxYw�Nr�zA Stream Socket was expected)	r rrrWrsrr�r+ru�r<rr�s   r�!test_create_connection_wrong_sockz@BaseEventLoopWithSelectorTests.test_create_connection_wrong_sock�s����}�}�V�^�^�V�->�->�?��
��9�9�.�.�w�T�.�B�D��'�'�
�(F�H��	�	�,�,�T�2�H��T�H�H���T��#�8B&�-B�	B&�B#	�B&�&B/c�d�tjtjtj�}|5|jj	t
|��}|j
td�5|jj|�ddd�ddd�y#1swY�xYw#1swYyxYwr�)	r rrrW�
create_serverrr�r+rur�s   r�test_create_server_wrong_sockz<BaseEventLoopWithSelectorTests.test_create_server_wrong_sock�s����}�}�V�^�^�V�->�->�?��
��9�9�*�*�7��*�>�D��'�'�
�(F�H��	�	�,�,�T�2�H��T�H�H���T�r�c���|jjtddd��}|jtd�5|jj|�ddd�y#1swYyxYw�Nror]r6)�ssl_handshake_timeoutz1ssl_handshake_timeout is only meaningful with ssl)rWr�rr�r+rur�s  r�/test_create_server_ssl_timeout_for_plain_socketzNBaseEventLoopWithSelectorTests.test_create_server_ssl_timeout_for_plain_socket�sa���y�y�&�&��]�B�a�'�A��
�
#�
#��C�E�
�I�I�(�(��.�E�E�E���A�A(�
SOCK_NONBLOCKz$no socket.SOCK_NONBLOCK (linux only)c��tjtjtjtjz�}|5|jjd�|��}|jj
|�}|j�|jj
|j��ddd�y#1swYyxYw)Nc��yrrrrrrzzRBaseEventLoopWithSelectorTests.test_create_server_stream_bittype.<locals>.<lambda>�s��4rr�)	r rrr�rWr�rurp�wait_closed)r<rr��srvs    r�!test_create_server_stream_bittypez@BaseEventLoopWithSelectorTests.test_create_server_stream_bittype�s����}�}��N�N�F�.�.��1E�1E�E�G��
��9�9�*�*�<�d�*�C�D��)�)�.�.�t�4�C��I�I�K��I�I�(�(����):�;�	�T�T�s
�A3C�Czno IPv6 supportc����fd�}	�jj|��y#t$rJ}ttd�r/|jtj
k(r�j
d�n�Yd}~yd}~wwxYw)Nc��N�K�tjd�dd��d{���}	�jt|j�d�|j�|j
��d{���y7�S7�#|j�|j
��d{���7wxYw�w)Nc��yrrrrrrzzVBaseEventLoopWithSelectorTests.test_create_server_ipv6.<locals>.main.<locals>.<lambda>�s��Tr�::1r)r
�start_server�
assertGreaterr�socketsrpr�)r�r<s �r�mainzDBaseEventLoopWithSelectorTests.test_create_server_ipv6.<locals>.main�s}������,�,�\�5�!�D�D�C�
(��"�"�3�s�{�{�#3�Q�7��	�	���o�o�'�'�'�E��
(���	�	���o�o�'�'�'�sD�B%�A3�B%�%A7�
#B%�-A5�.B%�5B%�7$B"�B�B"�"B%�
EADDRNOTAVAILzfailed to bind to ::1)rWrurkr!�errnor��skipTest)r<r��exs`  r�test_create_server_ipv6z6BaseEventLoopWithSelectorTests.test_create_server_ipv6�sb���	(�	��I�I�(�(���0���	����/��H�H�� 3� 3�3��
�
�5�6��7��	�s� )�	A<�AA7�7A<c�F�tjtj�}|5|jjt|��}|jtd�5|jj|�ddd�ddd�y#1swY�xYw#1swYyxYw)Nr�zA datagram socket was expected)r rrW�create_datagram_endpointrr�r+rur�s   r�(test_create_datagram_endpoint_wrong_sockzGBaseEventLoopWithSelectorTests.test_create_datagram_endpoint_wrong_sock�sx���}�}�V�^�^�,��
��9�9�5�5�g�D�5�I�D��'�'�
�(H�J��	�	�,�,�T�2�J��T�J�J���T�s#�8B�B�:B�B	�B�B c��|jjt�}|jt|jj
|�yr�rWrsrr_r+rur�s  r�(test_create_connection_no_host_port_sockzGBaseEventLoopWithSelectorTests.test_create_connection_no_host_port_sock�s2���y�y�*�*�7�3�����*�d�i�i�&B�&B�D�Irc�����d����fd�}|�j_�jjtdd�}�j	t
�jj|�y)Nc��K�gS�wrrr^s  rr`zYBaseEventLoopWithSelectorTests.test_create_connection_no_getaddrinfo.<locals>.getaddrinfo�s�����I�s�c�F���jj�|i|���Srrcrds  ��rrfz^BaseEventLoopWithSelectorTests.test_create_connection_no_getaddrinfo.<locals>.getaddrinfo_task�rgrror])rWr`rsrr_rkru�r<rfr�r`s`  @r�%test_create_connection_no_getaddrinfozDBaseEventLoopWithSelectorTests.test_create_connection_no_getaddrinfo�sS���	�	E�!1��	�	���y�y�*�*�7�M�2�F������T�Y�Y�1�1�4�	9rc� ���d����fd�}|�j_tj��j_t
�jj_�jjtdd�}�jt
�jj|��jjtddd��}�jt�5}�jj|�ddd��jjt��jt|jj �d��j|jj dt
�y#1swY��xYw)	Nc��K�dgS�wrZrr^s  rr`zVBaseEventLoopWithSelectorTests.test_create_connection_connect_err.<locals>.getaddrinfo�s����7�8�8�s�c�F���jj�|i|���Srrcrds  ��rrfz[BaseEventLoopWithSelectorTests.test_create_connection_connect_err.<locals>.getaddrinfo_task�rgrror]Trpr6r)rWr`rrXr}rkrQrsrr_rurur�rrr8rrv)r<rfr�rwr`s`   @r�"test_create_connection_connect_errzABaseEventLoopWithSelectorTests.test_create_connection_connect_err�s���	9�	E�!1��	�	��!%�����	�	��-4��	�	���*��y�y�*�*�7�M�2�F������T�Y�Y�1�1�4�	9��y�y�*�*�7�M�2�RV�*�W��
�
�
�~�
.�"��I�I�(�(��.�/�	
���b�l�l�N�;�����R�\�\�4�4�5�q�9����b�l�l�5�5�a�8�'�B�/�
.�s�#F�F
c�<���d����fd�}|�j_tj��j_t
�jj_�jjtddtj��}�jt
�5�jj|�ddd��jjtddtjd��}�jt�5}�jj|�ddd��jjt�|jj D]}�j|t
��y#1swY��xYw#1swY�gxYw)Nc��K�ddgS�w�N)rr6r\r3)�0.0.0.1r])rr6r\r3)z0.0.0.2r]rr^s  rr`zSBaseEventLoopWithSelectorTests.test_create_connection_multiple.<locals>.getaddrinfo������2�2�4�
4�rac�F���jj�|i|���Srrcrds  ��rrfzXBaseEventLoopWithSelectorTests.test_create_connection_multiple.<locals>.getaddrinfo_task�rgrror]��familyT)r�rq)rWr`rrXr}rkrQrsrr rr_rurur�rrrv)r<rfr�rwrxr`s`    @r�test_create_connection_multiplez>BaseEventLoopWithSelectorTests.test_create_connection_multiple�s)���	4�	E�!1��	�	��!%�����	�	��-4��	�	���*��y�y�*�*��]�B�v�~�~�+�?��
�
�
�w�
'��I�I�(�(��.�(��y�y�*�*��]�B�v�~�~�$�+�P��
�
�
�~�
.�"��I�I�(�(��.�/�	
���b�l�l�N�;����(�(�A��!�!�!�W�-�)�(�
'��
/�
.�s�%F�F�F�Fc�`���d�}||jj_d����fd�}|�j_tj��j_td��jj_	�jjtddtjd��}�jt�5}�jj|�ddd��jt!j"�j%d	���j|jjj&j(��jjtddtjdd
��}�jt*�5}�jj|�ddd��j-|j"t*�|j"j.D]}�j-|t��y#1swY��4xYw#1swY�hxYw)Nc�<�|ddk(rtd�}d|_|�y)Nrr��Err)rk�strerror)rD�errs  r�bindz^BaseEventLoopWithSelectorTests.test_create_connection_multiple_errors_local_addr.<locals>.binds(���A�w�)�#��e�n��$����	�$rc��K�ddgS�wr�rr^s  rr`zeBaseEventLoopWithSelectorTests.test_create_connection_multiple_errors_local_addr.<locals>.getaddrinfo
r�rac�F���jj�|i|���Srrcrds  ��rrfzjBaseEventLoopWithSelectorTests.test_create_connection_multiple_errors_local_addr.<locals>.getaddrinfo_taskrgr�Err2ror]�Ni��r��
local_addrzMultiple exceptions: T)r�r�rq)r r'r�rWr`rrXr}rkrQrsrrr_rurqrtrr�
startswithrpr�rur�rv)r<r(r�rfr�rwrxr`s`      @r�1test_create_connection_multiple_errors_local_addrzPBaseEventLoopWithSelectorTests.test_create_connection_multiple_errors_local_addrs����	�-1����$�$�)�	4�	E�!1��	�	��!%�����	�	��-4�V�_��	�	���*��y�y�*�*��]�B�v�~�~�#�+�%���
�
�w�
'�2��I�I�(�(��.�(�	
����B�L�L�)�4�4�5L�M�N�������4�4�:�:�A�A�B��y�y�*�*��]�B�v�~�~�#��+�6���
�
�~�
.�"��I�I�(�(��.�/�	
���b�l�l�N�;����(�(�A��!�!�!�W�-�)�(�
'��/�
.�s�	H�!H$�H!�$H-c��|s|`tj|_|jj}t	j
�|j_t	j
�|j_|jjtjdd�}|jj|�\}}	|jjd�|jj\}}|j!|d|j"�|j!|d|j$�|j'�t)j*|j�t,j.�r-tj0|_|jjtjdd�}|jj|�\}}	|jjd\}	|	dd\}
}|j5|
d	�|j!|d�|jj\}}|j!|d|j0�|j!|d|j$�|j'�t)j*|j�yy#|j'�t)j*|j�wxYw#|j'�t)j*|j�wxYw)
Nr5r]�r5r]r�r�r�rrz	::(0\.)*1)rr r`r'rrXrW�_add_reader�_add_writerrsr
rrru�connectrZr�r8rrrpr%r�r
r;rr��assertRegex)r<r(�allow_inet_ptonrr�r�p�_r��address�host�ports            r�_test_create_connection_ip_addrz>BaseEventLoopWithSelectorTests._test_create_connection_ip_addr+s7����"�%�1�1������+�+�� $�	�	���	�	�� $�	�	���	�	���y�y�*�*�7�+;�+;�Y��K���y�y�+�+�D�1���1�	.��L�L�+�+�O�<� ���1�1�I�A�v����V�H�-�x�/?�/?�@����V�F�^�X�-A�-A�B�
�G�G�I��"�"�4�9�9�-��%�%� �/�/�D�K��9�9�.�.�w�/?�/?���K�D��9�9�/�/��5�D�A�q�

2�!�L�L�2�2�1�5�	��$�R�a�[�
��d�� � ��|�4�� � ��r�*�$�O�O�5�5�	��6�� � ���!1�8�3D�3D�E�� � �����1E�1E�F����	��&�&�t�y�y�1�#&��
�G�G�I��"�"�4�9�9�-��$���	��&�&�t�y�y�1�s�A2J �BK� 1K�1L�aixzDbpo-25545: IPv6 scope id and getaddrinfo() behave differently on AIXc�N�tj|_|jj}tj|_tj�|j_tj�|j_	|jjtjdd�}|jj|�\}}	|jjd�|jj \}}|j#|d|j�|j#|d|j$�|j'�t)j*|j�y#|j'�t)j*|j�wxYw)Nz	fe80::1%1r])zfe80::1r]rr6r�r�)r r`r'rr�rrXrWr�r�rsr
rrrur�rZr�r8rrpr%r�)r<r(rr�rr�r�r�s        r�!test_create_connection_ipv6_scopez@BaseEventLoopWithSelectorTests.test_create_connection_ipv6_scopeTs ��
 &�1�1������+�+���o�o��� $�	�	���	�	�� $�	�	���	�	���y�y�*�*�7�+;�+;�[�"�M���y�y�+�+�D�1���1�	.��L�L�+�+�,A�B� ���1�1�I�A�v����V�H�-�x�/@�/@�A����V�F�^�X�-A�-A�B�
�G�G�I��"�"�4�9�9�-��
�G�G�I��"�"�4�9�9�-�s
�A2E3�31F$c�(�|j|d�yr��r�rKs  r�test_create_connection_ip_addrz=BaseEventLoopWithSelectorTests.test_create_connection_ip_addrks���,�,�X�t�<rc�(�|j|d�yryr�rKs  r�#test_create_connection_no_inet_ptonzBBaseEventLoopWithSelectorTests.test_create_connection_no_inet_ptonos���,�,�X�u�=rc�*�tj|_|jj}tj�|j
_tj�|j
_dD]�\}}|j
jtjd|�}|j
j|�\}}	|jjd|f�|jj\}}	|j|	d|j �|j|	d|j"�|j%�t'j(|j
���dD]f}|j
jtjd|�}|j+t,�5|j
j|�ddd��hy#|j%�t'j(|j
�wxYw#1swY��xYw)N))�httpr])shttpr]r|r�r�)�nonsensesnonsense)r r`r'rrXrWr�r�rsr
rrrur�rZr�r8rrrpr%r�r_rk)
r<r(r�servicer�r�rr�r�r�s
          r�#test_create_connection_service_namezBBaseEventLoopWithSelectorTests.test_create_connection_service_namess���%�1�1������+�+�� $�	�	���	�	�� $�	�	���	�	��8�M�G�T��9�9�.�.�w�/?�/?�/:�G�E�D��9�9�/�/��5�D�A�q�
2����/�/��d�0C�D�$�O�O�5�5�	��6�� � ���!1�8�3C�3C�D�� � �����1E�1E�F����	��&�&�t�y�y�1�9�/�G��9�9�.�.�w�/?�/?�/:�G�E�D��"�"�7�+��	�	�,�,�T�2�,�+�	/�����	��&�&�t�y�y�1��,�+�s�A4G�.H	�1H�	H	c����d����fd�}|�j_�jjtddtj
d��}�j
t�jj|�y)Nc�� K�|dk(rddgSgS�w)Nror[r)r�r�r_s   rr`zXBaseEventLoopWithSelectorTests.test_create_connection_no_local_addr.<locals>.getaddrinfo�s%�����}�$�;�;�=�=��	�s�c�F���jj�|i|���Srrcrds  ��rrfz]BaseEventLoopWithSelectorTests.test_create_connection_no_local_addr.<locals>.getaddrinfo_task�rgrror]r�r�)	rWr`rsrr rr_rkrur�s`  @r�$test_create_connection_no_local_addrzCBaseEventLoopWithSelectorTests.test_create_connection_no_local_addr�sd���	�	E� 0��	�	���y�y�*�*��]�B�v�~�~�#�+�%��	
����T�Y�Y�1�1�4�	9rc����d���fd�}||_|j�}�jj|��}�jj	|�y)N)z00:01:02:03:04:05r6c�@���j||f��dddd�dffgS)Ni�r6r3)r8)r�r�r�r_rDr<s    ��rr`zTBaseEventLoopWithSelectorTests.test_create_connection_bluetooth.<locals>.getaddrinfo�s/������d�D�\�4�0��!�S�"�t�Q�i�0�1�1r)r`r rWr}ru)r<r(r`rr�rDs`    @r� test_create_connection_bluetoothz?BaseEventLoopWithSelectorTests.test_create_connection_bluetooth�sM���(��	2� +������ ���y�y�%�%�d�D�1���	�	�$�$�T�*rc
�V��	�tj��j_�fd�}|�jj_tj��j_�jj
��jj
_�jj
jjd�tj��j_	Gd�d��	�	fd�}|�jj_tj}t�}t�}�jjj��jjtddd||��}�jj|�\}}|j!��jjj#||||d	d||�
��jjj��jjtdddd||��}�jj|�\}}|j!��jjj#||||d	d||�
��jjj��jjtdddd
||��}�jj|�\}}|j!��jjj#||||d	d
||�
�y)Nc����jj�}|jtjtj
tjddfg�|S)Nr3r�)rWrrr�r rr�SOL_TCP)r�rer.r<s   �r�mock_getaddrinfozkBaseEventLoopWithSelectorTests.test_create_connection_ssl_server_hostname_default.<locals>.mock_getaddrinfo�sL����	�	�'�'�)�A�
�L�L�6�>�>�6�+=�+=�!�>�>�2��@�A�
B��Hrc��eZdZdZd�Zd�Zy)�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�y�{�"rc�8�|jj�yr)�_sockrpr�s rrpzwBaseEventLoopWithSelectorTests.test_create_connection_ssl_server_hostname_default.<locals>._SelectorTransportMock.close�s���
�
� � �"r)rMrNrOr�r�rprrr�_SelectorTransportMockr��s���E�
#�
#rr�c�F��|jd���}||_|Sr)r�r�)r�protocol�
sslcontext�waiterrer+r�s      �r�mock_make_ssl_transportzrBaseEventLoopWithSelectorTests.test_create_connection_ssl_server_hostname_default.<locals>.mock_make_ssl_transport�s&������d�#�.�0�I�"�I�O��r�
python.orgr]T)�sslr��ssl_shutdown_timeoutF)�server_side�server_hostnamer�r�zperl.com)r�rr�r�r3)rrXrWr`rQr}rrr'r�rb�ANYr�rwrsrrurprZ)
r<r�r�r�handshake_timeout�shutdown_timeoutr�r+r�r�s
`        @r�2test_create_connection_ssl_server_hostname_defaultzQBaseEventLoopWithSelectorTests.test_create_connection_ssl_server_hostname_default�s���� $�	�	���	�	��	�-=��	�	���)�!%�����	�	��.2�i�i�.E�.E�.G��	�	���+��	�	���+�+�6�6�t�<�(,�	�	���	�	�%�	#�	#�	�5L��	�	�%�%�1��h�h��"�H��!�8���	�	�%�%�0�0�2��y�y�*�*���r�t�&7�%5�+�7���y�y�3�3�D�9��	�1������	�	�%�%�8�8���c�3��(�"3�!1�	9�	3�	
�	�	�%�%�0�0�2��y�y�*�*���r�t� *�&7�%5�	+�7��
�y�y�3�3�D�9��	�1������	�	�%�%�8�8���c�3��&�"3�!1�	9�	3�	
�	�	�%�%�0�0�2��y�y�*�*���r�t� "�&7�%5�	+�7��
�y�y�3�3�D�9��	�1������	�	�%�%�8�8��S�#�s�!� "�&7�%5�	9�	7rc�<�|jjtddd��}|jt|jj
|�|jjtddd��}|jt|jj
|�y)Nr�r]r3)rr�r�s  r�4test_create_connection_no_ssl_server_hostname_errorszSBaseEventLoopWithSelectorTests.test_create_connection_no_ssl_server_hostname_errorss���y�y�*�*�7�L�"�;=�+�?�����*�d�i�i�&B�&B�D�I��y�y�*�*�7�L�"�;G�+�I�����*�d�i�i�&B�&B�D�Irc�8�|jjtddd��}|jt|jj
|�|jjtddd��}|jt|jj
|�t
j�}|jjtddd|��}|j|j�|jt|jj
|�y)Nr3r]T)r�)r�r)	rWrsrr_r+rur r*rp)r<r�rs   r�1test_create_connection_ssl_server_hostname_errorszPBaseEventLoopWithSelectorTests.test_create_connection_ssl_server_hostname_errors
s����y�y�*�*�7�B���*�E�����*�d�i�i�&B�&B�D�I��y�y�*�*�7�D�"�$�*�G�����*�d�i�i�&B�&B�D�I��}�}����y�y�*�*�7�D�$�/3�$�+�@������
�
�#����*�d�i�i�&B�&B�D�Irc���|jjtddd��}|jtd�5|jj|�ddd�y#1swYyxYwr�)rWrsrr�r+rur�s  r�3test_create_connection_ssl_timeout_for_plain_socketzRBaseEventLoopWithSelectorTests.test_create_connection_ssl_timeout_for_plain_socketsa���y�y�*�*��]�B�a�+�A��
�
#�
#��C�E�
�I�I�(�(��.�E�E�E�r�c�����t���fd����fd�}|�j_�jjtdd�}�jt�jj|��j��y)Nc���K�|d�gS�wr�r)r�r_r�s  �rr`zQBaseEventLoopWithSelectorTests.test_create_server_empty_host.<locals>.getaddrinfo"s�������7�D��I�s�c�F���jj�|i|���Srrcrds  ��rrfzVBaseEventLoopWithSelectorTests.test_create_server_empty_host.<locals>.getaddrinfo_task'rgrr3r)	r�rWr`r�rr_rkrur:)r<rfr�r`r�s`  @@r�test_create_server_empty_hostz<BaseEventLoopWithSelectorTests.test_create_server_empty_hostse����x��	�
	E�!1��	�	���i�i�%�%�g�r�1�5�����'�4�9�9�#?�#?��E����$�rc��|jjtddt���}|j	t
|jj|�y)N�0.0.0.0rr�)rWr�rr�r_r+ru�r<r�s  r�!test_create_server_host_port_sockz@BaseEventLoopWithSelectorTests.test_create_server_host_port_sock/sB���i�i�%�%��Y����&�2�����*�d�i�i�&B�&B�C�Hrc��|jjt�}|jt|jj
|�yr)rWr�rr_r+rurs  r�$test_create_server_no_host_port_sockzCBaseEventLoopWithSelectorTests.test_create_server_no_host_port_sock4s2���i�i�%�%�g�.�����*�d�i�i�&B�&B�C�Hrc�Z�tj�x}|j_|jj	�|_|j
j
d�|jjtdd�}|jt|jj|�y)Nr�r)rrXrWr`rrr'r�r�rr_rkru)r<r`r.s   r�!test_create_server_no_getaddrinfoz@BaseEventLoopWithSelectorTests.test_create_server_no_getaddrinfo8sv��.2�i�i�k�9��d�i�i�+�#'�9�9�#:�#:�#<�� �� � �+�+�D�1��I�I�#�#�G�\�1�=�����'�4�9�9�#?�#?��Crc��tj|_|`tj�|j_|jjtddd��}|jt|jj|�y)NrrT��
reuse_port)r r`�SO_REUSEPORTrrXr'rWr�rr_r+ru�r<r(r.s   r� test_create_server_nosoreuseportz?BaseEventLoopWithSelectorTests.test_create_server_nosoreuseport@sh��%�1�1����!�'+�y�y�{����$��I�I�#�#��Y��d�
$�
4��	
���*�d�i�i�&B�&B�A�Frc��tj|_tj�|j_d|_|jjtddd��}|jt|jj|�y)Nr�rrTr)r r`rrXr'rrWr�rr_r+rurs   r�+test_create_server_soreuseport_only_definedzJBaseEventLoopWithSelectorTests.test_create_server_soreuseport_only_definedKsj��%�1�1���'+�y�y�{����$� "����I�I�#�#��Y��d�
$�
4��	
���*�d�i�i�&B�&B�A�Frc��Gd�dt�}dg|j_tj�x}|j
_||j_|jjtdd�}|jt|jj|�|j|jj�y)Nc��eZdZdZy)�HBaseEventLoopWithSelectorTests.test_create_server_cant_bind.<locals>.ErrrYN)rMrNrOr�rrrr�r"Ys���Hrr�)rr6r\r3)r|it'rr)rkr`r'rrXr r�rQrWr�rr_rurqrpr��r<r(r��m_sockr�s     r�test_create_server_cant_bindz;BaseEventLoopWithSelectorTests.test_create_server_cant_bindVs���	�'�	�
0�-1����)�04�	�	��;�����-�"%������i�i�%�%�g�y�!�<�����'�4�9�9�#?�#?��E�������+�+�,rc��g|j_|jjtd��}|jt|jj|�y)N)�	localhostr�r�)r`r'rWr�r=r_rkru�r<r(r�s   r�)test_create_datagram_endpoint_no_addrinfozHBaseEventLoopWithSelectorTests.test_create_datagram_endpoint_no_addrinfoesN��,.����)��y�y�1�1��(8�2�:������T�Y�Y�1�1�4�	9rc�4�|jjtd��}|jt|jj
|�|jjtd��}|jt|jj
|�y)Nr'r()r'r6rr�)rWr�r=r_r�rur�s  r�(test_create_datagram_endpoint_addr_errorzGBaseEventLoopWithSelectorTests.test_create_datagram_endpoint_addr_errorns~���y�y�1�1���2�5������t�y�y�3�3�T�	;��y�y�1�1��(>�2�@������t�y�y�3�3�T�	;rc�4�tj�|j_t|jj_|jj
tjd��}|jt|jj|�y)N�r|r)�remote_addr)rrXrWr}rkrQr�r
�DatagramProtocolr_rur�s  r�)test_create_datagram_endpoint_connect_errzHBaseEventLoopWithSelectorTests.test_create_datagram_endpoint_connect_errxsk��!%�����	�	��-4��	�	���*��y�y�1�1��$�$�2B�2�D������T�Y�Y�1�1�4�	9rc����td|j���tj�x|j_}g|_|jj
�fd�dd��}|jj|�\}}|j|j�|j�|jj�j�|jd�j�y)NT�rrrWc����Srr)r�s�rrzz^BaseEventLoopWithSelectorTests.test_create_datagram_endpoint_allow_broadcast.<locals>.<lambda>�s���Hrr.)r/�allow_broadcastr8)r=rWrrXr}r'r�rurnr�rpr r8r)r<r}r�r+r�r�s     @r�-test_create_datagram_endpoint_allow_broadcastzLBaseEventLoopWithSelectorTests.test_create_datagram_endpoint_allow_broadcast�s����"��D�I�I�F��04�	�	��;��	�	���$&��!��y�y�1�1��(� �2�"��
�y�y�3�3�D�9��	�1�����,�,�-������	�	�$�$�X�]�]�3�����8�>�>�2rc���tj|_t|j_|jjtjtj��}|jt|jj|�|jjtjd��}|jt|jj|�y)Nr�r.r()r r`rkrQrWr�r
r0rr_rur)s   r�(test_create_datagram_endpoint_socket_errzGBaseEventLoopWithSelectorTests.test_create_datagram_endpoint_socket_err�s���%�1�1���&-����#��y�y�1�1��$�$�V�^�^�2�=������T�Y�Y�1�1�4�	9��y�y�1�1��$�$�1A�2�C������T�Y�Y�1�1�4�	9rzIPv6 not supported or enabledc��|jjtjdd��}|j	t
|jj|�y)Nr.)r�r)r/r��rWr�r
r0r_r+rur�s  r�0test_create_datagram_endpoint_no_matching_familyzOBaseEventLoopWithSelectorTests.test_create_datagram_endpoint_no_matching_family�sK���y�y�1�1��$�$�(�Z�2�A��	
�����	�	�4�4�d�	<rc��t|jjj_|j
j
tjtj��}|jt|j
j|�|j|jjjj�y)Nr�)rkr r'�setblockingrQrWr�r
r0rr_rurqrpr�r)s   r�(test_create_datagram_endpoint_setblk_errzGBaseEventLoopWithSelectorTests.test_create_datagram_endpoint_setblk_err�s���?F����$�$�0�0�<��y�y�1�1��$�$�V�^�^�2�=������T�Y�Y�1�1�4�	9�����O�O�(�(�.�.�5�5�	7rc��|jjtj�}|j	t
|jj|�yrr:r�s  r�-test_create_datagram_endpoint_noaddr_nofamilyzLBaseEventLoopWithSelectorTests.test_create_datagram_endpoint_noaddr_nofamily�s;���y�y�1�1��$�$�&�����*�d�i�i�&B�&B�D�Irc��Gd�dt�}tj|_tj�x}|j_||j_|jjtdtj��}|j||jj|�|j|jj �y)Nc��eZdZy)�SBaseEventLoopWithSelectorTests.test_create_datagram_endpoint_cant_bind.<locals>.ErrNr2rrrr�rC�r4rr�r.)r�r�)rkr r`rrXr'r�rQrWr�r=rr_rurqrpr�r#s     r�'test_create_datagram_endpoint_cant_bindzFBaseEventLoopWithSelectorTests.test_create_datagram_endpoint_cant_bind�s���	�'�	� &�1�1���04�	�	��;�����-�"%������i�i�0�0��'����1�@��	
���#�t�y�y�;�;�S�A�������+�+�,rc���tjtjtj�}|jd��jj�fd�|��}�jj
|�\}}|j��jj
|j��jd|j�y)Nr.c�2��td�j��S�NTr3�r=rWr�s�rrzzSBaseEventLoopWithSelectorTests.test_create_datagram_endpoint_sock.<locals>.<lambda>�����O�$�T�Y�Y�Grr�r8)r rrr�rWr�rurpr r8r)r<rr�r+r�s`    r�"test_create_datagram_endpoint_sockzABaseEventLoopWithSelectorTests.test_create_datagram_endpoint_sock�s�����}�}�V�^�^�V�->�->�?���	�	�"�#��i�i�0�0�G��1���#�i�i�:�:�3�?��	�8������	�	�$�$�X�]�]�3�����8�>�>�2r�AF_UNIXzNo UNIX Socketsc����jj�fd�tj��}�jj	|�\}}�j|jjtj�|j��jj	|j��jd|j�y)Nc�2��td�j��SrGrHr�s�rrzzXBaseEventLoopWithSelectorTests.test_create_datagram_endpoint_sock_unix.<locals>.<lambda>�rIrr�r8)rWr�r rKrur8r�r�rpr r)r<r�r+r�s`   r�'test_create_datagram_endpoint_sock_unixzFBaseEventLoopWithSelectorTests.test_create_datagram_endpoint_sock_unix�s�����i�i�0�0�G��>�>�1�#��#�i�i�:�:�3�?��	�8�������/�/����@������	�	�$�$�X�]�]�3�����8�>�>�2rc���tj�5}tjtjtj��}|j|�|j
��jj�fd�|tj��}�jj|�\}}|j
��jj|j�ddd�y#1swYyxYw)N)r�c�2��td�j��SrGrHr�s�rrzzaBaseEventLoopWithSelectorTests.test_create_datagram_endpoint_existing_sock_unix.<locals>.<lambda>�s����d����Krr�)r%�unix_socket_pathr rKrr�rprWr�rur )r<�pathrr�r+r�s`     r�0test_create_datagram_endpoint_existing_sock_unixzOBaseEventLoopWithSelectorTests.test_create_datagram_endpoint_existing_sock_unix�s����
�
(�
(�
*�d��=�=����f�6G�6G�H�D��I�I�d�O��J�J�L��9�9�5�5�K��V�^�^�6�-�D�#'�)�)�">�">�t�"D��I�x��O�O���I�I�(�(����7�+�
*�
*�s�CC6�6C?c��Gd�d�}|jjtd|���}|jt|jj
|�|jjtd|���}|jt|jj
|�|jjtd|���}|jt|jj
|�|jjtd|���}|jt|jj
|�|jjtd|��	�}|jt|jj
|�|jjtd
|���}|jt|jj
|�|jjtd
|���}|jt|jj
|�y)
Nc�$�eZdZejZy)�\BaseEventLoopWithSelectorTests.test_create_datagram_endpoint_sock_sockopts.<locals>.FakeSockN)rMrNrOr rr�rrr�FakeSockrV�s
���$�$�DrrWr.)r�r)r/rr6)r�r)�protor)�flagsrT)rr)r5r)rWr�r=r_r+ru)r<rWr�s   r�+test_create_datagram_endpoint_sock_sockoptszJBaseEventLoopWithSelectorTests.test_create_datagram_endpoint_sock_sockopts�s���	%�	%��i�i�0�0��(8�x�z�1�K�����*�d�i�i�&B�&B�C�H��i�i�0�0��)9��
�1�L�����*�d�i�i�&B�&B�C�H��i�i�0�0��A�H�J�1�8�����*�d�i�i�&B�&B�C�H��i�i�0�0��1�8�:�1�7�����*�d�i�i�&B�&B�C�H��i�i�0�0��1�8�:�1�7�����*�d�i�i�&B�&B�C�H��i�i�0�0���8�:�1�?�����*�d�i�i�&B�&B�C�H��i�i�0�0��T��
�1�D�����*�d�i�i�&B�&B�C�Hr�vxworksz-SO_BROADCAST is enabled by default on VxWorksc����jj�fd�d��}�jj|�\}}|jd�}t	t
d�}|r=�j
|jt
jt
j���j
|jt
jt
j��|j��jj|j��jd|j��jj�fd�d|d�	�}�jj|�\}}|jd�}�j
|jt
jt
j��|r=�j!|jt
jt
j���j!|jt
jt
j��|j��jj|j��jd|j�y)
Nc�2��td�j��SrGrHr�s�rrzzWBaseEventLoopWithSelectorTests.test_create_datagram_endpoint_sockopts.<locals>.<lambda>rIrr.r(r rr8c�2��td�j��SrGrHr�s�rrzzWBaseEventLoopWithSelectorTests.test_create_datagram_endpoint_sockopts.<locals>.<lambda>'rIrT)r�rr5)rWr�rur�r!r rn�
getsockoptrr�SO_BROADCASTrpr r8rrrq)r<r�r+r�r�reuseport_supporteds`     r�&test_create_datagram_endpoint_sockoptszEBaseEventLoopWithSelectorTests.test_create_datagram_endpoint_sockoptss�����y�y�1�1�G�'�2�)��#�i�i�:�:�4�@��	�8��'�'��1��%�f�n�=����������%�%�v�':�':�<�
=�	
����O�O��!�!�6�#6�#6�
8�	9�	�����	�	�$�$�X�]�]�3�����8�>�>�2��y�y�1�1�G�'�*� �	2�"��
#�i�i�:�:�4�@��	�8��'�'��1������O�O��!�!�6�#6�#6�
8�	9���O�O�����%�%�v�':�':�<�
=�	
����O�O��!�!�6�#6�#6�
8�	9�	�����	�	�$�$�X�]�]�3�����8�>�>�2rc����|`tj�|j_�j
j
�fd�dd��}�jt�j
j|�y)Nc�0��t�j��Sr�rHr�s�rrzz\BaseEventLoopWithSelectorTests.test_create_datagram_endpoint_nosoreuseport.<locals>.<lambda>C����O����3rr.T�r�r)
rrrXr r'rWr�r_r+rur)s`  r�+test_create_datagram_endpoint_nosoreuseportzJBaseEventLoopWithSelectorTests.test_create_datagram_endpoint_nosoreuseport=s[����!�'+�y�y�{����$��y�y�1�1�3�'��2���
	
���*�d�i�i�&B�&B�D�Irc�����fd�}||_tj�x|jj_}tj��j_ttd�}�jj�fd�d|��}�jj|�\}}	|jd�|jj|j|j|j��|j�t!j"�j�y#|j�t!j"�j�wxYw)Nc�(���jd�y)Nz"should not have called getaddrinfo)�fail)r�r_r<s  �rr`zYBaseEventLoopWithSelectorTests.test_create_datagram_endpoint_ip_addr.<locals>.getaddrinfoKs����I�I�:�;rrc�0��t�j��Sr�rHr�s�rrzzVBaseEventLoopWithSelectorTests.test_create_datagram_endpoint_ip_addr.<locals>.<lambda>TrerrFrf)r�rXr�)r`rrXr r'r�rWr�r!r�rurZrrrrpr%r�)r<r(r`r�rar�rr�s`       r�%test_create_datagram_endpoint_ip_addrzDBaseEventLoopWithSelectorTests.test_create_datagram_endpoint_ip_addrIs���	<� +���37�9�9�;�>����$�$�)�D� $�	�	���	�	��%�f�n�=���y�y�1�1�3�%�*�2�,��
�y�y�+�+�D�1���1�	.��#�#�N�3��O�O�.�.�h�6F�6F�5=�5I�5I�4<�4G�4G�
/�
I�
�G�G�I��"�"�4�9�9�-��
�G�G�I��"�"�4�9�9�-�s
�0A
D-�-1Ec���tj�}t�|j_|j
j
t|�|j|jj�yr)rrX�BlockingIOError�acceptrQrW�_accept_connectionrrnrpr��r<rs  r�test_accept_connection_retryz;BaseEventLoopWithSelectorTests.test_accept_connection_retrybsH���y�y�{��"1�"3������	�	�$�$�W�d�3�������*�*�+rrPc�8�tj�}d|j_t	t
jd�|j_tj�|j_
tj�|j_|jjt|�|j|jj �|j#|j$j �|jjj'd�|jjj't(j*tj,t|ddtj,tj,tj,�	y)N�
zToo many open files)rrX�filenor'rkr��EMFILErorQrW�_remove_readerr�rprrqrYr�rnrprZr�ACCEPT_RETRY_DELAYr)r<�m_logrs   r� test_accept_connection_exceptionz?BaseEventLoopWithSelectorTests.test_accept_connection_exceptionis����y�y�{��#%���� �")�%�,�,�8M�"N�����#'�9�9�;��	�	� �#�y�y�{��	�	���	�	�$�$�W�d�3�������*�*�+�������*�*�+��	�	� � �3�3�B�7��	�	���/�/��(�(��H�H��T�4��t�x�x����4�8�8�		Erc���d�}|jjd�|}|�}|j|j�||fD�]W}|j	t
�5|jj
|�ddd�|j	t
�5|jj|�ddd�|j	t
�5|jjd|�ddd�|j	t
�5|jj|jj�dz|�ddd�|j	t
�5|jj|jjd|��ddd���Zy#1swY��)xYw#1swY��xYw#1swY��xYw#1swY��xYw#1swY���xYw)Nc��K�y�wrrrrr�simple_coroutinezLBaseEventLoopWithSelectorTests.test_call_coroutine.<locals>.simple_coroutine|r�r�Tr�)
rWr�r*rpr_r�r�r�r�r�r�rur)r<r}�	coro_func�coro_objr�s     r�test_call_coroutinez2BaseEventLoopWithSelectorTests.test_call_coroutine{sM��	�	
�	�	���D�!�$�	��;��������'���)�D��"�"�9�-��	�	�#�#�D�)�.��"�"�9�-��	�	�.�.�t�4�.��"�"�9�-��	�	�$�$�R��.�.��"�"�9�-��	�	�!�!�$�)�)�.�.�"2�R�"7��>�.��"�"�9�-��	�	�,�,��I�I�-�-�d�D�9�;�.�-�*�-�-��-�-��-�-��-�-��-�-�s<� F#�F0�F<�8G�!6G�#F-	�0F9	�<G	�G	�G	c��d�}d�}tj|j�|jjd�d|j_|jj||j�|jj
�|jjd^}}|j|t|�zd�tj||j�|j��|jj
�|jjd^}}|j|t|�zd�y)	Nc�$�|j�yr�r�rcs r�stop_loop_cbzLBaseEventLoopWithSelectorTests.test_log_slow_callbacks.<locals>.stop_loop_cb�s���I�I�Krc��,K�|j�y�wrr�rcs r�stop_loop_corozNBaseEventLoopWithSelectorTests.test_log_slow_callbacks.<locals>.stop_loop_coro�s�����I�I�K���Tgrz4^Executing <Handle.*stop_loop_cb.*> took .* seconds$rcz4^Executing <Task.*stop_loop_coro.*> took .* seconds$)r
r[rWr��slow_callback_durationr�rt�warningr�r��tuplere)r<�m_loggerr�r��fmtr�s      r�test_log_slow_callbacksz6BaseEventLoopWithSelectorTests.test_log_slow_callbacks�s��	�	�	���t�y�y�)��	�	���D�!�+.��	�	�(�	
�	�	���L�$�)�)�4��	�	�����%�%�/�/��2�
��d�����u�T�{�*�,�	-�
	���n�T�Y�Y�7�d�i�i�H��	�	�����%�%�/�/��2�
��d�����u�T�{�*�,�	-r)HrMrNrOrUrr-rUr/ryr�r�r�r�r��unittest�
skipUnlessr!r r�r
r;r�r�r�r�r�r�r�r��skipIfrD�platformr�r�r�r�r�r�r�rrr	rrrrrrrr%r*r,r1r6r8r;r>r@rDrJrN�skip_unless_bind_unix_socketrSrZrbrgrlrrrzr�r�rrs@rrJrJ4s����'�
�T�Z�Z�$�%� �&� �
�%.��%.�N�/��/�(J�
3�3�/��X������9�?�A�<�A�<��X����3�3�5F�G��H��$3�J�
9�C�..�4�&.��&.�P'2�R�X����3�3�5F�G��X�_�_�S�\�\�,�,�U�3�Z�\��.��\�H�.�&�=��=��>��>��3��3�89�$�+��+�N7�`J�
J�/� �"I�
I�D��G��G��G��G��-��-��9��9�;�9�3�"�9��9��X����3�3�5T�U�<�V�<��7��7�J�
�-��-�	3��X������3�5F�G�3�H�3��/�/�8�0�8�I�@�X�_�_�S�\�\�Y�.�C�E�-3�E�-3�^�	J��	J��.��.�0,��T�Z�Z�,�-�E�.�E�";�*�T�Z�Z�,�-�-�.�-rrJc��eZdZd�Zy)�RunningLoopTestsc�j�d�}tj�}tj�}	|jtd�5|j	||��ddd�|j�|j�y#1swY�*xYw#|j�|j�wxYw)Nc��,K�|j�y�wr)rtrcs r�runnerz@RunningLoopTests.test_running_loop_within_a_loop.<locals>.runner�s��������r�zwhile 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��-�-�f�T�l�;�I�
�J�J�L�����I�I��
�J�J�L�����s#�B�B�B�B
�	B�"B2N)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�Zy)�!BaseLoopSockSendfileTests.MyProtoc�v�d|_d|_t�|_|j	�|_d|_yry)r��closed�	bytearrayr2rrr�r+)r<rWs  rr!z*BaseLoopSockSendfileTests.MyProto.__init__�s0�� �D�L��D�K�!��D�I��)�)�+�D�H�!�D�Nrc� �d|_||_yr�)r�r+r-s  rr.z1BaseLoopSockSendfileTests.MyProto.connection_made�s���D�L�&�D�Nrc�:�|jj|�yr)r2�extendr1s  rr3z/BaseLoopSockSendfileTests.MyProto.data_received�s���I�I���T�"rc�V�d|_|jjd�d|_yr�)r�r�r�r+r:s  rr;z1BaseLoopSockSendfileTests.MyProto.connection_lost�s"���D�K��H�H����%�!�D�Nrc��8K�|j�d{���y7��wrrNr�s rr�z-BaseLoopSockSendfileTests.MyProto.wait_closed�s�����(�(�N�N�s���N)rMrNrOr!r.r3r;r�rrrrr��s��	"�	'�	#�	"�
	rrc���tj|_dt_ttj
d�5}|j
|j�ddd�t�|�%�y#1swY�xYw)Ni@�wb)
r�!SENDFILE_FALLBACK_READBUFFER_SIZE�'_BaseLoopSockSendfileTests__old_bufsize�openr	�TESTFNr,�DATArT�
setUpClass)�cls�fpr]s  �rr�z$BaseLoopSockSendfileTests.setUpClass�sT���%�G�G���6?�	�3�
�)�"�"�D�
)�R��H�H�S�X�X��*�
����*�
)�s�A/�/A8c���|jt_tjtj
�t�|��yr)r�rr�r	�unlinkr�rT�
tearDownClass)r�r]s �rr�z'BaseLoopSockSendfileTests.tearDownClass�s0���69�6G�6G�	�3�����)�)�*�
���rc���ddlm}|�|_|j|j�t	t
jd�|_|j|jj�t�|�-�y)Nr)�BaseSelectorEventLoop�rb)�asyncio.selector_eventsr�rWr[r�r	r��filer*rprTrU)r<r�r]s  �rrUzBaseLoopSockSendfileTests.setUp�sS���A�)�+��	����D�I�I�&���)�)�4�0��	�����	�	���(�
��
�rc���tjtjtj�}|j|�|j	|j
�|Sr)r rrr=r*rp)r<�blockingrs   r�make_socketz%BaseLoopSockSendfileTests.make_socket�s?���}�}�V�^�^�V�-?�-?�@������"�����
�
�#��rc�8�|jj|�Sr)rWrur�s  rrqz"BaseLoopSockSendfileTests.run_loop�s���y�y�+�+�D�1�1rc�������j���j�j���j�jj	�fd�t
jdtj�����jdj�}td�D]/}	�j�jj�|��n,�j�jj�|������fd�}�j!|���fS#t$r'�jtjd��Y��wxYw)Nc����Srr)rXs�rrzz3BaseLoopSockSendfileTests.prepare.<locals>.<lambda>�s���Errr�rtg�?c����j��j��j�9�jj��j�j���j�j��yr)rpr+rqr�)rXr<�serverrs����r�cleanupz2BaseLoopSockSendfileTests.prepare.<locals>.cleanup
sY����L�L�N��J�J�L����*����%�%�'��
�
�e�/�/�1�2��M�M�&�,�,�.�/r)r�rrWrqr�r
�HOSTr rr��getsocknamerr}rkr
r�r*)r<rDr�r�rXr�rs`   @@@r�preparez!BaseLoopSockSendfileTests.prepare�s
������!�����T�Y�Y�'�����t�y�y�6�6��=�-�-�q���� 7� I�J���~�~�a� �,�,�.���r��A�
��
�
�d�i�i�4�4�T�4�@�A�
��
�M�M�$�)�)�0�0��t�<�=�	0�	
���� ��U�{���'�
��
�
�g�m�m�C�0�1��
�s�)+D�-E�Ec	��|j�\}}|jtjd�5|j	|j
j
||jdd��ddd�|j|jd�|j|jj�d�y#1swY�PxYw)N�sendfile is not availablerr)r�r�r
�SendfileNotAvailableErrorrqrW�_sock_sendfile_nativer�r8r2�tell�r<rrXs   r�"test__sock_sendfile_native_failurez<BaseLoopSockSendfileTests.test__sock_sendfile_native_failures����l�l�n���e�
�
#�
#�G�$E�$E�$?�A��M�M�$�)�)�9�9�$��	�	�:;�T�C�
D�A�
	
������S�)���������)�1�-�
A�A���8B;�;Cc��|j�\}}|jtjd�5|j	|j
j
||jd���ddd�|j|jj�d�|j|jd�y#1swY�PxYw)Nr�F)�fallbackrr)r�r�r
r�rqrW�
sock_sendfiler�r8r�r2r�s   r�test_sock_sendfile_no_fallbackz8BaseLoopSockSendfileTests.test_sock_sendfile_no_fallback$s����l�l�n���e�
�
#�
#�G�$E�$E�$?�A��M�M�$�)�)�1�1�$��	�	�;@�2�B�
C�A�
	
��������)�1�-�������S�)�
A�A�r�c��|j�\}}|j|jj||j��}|j�|j|j
��|j|t|j��|j|jj�t|j��|j|j|j�yr)r�rqrWr�r�rpr�r8rr�r�r2�r<rrX�rets    r�test_sock_sendfile_fallbackz5BaseLoopSockSendfileTests.test_sock_sendfile_fallback/s����l�l�n���e��m�m�D�I�I�3�3�D�$�)�)�D�E���
�
���
�
�e�'�'�)�*�����c�$�)�)�n�-���������)�3�t�y�y�>�:�������T�Y�Y�/rc��|j�\}}|j|jj||jdd��}|j�|j|j
��|j|d�|j|jj�d�|j|j|jdd�y)Ni�i�r)r�rqrWr�r�rpr�r8r�r2r�r�s    r�,test_sock_sendfile_fallback_offset_and_countzFBaseLoopSockSendfileTests.test_sock_sendfile_fallback_offset_and_count:s����l�l�n���e��m�m�D�I�I�3�3�D�$�)�)�48�$�@�A���
�
���
�
�e�'�'�)�*�����d�#���������)�4�0�������T�Y�Y�t�D�%9�:rc��|jjd�|jd��}|jtd�5|j|jj
||j��ddd�y#1swYyxYw)NT)r�zmust be non-blocking)rWr�r�r�r+rqr�r�rqs  r�test_blocking_socketz.BaseLoopSockSendfileTests.test_blocking_socketFsf���	�	���D�!������.��
�
#�
#�J�0F�
G��M�M�$�)�)�1�1�$��	�	�B�C�H�
G�
G�s�6B�Bc�0�|j�}ttjd��5}|j	t
d�5|j
|jj||��ddd�ddd�y#1swY�xYw#1swYyxYw)Nzutf-8)�encodingzbinary mode)	r�r�r	r�r�r+rqrWr�)r<rr.s   r�test_nonbinary_filez-BaseLoopSockSendfileTests.test_nonbinary_fileLsm�����!��
�)�"�"�W�
5���'�'�
�M�B��
�
�d�i�i�5�5�d�A�>�?�C�6�
5�B�B��6�
5�s#�B�,B�/B�B		�B�Bc��tjtjtj�}|jd�|j	|j
�|j
td�5|j|jj||j��ddd�y#1swYyxYw)NFzonly SOCK_STREAM type)r rrr=r*rpr�r+rqrWr�r�rqs  r�test_nonstream_socketz/BaseLoopSockSendfileTests.test_nonstream_socketRsy���}�}�V�^�^�V�->�->�?�����������
�
�#�
�
#�
#�J�0G�
H��M�M�$�)�)�1�1�$��	�	�B�C�I�
H�
H�s�56B4�4B=c	���|j�}|jtd�5|j|jj||jdd��ddd�y#1swYyxYw)N� count must be a positive integerrr��r�r�r�rqrWr�r�rqs  r�test_notint_countz+BaseLoopSockSendfileTests.test_notint_countYs\�����!��
�
#�
#�I�$F�H��M�M�$�)�)�1�1�$��	�	�1�g�N�O�H�H�H���8A(�(A1c	���|j�}|jtd�5|j|jj||jdd��ddd�y#1swYyxYw)Nr�rr��r�r�r+rqrWr�r�rqs  r�test_negative_countz-BaseLoopSockSendfileTests.test_negative_count_s\�����!��
�
#�
#�J�$F�H��M�M�$�)�)�1�1�$��	�	�1�b�I�J�H�H�H�r�c���|j�}|jtd�5|j|jj||jd��ddd�y#1swYyxYw)N�%offset must be a non-negative integer�offsetr�rqs  r�test_notint_offsetz,BaseLoopSockSendfileTests.test_notint_offsetesZ�����!��
�
#�
#�I�$K�M��M�M�$�)�)�1�1�$��	�	�8�L�M�M�M�M���7A'�'A0c���|j�}|jtd�5|j|jj||jd��ddd�y#1swYyxYw)Nr�r�r�rqs  r�test_negative_offsetz.BaseLoopSockSendfileTests.test_negative_offsetksZ�����!��
�
#�
#�J�$K�M��M�M�$�)�)�1�1�$��	�	�2�F�G�M�M�M�r�r�)rMrNrOr�r
rrr�classmethodr�r�rUr�rqr�r�r�r�r�r�r�r�r�r�r�r�rrs@rr�r��s������$�D��'�"�"��0����� �� �
��2��>	.�	*�	0�
;�D�@�D�P�K�N�Hrr�c�R�eZdZd�Zej
eed�d�d��Zy)�TestSelectorUtilsc�*�|jtjtj�}|j	|�tj|�|jtjtj�}|j|�yr)r_r r�TCP_NODELAYrnr�_set_nodelayrq)r<r�opts   r�check_set_nodelayz#TestSelectorUtils.check_set_nodelayssb���o�o�f�0�0�&�2D�2D�E�������� � ��&��o�o�f�0�0�&�2D�2D�E������rr�zneed socket.TCP_NODELAYc���tjtjtjtj��}|5|j	|�ddd�tjtjtjtj��}|5|jd�|j	|�ddd�y#1swY�yxYw#1swYyxYw)N)r�r�rXF)r rrrr�r=rqs  r�test_set_nodelayz"TestSelectorUtils.test_set_nodelay|s����}�}�F�N�N��9K�9K�#)�#5�#5�7��
��"�"�4�(���}�}�F�N�N��9K�9K�#)�#5�#5�7��
����U�#��"�"�4�(��T��T��
�T�s�C�##C�C�C$N)	rMrNrOr�r�r�r!r r�rrrr�r�rs4����X������7�2�4�
)�4�
)rr��__main__)+�__doc__�concurrent.futuresr�r�rr rDr�r�r�rr
rr�test.test_asynciorr%r�r�test.support.script_helperr�test.supportr	r
r�rr]rr*r/�TestCaser1rQrrrr0r=rJr�r�r�rMr�rrr�<module>r�s������
�
��������1��7�"�&���8�8��(��":�
^H�Z�(�(�^H�BZ
1��,�,�Z
1�z'�g���'�D'�g�.�.�'�@v
-�Z�%8�%8�v
-�r�x�(�(��"qH�
� 3� 3�qH�h)�
�+�+�)�4�z���H�M�M�O�r

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