Your IP : 216.73.216.213


Current Path : /proc/242857/root/opt/alt/python34/lib64/python3.4/test/__pycache__/
Upload File :
Current File : //proc/242857/root/opt/alt/python34/lib64/python3.4/test/__pycache__/test_asyncore.cpython-34.pyc

�
g fk�@s�ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZddlm
Z
yddlZWnek
r�dZYnXdZeed�ZGdd�d�ZGdd	�d	�ZGd
d�d�ZGdd
�d
�Zdd�Zdd�ZGdd�dej�ZGdd�dej�ZGdd�dej�ZGdd�dej�ZGdd�de�Zej eed�d�Gdd�dej��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'ej ej(d*�Gd+d,�d,e&��Z)ej ed-�Gd.d/�d/e&��Z*Gd0d1�d1e'ej�Z+ej eed2�d3�Gd4d5�d5e'ej��Z,Gd6d7�d7e)ej�Z-ej eed2�d3�Gd8d9�d9e)ej��Z.Gd:d;�d;e*ej�Z/ej eed2�d3�Gd<d=�d=e*ej��Z0e1d>kr�ej2�ndS)?�N)�support)�BytesIO��AF_UNIXc@s4eZdZdd�Zdd�Zdd�ZdS)�dummysocketcCs
d|_dS)NF)�closed)�self�r	�7/opt/alt/python34/lib64/python3.4/test/test_asyncore.py�__init__szdummysocket.__init__cCs
d|_dS)NT)r)rr	r	r
�closeszdummysocket.closecCsdS)N�*r	)rr	r	r
�filenoszdummysocket.filenoN)�__name__�
__module__�__qualname__rrrr	r	r	r
rsrc@s(eZdZdd�Zdd�ZdS)�dummychannelcCst�|_dS)N)r�socket)rr	r	r
r"szdummychannel.__init__cCs|jj�dS)N)rr)rr	r	r
r%szdummychannel.closeN)rrrrrr	r	r	r
r!src@s:eZdZdd�Zdd�ZeZeZeZdS)�exitingdummycCsdS)Nr	)rr	r	r
r)szexitingdummy.__init__cCstj��dS)N)�asyncore�ExitNow)rr	r	r
�handle_read_event,szexitingdummy.handle_read_eventN)rrrrr�handle_write_event�handle_close�handle_expt_eventr	r	r	r
r(s
rc@sFeZdZdd�Zdd�ZeZeZeZdd�ZdS)�
crashingdummycCs
d|_dS)NF)�
error_handled)rr	r	r
r4szcrashingdummy.__init__cCs
t��dS)N)�	Exception)rr	r	r
r7szcrashingdummy.handle_read_eventcCs
d|_dS)NT)r)rr	r	r
�handle_error>szcrashingdummy.handle_errorN)	rrrrrrrrrr	r	r	r
r3srcCszy#|jd�|j�\}}Wntjk
r=Yn�Xd}tj�}x�|dkr�tj�|dkr�tj|gggd�\}}}	|r�|d8}|jd�}
|j|
jdd	��d|
kr�Pq�ntj	d
�qSW|j
�Wd|j
�|j�XdS)N���rg@g�������?��
s
�g{�G�z�?)�listenZacceptr�timeout�time�select�recv�write�replace�sleepr�set)�evtZbufZserv�conn�addr�n�start�r�w�e�datar	r	r
�capture_serverBs&
%$

r6cCs9tr(|jtjkr(tj|�n|j|�dS)z9Helper function to bind a socket according to its family.N)�HAS_UNIX_SOCKETS�familyrrr�unlink�bind)�sockr/r	r	r
�
bind_af_aware[sr<c@sseZdZdd�Zejeed�d�dd��Zdd�Z	d	d
�Z
dd�Zd
d�ZdS)�HelperFunctionTestscCs�t�}|jtjtj|�|jtjtj|�|jtjtj|�t�}tj|�|j|j	d�t�}tj|�|j|j	d�t�}tj|�|j|j	d�dS)NT)
r�assertRaisesrr�readr)Z
_exceptionr�assertEqualr)r�tr1�tr2r	r	r
�test_readwriteexcds		
	
	
z%HelperFunctionTests.test_readwriteexc�pollzselect.poll requiredc
CsHd
}tjdftjdftjdftjdftjdftjdff}Gdd�d�}x�|D]�\}}|�}|jt||�d�t	j
||�x-|D]%}|jt||�||k�q�Wt�}|jt	j
t	j
||�t�}	|j|	jd�t	j
|	|�|j|	jd	�qnWdS)Nr?�exptr)rrc@sXeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)z3HelperFunctionTests.test_readwrite.<locals>.testobjcSs1d|_d|_d|_d|_d|_dS)NF)r?r)rrEr)rr	r	r
r�s
				z<HelperFunctionTests.test_readwrite.<locals>.testobj.__init__cSs
d|_dS)NT)r?)rr	r	r
r�szEHelperFunctionTests.test_readwrite.<locals>.testobj.handle_read_eventcSs
d|_dS)NT)r))rr	r	r
r�szFHelperFunctionTests.test_readwrite.<locals>.testobj.handle_write_eventcSs
d|_dS)NT)r)rr	r	r
r�sz@HelperFunctionTests.test_readwrite.<locals>.testobj.handle_closecSs
d|_dS)NT)rE)rr	r	r
r�szEHelperFunctionTests.test_readwrite.<locals>.testobj.handle_expt_eventcSs
d|_dS)NT)r)rr	r	r
r�sz@HelperFunctionTests.test_readwrite.<locals>.testobj.handle_errorN)	rrrrrrrrrr	r	r	r
�testobj�srFFT)zreadzexptzwritezclosedz
error_handled)r'ZPOLLINZPOLLPRIZPOLLOUTZPOLLERRZPOLLHUPZPOLLNVALr@�getattrrZ	readwriterr>rrr)
rZ
attributes�expectedrF�flagZexpectedattrZtobj�attrrArBr	r	r
�test_readwrite�s(	
#		z"HelperFunctionTests.test_readwritecCs|jd�dS)NF)�closeall_check)rr	r	r
�
test_closeall�sz!HelperFunctionTests.test_closeallcCs|jd�dS)NT)rL)rr	r	r
�test_closeall_default�sz)HelperFunctionTests.test_closeall_defaultcCs�g}i}xJtd�D]<}t�}|j|�|j|jjd�|||<qW|r�tj}z|t_tj�Wdtj|}t_Xn
tj|�|jt	|�d�x$|D]}|j|jjd�q�WdS)Nr"FrT)
�ranger�appendr@rrr�
socket_map�	close_all�len)rZ
usedefault�lZtestmap�i�cZ	socketmapr	r	r
rL�s"	
		

z"HelperFunctionTests.closeall_checkcCs�ytd��Wn)tj�\}}}tj�}YnX|jd�|\\}}}}}	}
|jtjj	|�dd�|j|d�|j||�|j|	|�|j|
d|||f�dS)NzI don't like spam!zExpected exceptionr!ztest_asyncore.py�test_compact_tracebackz
[%s|%s|%s]���)
r�sys�exc_inforZcompact_traceback�failr@�os�path�split)rZreal_tZreal_vZreal_tbr2�fZfunction�line�t�v�infor	r	r
rW�s
 z*HelperFunctionTests.test_compact_tracebackN)
rrrrC�unittest�
skipUnless�hasattrr'rKrMrNrLrWr	r	r	r
r=cs'<r=c@s|eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZdS)�DispatcherTestscCsdS)Nr	)rr	r	r
�setUp�szDispatcherTests.setUpcCstj�dS)N)rrR)rr	r	r
�tearDown�szDispatcherTests.tearDowncCs<tj�}|j|j�d�|j|j�d�dS)NT)r�
dispatcherr@�readable�writable)r�dr	r	r
�
test_basic�szDispatcherTests.test_basiccCs0tj�}|jt|�dt|��dS)Nz<asyncore.dispatcher at %#x>)rrjr@�repr�id)rrmr	r	r
�	test_repr�szDispatcherTests.test_reprcCs{tj�}d}d}tj��!}|j|�|j|�WdQX|j�j�}|j|d|d|g�dS)NzLovely spam! Wonderful spam!zI don't like spam!zlog: %s)rrjrZcaptured_stderr�log�getvalue�
splitlinesr@)rrm�l1�l2�stderr�linesr	r	r
�test_log�s
zDispatcherTests.test_logc
Cs�tj�}d}d}d}tj��4}|j|d�|j|�|j|d�WdQX|j�j�}d|d|d|g}|j||�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)rrjr�captured_stdoutZlog_inforsrtr@)rrmrurv�l3�stdoutrxrHr	r	r
�
test_log_infos
zDispatcherTests.test_log_infoc
Cs�tj�}f|_tj��/}|j�|j�|j�|j�WdQX|j	�j
�}ddddg}|j||�dS)Nz*warning: unhandled incoming priority eventzwarning: unhandled read eventzwarning: unhandled write eventz warning: unhandled connect event)rrjZignore_log_typesrrz�handle_expt�handle_read�handle_write�handle_connectrsrtr@)rrmr|rxrHr	r	r
�test_unhandleds	


	zDispatcherTests.test_unhandledcCs�tjtj��}|jtdt|d�tjdd��c}tjd�|j	}|j
|tj�|j
t|�d�|j
t|djt��WdQXdS)Nzdispatcher instanceZfoo�recordT�alwaysr!r)rrjrZassertRaisesRegex�AttributeErrorrG�warnings�catch_warnings�simplefilterr8r@�AF_INETrS�
assertTrue�
issubclass�category�DeprecationWarning)rrmr3r8r	r	r
�test_issue_8594-s

	zDispatcherTests.test_issue_8594cCsftjtj�}ttd�r@|j|tjtj��ntjd�}|j|dk�dS)N�strerrorr!�rX)	rZ	_strerror�errnoZEPERMrfr\r@r�r�)r�errr	r	r
�
test_strerror>s
zDispatcherTests.test_strerrorN)rrrrhrirnrqryr}r�r�r�r	r	r	r
rg�s
rgc@s(eZdZdd�Zdd�ZdS)�dispatcherwithsend_noreadcCsdS)NFr	)rr	r	r
rkHsz"dispatcherwithsend_noread.readablecCsdS)Nr	)rr	r	r
r�Ksz(dispatcherwithsend_noread.handle_connectN)rrrrkr�r	r	r	r
r�Gsr�c@sUeZdZdZdd�Zdd�Zejed�e	j
dd���Zd	S)
�DispatcherWithSendTestsFcCsdS)Nr	)rr	r	r
rhQszDispatcherWithSendTests.setUpcCstj�dS)N)rrR)rr	r	r
riTsz DispatcherWithSendTests.tearDownz!Threading required for this test.c
Csptj�}tj�}|jd�tj|�}t�}|||f}tjdtd|�}|j	�z�t
jd�d}t�}|j
�|jtj|f�t
jd�|j|�|j|�|jd�d}	x-|jr|	d	krtj�|	d
8}	q�W|j�|j|j�|d�Wd|jdt�|j�rk|jd
�nXdS)Nr�target�argsg�������?s$Suppose there isn't a 16-ton weight?g�������?s
i�rr!�r%zjoin() timed out)�	threadingZEventr�
settimeoutrZ	bind_portr�Threadr6r1r&r+r��
create_socket�connect�HOST�sendZ
out_bufferrrD�waitr@rs�join�TIMEOUT�is_aliver[)
rr-r;�portZcapr�rar5rmr0r	r	r
�	test_sendWs6
	

	






z!DispatcherWithSendTests.test_sendN)rrr�usepollrhrirdrer�r�reap_threadsr�r	r	r	r
r�Ns
r�c@seZdZdZdS)�DispatcherWithSendTests_UsePollTN)rrrr�r	r	r	r
r��sr��file_wrapperzasyncore.file_wrapper requiredc@seZdZdd�Zdd�Zdd�Zdd�Zeje	e
d	�d
�dd��Zd
d�Zdd�Z
dS)�FileWrapperTestc	Cs8d|_ttjd��}|j|j�WdQXdS)NsIt's not dead, it's sleeping!�wb)rm�openr�TESTFNr))r�filer	r	r
rh�s	zFileWrapperTest.setUpcCstjtj�dS)N)rr9r�)rr	r	r
ri�szFileWrapperTest.tearDowncCs�tjtjtj�}tj|�}tj|�|j|j	|�|j|j
�|�|j|jd�d�|j|j
d�d�|j�|jt|j
d�dS)N�
s
It's not dead�s, it'sr!)r\r�rr��O_RDONLYrr�rZassertNotEqual�fdrr@r(r?r>�OSError)rr�r3r	r	r
�	test_recv�s

zFileWrapperTest.test_recvcCs�d}d}tjtjtjtjB�}tj|�}tj|�|j	|�|j
|�|j�ttjd��(}|j|j�|j
||�WdQXdS)NsCome again?sI want to buy some cheese.�rb)r\r�rr��O_WRONLY�O_APPENDrr�rr)r�r@r?rm)rZd1Zd2r�r3r�r	r	r
r��s



zFileWrapperTest.test_send�file_dispatcherz!asyncore.file_dispatcher requiredcs�tjtjtj�}g�G�fdd�dtj�}||�}tj|�tjdddddd�|j	d	j
��|j�dS)
Ncs"eZdZ�fdd�ZdS)z7FileWrapperTest.test_dispatcher.<locals>.FileDispatchercs�j|jd��dS)N�)rPr()r)r5r	r
r�szCFileWrapperTest.test_dispatcher.<locals>.FileDispatcher.handle_readN)rrrrr	)r5r	r
�FileDispatcher�sr�r%g{�G�z�?�use_pollT�countr�r#)r\r�rr�r�rr�r�loopr@r�rm)rr�r��sr	)r5r
�test_dispatcher�s
zFileWrapperTest.test_dispatchercCsdtjtjtj�}tj|�}tj|�tjdt	f��d}tj
�WdQXdS)Nr�)r\r�rr�r�rr�rZcheck_warnings�ResourceWarningZ
gc_collect)rr�r_r	r	r
�test_resource_warning�s
z%FileWrapperTest.test_resource_warningcCs_tjtjtj�}tj|�}tj|�|j�|j|j	d�|j�dS)Nr!rX)
r\r�rr�r�rr�rr@r�)rr�r_r	r	r
�test_close_twice�s

z FileWrapperTest.test_close_twiceN)rrrrhrir�r�rdrerfrr�r�r�r	r	r	r
r��s

r�c@sgeZdZddd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dS)�BaseTestHandlerNcCs tjj||�d|_dS)NF)rrjrrI)rr;r	r	r
r�szBaseTestHandler.__init__cCstd��dS)Nz'handle_accept not supposed to be called)r)rr	r	r
�
handle_accept�szBaseTestHandler.handle_acceptcCstd��dS)Nz)handle_accepted not supposed to be called)r)rr	r	r
�handle_accepted�szBaseTestHandler.handle_acceptedcCstd��dS)Nz(handle_connect not supposed to be called)r)rr	r	r
r��szBaseTestHandler.handle_connectcCstd��dS)Nz%handle_expt not supposed to be called)r)rr	r	r
r~�szBaseTestHandler.handle_exptcCstd��dS)Nz&handle_close not supposed to be called)r)rr	r	r
r�szBaseTestHandler.handle_closecCs�dS)Nr	)rr	r	r
r�szBaseTestHandler.handle_error)
rrrrr�r�r�r~rrr	r	r	r
r��sr�c@sOeZdZdZedd�Zedd��Zdd�Zdd	�Z	d
S)�
BaseServerzYA server which listens on an address and dispatches the
    connection to a handler.
    cCsQtjj|�|j|�|j�t|j|�|jd�||_dS)Nr)	rrjrr��set_reuse_addrr<rr$�handler)rr8r/r�r	r	r
r�s


zBaseServer.__init__cCs
|jj�S)N)r�getsockname)rr	r	r
�address�szBaseServer.addresscCs|j|�dS)N)r�)rr;r/r	r	r
r��szBaseServer.handle_acceptedcCs�dS)Nr	)rr	r	r
r�szBaseServer.handle_errorN)
rrr�__doc__r�r�propertyr�r�rr	r	r	r
r��s
r�c@s(eZdZdd�Zdd�ZdS)�
BaseClientcCs+tj|�|j|�|j|�dS)N)r�rr�r�)rr8r�r	r	r
r�s

zBaseClient.__init__cCsdS)Nr	)rr	r	r
r�szBaseClient.handle_connectN)rrrrr�r	r	r	r
r��sr�c@seZdZdd�Zddd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zej
ejjd�d�dd��Zdd�Zdd�Zdd�Zdd�Zd d!�Zejed"�ejd#d$���Zd%S)&�BaseTestAPIcCstj�dS)N)rrR)rr	r	r
ri
szBaseTestAPI.tearDownrcCs�t|�d}d}x\tjrt|dkrttjddddd|j�|jrZdS|d8}tj|�qW|jd�dS)	N�drr%g{�G�z�?r�r!r�zflag not set)	�floatrrQr�r�rIr&r+r[)r�instancer%r�r	r	r
�loop_waiting_for_flag
s	
z!BaseTestAPI.loop_waiting_for_flagcCsQGdd�dt�}t|j|j�}||j|j�}|j|�dS)Nc@seZdZdd�ZdS)z3BaseTestAPI.test_handle_connect.<locals>.TestClientcSs
d|_dS)NT)rI)rr	r	r
r�szBBaseTestAPI.test_handle_connect.<locals>.TestClient.handle_connectN)rrrr�r	r	r	r
�
TestClientsr�)r�r�r8r/r�r�)rr��server�clientr	r	r
�test_handle_connectszBaseTestAPI.test_handle_connectcCsQGdd�dt�}||j|j�}t|j|j�}|j|�dS)Nc@s(eZdZdd�Zdd�ZdS)z4BaseTestAPI.test_handle_accept.<locals>.TestListenercSsMtj|�|j|�t|j|�|jd�|jj�|_dS)Nr)r�rr�r<rr$r�r�)rr8r/r	r	r
r(s



z=BaseTestAPI.test_handle_accept.<locals>.TestListener.__init__cSs
d|_dS)NT)rI)rr	r	r
r�/szBBaseTestAPI.test_handle_accept.<locals>.TestListener.handle_acceptN)rrrrr�r	r	r	r
�TestListener&sr�)r�r8r/r�r�r�)rr�r�r�r	r	r
�test_handle_accept#szBaseTestAPI.test_handle_acceptcCsQGdd�dt�}||j|j�}t|j|j�}|j|�dS)Nc@s4eZdZdd�Zdd�Zdd�ZdS)z6BaseTestAPI.test_handle_accepted.<locals>.TestListenercSsMtj|�|j|�t|j|�|jd�|jj�|_dS)Nr)r�rr�r<rr$r�r�)rr8r/r	r	r
r;s



z?BaseTestAPI.test_handle_accepted.<locals>.TestListener.__init__cSstjj|�dS)N)rrjr�)rr	r	r
r�BszDBaseTestAPI.test_handle_accepted.<locals>.TestListener.handle_acceptcSs|j�d|_dS)NT)rrI)rr;r/r	r	r
r�Es
zFBaseTestAPI.test_handle_accepted.<locals>.TestListener.handle_acceptedN)rrrrr�r�r	r	r	r
r�9sr�)r�r8r/r�r�r�)rr�r�r�r	r	r
�test_handle_accepted6sz BaseTestAPI.test_handle_acceptedcCsjGdd�dt�}Gdd�dt�}t|j|j|�}||j|j�}|j|�dS)Nc@seZdZdd�ZdS)z0BaseTestAPI.test_handle_read.<locals>.TestClientcSs
d|_dS)NT)rI)rr	r	r
rRsz<BaseTestAPI.test_handle_read.<locals>.TestClient.handle_readN)rrrrr	r	r	r
r�Qsr�c@seZdZdd�ZdS)z1BaseTestAPI.test_handle_read.<locals>.TestHandlercSs%tj||�|jdd�dS)N�xi)r�rr�)rr.r	r	r
rVsz:BaseTestAPI.test_handle_read.<locals>.TestHandler.__init__N)rrrrr	r	r	r
�TestHandlerUsr�)r�r�r�r8r/r�r�)rr�r�r�r�r	r	r
�test_handle_readNs
zBaseTestAPI.test_handle_readcCsQGdd�dt�}t|j|j�}||j|j�}|j|�dS)Nc@seZdZdd�ZdS)z1BaseTestAPI.test_handle_write.<locals>.TestClientcSs
d|_dS)NT)rI)rr	r	r
r�bsz>BaseTestAPI.test_handle_write.<locals>.TestClient.handle_writeN)rrrr�r	r	r	r
r�asr�)r�r�r8r/r�r�)rr�r�r�r	r	r
�test_handle_write^szBaseTestAPI.test_handle_writecCsjGdd�dt�}Gdd�dt�}t|j|j|�}||j|j�}|j|�dS)Nc@s(eZdZdd�Zdd�ZdS)z1BaseTestAPI.test_handle_close.<locals>.TestClientcSs|jd�dS)Ni)r()rr	r	r
rosz=BaseTestAPI.test_handle_close.<locals>.TestClient.handle_readcSsd|_|j�dS)NT)rIr)rr	r	r
rts	z>BaseTestAPI.test_handle_close.<locals>.TestClient.handle_closeN)rrrrrr	r	r	r
r�msr�c@seZdZdd�ZdS)z2BaseTestAPI.test_handle_close.<locals>.TestHandlercSstj||�|j�dS)N)r�rr)rr.r	r	r
rysz;BaseTestAPI.test_handle_close.<locals>.TestHandler.__init__N)rrrrr	r	r	r
r�xsr�)r�r�r�r8r/r�r�)rr�r�r�r�r	r	r
�test_handle_closeis
zBaseTestAPI.test_handle_closecs�dd�G�fdd�dt�}G�fdd�dt�}t|j|j|�}||j|j�}|j|�dS)Ns�cs:eZdZ�fdd�Zdd�Zdd�ZdS)zCBaseTestAPI.test_handle_close_after_conn_broken.<locals>.TestClientcs|j��dS)N)r�)r)r5r	r
r��szPBaseTestAPI.test_handle_close_after_conn_broken.<locals>.TestClient.handle_writecSsd|_|j�dS)NT)rIr)rr	r	r
r�s	zPBaseTestAPI.test_handle_close_after_conn_broken.<locals>.TestClient.handle_closecSsd|_|j�dS)NT)rIr)rr	r	r
r~�s	zOBaseTestAPI.test_handle_close_after_conn_broken.<locals>.TestClient.handle_exptN)rrrr�rr~r	)r5r	r
r��sr�cs.eZdZ�fdd�Zdd�ZdS)zDBaseTestAPI.test_handle_close_after_conn_broken.<locals>.TestHandlercs!|jt���|j�dS)N)r(rSr)r)r5r	r
r�szPBaseTestAPI.test_handle_close_after_conn_broken.<locals>.TestHandler.handle_readcSsdS)NFr	)rr	r	r
rl�szMBaseTestAPI.test_handle_close_after_conn_broken.<locals>.TestHandler.writableN)rrrrrlr	)r5r	r
r��sr�)r�r�r�r8r/r�r�)rr�r�r�r�r	)r5r
�#test_handle_close_after_conn_broken�s

	z/BaseTestAPI.test_handle_close_after_conn_broken�sunosz OOB support is broken on SolariscCs�tr(|jtjkr(|jd�nGdd�dt�}Gdd�dt�}t|j|j|�}||j|j	�}|j
|�dS)Nz"Not applicable to AF_UNIX sockets.c@seZdZdd�ZdS)z0BaseTestAPI.test_handle_expt.<locals>.TestClientcSs#|jjdtj�d|_dS)NiT)rr(�MSG_OOBrI)rr	r	r
r~�sz<BaseTestAPI.test_handle_expt.<locals>.TestClient.handle_exptN)rrrr~r	r	r	r
r��sr�c@seZdZdd�ZdS)z1BaseTestAPI.test_handle_expt.<locals>.TestHandlercSs9tj||�|jjttd�d�tj�dS)N��zlatin-1)r�rrr��bytes�chrr�)rr.r	r	r
r�sz:BaseTestAPI.test_handle_expt.<locals>.TestHandler.__init__N)rrrrr	r	r	r
r��sr�)r7r8rr�skipTestr�r�r�r/r�r�)rr�r�r�r�r	r	r
�test_handle_expt�szBaseTestAPI.test_handle_exptcCsQGdd�dt�}t|j|j�}||j|j�}|j|�dS)Nc@s(eZdZdd�Zdd�ZdS)z1BaseTestAPI.test_handle_error.<locals>.TestClientcSsdddS)Ng�?rr	)rr	r	r
r��sz>BaseTestAPI.test_handle_error.<locals>.TestClient.handle_writecSs5d|_y�Wntk
r$Yn
Xtd��dS)NTzexception not raised)rI�ZeroDivisionErrorr)rr	r	r
r�s	
z>BaseTestAPI.test_handle_error.<locals>.TestClient.handle_errorN)rrrr�rr	r	r	r
r��sr�)r�r�r8r/r�r�)rr�r�r�r	r	r
�test_handle_error�szBaseTestAPI.test_handle_errorcCs1t|j|j�}t|j|j�}|j|j�|j|j�|j|j�t	j
ddd|jdd�|j|j�|j|j�|j|j�|j|j�|j�|j|j�|j|j�|j|j�|j|j�|j�|j|j�|j|j�dS)Nr%g{�G�z�?r�r�r�)
r�r8r/r�r��assertFalseZ	connectedr�Z	acceptingrr�r�r)rr�r�r	r	r
�test_connection_attributes�s$

z&BaseTestAPI.test_connection_attributescCs�tj�}|j|j�|j|jj|j�ttdd�}tj|B}ttd�r�|j	|jj
|tjB|f�n|j|jj
|�dS)N�
SOCK_NONBLOCKr�SOCK_CLOEXEC)rrjr�r8r@rrG�SOCK_STREAMrfZassertIn�typer�)rr�r�Z	sock_typer	r	r
�test_create_socket�s
zBaseTestAPI.test_create_socketcCs�tr(|jtjkr(|jd�ntj�}|j|j�|j|j	�|j
d�|jj�d}tj�}|j|j�|jt
|j|j	d|f�dS)Nz"Not applicable to AF_UNIX sockets.rr!r)r7r8rrr�rrjr�r:r/r$r�r>r�)r�s1r��s2r	r	r
�	test_bind�s
zBaseTestAPI.test_bindcCstr(|jtjkr(|jd�ntj|j�}z�y|jtjtjd�Wntk
r{t	j
d�Yn�Xtjtj|j��}|j
|jjtjtj��|jj�|j|j�|j�|j|jjtjtj��Wd|j�XdS)Nz"Not applicable to AF_UNIX sockets.r!z+SO_REUSEADDR not supported on this platform)r7r8rrr��
setsockopt�
SOL_SOCKETZSO_REUSEADDRr�rd�skiprrjr�Z
getsockoptrr�r�r�)rr;r�r	r	r
�test_set_reuse_addrs 



zBaseTestAPI.test_set_reuse_addrz!Threading required for this test.cs�jtjttdt��fkrt�j�j�}tjddd����j	���fdd�}�j
|�tj�jtj�}|jd�|j
tjtjtjdd	d
��z-y|j|j�Wntk
r�YnXWd|j�XndS)N�AF_INET6r�cSstjdddd�S)Nr%g�������?r�i�)rr�r	r	r	r
�<lambda>sz0BaseTestAPI.test_quick_connect.<locals>.<lambda>cs0�jdt��j�r,�jd�ndS)Nr%zjoin() timed out)r�r�r�r[r	)rrar	r
�cleanup!sz/BaseTestAPI.test_quick_connect.<locals>.cleanupg�������?Ziir!r)r8rr�rG�objectr�r/r�r�r1Z
addCleanupr�r�r�r�Z	SO_LINGER�structZpackr�r�r�r)rr�r�r�r	)rrar
�test_quick_connects'



	zBaseTestAPI.test_quick_connectN)rrrrir�r�r�r�r�r�r�r�rdZskipIfrY�platform�
startswithr�r�r�r�r�r�rer�rr�r�r	r	r	r
r�s$ r�c@s(eZdZejZejdfZdS)�TestAPI_UseIPv4SocketsrN)	rrrrr�r8rr�r/r	r	r	r
r2s	rzIPv6 support requiredc@s(eZdZejZejdfZdS)�TestAPI_UseIPv6SocketsrN)	rrrrr�r8rZHOSTv6r/r	r	r	r
r6s	rzUnix sockets requiredc@s7eZdZerejZnejZ	dd�Z
dS)�TestAPI_UseUnixSocketscCs!tj|j�tj|�dS)N)rr9r/r�ri)rr	r	r
riAszTestAPI_UseUnixSockets.tearDownN)rrrr7rrr8rr�r/rir	r	r	r
r;s	rc@seZdZdZdS)�TestAPI_UseIPv4SelectFN)rrrr�r	r	r	r
rEsrrDzselect.poll requiredc@seZdZdZdS)�TestAPI_UseIPv4PollTN)rrrr�r	r	r	r
rHsrc@seZdZdZdS)�TestAPI_UseIPv6SelectFN)rrrr�r	r	r	r
rLsrc@seZdZdZdS)�TestAPI_UseIPv6PollTN)rrrr�r	r	r	r
rOsrc@seZdZdZdS)�TestAPI_UseUnixSocketsSelectFN)rrrr�r	r	r	r
rSsrc@seZdZdZdS)�TestAPI_UseUnixSocketsPollTN)rrrr�r	r	r	r
rVsr�__main__)3rrdr'r\rrYr&r�r�r�Ztestr�iorr��ImportErrorr�rfr7rrrrr6r<ZTestCaser=rgZdispatcher_with_sendr�r�r�rer�rjr�r�r�r�rZIPV6_ENABLEDrrrrrrrrr�mainr	r	r	r
�<module>sh

�Y5D�+	%%%