HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //usr/local/lib/python3.10/test/__pycache__/test_asyncore.cpython-310.pyc
o

�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�//usr/local/lib/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�?)�listen�accept�TimeoutError�time�	monotonic�select�recv�write�replace�sleepr�set)�evt�bufZserv�conn�addr�n�start�r�w�e�datarrr�capture_serverHs4�

�
��
rRcCs8tr|jtjkrt�|�t�||�dS|�|�dS)z9Helper function to bind a socket according to its family.N)	�HAS_UNIX_SOCKETS�familyr"r	r�unlinkrZbind_unix_socket�bind)�sockrKrrr�
bind_af_awareas
rXc@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)�readrD�
_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)r[�exptrDrr1r[rcrDrc@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)z3HelperFunctionTests.test_readwrite.<locals>.testobjcSs"d|_d|_d|_d|_d|_dSr
)r[rDrrcr1rrrrr�s

z<HelperFunctionTests.test_readwrite.<locals>.testobj.__init__cSrr)r[rrrrr*�rzEHelperFunctionTests.test_readwrite.<locals>.testobj.handle_read_eventcSrr)rDrrrrr,�rzFHelperFunctionTests.test_readwrite.<locals>.testobj.handle_write_eventcSrrrrrrrr-�rz@HelperFunctionTests.test_readwrite.<locals>.testobj.handle_closecSrr)rcrrrrr.�rzEHelperFunctionTests.test_readwrite.<locals>.testobj.handle_expt_eventcSrrr0rrrrr4�rz@HelperFunctionTests.test_readwrite.<locals>.testobj.handle_errorNr5rrrr�testobj�srdFT)rB�POLLIN�POLLPRI�POLLOUT�POLLERR�POLLHUP�POLLNVALr]�getattrr(Z	readwriter&rZr)r/r1)
rZ
attributes�expectedrd�flagZexpectedattrZtobj�attrr^r_rrr�test_readwrite�s,�	�z"HelperFunctionTests.test_readwritecC�|�d�dSr
��closeall_checkrrrr�
test_closeall�r$z!HelperFunctionTests.test_closeallcCrprrqrrrr�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 �appendr]r"rr(�
socket_map�	close_all�len)rZ
usedefault�lZtestmap�i�cZ	socketmaprrrrr�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�failr]�os�path�split)rZreal_tZreal_vZreal_tbrN�f�function�line�t�v�inforrrr�s
z*HelperFunctionTests.test_compact_tracebackN)
rrrr`�unittest�
skipUnless�hasattrrBrorsrtrrrrrrrrYks
;rYc@sLeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dS)�DispatcherTestscCr'r!rrrrr�setUp�rzDispatcherTests.setUpcC�t��dSr!�r(rxrrrr�tearDown�r#zDispatcherTests.tearDowncCs,t��}|�|��d�|�|��d�dSr)r(�
dispatcherr]�readable�writable�r�drrr�
test_basic�szDispatcherTests.test_basiccCs$t��}|�t|�dt|��dS)Nz<asyncore.dispatcher at %#x>)r(r�r]�repr�idr�rrr�	test_reprszDispatcherTests.test_reprcCstt��}d}d}t���}|�|�|�|�Wd�n1s!wY|����}|�|d|d|g�dS)NzLovely spam! Wonderful spam!r}zlog: %s)r(r�rZcaptured_stderr�log�getvalue�
splitlinesr])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�r])rr�r�r��l3�stdoutr�rlrrr�
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�r])rr�r�r�rlrrr�test_unhandled#s

�zDispatcherTests.test_unhandledcCsFt�tj�}ttd�r|�|t�tj��t�d�}|�|dk�dS)N�strerrorr~�)	r(Z	_strerror�errno�EPERMr�r�r]r��
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�)�	threading�Eventr"�
settimeoutrZ	bind_portr�ThreadrRrMr@rFr��
create_socket�connect�HOST�sendZ
out_bufferr(ra�waitr]r�r�join_thread)
rrHrW�portZcapr�r�rQr�rLrrr�	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�TESTFNrD)r�filerrrr�xs"�zFileWrapperTest.setUpcCst�tj�dSr!)rrUr�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)r�r�rr��O_RDONLYr(r�rZassertNotEqual�fdrr]rCr[rZ�OSError)rr�rOrrr�	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)r�r�rr��O_WRONLY�O_APPENDr(r�rrDr�r]r[r�)rZd1Zd2r�rOr�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�)rvrCr�rQrrr��szCFileWrapperTest.test_dispatcher.<locals>.FileDispatcher.handle_readN�rrrr�rr�rr�FileDispatcher�sr�r<Tr���timeout�use_poll�countr;)r�r�rr�r�r(r�r�loopr]�joinr�)rr�r��srr�r�test_dispatcher�s
zFileWrapperTest.test_dispatchercCsdt�tjtj�}t�|�}t�|�t�	dt
f��d}t��Wd�dS1s+wYdS)Nr�)
r�r�rr�r�r(r�rrZcheck_warnings�ResourceWarningr�
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)Nr~)r�r�rr�r�r(r�rr�rZr�r]r�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�rrm)rrWrrrr�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@s8eZdZdZefdd�Zedd��Zdd�Zdd	�Z	d
S)�
BaseServerzYA server which listens on an address and dispatches the
    connection to a handler.
    cCs>tj�|�|�|�|��t|j|�|�d�||_dS�N�)	r(r�rr��set_reuse_addrrXr"r=�handler)rrTrKr�rrrr�s


zBaseServer.__init__cCs
|j��Sr!)r"�getsocknamerrrr�address�s
zBaseServer.addresscCs|�|�dSr!)r��rrWrKrrrr��r$zBaseServer.handle_acceptedcCr�r!rrrrrr4�r�zBaseServer.handle_errorN)
rrr�__doc__r�r�propertyr�r�r4rrrrr��s
r�c@r)�
BaseClientcCs"t�|�|�|�|�|�dSr!)r�rr�r�)rrTr�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(rwr�r�rmr@rFr�)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�rmrrrrr�rzBBaseTestAPI.test_handle_connect.<locals>.TestClient.handle_connectN)rrrr�rrrr�
TestClient
�r�r�r�rTrKr�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�rXr"r=r�r��rrTrKrrrr�



z=BaseTestAPI.test_handle_accept.<locals>.TestListener.__init__cSrrrrrrrr�!rzBBaseTestAPI.test_handle_accept.<locals>.TestListener.handle_acceptN)rrrrr�rrrr�TestListenersr�r�rTrKr�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)rrmr�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rrrrrrr�Drz<BaseTestAPI.test_handle_read.<locals>.TestClient.handle_readNr�rrrrrCrrc@r)z1BaseTestAPI.test_handle_read.<locals>.TestHandlercSst�||�|�d�dS)Nsxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx)r�rr��rrJrrrrH�z:BaseTestAPI.test_handle_read.<locals>.TestHandler.__init__N�rrrrrrrr�TestHandlerGrr�r�r�r�rTrKr�r�rrrr	r
rrr�test_handle_read@s
zBaseTestAPI.test_handle_readcCr)Nc@r)z1BaseTestAPI.test_handle_write.<locals>.TestClientcSrrrrrrrr�Trz>BaseTestAPI.test_handle_write.<locals>.TestClient.handle_writeN)rrrr�rrrrrSrrrrrrr�test_handle_writePrzBaseTestAPI.test_handle_writecCr)Nc@r)z1BaseTestAPI.test_handle_close.<locals>.TestClientcSrp)N�)rCrrrrr�asz=BaseTestAPI.test_handle_close.<locals>.TestClient.handle_readcS�d|_|��dSr�rmrrrrrr-f�z>BaseTestAPI.test_handle_close.<locals>.TestClient.handle_closeN)rrrr�r-rrrrr_r�rc@r)z2BaseTestAPI.test_handle_close.<locals>.TestHandlercSst�||�|��dSr!)r�rrrrrrrksz;BaseTestAPI.test_handle_close.<locals>.TestHandler.__init__Nrrrrrrjrrrrrrr�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_writecSr!rr"rrrrr-~r#zPBaseTestAPI.test_handle_close_after_conn_broken.<locals>.TestClient.handle_closecSr!rr"rrrrr��r#zOBaseTestAPI.test_handle_close_after_conn_broken.<locals>.TestClient.handle_exptN)rrrr�r-r�rr�rrrysrcs eZdZ�fdd�Zdd�ZdS)zDBaseTestAPI.test_handle_close_after_conn_broken.<locals>.TestHandlercs|�t���|��dSr!)rCryrrr�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rrrrr�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)Nr T)r"rC�MSG_OOBrmrrrrr��s
z<BaseTestAPI.test_handle_expt.<locals>.TestClient.handle_exptN)rrrr�rrrrr�rrc@r)z1BaseTestAPI.test_handle_expt.<locals>.TestHandlercSs*t�||�|j�ttd�d�tj�dS)N��zlatin-1)r�rr"r��bytes�chrr(rrrrr�sz:BaseTestAPI.test_handle_expt.<locals>.TestHandler.__init__Nrrrrrr�rr)rSrTr"r	�skipTestr��platformr�r�r�r�rKr�rrrrr�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)rm�ZeroDivisionErrorr3rrrrr4�s�z>BaseTestAPI.test_handle_error.<locals>.TestClient.handle_errorN)rrrr�r4rrrrr�srrrrrr�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�rTrKr�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�rTr]r"�type�SOCK_STREAM�
gettimeoutr1�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)Nr&r�r8r)rSrTr"r	r,r(r�r�rVrKr=r�rZr�)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)Nr&r8z+SO_REUSEADDR not supported on this platform)rSrTr"r	r,�
setsockopt�
SOL_SOCKET�SO_REUSEADDRr�r��skipr(r�r1�
getsockoptrr�r�r�)rrWr�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��iir8r)rTr"�AF_INETrk�objectr,r�rKr�r�rMr4r�r;r<�	SO_LINGER�struct�packr�r�r�rr�)rr	r�r�rrr�test_quick_connects*

����
�
zBaseTestAPI.test_quick_connectN)r�)rrrr�rrrrrrr$r%r�ZskipIfr�r-�
startswithr.r0r2r7r:r@rr�rIrrrrr��s*
 �
r�c@�eZdZejZejdfZdS)�TestAPI_UseIPv4SocketsrN)	rrrr"rDrTrr�rKrrrrrL srLzIPv6 support requiredc@rK)�TestAPI_UseIPv6SocketsrN)	rrrr"rArTrZHOSTv6rKrrrrrM$srMzUnix sockets requiredc@s$eZdZer	ejZejZ	dd�Z
dS)�TestAPI_UseUnixSocketscCst�|j�t�|�dSr!)rrUrKr�r�rrrrr�/rzTestAPI_UseUnixSockets.tearDownN)rrrrSr"r	rTrr�rKr�rrrrrN)s
rNc@�eZdZdZdS)�TestAPI_UseIPv4SelectFN�rrrr�rrrrrP3�rPrarbc@rO)�TestAPI_UseIPv4PollTNrQrrrrrS6�rSc@rO)�TestAPI_UseIPv6SelectFNrQrrrrrU:rRrUc@rO)�TestAPI_UseIPv6PollTNrQrrrrrV=rTrVc@rO)�TestAPI_UseUnixSocketsSelectFNrQrrrrrWArRrWc@rO)�TestAPI_UseUnixSocketsPollTNrQrrrrrXDrTrX�__main__):r�rBr�r"r�r@r�rGr��testrZtest.supportrrrr�iorZPGOZSkipTest�warnings�catch_warnings�simplefilter�DeprecationWarningr(r�rSrr r&r/rRrXZTestCaserYr�Zdispatcher_with_sendr�r�r�r�r�r�r�r�r�rLZIPV6_ENABLEDrMrNrPrSrUrVrWrXr�mainrrrr�<module>sz


�


H/�G(
	
�