Current File : //opt/imh-python/lib/python2.7/test/test_socketserver.pyc
�
��Wc@s-dZddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlm
Z
mZmZyddlZWnek
r�eZnXejjd�dZejjZeed�Ze	jed�Zeed�o:ejd	kZe	jed
�Zd�ZejZdd
�Z er�de
j!e
j"fd��YZ#de
j!e
j$fd��YZ%nej&d��Z'e	jed�de	j(fd��Y�Z)de	j(fd��YZ*d�Z+e,dkr)e+�ndS(s!
Test suite for SocketServer.py.
i����N(t
reap_childrentreap_threadstverbosetnetworkshello world
tAF_UNIXsrequires Unix socketstforktos2srequires forkingcCs#ttd�rtj|�ndS(s7Call signal.alarm when it exists (i.e. not on Windows).talarmN(thasattrtsignalR(tn((so/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_socketserver.pytsignal_alarm#sicCsNt|ggg|�\}}}||kr:|j|�Std|f�dS(Nstimed out on %r(t_real_selecttrecvtRuntimeError(tsockR
ttimeouttrtwtx((so/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_socketserver.pytreceive+s!
tForkingUnixStreamServercBseZRS((t__name__t
__module__(((so/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_socketserver.pyR3stForkingUnixDatagramServercBseZRS((RR(((so/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_socketserver.pyR7sccsitj�}|dkr(tjd�ndVtj|d�\}}|j||�|jd|�dS(NiiHiiH(tosRt_exittNonetwaitpidtassertEqual(ttestcasetpidtpid2tstatus((so/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_socketserver.pytsimple_subprocess<ss!Threading required for this test.tSocketServerTestcBs.eZdZd�Zd�Zd�Zd�Zed��Zd�Z	d�Z
d�Zd	�Ze
d
��Zed��Zed��Zee
d
���Zd�Zd�Ze
d��Zejd��Zd�Zed��Zed��Zee
d���Zed��Zd�ZRS(sTest all socket servers.cCs td�d|_g|_dS(Ni<i(Rt	port_seedt
test_files(tself((so/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_socketserver.pytsetUpLs
	cCs[td�t�x9|jD].}ytj|�Wqtjk
rHqXqWg|j(dS(Ni(RRR%Rtremoveterror(R&tfn((so/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_socketserver.pyttearDownQs
cCs|tjkrtdfSd}tjdkr7d}ntjddd|�}tjdkr�|ddkr{|d	}n|dtjtj	fkr�|d}ntjd
kr�|j
tjtj	�}q�|j
tj	tj�}n|jj|�|SdS(NiRs\sockettprefixsunix_socket.tdirit:it/(
tsockettAF_INETtHOSTRRtnamettempfiletmktemptseptaltseptreplaceR%tappend(R&tprotoR-R*((so/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_socketserver.pytpickaddr\s 
	

cCsid|fd��Y}d|fd��Y}tr:dGHn|||�}|j|j|jj��|S(NtMyServercBseZd�ZRS(cSs|j|�|j��dS(N(t
close_requesttserver_close(R&trequesttclient_address((so/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_socketserver.pythandle_errorws

(RRRA(((so/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_socketserver.pyR<vst	MyHandlercBseZd�ZRS(cSs#|jj�}|jj|�dS(N(trfiletreadlinetwfiletwrite(R&tline((so/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_socketserver.pythandle}s(RRRH(((so/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_socketserver.pyRB|sscreating server(RRtserver_addressR0tgetsockname(R&taddrtsvrclsthdlrbaseR<RBtserver((so/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_socketserver.pytmake_serverusc	Cs'|j|j|j�||�}|j}trJdGHdG|GHdG|GHntjdd|d|jdidd	6�}t|_	|j
�tr�d
GHnx6td�D](}tr�dG|GHn||j|�q�Wtr�d
GHn|j�|j
�|j�|jtj|jj�tr#dGHndS(Nsserver createdsADDR =sCLASS =R3s
%s servingttargettkwargsg{�G�z�?t
poll_intervalsserver runningistest clientswaiting for servertdone(ROR;taddress_familyRIRt	threadingtThreadt
serve_forevertTruetdaemontstarttrangetshutdowntjoinR>tassertRaisesR0R)tfileno(R&RLRMttestfuncRNRKttti((so/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_socketserver.pyt
run_server�s6			
		



cCs�tj|tj�}|j|�|jt�t|d�}}x/|rsd|krst|d�}||7}qEW|j|t�|j�dS(Nids
(R0tSOCK_STREAMtconnecttsendalltTEST_STRRRtclose(R&R:RKtstbuftdata((so/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_socketserver.pytstream_examine�s

cCs�tj|tj�}trC|tjkrC|j|j|��n|jt|�t|d�}}x/|r�d|kr�t|d�}||7}qiW|j	|t�|j
�dS(Nids
(R0t
SOCK_DGRAMtHAVE_UNIX_SOCKETSRtbindR;tsendtoRgRRRh(R&R:RKRiRjRk((so/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_socketserver.pyt
dgram_examine�scCs |jtjtj|j�dS(N(RctSocketServert	TCPServertStreamRequestHandlerRl(R&((so/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_socketserver.pyttest_TCPServer�scCs |jtjtj|j�dS(N(RcRrtThreadingTCPServerRtRl(R&((so/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_socketserver.pyttest_ThreadingTCPServer�scCs3t|��!|jtjtj|j�WdQXdS(N(R"RcRrtForkingTCPServerRtRl(R&((so/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_socketserver.pyttest_ForkingTCPServer�s
cCs |jtjtj|j�dS(N(RcRrtUnixStreamServerRtRl(R&((so/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_socketserver.pyttest_UnixStreamServer�scCs |jtjtj|j�dS(N(RcRrtThreadingUnixStreamServerRtRl(R&((so/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_socketserver.pyttest_ThreadingUnixStreamServer�scCs0t|��|jttj|j�WdQXdS(N(R"RcRRrRtRl(R&((so/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_socketserver.pyttest_ForkingUnixStreamServer�s
	cCs |jtjtj|j�dS(N(RcRrt	UDPServertDatagramRequestHandlerRq(R&((so/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_socketserver.pyttest_UDPServer�scCs |jtjtj|j�dS(N(RcRrtThreadingUDPServerR�Rq(R&((so/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_socketserver.pyttest_ThreadingUDPServer�scCs3t|��!|jtjtj|j�WdQXdS(N(R"RcRrtForkingUDPServerR�Rq(R&((so/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_socketserver.pyttest_ForkingUDPServer�s
c#sKtj�dd�fd��Y}|�t_ztjVWd�t_XdS(s<Mocks the select.select() call to raise EINTR for first callt
MockSelectcs eZd�Z�fd�ZRS(cSs
d|_dS(Ni(tcalled(R&((so/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_socketserver.pyt__init__�scsP|jd7_|jdkrBtjtjtjtj���n
�|�SdS(Ni(R�tselectR)terrnotEINTRRtstrerror(R&targs(t
old_select(so/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_socketserver.pyt__call__�s$(RRR�R�((R�(so/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_socketserver.pyR��s	N((R�(R&R�((R�so/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_socketserver.pytmocked_select_module�s	
cCsJ|j��8}|jtjtj|j�}|j|jd�WdQXdS(Ni(R�RcRrRsRtRlt
assertGreaterR�(R&tmock_selectR((so/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_socketserver.pyttest_InterruptServerSelectCall
s
cCs |jtjtj|j�dS(N(RcRrtUnixDatagramServerR�Rq(R&((so/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_socketserver.pyttest_UnixDatagramServerscCs |jtjtj|j�dS(N(RcRrtThreadingUnixDatagramServerR�Rq(R&((so/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_socketserver.pyt test_ThreadingUnixDatagramServerscCs|jttj|j�dS(N(RcRRrR�Rq(R&((so/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_socketserver.pyttest_ForkingUnixDatagramServers	c
Cs�dtjfd��Y}dtjfd��Y}g}xmtd�D]_}|tdf|�}tjddd	|jd
idd6�}t|_	|j
||f�qEWx(|D] \}}|j�|j�q�Wx|D]\}}|j
�q�WdS(
NR<cBseZRS((RR(((so/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_socketserver.pyR<)sRBcBseZRS((RR(((so/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_socketserver.pyRB,siiR3sMyServer servingRPRQg{�G�z�?RR(RrRsRtR[R2RURVRWRXRYR9RZR\R](R&R<RBtthreadsRbRiRa((so/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_socketserver.pyt
test_shutdown%s 			
cCsJxCtd�D]5}|jt��tjtdftj�WdQXq
WdS(Nii����(R[R^t
OverflowErrorRrRsR2Rt(R&Rb((so/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_socketserver.pyttest_tcpserver_bind_leak>s(RRt__doc__R'R+R;RORRcRlRqRuRwtrequires_forkingRytrequires_unix_socketsR{R}R~R�R�R�t
contextlibtcontextmanagerR�R�R�R�R�R�R�(((so/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_socketserver.pyR#Hs4											tMiscTestCasecBseZd�ZRS(cCs�dtjfd��Y}|tdftj�}tj|jtj�}|j|j�|j	�|j
�|j|jd�|j
�dS(NR<cBs eZd�ZdZd�ZRS(cSstS(N(tFalse(R&R?R@((so/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_socketserver.pytverify_requestPsicSs&|jd7_tjj||�dS(Ni(tshutdown_calledRrRstshutdown_request(R&R?((so/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_socketserver.pyR�Ts(RRR�R�R�(((so/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_socketserver.pyR<Os	ii(RrRsR2RtR0RTRdReRIRhthandle_requestRR�R>(R&R<RNRi((so/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_socketserver.pyt4test_shutdown_request_called_if_verify_request_falseKs	

(RRR�(((so/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_socketserver.pyR�IscCs2tj�rtjd��ntjjt�dS(Ns"can't run when import lock is held(timpt	lock_heldtunittesttSkipTestttestttest_supporttrun_unittestR#(((so/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_socketserver.pyt	test_mainast__main__(-R�R�R�RR�R	R0R�R4R�Rrttest.test_supportR�RRRRUtImportErrorRR�trequiresRgR2RRnt
skipUnlessR�R3tHAVE_FORKINGR�RRRtForkingMixInRzRR�RR�R"tTestCaseR#R�R�R(((so/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_socketserver.pyt<module>sR

						�