Your IP : 216.73.216.196


Current Path : /opt/alt/python310/lib64/python3.10/test/__pycache__/
Upload File :
Current File : //opt/alt/python310/lib64/python3.10/test/__pycache__/test_asyncore.cpython-310.opt-2.pyc

o

0�i�h�@s�ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
ddlmZddlm
Z
ddlmZddlmZddlmZe
jrPe�d��ddlZe���e�d	e�ddlZWd�n1smwYeed
�ZGdd�d�ZGd
d�d�ZGdd�d�ZGdd�d�Zdd�Zdd�Z Gdd�dej!�Z"Gdd�dej!�Z#Gdd�dej$�Z%Gdd�dej!�Z&e�'eed�d �Gd!d"�d"ej!��Z(Gd#d$�d$ej)�Z*Gd%d&�d&ej)�Z+Gd'd(�d(e*�Z,Gd)d*�d*�Z-Gd+d,�d,e-�Z.e�'e
j/d-�Gd.d/�d/e-��Z0e�'ed0�Gd1d2�d2e-��Z1Gd3d4�d4e.ej!�Z2e�'eed5�d6�Gd7d8�d8e.ej!��Z3Gd9d:�d:e0ej!�Z4e�'eed5�d6�Gd;d<�d<e0ej!��Z5Gd=d>�d>e1ej!�Z6e�'eed5�d6�Gd?d@�d@e1ej!��Z7e8dAk�rye�9�dSdS)B�N)�support)�	os_helper)�
socket_helper)�threading_helper)�warnings_helper)�BytesIOztest is not helpful for PGO�ignore�AF_UNIXc@�$eZdZdd�Zdd�Zdd�ZdS)�dummysocketcC�
d|_dS�NF��closed��self�r�9/opt/alt/python310/lib64/python3.10/test/test_asyncore.py�__init__�
zdummysocket.__init__cCr�NTrrrrr�close!rzdummysocket.closecC�dS)N�*rrrrr�fileno$�zdummysocket.filenoN)�__name__�
__module__�__qualname__rrrrrrrrsrc@�eZdZdd�Zdd�ZdS)�dummychannelcCst�|_dS�N)r�socketrrrrr(�zdummychannel.__init__cCs|j��dSr!)r"rrrrrr+�zdummychannel.closeN)rrrrrrrrrr '�r c@s(eZdZdd�Zdd�ZeZeZeZdS)�exitingdummycC�dSr!rrrrrr/rzexitingdummy.__init__cCst���r!)�asyncore�ExitNowrrrr�handle_read_event2�zexitingdummy.handle_read_eventN)rrrrr*�handle_write_event�handle_close�handle_expt_eventrrrrr&.sr&c@s0eZdZdd�Zdd�ZeZeZeZdd�ZdS)�
crashingdummycCrr
��
error_handledrrrrr:rzcrashingdummy.__init__cCst��r!��	Exceptionrrrrr*=szcrashingdummy.handle_read_eventcCrrr0rrrr�handle_errorDrzcrashingdummy.handle_errorN�	rrrrr*r,r-r.r4rrrrr/9sr/cCszxz|��|��\}}Wn	tyYnXwd}t��}|dkr_t��|dkr_t�|gggd�\}}}	|rN|d8}|�d�}
|�|
�dd��d|
vrNnt�	d	�|dkr_t��|dks)|�
�W|�
�|��dSW|�
�|��dS|�
�|��w)
N��rg@皙�����?��
�
��{�G�z�?)�listenZaccept�TimeoutError�time�	monotonic�select�recv�write�replace�sleepr�set)�evtZbufZserv�conn�addr�n�start�r�w�e�datarrr�capture_serverHs4�

�
��
rPcCs:	tr|jtjkrt�|�t�||�dS|�|�dSr!)	�HAS_UNIX_SOCKETS�familyr"r	r�unlinkrZbind_unix_socket�bind)�sockrIrrr�
bind_af_awareas

rVc@sNeZdZdd�Ze�eed�d�dd��Zdd�Z	d	d
�Z
dd�Zd
d�ZdS)�HelperFunctionTestscCs�t�}|�tjtj|�|�tjtj|�|�tjtj|�t�}t�|�|�|j	d�t�}t�|�|�|j	d�t�}t�|�|�|j	d�dSr)
r&�assertRaisesr(r)�readrCZ
_exceptionr/�assertEqualr1)r�tr1�tr2rrr�test_readwriteexcls


z%HelperFunctionTests.test_readwriteexc�poll�select.poll requiredc
Cs�d}tjdftjdftjdftjdftjdftjdff}Gdd�d�}|D]J\}}|�}|�t||�d�t	�
||�|D]
}|�t||�||k�q=t�}|�t	j
t	j
||�t�}	|�|	jd�t	�
|	|�|�|	jd	�q%dS)
N)rY�exptrCrr1rYr`rCrc@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)z3HelperFunctionTests.test_readwrite.<locals>.testobjcSs"d|_d|_d|_d|_d|_dSr
)rYrCrr`r1rrrrr�s

z<HelperFunctionTests.test_readwrite.<locals>.testobj.__init__cSrr)rYrrrrr*�rzEHelperFunctionTests.test_readwrite.<locals>.testobj.handle_read_eventcSrr)rCrrrrr,�rzFHelperFunctionTests.test_readwrite.<locals>.testobj.handle_write_eventcSrrrrrrrr-�rz@HelperFunctionTests.test_readwrite.<locals>.testobj.handle_closecSrr)r`rrrrr.�rzEHelperFunctionTests.test_readwrite.<locals>.testobj.handle_expt_eventcSrrr0rrrrr4�rz@HelperFunctionTests.test_readwrite.<locals>.testobj.handle_errorNr5rrrr�testobj�sraFT)rAZPOLLINZPOLLPRIZPOLLOUTZPOLLERRZPOLLHUPZPOLLNVALrZ�getattrr(Z	readwriter&rXr)r/r1)
rZ
attributes�expectedra�flagZexpectedattrZtobj�attrr[r\rrr�test_readwrite�s,�	�z"HelperFunctionTests.test_readwritecC�|�d�dSr
��closeall_checkrrrr�
test_closeall�r$z!HelperFunctionTests.test_closeallcCrgrrhrrrr�test_closeall_default�r$z)HelperFunctionTests.test_closeall_defaultcCs�g}i}td�D]}t�}|�|�|�|jjd�|||<q|r=tj}z|t_t��Wtj|}t_n
tj|}t_wt�|�|�t	|�d�|D]
}|�|jjd�qLdS)Nr9FrT)
�ranger �appendrZr"rr(�
socket_map�	close_all�len)rZ
usedefault�lZtestmap�i�cZ	socketmaprrrri�s$


 
�z"HelperFunctionTests.closeall_checkcCs�ztd��t��\}}}t��}Y|\\}}}}}	}
|�tj�	|�dd�|�|d�|�||�|�|	|�|�|
d|||f�dS)N�I don't like spam!zExpected exception���ztest_asyncore.py�test_compact_tracebackz
[%s|%s|%s])
r3�sys�exc_infor(Zcompact_traceback�failrZ�os�path�split)rZreal_tZreal_vZreal_tbrL�fZfunction�line�t�v�inforrrrv�s
z*HelperFunctionTests.test_compact_tracebackN)
rrrr]�unittest�
skipUnless�hasattrrArfrjrkrirvrrrrrWks
;rWc@sLeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dS)�DispatcherTestscCr'r!rrrrr�setUp�rzDispatcherTests.setUpcC�t��dSr!�r(rorrrr�tearDown�r#zDispatcherTests.tearDowncCs,t��}|�|��d�|�|��d�dSr)r(�
dispatcherrZ�readable�writable�r�drrr�
test_basic�szDispatcherTests.test_basiccCs$t��}|�t|�dt|��dS)Nz<asyncore.dispatcher at %#x>)r(r�rZ�repr�idr�rrr�	test_reprszDispatcherTests.test_reprcCstt��}d}d}t���}|�|�|�|�Wd�n1s!wY|����}|�|d|d|g�dS)NzLovely spam! Wonderful spam!rtzlog: %s)r(r�rZcaptured_stderr�log�getvalue�
splitlinesrZ)rr��l1�l2�stderr�linesrrr�test_logs

�zDispatcherTests.test_logcCs�t��}d}d}d}t���}|�|d�|�|�|�|d�Wd�n1s*wY|����}d|d|d|g}|�||�dS)	Nz#Have you got anything without spam?z.Why can't she have egg bacon spam and sausage?zTHAT'S got spam in it!ZEGGSZSPAMzEGGS: %szinfo: %szSPAM: %s)r(r�r�captured_stdoutZlog_infor�r�rZ)rr�r�r��l3�stdoutr�rcrrr�
test_log_infos

�zDispatcherTests.test_log_infocCszt��}d|_t���}|��|��|��|��Wd�n1s&wY|�	��
�}gd�}|�||�dS)Nr)z*warning: unhandled incoming priority eventzwarning: unhandled read eventzwarning: unhandled write eventz warning: unhandled connect event)r(r�Zignore_log_typesrr��handle_expt�handle_read�handle_write�handle_connectr�r�rZ)rr�r�r�rcrrr�test_unhandled#s

�zDispatcherTests.test_unhandledcCsFt�tj�}ttd�r|�|t�tj��t�d�}|�|dk�dS)N�strerrorru�)	r(Z	_strerror�errnoZEPERMr�rzrZr��
assertTrue)r�errrrr�
test_strerror5s


zDispatcherTests.test_strerrorN)rrrr�r�r�r�r�r�r�r�rrrrr��s
r�c@r)�dispatcherwithsend_noreadcCrr
rrrrrr�?rz"dispatcherwithsend_noread.readablecCr'r!rrrrrr�Brz(dispatcherwithsend_noread.handle_connectN)rrrr�r�rrrrr�>r%r�c@s*eZdZdd�Zdd�Zejdd��ZdS)�DispatcherWithSendTestscCr'r!rrrrrr�GrzDispatcherWithSendTests.setUpcCr�r!r�rrrrr�Jr#z DispatcherWithSendTests.tearDownc
	Cst��}t��}|�d�t�|�}t�}|||f}tjt|d�}|�	�zXt
�d�d}t�}|�
�|�tj|f�t
�d�|�|�|�|�|�d�d}	|jrh|	dkrht��|	d	8}	|jrh|	dksY|��|�|��|d
�Wt�|�dSt�|�w)N�)�target�args皙�����?s$Suppose there isn't a 16-ton weight?r7r:i�rr8�)�	threadingZEventr"�
settimeoutrZ	bind_portr�ThreadrPrKr?rEr��
create_socket�connect�HOST�sendZ
out_bufferr(r^�waitrZr�r�join_thread)
rrGrU�portZcapr�rrOr�rJrrr�	test_sendMs4







�z!DispatcherWithSendTests.test_sendN)rrrr�r�r�reap_threadsr�rrrrr�Fs
r��file_wrapperzasyncore.file_wrapper requiredc@sVeZdZdd�Zdd�Zdd�Zdd�Ze�e	e
d	�d
�dd��Zd
d�Zdd�Z
dS)�FileWrapperTestcCsDd|_ttjd��}|�|j�Wd�dS1swYdS)NsIt's not dead, it's sleeping!�wb)r��openr�TESTFNrC)r�filerrrr�xs"�zFileWrapperTest.setUpcCst�tj�dSr!)rrSr�rrrrr�}�zFileWrapperTest.tearDowncCs�t�tjtj�}t�|�}t�|�|�|j	|�|�|�
�|�|�|�d�d�|�|�
d�d�|��|�t|j
d�dS)N�
s
It's not dead�s, it'sr8)rzr�rr��O_RDONLYr(r�rZassertNotEqual�fdrrZrBrYrX�OSError)rr�rMrrr�	test_recv�s

zFileWrapperTest.test_recvcCs�d}d}t�tjtjtjB�}t�|�}t�|�|�	|�|�
|�|��ttjd��}|�|��|j
||�Wd�dS1sFwYdS)NsCome again?sI want to buy some cheese.�rb)rzr�rr��O_WRONLY�O_APPENDr(r�rrCr�rZrYr�)rZd1Zd2r�rMr�rrrr��s



"�zFileWrapperTest.test_send�file_dispatcherz!asyncore.file_dispatcher requiredcsdt�tjtj�}g�G�fdd�dtj�}||�}t�|�tjdddd�|�	d�
��|j�dS)NcseZdZ�fdd�ZdS)z7FileWrapperTest.test_dispatcher.<locals>.FileDispatchercs��|�d��dS)N�)rmrBr�rOrrr��szCFileWrapperTest.test_dispatcher.<locals>.FileDispatcher.handle_readN�rrrr�rr�rr�FileDispatcher�sr�r<Tr���timeout�use_poll�countr;)rzr�rr�r�r(r�r�looprZ�joinr�)rr�r��srr�r�test_dispatcher�s
zFileWrapperTest.test_dispatchercCsdt�tjtj�}t�|�}t�|�t�	dt
f��d}t��Wd�dS1s+wYdS)Nr�)
rzr�rr�r�r(r�rrZcheck_warnings�ResourceWarningrZ
gc_collect�rr�r}rrr�test_resource_warning�s


"�z%FileWrapperTest.test_resource_warningcCs|t�tjtj�}t�|�}t�|�t�|j�|�	t
��|��Wd�n1s,wY|�|jd�|��dS)Nru)rzr�rr�r�r(r�rr�rXr�rZr�rrr�test_close_twice�s


�z FileWrapperTest.test_close_twiceN)rrrr�r�r�r�r�r�r�r(r�r�r�rrrrr�us
�

r�c@sFeZdZddd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dS)�BaseTestHandlerNcCstj�||�d|_dSr
)r(r�rrd)rrUrrrr�s
zBaseTestHandler.__init__cC�td��)Nz'handle_accept not supposed to be calledr2rrrr�
handle_accept�r+zBaseTestHandler.handle_acceptcCr�)Nz)handle_accepted not supposed to be calledr2rrrr�handle_accepted�r+zBaseTestHandler.handle_acceptedcCr�)Nz(handle_connect not supposed to be calledr2rrrrr��r+zBaseTestHandler.handle_connectcCr�)Nz%handle_expt not supposed to be calledr2rrrrr��r+zBaseTestHandler.handle_exptcCr�)Nz&handle_close not supposed to be calledr2rrrrr-�r+zBaseTestHandler.handle_closecC��r!rrrrrr4��zBaseTestHandler.handle_errorr!)
rrrrr�r�r�r�r-r4rrrrr��s
r�c@s6eZdZ	efdd�Zedd��Zdd�Zdd�Zd	S)
�
BaseServercCs>tj�|�|�|�|��t|j|�|�d�||_dS�N�)	r(r�rr��set_reuse_addrrVr"r=�handler)rrRrIr�rrrr�s


zBaseServer.__init__cCs
|j��Sr!)r"�getsocknamerrrr�address�s
zBaseServer.addresscCs|�|�dSr!)r��rrUrIrrrr��r$zBaseServer.handle_acceptedcCr�r!rrrrrr4�r�zBaseServer.handle_errorN)	rrrr�r�propertyr�r�r4rrrrr��s
r�c@r)�
BaseClientcCs"t�|�|�|�|�|�dSr!)r�rr�r�)rrRr�rrrr�s

zBaseClient.__init__cCr'r!rrrrrr��rzBaseClient.handle_connectN)rrrrr�rrrrr���r�c@s�eZdZdd�Zd%dd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Ze�
ej�d�d�dd��Zdd�Zdd�Zdd�Zdd�Zd d!�Zejd"d#��Zd$S)&�BaseTestAPIcCstjdd�dS)NT)Z
ignore_allr�rrrrr��r�zBaseTestAPI.tearDownr�cCsht|�d}d}tjr-|dkr-tjdd|jd�|jrdS|d8}t�|�tjr-|dks|�d�dS)N�drr<r8)r�r�r�zflag not set)	�floatr(rnr�r�rdr?rEry)r�instancer�r�rrr�loop_waiting_for_flag�s
�z!BaseTestAPI.loop_waiting_for_flagcC�:Gdd�dt�}t|j|j�}||j|j�}|�|�dS)Nc@�eZdZdd�ZdS)z3BaseTestAPI.test_handle_connect.<locals>.TestClientcSrr�rdrrrrr�rzBBaseTestAPI.test_handle_connect.<locals>.TestClient.handle_connectN)rrrr�rrrr�
TestClient
�r��r�r�rRrIr�r��rr��server�clientrrr�test_handle_connect
�zBaseTestAPI.test_handle_connectcC�:Gdd�dt�}||j|j�}t|j|j�}|�|�dS)Nc@r)z4BaseTestAPI.test_handle_accept.<locals>.TestListenercS�:t�|�|�|�t|j|�|�d�|j��|_dSr��r�rr�rVr"r=r�r��rrRrIrrrr�



z=BaseTestAPI.test_handle_accept.<locals>.TestListener.__init__cSrrr�rrrrr�!rzBBaseTestAPI.test_handle_accept.<locals>.TestListener.handle_acceptN)rrrrr�rrrr�TestListenersr�r�rRrIr�r�r��rrr�r�rrr�test_handle_acceptszBaseTestAPI.test_handle_acceptcCr�)Nc@r
)z6BaseTestAPI.test_handle_accepted.<locals>.TestListenercSrr�rrrrrr-rz?BaseTestAPI.test_handle_accepted.<locals>.TestListener.__init__cSstj�|�dSr!)r(r�r�rrrrr�4r�zDBaseTestAPI.test_handle_accepted.<locals>.TestListener.handle_acceptcSs|��d|_dSr)rrdr�rrrr�7s
zFBaseTestAPI.test_handle_accepted.<locals>.TestListener.handle_acceptedN)rrrrr�r�rrrrr+srrrrrr�test_handle_accepted(sz BaseTestAPI.test_handle_acceptedcC�LGdd�dt�}Gdd�dt�}t|j|j|�}||j|j�}|�|�dS)Nc@r�)z0BaseTestAPI.test_handle_read.<locals>.TestClientcSrrr�rrrrr�Drz<BaseTestAPI.test_handle_read.<locals>.TestClient.handle_readNr�rrrrr�Cr�r�c@r�)z1BaseTestAPI.test_handle_read.<locals>.TestHandlercSst�||�|�d�dS)Nsxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx)r�rr��rrHrrrrH�z:BaseTestAPI.test_handle_read.<locals>.TestHandler.__init__N�rrrrrrrr�TestHandlerGr�r
�r�r�r�rRrIr�r��rr�r
r�r�rrr�test_handle_read@s
zBaseTestAPI.test_handle_readcCr�)Nc@r�)z1BaseTestAPI.test_handle_write.<locals>.TestClientcSrrr�rrrrr�Trz>BaseTestAPI.test_handle_write.<locals>.TestClient.handle_writeN)rrrr�rrrrr�Sr�r�r�r�rrr�test_handle_writePr�zBaseTestAPI.test_handle_writecCr	)Nc@r)z1BaseTestAPI.test_handle_close.<locals>.TestClientcSrg)N�)rBrrrrr�asz=BaseTestAPI.test_handle_close.<locals>.TestClient.handle_readcS�d|_|��dSr�rdrrrrrr-f�z>BaseTestAPI.test_handle_close.<locals>.TestClient.handle_closeN)rrrr�r-rrrrr�_r�r�c@r�)z2BaseTestAPI.test_handle_close.<locals>.TestHandlercSst�||�|��dSr!)r�rrr
rrrrksz;BaseTestAPI.test_handle_close.<locals>.TestHandler.__init__Nrrrrrr
jr�r
rrrrr�test_handle_close[s
zBaseTestAPI.test_handle_closecsXd�G�fdd�dt�}G�fdd�dt�}t|j|j|�}||j|j�}|�|�dS)Ns�cs(eZdZ�fdd�Zdd�Zdd�ZdS)zCBaseTestAPI.test_handle_close_after_conn_broken.<locals>.TestClientcs|���dSr!)r�rr�rrr�{r$zPBaseTestAPI.test_handle_close_after_conn_broken.<locals>.TestClient.handle_writecSrrrrrrrr-~rzPBaseTestAPI.test_handle_close_after_conn_broken.<locals>.TestClient.handle_closecSrrrrrrrr��rzOBaseTestAPI.test_handle_close_after_conn_broken.<locals>.TestClient.handle_exptN)rrrr�r-r�rr�rrr�ysr�cs eZdZ�fdd�Zdd�ZdS)zDBaseTestAPI.test_handle_close_after_conn_broken.<locals>.TestHandlercs|�t���|��dSr!)rBrprrr�rrr��szPBaseTestAPI.test_handle_close_after_conn_broken.<locals>.TestHandler.handle_readcSrr
rrrrrr��rzMBaseTestAPI.test_handle_close_after_conn_broken.<locals>.TestHandler.writableN)rrrr�r�rr�rrr
�sr
rrrr�r�#test_handle_close_after_conn_brokenss
	z/BaseTestAPI.test_handle_close_after_conn_brokenZsunosz OOB support is broken on SolariscCs�tr
|jtjkr
|�d�tjdkr|jr|�d�Gdd�dt�}Gdd�dt	�}t
|j|j|�}||j|j�}|�
|�dS)N�"Not applicable to AF_UNIX sockets.�darwinz(poll may fail on macOS; see issue #28087c@r�)z0BaseTestAPI.test_handle_expt.<locals>.TestClientcSs|j�dtj�d|_dS)NrT)r"rB�MSG_OOBrdrrrrr��s
z<BaseTestAPI.test_handle_expt.<locals>.TestClient.handle_exptN)rrrr�rrrrr��r�r�c@r�)z1BaseTestAPI.test_handle_expt.<locals>.TestHandlercSs*t�||�|j�ttd�d�tj�dS)N��zlatin-1)r�rr"r��bytes�chrrr
rrrr�sz:BaseTestAPI.test_handle_expt.<locals>.TestHandler.__init__Nrrrrrr
�r�r
)rQrRr"r	�skipTestrw�platformr�r�r�r�rIr�r�rrrr�test_handle_expt�s

zBaseTestAPI.test_handle_exptcCr�)Nc@r)z1BaseTestAPI.test_handle_error.<locals>.TestClientcSsdddS)Ng�?rrrrrrr��r#z>BaseTestAPI.test_handle_error.<locals>.TestClient.handle_writecSsd|_z�tyYdSwr)rd�ZeroDivisionErrorr3rrrrr4�s�z>BaseTestAPI.test_handle_error.<locals>.TestClient.handle_errorN)rrrr�r4rrrrr��sr�r�r�rrr�test_handle_error�szBaseTestAPI.test_handle_errorcCs�t|j|j�}t|j|j�}|�|j�|�|j�|�|j�t	j
d|jdd�|�|j�|�|j�|�|j�|�|j�|��|�|j�|�|j�|�|j�|�|j�|��|�|j�|�|j�dS)Nr<r�r�)
r�rRrIr�r��assertFalseZ	connectedr�Z	acceptingr(r�r�r)rr�r�rrr�test_connection_attributes�s$z&BaseTestAPI.test_connection_attributescCs^t��}|�|j�|�|jjtj�|�|jj|j�|�|j��d�|�	|j�
��dS)Nr)r(r�r�rRrZr"�type�SOCK_STREAMZ
gettimeoutr#�get_inheritable)rr�rrr�test_create_socket�szBaseTestAPI.test_create_socketcCs�tr
|jtjkr
|�d�t��}|�|j�|�|j	�|�
d�|j��d}t��}|�|j�|�t
|j|j	d|f�dS)Nrr�r8r)rQrRr"r	rr(r�r�rTrIr=r�rXr�)r�s1r��s2rrr�	test_bind�s

zBaseTestAPI.test_bindc	Cs�tr
|jtjkr
|�d�t�|j��[}z|�tjtjd�Wnty-t	�
d�Yn9wt�t�|j��}|�
|j�tjtj��|j��|�|j�|��|�|j�tjtj��Wd�dSWd�dS1sqwYdS)Nrr8z+SO_REUSEADDR not supported on this platform)rQrRr"r	r�
setsockopt�
SOL_SOCKETZSO_REUSEADDRr�r��skipr(r�r#Z
getsockoptrr�r�r�)rrUr�rrr�test_set_reuse_addr�s*
��
��"�zBaseTestAPI.test_set_reuse_addrc
Cs�|jtjttdt��fvr|�d�t|j|j�}tj	dd�d�}|�
�zMt�|jtj��-}|�d�|�
tjtjt�ddd	��z|�|j�Wn	tySYnwWd�n1s^wYWt�|�dSWt�|�dSt�|�w)
N�AF_INET6z%test specific to AF_INET and AF_INET6cSstjddd�S)Nr7r�)r�r�)r(r�rrrr�<lambda>s�z0BaseTestAPI.test_quick_connect.<locals>.<lambda>)r�r�Ziir8r)rRr"�AF_INETrb�objectrr�rIr�r�rKr&r�r,r-Z	SO_LINGER�structZpackr�r�r�rr�)rr�rr�rrr�test_quick_connects*

����
�
zBaseTestAPI.test_quick_connectN)r�)rrrr�r�r�rrrrrrr�ZskipIfrwr�
startswithr r"r$r(r+r/rr�r5rrrrr��s*
 �
r�c@�eZdZejZejdfZdS)�TestAPI_UseIPv4SocketsrN)	rrrr"r2rRrr�rIrrrrr8 sr8zIPv6 support requiredc@r7)�TestAPI_UseIPv6SocketsrN)	rrrr"r0rRrZHOSTv6rIrrrrr9$sr9zUnix sockets requiredc@s$eZdZer	ejZejZ	dd�Z
dS)�TestAPI_UseUnixSocketscCst�|j�t�|�dSr!)rrSrIr�r�rrrrr�/rzTestAPI_UseUnixSockets.tearDownN)rrrrQr"r	rRrr�rIr�rrrrr:)s
r:c@�eZdZdZdS)�TestAPI_UseIPv4SelectFN�rrrr�rrrrr<3�r<r^r_c@r;)�TestAPI_UseIPv4PollTNr=rrrrr?6�r?c@r;)�TestAPI_UseIPv6SelectFNr=rrrrrA:r>rAc@r;)�TestAPI_UseIPv6PollTNr=rrrrrB=r@rBc@r;)�TestAPI_UseUnixSocketsSelectFNr=rrrrrCAr>rCc@r;)�TestAPI_UseUnixSocketsPollTNr=rrrrrDDr@rD�__main__):r�rArzr"rwr?r�r4r��testrZtest.supportrrrr�iorZPGOZSkipTest�warnings�catch_warnings�simplefilter�DeprecationWarningr(r�rQrr r&r/rPrVZTestCaserWr�Zdispatcher_with_sendr�r�r�r�r�r�r�r�r�r8ZIPV6_ENABLEDr9r:r<r?rArBrCrDr�mainrrrr�<module>sz


�


H/�G(
	
�