%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/local/lib/python2.7/test/
Upload File :
Create Path :
Current File : //usr/local/lib/python2.7/test/test_socket.pyo


Nac@sddlZddlmZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlZyddlZWnek
reZnXdZdejdZejZdZejZyddlZddlZWnek
rYeZeZnXejZdZdejfdYZd	ejfd
YZdfdYZ d
ee fdYZ!dee fdYZ"de!fdYZ#deje fdYZ$dejfdYZ%ej&edde#fdYZ'ej&edde"fdYZ(ej&edde!fdYZ)ej&e*eddej&edd e$fd!YZ+ej&edd"e!fd#YZ,ej&edd$e#fd%YZ-d&ejfd'YZ.d(e-fd)YZ/d*e-fd+YZ0d,e-fd-YZ1d.e2fd/YZ3d0e3e'fd1YZ4d2ejfd3YZ5ej&edd4ee fd5YZ6ej&edd6ee fd7YZ7d8ejfd9YZ8d:efd;YZ9d<efd=YZ:d>ejfd?YZ;ej&e
j<d@kdAdBejfdCYZ=ej&eddDe#fdEYZ>dFZ?dGZ@dHZAdIZBej&eBdJdKejfdLYZCej&eBdJdMeje fdNYZDdOZEeFdPkreEndS(QiN(ttest_supportgN@icCs_y,tj|tj}|j||fWntjtjfk
rLtSX|jtSdS(sZTry to bind a socket on the given host:port and return True
    if that has been possible.N(tsockettSOCK_STREAMtbindterrortgaierrortFalsetclosetTrue(thosttporttfamilytsock((s,/usr/local/lib/python2.7/test/test_socket.pyttry_addresss
sMichael Gilfix was here
t
SocketTCPTestcBseZdZdZRS(cCsDtjtjtj|_tj|j|_|jjddS(Ni(RtAF_INETRtservRt	bind_portR
tlisten(tself((s,/usr/local/lib/python2.7/test/test_socket.pytsetUp7scCs|jjd|_dS(N(RRtNone(R((s,/usr/local/lib/python2.7/test/test_socket.pyttearDown<s
(t__name__t
__module__RR(((s,/usr/local/lib/python2.7/test/test_socket.pyR5s	t
SocketUDPTestcBseZdZdZRS(cCs4tjtjtj|_tj|j|_dS(N(RRt
SOCK_DGRAMRRRR
(R((s,/usr/local/lib/python2.7/test/test_socket.pyRBscCs|jjd|_dS(N(RRR(R((s,/usr/local/lib/python2.7/test/test_socket.pyRFs
(RRRR(((s,/usr/local/lib/python2.7/test/test_socket.pyR@s	tThreadableTestcBsMeZdZdZdZdZdZdZdZdZ	RS(sThreadable Test class

    The ThreadableTest class makes it easy to create a threaded
    client/server pair from an existing unit test. To create a
    new threaded class from an existing unit test, use multiple
    inheritance:

        class NewClass (OldClass, ThreadableTest):
            pass

    This class defines two new fixture functions with obvious
    purposes for overriding:

        clientSetUp ()
        clientTearDown ()

    Any new test functions within the class must then define
    tests in pairs, where the test name is preceded with a
    '_' to indicate the client portion of the test. Ex:

        def testFoo(self):
            # Server portion

        def _testFoo(self):
            # Client portion

    Any exceptions raised by the clients during their tests
    are caught and transferred to the main thread to alert
    the testing framework.

    Note, the server setup function cannot call any blocking
    functions that rely on the client thread during setup,
    unless serverExplicitReady() is called just before
    the blocking call (such as in setting up a client/server
    connection and performing the accept() in setUp().
    cCs4|j|_|j|_|j|_|j|_dS(N(Rt_ThreadableTest__setUpRt_ThreadableTest__tearDownt_setUpt	_tearDown(R((s,/usr/local/lib/python2.7/test/test_socket.pyt__init__pscCs|jjdS(sThis method allows the server to explicitly indicate that
        it wants the client thread to proceed. This is useful if the
        server is about to execute a blocking routine that is
        dependent upon the client thread during its setup routine.N(tserver_readytset(R((s,/usr/local/lib/python2.7/test/test_socket.pytserverExplicitReadywscCstj|_tj|_tj|_tjd|_|j}|jd}||d}t	|d|}t
j|j|f|_
|j|jjs|jjn|jjdS(Nit.t_(t	threadingtEventR!tclient_readytdonetQueuetqueuetidtrfindtgetattrtthreadtstart_new_threadt	clientRunt
client_threadRtis_setR"twait(Rt
methodnametittest_method((s,/usr/local/lib/python2.7/test/test_socket.pyR~s
cCsI|j|jj|jjsE|jj}|j|ndS(N(RR)R4R+temptytgettfail(Rtmsg((s,/usr/local/lib/python2.7/test/test_socket.pyRs


cCs~|jj|j|jjt|s?tdny|Wn#tk
ro}|jj	|nX|j
dS(Ns&test_func must be a callable function.(R!R4tclientSetUpR(R"tcallablet	TypeErrort	ExceptionR+tputtclientTearDown(Rt	test_functstrerror((s,/usr/local/lib/python2.7/test/test_socket.pyR1s


cCstddS(Ns clientSetUp must be implemented.(tNotImplementedError(R((s,/usr/local/lib/python2.7/test/test_socket.pyR<scCs|jjtjdS(N(R)R"R/texit(R((s,/usr/local/lib/python2.7/test/test_socket.pyRAs
(
RRt__doc__R R#RRR1R<RA(((s,/usr/local/lib/python2.7/test/test_socket.pyRJs$						tThreadedTCPSocketTestcBs&eZddZdZdZRS(trunTestcCs$tj|d|tj|dS(Nt
methodName(RR R(RRI((s,/usr/local/lib/python2.7/test/test_socket.pyR scCstjtjtj|_dS(N(RRRtcli(R((s,/usr/local/lib/python2.7/test/test_socket.pyR<scCs'|jjd|_tj|dS(N(RJRRRRA(R((s,/usr/local/lib/python2.7/test/test_socket.pyRAs
	(RRR R<RA(((s,/usr/local/lib/python2.7/test/test_socket.pyRGs	tThreadedUDPSocketTestcBs&eZddZdZdZRS(RHcCs$tj|d|tj|dS(NRI(RR R(RRI((s,/usr/local/lib/python2.7/test/test_socket.pyR scCstjtjtj|_dS(N(RRRRJ(R((s,/usr/local/lib/python2.7/test/test_socket.pyR<scCs'|jjd|_tj|dS(N(RJRRRRA(R((s,/usr/local/lib/python2.7/test/test_socket.pyRAs
	(RRR R<RA(((s,/usr/local/lib/python2.7/test/test_socket.pyRKs	tSocketConnectedTestcBs8eZddZdZdZdZdZRS(RHcCstj|d|dS(NRI(RGR (RRI((s,/usr/local/lib/python2.7/test/test_socket.pyR scCs9tj||j|jj\}}||_dS(N(RGRR#Rtaccepttcli_conn(Rtconntaddr((s,/usr/local/lib/python2.7/test/test_socket.pyRs

cCs'|jjd|_tj|dS(N(RNRRRGR(R((s,/usr/local/lib/python2.7/test/test_socket.pyRs
	cCs6tj||jjt|jf|j|_dS(N(RGR<RJtconnecttHOSTR
t	serv_conn(R((s,/usr/local/lib/python2.7/test/test_socket.pyR<s
cCs'|jjd|_tj|dS(N(RSRRRGRA(R((s,/usr/local/lib/python2.7/test/test_socket.pyRAs
	(RRR RRR<RA(((s,/usr/local/lib/python2.7/test/test_socket.pyRLs
			tSocketPairTestcBs8eZddZdZdZdZdZRS(RHcCs'tjj|d|tj|dS(NRI(tunittesttTestCaseR R(RRI((s,/usr/local/lib/python2.7/test/test_socket.pyR scCstj\|_|_dS(N(Rt
socketpairRRJ(R((s,/usr/local/lib/python2.7/test/test_socket.pyRscCs|jjd|_dS(N(RRR(R((s,/usr/local/lib/python2.7/test/test_socket.pyRs
cCsdS(N((R((s,/usr/local/lib/python2.7/test/test_socket.pyR<scCs'|jjd|_tj|dS(N(RJRRRRA(R((s,/usr/local/lib/python2.7/test/test_socket.pyRAs
	(RRR RRR<RA(((s,/usr/local/lib/python2.7/test/test_socket.pyRTs
			tGeneralModuleTestscBs$eZejed.k	ddZdZdZdZ	dZ
dZdZeje
edd	d
ZdZdZd
ZdZdZeje
edddZeje
edddZeje
edddZeje
edddZeje
edddZddZdZdZdZd Zd!Z d"Z!eje"j#d#kd$d%Z$d&Z%d'Z&d(Z'd)Z(d*Z)e*j+d+Z,eje-d,d-Z.RS(/sneed _socket modulecCstjtjtj}z?d|j|j|j|jf}|jt	||Wd|j
Xd|j|j|jf}|jt	||dS(Ns7<socket object, fd=%s, family=%s, type=%s, protocol=%s>s7<socket object, fd=-1, family=%s, type=%s, protocol=%s>(t_socketRRRtfilenoRttypetprototassertEqualtreprR(Rtstexpected((s,/usr/local/lib/python2.7/test/test_socket.pyttest_csocket_reprs"cCstjtjtj}tj|}|j|j|j|jd}y|jWnt	k
rtnX|j
ddS(NsSocket proxy still exists(RRRtweakreftproxyR]RZRRtReferenceErrorR:(RR_tp((s,/usr/local/lib/python2.7/test/test_socket.pyttest_weakrefs

cCsRtjj}tj|}|j||~tj|j|dS(N(Rt_sockRbtreftassertIsRt
gc_collecttassertIsNone(RR_tw((s,/usr/local/lib/python2.7/test/test_socket.pyttest_weakref__socks
cCsad}d}d}|jtj|d|jtj|d|jtj|ddS(Nc_s
tjdS(N(RR(targstkwargs((s,/usr/local/lib/python2.7/test/test_socket.pytraise_error#sc_s
tjdS(N(Rtherror(RnRo((s,/usr/local/lib/python2.7/test/test_socket.pytraise_herror%sc_s
tjdS(N(RR(RnRo((s,/usr/local/lib/python2.7/test/test_socket.pytraise_gaierror'ssError raising socket exception.(tassertRaisesRR(RRpRrRs((s,/usr/local/lib/python2.7/test/test_socket.pyttestSocketError!s			cCstjtjtj}|j|j|jd
|j}|jt|j	d|WdQX|jt
}|j	d|WdQX|jdt|j
|jt
}|j	ddWdQX|jdt|j
|jt|j	dd|WdQX|jt
}|j	dd|WdQX|jdt|j
|jt
}|j	dddWdQX|jdt|j
|jt
}|j	dd|WdQX|jd	t|j
|jt
}|j	dddWdQX|jd	t|j
|jt
}|j	dWdQX|jd
t|j
|jt
}|j	dd|dWdQX|jdt|j
dS(Ntiu☠y@snot complextfoosnot NoneTypetbarsan integer is requireds	(1 given)is	(4 given)(Rvi(RRRt
addCleanupRRtgetsocknameRttUnicodeEncodeErrortsendtoR>tassertIntstrt	exceptionR(RR_tsocknametcm((s,/usr/local/lib/python2.7/test/test_socket.pyttestSendtoErrors0s@
cCs<tjtjtjtjtjtjtjtjdS(N(	RRRRtSOCK_RAWtSOCK_RDMtSOCK_SEQPACKETt
SOL_SOCKETtSO_REUSEADDR(R((s,/usr/local/lib/python2.7/test/test_socket.pyttestCrucialConstantsWscCstj}ytj|}Wn!tjk
rB|jdnX|j|jddkdytj|\}}}Wn!tjk
r|jdnX||g|}tj|}||kr|j	d|t
|fndS(Nsname lookup failureR$isError resolving host to ip.saddress lookup failures=Error testing host resolution mechanisms. (fqdn: %s, all: %s)(Rtgethostnamet
gethostbynameRtskipTestt
assertTruetfindt
gethostbyaddrtgetfqdnR:R^(Rthostnametipthnametaliasestipaddrstall_host_namestfqhn((s,/usr/local/lib/python2.7/test/test_socket.pyttestHostnameResbstgetrefcountstest needs sys.getrefcount()cCsWy#tjt}tjtdWn-tk
rR|jtjt|dnXdS(Nis$socket.getnameinfo loses a reference(tsysRRRtgetnameinfoR>R](Rtorig((s,/usr/local/lib/python2.7/test/test_socket.pyttestRefCountGetNameInfous
cCs/ytjddWntjk
r*nXdS(Ntxi(Riii(RRR(R((s,/usr/local/lib/python2.7/test/test_socket.pyttestInterpreterCrashscCsidtj6dtj6dtj6dtj6}x|jD]\}}d|>d}xKddddddd	fD].}|j||@||||@|@qqW||}|j||@||jt|dq;WdS(
Ni iliiiiigE#i2Tvi"il(	RthtonltntohlthtonstntohstitemsR]Rtt
OverflowError(RtsizestfunctsizetmaskR6tswapped((s,/usr/local/lib/python2.7/test/test_socket.pyttestNtoHs",cCsddddddg}ddd	d
ddg}xB|D]:}tj|tj|tj|tj|q7Wxf|D]^}|jttj||jttj||jttj||jttj|q|WdS(
Niiillliiilll(RRRRRRtR(Rtgood_valuest
bad_valuestk((s,/usr/local/lib/python2.7/test/test_socket.pyttestNtoHErrorss




cCs|j}tjjdsNtjjdsNtjjdsNtjdkrWd
}nd}xE|D]4}ytj|d	}PWqdtjk
rqdXqdWtjtj|}|||ytj|d
}Wntjk
rd}nX||||tj|||tj|d	||dk	rX|tj|d
|n|j	t
tjd|j	t
tjddS(Ntlinuxtfreebsdtnetbsdtdarwintdaytimetqotdtdomaintechottcptudpii(RRR(RRR(R]Rtplatformt
startswithRt
getservbynameRRt
getservbyportRtR(RteqtservicestserviceR
tport2tudpport((s,/usr/local/lib/python2.7/test/test_socket.pyt
testGetServBys6		
	


cCs|jtjdtj}|j|jd|jtjd|jtjdtj}|j|jd|jtjd|jtjdtj}|j|jd|j|jttjd|jt	tjddS(Ni
itspam(
R]RtgetdefaulttimeoutRt
gettimeoutRtsetdefaulttimeoutRtt
ValueErrorR>(RR_((s,/usr/local/lib/python2.7/test/test_socket.pyttestDefaultTimeouts 




t	inet_atonstest needs socket.inet_aton()cCs6|jdtjd|jdtjddS(Nsis0.0.0.0ss255.255.255.255ss(R]RR(R((s,/usr/local/lib/python2.7/test/test_socket.pyttestIPv4_inet_aton_fourbytesst	inet_ptonstest needs socket.inet_pton()csddlm}mmfd}|jd|d|jd|d|jd|d	|jd
|d|jd|d
|jd|d|jd|d|jd|d	|jd|d
dS(Ni(RRRcs
|S(N((ta(RR(s,/usr/local/lib/python2.7/test/test_socket.pyt<lambda>Rvss0.0.0.0ss255.0.255.0ss170.170.170.170ss1.2.3.4ss255.255.255.255(RRRRR](Rtftg((RRs,/usr/local/lib/python2.7/test/test_socket.pyttestIPv4toStringscsy6ddlmmm}|s5|jdnWntk
rV|jdnXfd}|jd|d|jd|d	|jd
d|d|jd
|ddS(Ni(RtAF_INET6thas_ipv6sIPv6 not availables+could not import needed symbols from socketcs
|S(N((R(RR(s,/usr/local/lib/python2.7/test/test_socket.pyRRvsis::s0::0sis1::sEvV$s$45ef:76cb:1a:56ef:afeb:bac:1924:aeaesss(RRRRRtImportErrorR](RRR((RRs,/usr/local/lib/python2.7/test/test_socket.pyttestIPv6toStrings
t	inet_ntopstest needs socket.inet_ntop()csddlm}mmfd}|jd|d|jd|d|jd|d	|jd
|d|jd|d|jd|d|jd|d	dS(Ni(t	inet_ntoaRRcs
|S(N((R(RR(s,/usr/local/lib/python2.7/test/test_socket.pyRRvs1.0.1.0ss
170.85.170.85sUUs255.255.255.255ss1.2.3.4s(RRRRR](RRR((RRs,/usr/local/lib/python2.7/test/test_socket.pyttestStringToIPv4scsy6ddlmmm}|s5|jdnWntk
rV|jdnXfd}|jd|d|jd	|d|jd|d
dS(Ni(RRRsIPv6 not availables+could not import needed symbols from socketcs
|S(N((R(RR(s,/usr/local/lib/python2.7/test/test_socket.pyR.Rvs::sis::1iss!aef:b01:506:1001:ffff:9997:55:170s
Upsss(RRRRRRR](RRR((RRs,/usr/local/lib/python2.7/test/test_socket.pyttestStringToIPv6%s
s0.0.0.0cCs?tj}|j|df|j\}}|j|S(sUse a temporary socket to elicit an unused ephemeral port.

        Args:
            bind_address: Hostname or IP address to search for a port on.

        Returns: A most likely to be unused port.
        i(RRRzR(Rtbind_addressttempsockR	R
((s,/usr/local/lib/python2.7/test/test_socket.pyt_get_unused_port9s

cCs|j}tjtjtj}|j|j|jd|f|j}ytjtj	}Wn!tj
k
r|jdnX|j|dd|fd|d|j
|d|dS(Ns0.0.0.0sname lookup failureis
%s invalidi(RRRRRyRRRzRRRRR}R](RR
Rtnamet
my_ip_addr((s,/usr/local/lib/python2.7/test/test_socket.pyttestSockNameGs%cCsZtjtjtj}|j|j|jtjtj}|j|dkddS(Nisinitial mode is reuse(	RRRRyRt
getsockoptRRtassertFalse(RRtreuse((s,/usr/local/lib/python2.7/test/test_socket.pyttestGetSockOptYscCsstjtjtj}|j|j|jtjtjd|jtjtj}|j	|dkddS(Niisfailed to set reuse mode(
RRRRyRt
setsockoptRRRR(RRR((s,/usr/local/lib/python2.7/test/test_socket.pyttestSetSockOptas
cCsLtjtjtj}|jd|j|jtj|jddS(NiR(RRRt
settimeoutRRtRtsend(RR((s,/usr/local/lib/python2.7/test/test_socket.pyttestSendAfterCloseis

cCsetjtjtj}|j|jtj|j|jtj|j|jd|jdS(Ni(RRRR]RR[R\R(RR((s,/usr/local/lib/python2.7/test/test_socket.pyttestNewAttributesps
cCstj}|j|jtj}|d}|d}|jt|jt|f|jt|jt|fxrt	j
D]d}tj}y|jt|fWn7tk
r}|jtj
ks|dkrqqXPqWdS(Nii(RRyRRtfind_unused_portRtRRRRt	itertoolstcounttOSErrorterrnot
EADDRINUSE(RRR
tbig_porttneg_portR6te((s,/usr/local/lib/python2.7/test/test_socket.pyttest_getsockaddrargxs


tntsWindows specificcCs|jttjd|jttd|jttd|jttd|jttdtj}|j|j|jt|jdd|jtj	d	dS(
Ntioctlt
SIO_RCVALLt	RCVALL_ONt
RCVALL_OFFtSIO_KEEPALIVE_VALSiiid(iidid(
RthasattrRRyRRtRRRR(RR_((s,/usr/local/lib/python2.7/test/test_socket.pyttest_sock_ioctlscCsWytjddWn;tjk
rQ}|jtjkrK|jdnnXx0tjtdD]}|jt	|dqeWtjddtjddtjddt
rtjddntjtdtjtdtjtdtjtdtjtdtj}x0|D](\}}}}}|j|tjq-Wtjtdd	tj}x0|D](\}}}}}|j|tjq{Wtjtdd	d	tj
tjtdd	d	d	tjtjdd	tjtjd	tjttd
rSy#tjddd	d	d	tjWqStjk
rOqSXndS(Nt	localhostiPsbuggy libc versionis	127.0.0.1s::1thttplPitAI_NUMERICSERV(RtgetaddrinfoRRtEAI_SERVICERRRRR]tlent
SUPPORTS_IPV6RRtSOL_TCPt
AI_PASSIVEt	AF_UNSPECRR(RterrtinfotinfosRR%tsocktype((s,/usr/local/lib/python2.7/test/test_socket.pyttestGetaddrinfosB
csKttds ttdr0jdnfd}fd}tj\}}tjtj|}z|r|jdnjt&tj	d|j
dtjWdQX|rtjtj|tj	djtj
|j
dtjnWdtj	d	tjtj||j|jXdS(
NtalarmRWs9signal.alarm and socket.socketpair required for this testcsjttjddS(Ni(RtRtmathtacosh(Rn(R(s,/usr/local/lib/python2.7/test/test_socket.pyt
ok_handlerscs"jttjddddS(Nii(RtRRR(Rn(R(s,/usr/local/lib/python2.7/test/test_socket.pytraising_handlersg?iRi(RtsignalRRRWtSIGALRMRRttZeroDivisionErrorR
tsendallRt
SOCK_MAX_SIZEttimeoutR(Rtwith_timeoutR
RtcR_t	old_alarm((Rs,/usr/local/lib/python2.7/test/test_socket.pytcheck_sendall_interrupteds* 



cCs|jtdS(N(RR(R((s,/usr/local/lib/python2.7/test/test_socket.pyttest_sendall_interruptedscCs|jtdS(N(RR(R((s,/usr/local/lib/python2.7/test/test_socket.pyt%test_sendall_interrupted_with_timeoutscCsWxPdD]H}tjtjtj}|jtdf|j||jqWdS(Nii(ii(RRRRRRRR(Rtbacklogtsrv((s,/usr/local/lib/python2.7/test/test_socket.pyttest_listen_backlogs


cCsbddl}tjtjtj}|jtdf|jt|j|j	d|j
dS(Niii(t	_testcapiRRRRRRRtRRtINT_MAXR(RRR((s,/usr/local/lib/python2.7/test/test_socket.pyttest_listen_backlog_overflows
sIPv6 required for this test.cCs]|jttjddtjtjtj}z|jt|jdWd|jXdS(Ns::1iIi(s::1iI(s::1ii(RtRRRRRRR(RR_((s,/usr/local/lib/python2.7/test/test_socket.pyt
test_flowinfos
N(/RRRUt
skipUnlessRYRRaRfRmRuRRRRRRRRRRRRRRRRRRRRRRRRtosRRR	RRRRRtcpython_onlyR RR!(((s,/usr/local/lib/python2.7/test/test_socket.pyRXsN!
	
			'						)							$	1					s!Threading required for this test.tBasicTCPTestcBseZddZdZdZdZdZdZdZdZ	d	Z
d
ZdZe
jeedd
dZdZdZdZdZdZejeZejdZRS(RHcCstj|d|dS(NRI(RLR (RRI((s,/usr/local/lib/python2.7/test/test_socket.pyR scCs&|jjd}|j|tdS(Ni(RNtrecvR]tMSG(RR;((s,/usr/local/lib/python2.7/test/test_socket.pyttestRecvscCs|jjtdS(N(RSRR'(R((s,/usr/local/lib/python2.7/test/test_socket.pyt	_testRecvscCsL|jjttd}|jjd}||}|j|tdS(Nii(RNR&RR'R](Rtseg1tseg2R;((s,/usr/local/lib/python2.7/test/test_socket.pyttestOverFlowRecvs
cCs|jjtdS(N(RSRR'(R((s,/usr/local/lib/python2.7/test/test_socket.pyt_testOverFlowRecvscCs,|jjd\}}|j|tdS(Ni(RNtrecvfromR]R'(RR;RP((s,/usr/local/lib/python2.7/test/test_socket.pyttestRecvFrom!scCs|jjtdS(N(RSRR'(R((s,/usr/local/lib/python2.7/test/test_socket.pyt
_testRecvFrom&scCsX|jjttd\}}|jjd\}}||}|j|tdS(Nii(RNR.RR'R](RR*RPR+R;((s,/usr/local/lib/python2.7/test/test_socket.pyttestOverFlowRecvFrom)s"
cCs|jjtdS(N(RSRR'(R((s,/usr/local/lib/python2.7/test/test_socket.pyt_testOverFlowRecvFrom0scCsKd}x*|jjd}|s%Pn||7}q	W|j|dddS(NRviRi(RNR&R](RR;tread((s,/usr/local/lib/python2.7/test/test_socket.pyttestSendAll3scCsdd}|jj|dS(NRi(RSR(Rt	big_chunk((s,/usr/local/lib/python2.7/test/test_socket.pyt_testSendAll=s
tfromfdssocket.fromfd not availablecCs]|jj}tj|tjtj}|j|j|jd}|j	|t
dS(Ni(RNRZRR7RRRyRR&R]R'(RtfdRR;((s,/usr/local/lib/python2.7/test/test_socket.pyt
testFromFdAs
cCs|jjtdS(N(RSRR'(R((s,/usr/local/lib/python2.7/test/test_socket.pyt_testFromFdKscCsB|jj}|j|j|jd}|j|tdS(Ni(RNtdupRyRR&R]R'(RRR;((s,/usr/local/lib/python2.7/test/test_socket.pyttestDupNscCs|jjtdS(N(RSRR'(R((s,/usr/local/lib/python2.7/test/test_socket.pyt_testDupUscCs3|jjd}|j|t|jjdS(Ni(RNR&R]R'R)R4(RR;((s,/usr/local/lib/python2.7/test/test_socket.pyttestShutdownXscCs$|jjt|jjddS(Ni(RSRR'tshutdown(R((s,/usr/local/lib/python2.7/test/test_socket.pyt
_testShutdownascCstddl}|jjt|jt|jj|jd|jt|jjd|jd|jjddS(Niii(	RRSRR'RtRR?RtUINT_MAX(RR((s,/usr/local/lib/python2.7/test/test_socket.pyt_testShutdown_overflowgs(RRR R(R)R,R-R/R0R1R2R4R6RUR"RRR9R:R<R=R>R@RR$ttestShutdown_overflowRB(((s,/usr/local/lib/python2.7/test/test_socket.pyR%	s(									
								tBasicUDPTestcBsJeZddZdZdZdZdZdZdZRS(RHcCstj|d|dS(NRI(RKR (RRI((s,/usr/local/lib/python2.7/test/test_socket.pyR uscCs,|jjtt}|j|tdS(N(RR&RR'R](RR;((s,/usr/local/lib/python2.7/test/test_socket.pyttestSendtoAndRecvxscCs#|jjtdt|jfdS(Ni(RJR|R'RRR
(R((s,/usr/local/lib/python2.7/test/test_socket.pyt_testSendtoAndRecv}scCs2|jjtt\}}|j|tdS(N(RR.RR'R](RR;RP((s,/usr/local/lib/python2.7/test/test_socket.pyR/scCs#|jjtdt|jfdS(Ni(RJR|R'RRR
(R((s,/usr/local/lib/python2.7/test/test_socket.pyR0scCs|jt|jjddS(Ni(RtRRR.(R((s,/usr/local/lib/python2.7/test/test_socket.pyttestRecvFromNegativescCs#|jjtdt|jfdS(Ni(RJR|R'RRR
(R((s,/usr/local/lib/python2.7/test/test_socket.pyt_testRecvFromNegatives(	RRR RERFR/R0RGRH(((s,/usr/local/lib/python2.7/test/test_socket.pyRDrs					t
TCPCloserTestcBseZdZdZRS(cCs||jj\}}|j|j}tj|gggd\}}}|j||g|j|jdddS(Ng?iRv(RRMRRJtselectR]R&(RRORPtsdR3twriteR((s,/usr/local/lib/python2.7/test/test_socket.pyt	testCloses
	$cCs*|jjt|jftjddS(Ng?(RJRQRRR
ttimetsleep(R((s,/usr/local/lib/python2.7/test/test_socket.pyt
_testCloses(RRRMRP(((s,/usr/local/lib/python2.7/test/test_socket.pyRIs		RWstest needs socket.socketpair()tBasicSocketPairTestcBs8eZddZdZdZdZdZRS(RHcCstj|d|dS(NRI(RTR (RRI((s,/usr/local/lib/python2.7/test/test_socket.pyR scCs&|jjd}|j|tdS(Ni(RR&R]R'(RR;((s,/usr/local/lib/python2.7/test/test_socket.pyR(scCs|jjtdS(N(RJRR'(R((s,/usr/local/lib/python2.7/test/test_socket.pyR)scCs|jjtdS(N(RRR'(R((s,/usr/local/lib/python2.7/test/test_socket.pyttestSendscCs&|jjd}|j|tdS(Ni(RJR&R]R'(RR;((s,/usr/local/lib/python2.7/test/test_socket.pyt	_testSends(RRR R(R)RRRS(((s,/usr/local/lib/python2.7/test/test_socket.pyRQs
			tNonBlockingTCPTestscBs}eZddZdZdZejdZejeZdZ	dZ
dZdZd	Z
d
ZRS(RHcCs&tj|_tj|d|dS(NRI(R&R'teventRGR (RRI((s,/usr/local/lib/python2.7/test/test_socket.pyR scCs|jjt|j|jj|jjt|j|jjdtj}y|jjWnt	j
k
rnXtj}|j||dkddS(Ngg?s Error setting non-blocking mode.(RtsetblockingRRkRRR]RNRMRRR(Rtstarttend((s,/usr/local/lib/python2.7/test/test_socket.pyttestSetBlockingscCsdS(N((R((s,/usr/local/lib/python2.7/test/test_socket.pyt_testSetBlockingscCsddl}|j|jkr.|jdn|jjt|j|jjd|jj|jd|j	|jjdS(Nisneeds UINT_MAX < ULONG_MAXgi(
RRAt	ULONG_MAXRRRVRR]RRk(RR((s,/usr/local/lib/python2.7/test/test_socket.pyttestSetBlocking_overflowscCs|jjd|jtj|jj\}}WdQX|jjtj|jgggt	\}}}|j|kr|j
dn|jj\}}|j|j|j
|jdS(Nis'Error trying to do accept after select.(RRVRtRRRMRUR"RJtMAIN_TIMEOUTR:RyRRkR(RRORPR3RLR((s,/usr/local/lib/python2.7/test/test_socket.pyt
testAccepts
'cCs*|jj|jjt|jfdS(N(RUR4RJRQRRR
(R((s,/usr/local/lib/python2.7/test/test_socket.pyt_testAccepts
cCs#|jj\}}|jdS(N(RRMR(RRORP((s,/usr/local/lib/python2.7/test/test_socket.pyttestConnectscCs-|jjd|jjt|jfdS(Ni
(RJRRQRRR
(R((s,/usr/local/lib/python2.7/test/test_socket.pyt_testConnectscCs|jj\}}|j|j|jd|jtj|jt	t
}WdQX|jjt
j
|gggt\}}}||kr|jdn|jt	t
}|j|t
dS(Nis0Error during select call to non-blocking socket.(RRMRyRRVRtRRR&RR'RUR"RJR]R:R](RRORPR;R3RLR((s,/usr/local/lib/python2.7/test/test_socket.pyR(s

$cCs:|jjt|jf|jj|jjtdS(N(RJRQRRR
RUR4RR'(R((s,/usr/local/lib/python2.7/test/test_socket.pyR)s
(RRR RYRZRR$R\t_testSetBlocking_overflowR^R_R`RaR(R)(((s,/usr/local/lib/python2.7/test/test_socket.pyRTs							tFileObjectClassTestCasecBseZdZddZdZdZdZdZdZdZ	d	Z
d
ZdZdZ
d
ZdZdZdZdZdZdZdZRS(iRHcCstj|d|dS(NRI(RLR (RRI((s,/usr/local/lib/python2.7/test/test_socket.pyR  scCs,tj||jjd|j|_dS(Ntrb(RLRRNtmakefiletbufsizet	serv_file(R((s,/usr/local/lib/python2.7/test/test_socket.pyR#s
cCs:|jj|j|jjtj|d|_dS(N(RgRRtclosedRLRR(R((s,/usr/local/lib/python2.7/test/test_socket.pyR's

cCs&tj||jjd|_dS(Ntwb(RLR<RSRetcli_file(R((s,/usr/local/lib/python2.7/test/test_socket.pyR<-s
cCs:|jj|j|jjd|_tj|dS(N(RjRRRhRRLRA(R((s,/usr/local/lib/python2.7/test/test_socket.pyRA1s
	cCsL|jjttd}|jjd}||}|j|tdS(Ni(RgR3RR'R](Rt	first_segt
second_segR;((s,/usr/local/lib/python2.7/test/test_socket.pyt
testSmallRead7s
cCs!|jjt|jjdS(N(RjRLR'tflush(R((s,/usr/local/lib/python2.7/test/test_socket.pyt_testSmallRead>scCs#|jj}|j|tdS(N(RgR3R]R'(RR;((s,/usr/local/lib/python2.7/test/test_socket.pyttestFullReadBscCs!|jjt|jjdS(N(RjRLR'R(R((s,/usr/local/lib/python2.7/test/test_socket.pyt
_testFullReadGscCsGd}x*|jjd}|s%Pn||7}q	W|j|tdS(NRvi(RgR3R]R'(Rtbuftchar((s,/usr/local/lib/python2.7/test/test_socket.pyttestUnbufferedReadKscCs!|jjt|jjdS(N(RjRLR'Rn(R((s,/usr/local/lib/python2.7/test/test_socket.pyt_testUnbufferedReadUscCs#|jj}|j|tdS(N(RgtreadlineR]R'(Rtline((s,/usr/local/lib/python2.7/test/test_socket.pyttestReadlineYscCs!|jjt|jjdS(N(RjRLR'Rn(R((s,/usr/local/lib/python2.7/test/test_socket.pyt
_testReadline^scCs|jjtd}|jd||jjtd}|jd||jj}|jd||jj}|jd||jj}|jt|dS(Ns
A baloo iss a bears
sA BALOO IS A BEAR.
(RgR3RR]RvR'(Rt
a_baloo_ist_a_bearRw((s,/usr/local/lib/python2.7/test/test_socket.pyttestReadlineAfterReadbscCsA|jjd|jjd|jjt|jjdS(NsA baloo is a bear
sA BALOO IS A BEAR.
(RjRLR'Rn(R((s,/usr/local/lib/python2.7/test/test_socket.pyt_testReadlineAfterReadnscCsK|jjtd}|jd||jj}|jd|dS(NsEnd Of tLine(RgR3RR]Rv(Rtend_of_Rw((s,/usr/local/lib/python2.7/test/test_socket.pyttestReadlineAfterReadNoNewlinetscCs|jjddS(NsEnd Of Line(RjRL(R((s,/usr/local/lib/python2.7/test/test_socket.pyt_testReadlineAfterReadNoNewlinezscCs|j|jjdS(N(RRgRh(R((s,/usr/local/lib/python2.7/test/test_socket.pyttestClosedAttr}scCs|j|jjdS(N(RRjRh(R((s,/usr/local/lib/python2.7/test/test_socket.pyt_testClosedAttrs(RRRfR RRR<RARmRoRpRqRtRuRxRyR|R}RRRR(((s,/usr/local/lib/python2.7/test/test_socket.pyRcs(									
								tFileObjectInterruptedTestCasecBsreZdZdefdYZedZddZddZdZ	dZ
dd	Zd
ZRS(s=Test that the file object correctly handles EINTR internally.t
MockSocketcBseZddZdZRS(cCst||_dS(N(titert
_recv_step(Rt
recv_funcs((s,/usr/local/lib/python2.7/test/test_socket.pyR scCs|jjS(N(Rtnext(RR((s,/usr/local/lib/python2.7/test/test_socket.pyR&s((RRR R&(((s,/usr/local/lib/python2.7/test/test_socket.pyRscCstjtjdS(N(RRRtEINTR(((s,/usr/local/lib/python2.7/test/test_socket.pyt_raise_eintrsicKsr|jdd|jddg}tj||}|j|j|d|j|j|ddS(NRcSsdS(Ns"This is the first line
And the sec((((s,/usr/local/lib/python2.7/test/test_socket.pyRRvcSsdS(Nsond line is here
((((s,/usr/local/lib/python2.7/test/test_socket.pyRRvcSsdS(NRv((((s,/usr/local/lib/python2.7/test/test_socket.pyRRvsThis is the first line
sAnd the second line is here
(RRRt_fileobjectR]Rv(RRRot	mock_socktfo((s,/usr/local/lib/python2.7/test/test_socket.pyt_test_readlines	cKsY|jdd|jddg}tj||}|j|j|ddS(NRcSsdS(Ns"This is the first line
And the sec((((s,/usr/local/lib/python2.7/test/test_socket.pyRRvcSsdS(Nsond line is here
((((s,/usr/local/lib/python2.7/test/test_socket.pyRRvcSsdS(NRv((((s,/usr/local/lib/python2.7/test/test_socket.pyRRvs3This is the first line
And the second line is here
(RRRRR]R3(RRRoRR((s,/usr/local/lib/python2.7/test/test_socket.pyt
_test_reads	cCs8|j|jdd|j|jdddS(NRid(RR(R((s,/usr/local/lib/python2.7/test/test_socket.pyttest_defaults

cCsP|jdd|jdddd|jdd|jdddddS(NRfiRid(RR(R((s,/usr/local/lib/python2.7/test/test_socket.pyttest_with_1k_bufferscCs|jdddd|jddg}tj|dd}|j|j|d	|j|j|d
dS(NRcSsdS(Ntaa((((s,/usr/local/lib/python2.7/test/test_socket.pyRRvcSsdS(Ns
((((s,/usr/local/lib/python2.7/test/test_socket.pyRRvcSsdS(NtBB((((s,/usr/local/lib/python2.7/test/test_socket.pyRRvcSsdS(Ntbb((((s,/usr/local/lib/python2.7/test/test_socket.pyRRvcSsdS(NRv((((s,/usr/local/lib/python2.7/test/test_socket.pyRRvRfisaa
tBBbb(RRRRR]Rv(RRRR((s,/usr/local/lib/python2.7/test/test_socket.pyt_test_readline_no_buffers	cCsD|j|jdd|jdd|jdddddS(NRiRfiid(RR(R((s,/usr/local/lib/python2.7/test/test_socket.pyttest_no_buffers
(
RRRFtobjectRtstaticmethodRRRRRRR(((s,/usr/local/lib/python2.7/test/test_socket.pyRs			
t!UnbufferedFileObjectClassTestCasecBs&eZdZdZdZdZRS(sRepeat the tests from FileObjectClassTestCase with bufsize==0.

    In this case (and in this case only), it should be possible to
    create a file object, read a line from it, create another file
    object, read another line from it, without loss of data in the
    first file object's buffer.  Note that httplib relies on this
    when reading multiple requests from the same socket.icCsb|jj}|j|dt|jjdd|_|jj}|j|dtdS(NsA. RdisB. (RgRvR]R'RNRe(RRw((s,/usr/local/lib/python2.7/test/test_socket.pyttestUnbufferedReadlines
cCs9|jjdt|jjdt|jjdS(NsA. sB. (RjRLR'Rn(R((s,/usr/local/lib/python2.7/test/test_socket.pyt_testUnbufferedReadlines(RRRFRfRR(((s,/usr/local/lib/python2.7/test/test_socket.pyRs	t#LineBufferedFileObjectClassTestCasecBs?eZdZdefdYZdZdZdZRS(it
SocketMemocBsAeZdZdZddZddZdZdZRS(sGA wrapper to keep track of sent data, needed to examine write behaviourcCs||_g|_dS(N(Rgtsent(RR((s,/usr/local/lib/python2.7/test/test_socket.pyR s	icCs-|jj||}|jj|| |S(N(RgRRtappend(Rtdatatflagstn((s,/usr/local/lib/python2.7/test/test_socket.pyRscCs'|jj|||jj|dS(N(RgRRR(RRR((s,/usr/local/lib/python2.7/test/test_socket.pyRscCst|j|S(N(R.Rg(Rtattr((s,/usr/local/lib/python2.7/test/test_socket.pyt__getattr__scCs5g|jD]'}t|tr+|jn|^q
S(N(Rt
isinstancet
memoryviewttobytes(RR((s,/usr/local/lib/python2.7/test/test_socket.pytgetsents(RRRFR RRRR(((s,/usr/local/lib/python2.7/test/test_socket.pyRs		cCs,tj||j|jj|j_dS(N(RcRRRgRg(R((s,/usr/local/lib/python2.7/test/test_socket.pyRs
cCstj}|j|I|j|IJ|j|I|j|I|j|IJ|jdIJ|jjd||f}d|||f}d}|j|jjj|||gdS(NRvs%s %s
s	%s %s %s
s
(R'tstripRgRnR]RgR(RR;tmsg1tmsg2tmsg3((s,/usr/local/lib/python2.7/test/test_socket.pyttestLinebufferedWrites






cCstj}d||f}d|||f}d}|jj}|j|||jj}|j|||jj}|j||dS(Ns%s %s
s	%s %s %s
s
(R'RRjRvR](RR;RRRtl1tl2tl3((s,/usr/local/lib/python2.7/test/test_socket.pyt_testLinebufferedWrites(RRRfRRRRR(((s,/usr/local/lib/python2.7/test/test_socket.pyRs
		t$SmallBufferedFileObjectClassTestCasecBseZdZRS(i(RRRf(((s,/usr/local/lib/python2.7/test/test_socket.pyR"stNetworkConnectionTestcBseZdZdZRS(sProve network connection.cCs+tjt|jf|_|j|_dS(N(Rtcreate_connectionRRR
RJRS(R((s,/usr/local/lib/python2.7/test/test_socket.pyR<)s(RRRFR<(((s,/usr/local/lib/python2.7/test/test_socket.pyR'st
BasicTCPTest2cBseZdZRS(sLTests that NetworkConnection does not break existing TCP functionality.
    (RRRF(((s,/usr/local/lib/python2.7/test/test_socket.pyR/stNetworkConnectionNoServercBsNeZdejfdYZejdZdZdZdZ	RS(RcBseZdZRS(cGstjddS(Ns	timed out(RR(RRn((s,/usr/local/lib/python2.7/test/test_socket.pyRQ5s(RRRQ(((s,/usr/local/lib/python2.7/test/test_socket.pyR4sccs/tj}|jt_z	dVWd|t_XdS(s*Return a socket which times out on connectN(RR(Rt
old_socket((s,/usr/local/lib/python2.7/test/test_socket.pytmocked_socket_module8s
		cCstj}tjtjtj}|j|j|jtj}|j	t
|fWdQX|j|jj
t
jdS(N(RRRRRRyRRtRRQRRR]RRtECONNREFUSED(RR
RJR((s,/usr/local/lib/python2.7/test/test_socket.pyttest_connectBscCstj}|jtj}tjt|fWdQXtjg}t	tdrh|j
tjnt	tdr|j
tjn|j
|jj|dS(NtENETUNREACHt
EADDRNOTAVAIL(RRRtRRRRRRRRRRRR}R(RR
Rtexpected_errnos((s,/usr/local/lib/python2.7/test/test_socket.pyttest_create_connectionJscCsC|j1|jtjtjtdfWdQXWdQXdS(Ni(RRtRRRRR(R((s,/usr/local/lib/python2.7/test/test_socket.pyttest_create_connection_timeoutis
(
RRRRt
contextlibtcontextmanagerRRRR(((s,/usr/local/lib/python2.7/test/test_socket.pyR3s

		tNetworkConnectionAttributesTestcBseZddZdZdZdZeZdZeZdZ	eZ
dZeZdZ
eZd	ZeZd
ZRS(RHcCs$tj|d|tj|dS(NRI(RR R(RRI((s,/usr/local/lib/python2.7/test/test_socket.pyR tscCstj|_dS(N(RRtsource_port(R((s,/usr/local/lib/python2.7/test/test_socket.pyR<xscCs'|jjd|_tj|dS(N(RJRRRRA(R((s,/usr/local/lib/python2.7/test/test_socket.pyRA{s
	cCs#|jj\}}|jdS(N(RRMR(RRORP((s,/usr/local/lib/python2.7/test/test_socket.pyt_justAcceptscCsNtjt|jfdd|_|j|jj|j|jjddS(NRii(	RRRRR
RJRyRR]R(R((s,/usr/local/lib/python2.7/test/test_socket.pyt_testFamilys!cCsgtjt|jfdddd|jf|_|j|jj|j|jj	d|jdS(NRitsource_addressRvi(
RRRRR
RRJRyRR]Rz(R((s,/usr/local/lib/python2.7/test/test_socket.pyt_testSourceAddressscCs|jtjdktjdz2tjt|jf|_|j	|jj
WdtjdX|j|jjddS(Ni*(
RRRRRRRRR
RJRyRR]R(R((s,/usr/local/lib/python2.7/test/test_socket.pyt_testTimeoutDefaults
cCs|jtjdktjdz8tjt|jfdd|_|j	|jj
WdtjdX|j|jjddS(NiR(
RRRRRRRRR
RJRyRR]R(R((s,/usr/local/lib/python2.7/test/test_socket.pyt_testTimeoutNones
!cCs>tjt|jfdd|_|j|jjddS(NRi(RRRRR
RJR]R(R((s,/usr/local/lib/python2.7/test/test_socket.pyt_testTimeoutValueNameds!cCsNtjt|jfd|_|j|jj|j|jjddS(Ni(	RRRRR
RJRyRR]R(R((s,/usr/local/lib/python2.7/test/test_socket.pyt_testTimeoutValueNonameds(RRR R<RARt
testFamilyRttestSourceAddressRttestTimeoutDefaultRttestTimeoutNoneRttestTimeoutValueNamedRttestTimeoutValueNonamedR(((s,/usr/local/lib/python2.7/test/test_socket.pyRqs 								tNetworkConnectionBehaviourTestcBsGeZddZdZdZdZeZdZdZRS(RHcCs$tj|d|tj|dS(NRI(RR R(RRI((s,/usr/local/lib/python2.7/test/test_socket.pyR scCsdS(N((R((s,/usr/local/lib/python2.7/test/test_socket.pyR<scCs'|jjd|_tj|dS(N(RJRRRRA(R((s,/usr/local/lib/python2.7/test/test_socket.pyRAs
	cCsC|jj\}}|j|jtjd|jddS(Nisdone!(RRMRyRRNROR(RRORP((s,/usr/local/lib/python2.7/test/test_socket.pyttestInsideTimeouts
cCsBtjt|jf|_}|jd}|j|ddS(Nisdone!(RRRRR
RJR&R](RRR((s,/usr/local/lib/python2.7/test/test_socket.pyt_testInsideTimeoutscsEtjt|jfdd|_|jtjfddS(NRics
jdS(Ni(R&((R(s,/usr/local/lib/python2.7/test/test_socket.pyRRv(RRRRR
RJRtR(R((Rs,/usr/local/lib/python2.7/test/test_socket.pyt_testOutsideTimeouts%(	RRR R<RARttestOutsideTimeoutRR(((s,/usr/local/lib/python2.7/test/test_socket.pyRs				tUrllib2FileobjectTestcBseZdZRS(cCsdddY}|}tj|}|j|j|j|}tj|dt}|j|j|jdS(NRcBs eZeZdZdZRS(cSsdS(N((R((s,/usr/local/lib/python2.7/test/test_socket.pyRnRvcSs
t|_dS(N(RRh(R((s,/usr/local/lib/python2.7/test/test_socket.pyRRv(RRRRhRnR(((s,/usr/local/lib/python2.7/test/test_socket.pyRs	R((RRRRRhR(RRR_R((s,/usr/local/lib/python2.7/test/test_socket.pyRMs	
	
(RRRM(((s,/usr/local/lib/python2.7/test/test_socket.pyRstTCPTimeoutTestcBs>eZdZdZejeedddZRS(cs)fd}jtj|ddS(Ncs!jjdjjdS(Ng?(RRRM(RnRo(R(s,/usr/local/lib/python2.7/test/test_socket.pyt
raise_timeoutss*Error generating a timeout exception (TCP)(RtRR(RR((Rs,/usr/local/lib/python2.7/test/test_socket.pyttestTCPTimeoutscCst}y#|jjd|jj}WnMtjk
rL|jdn-tjk
ret}n|jdnX|s|jdndS(Ngs%caught timeout instead of error (TCP)s!caught unexpected exception (TCP)s3accept() returned success when we did not expect it(	RRRRMRRR:RR(RtokRw((s,/usr/local/lib/python2.7/test/test_socket.pyttestTimeoutZeros	R
stest needs signal.alarm()cs2|jjddtfdYfd}tjtj|}zyzy tjd|jj}Wn_tjk
r|j	dnLk
rn<|j	dt
jd tj
fnX|j	dWdtjd	XWnk
r|j	d
nXWdtjtj|XdS(Ng@tAlarmcBseZRS((RR(((s,/usr/local/lib/python2.7/test/test_socket.pyRscs
dS(N((Rtframe(R(s,/usr/local/lib/python2.7/test/test_socket.pyt
alarm_handlersiscaught timeout instead of Alarms3caught other exception instead of Alarm: %s(%s):
%ssnothing caughtisgot Alarm in wrong place(RRR?RRR
RMRRR:Rtexc_infot	tracebackt
format_exc(RRRRw((Rs,/usr/local/lib/python2.7/test/test_socket.pyttestInterruptedTimeouts,

	#
(	RRRRRUR"RRR(((s,/usr/local/lib/python2.7/test/test_socket.pyRs		tUDPTimeoutTestcBseZdZdZRS(cs)fd}jtj|ddS(Ncs$jjdjjddS(Ng?i(RRR&(RnRo(R(s,/usr/local/lib/python2.7/test/test_socket.pyR*ss*Error generating a timeout exception (UDP)(RtRR(RR((Rs,/usr/local/lib/python2.7/test/test_socket.pyttestUDPTimeout)scCst}y&|jjd|jjd}WnMtjk
rO|jdn-tjk
rht}n|jdnX|s|jdndS(Ngis%caught timeout instead of error (UDP)s!caught unexpected exception (UDP)s1recv() returned success when we did not expect it(	RRRR&RRR:RR(RRRw((s,/usr/local/lib/python2.7/test/test_socket.pyR0s	(RRRR(((s,/usr/local/lib/python2.7/test/test_socket.pyR's	tTestExceptionscBseZdZRS(cCsq|jttjt|jttjtj|jttjtj|jttjtjdS(N(Rt
issubclassRRR?RqRR(R((s,/usr/local/lib/python2.7/test/test_socket.pyttestExceptionTree@s(RRR(((s,/usr/local/lib/python2.7/test/test_socket.pyR>sRsLinux specific testtTestLinuxAbstractNamespacecBs)eZdZdZdZdZRS(ilcCsd}tjtjtj}|j||jdtjtjtj}|j|j|j|j|j||j|j	|dS(Nspython-test-helloi(
RtAF_UNIXRRRRQRzRMR]tgetpeername(Rtaddressts1ts2((s,/usr/local/lib/python2.7/test/test_socket.pyttestLinuxAbstractNamespaceKs


cCsTdd|jd}tjtjtj}|j||j|j|dS(Nsthi(t
UNIX_PATH_MAXRRRRR]Rz(RRR_((s,/usr/local/lib/python2.7/test/test_socket.pyttestMaxNameVs
cCsFdd|j}tjtjtj}|jtj|j|dS(NsR(RRRRRtRR(RRR_((s,/usr/local/lib/python2.7/test/test_socket.pyttestNameOverflow\s(RRRRRR(((s,/usr/local/lib/python2.7/test/test_socket.pyRFs		tBufferIOTestcBseZdZddZdZdZdZeZdZeZ	dZ
dZd	ZeZ
d
ZeZdZdZd
ZeZRS(sF
    Test the buffer versions of socket.recv() and socket.send().
    RHcCstj|d|dS(NRI(RLR (RRI((s,/usr/local/lib/python2.7/test/test_socket.pyR gscCshtjddd}|jj|}|j|tt|jtt }|j|tdS(NRt i(tarrayRNt	recv_intoR]RR'ttostring(RRrtnbytesR;((s,/usr/local/lib/python2.7/test/test_socket.pyttestRecvIntoArrayjs
cCs3tjtt}WdQX|jj|dS(N(Rtcheck_py3k_warningstbufferR'RSR(RRr((s,/usr/local/lib/python2.7/test/test_socket.pyt_testRecvIntoArrayqs
cCsXtd}|jj|}|j|tt|tt }|j|tdS(Ni(t	bytearrayRNRR]RR'(RRrRR;((s,/usr/local/lib/python2.7/test/test_socket.pyttestRecvIntoBytearrayvs
cCs^td}|jjt|}|j|tt|tt }|j|tdS(Ni(RRNRRR]RR'(RRrRR;((s,/usr/local/lib/python2.7/test/test_socket.pyttestRecvIntoMemoryviews
cCsntjddd}|jj|\}}|j|tt|jtt }|j|tdS(NRRi(RRNt
recvfrom_intoR]RR'R(RRrRRPR;((s,/usr/local/lib/python2.7/test/test_socket.pyttestRecvFromIntoArrays
cCs3tjtt}WdQX|jj|dS(N(RRRR'RSR(RRr((s,/usr/local/lib/python2.7/test/test_socket.pyt_testRecvFromIntoArrays
cCs^td}|jj|\}}|j|tt|tt }|j|tdS(Ni(RRNRR]RR'(RRrRRPR;((s,/usr/local/lib/python2.7/test/test_socket.pyttestRecvFromIntoBytearrays
cCsdtd}|jjt|\}}|j|tt|tt }|j|tdS(Ni(RRNRRR]RR'(RRrRRPR;((s,/usr/local/lib/python2.7/test/test_socket.pyttestRecvFromIntoMemoryviews
cCs,td}|jt|jj|ddS(Nii(RRtRRNR(RRr((s,/usr/local/lib/python2.7/test/test_socket.pyttestRecvFromIntoSmallBufferscCs3tjtt}WdQX|jj|dS(N(RRRR'RSR(RRr((s,/usr/local/lib/python2.7/test/test_socket.pyt_testRecvFromIntoSmallBuffers
cCs0t}|jj||jj|ddS(Ni(RRNR(RRr((s,/usr/local/lib/python2.7/test/test_socket.pyttestRecvFromIntoEmptyBuffers	(RRRFR RRRt_testRecvIntoBytearrayRt_testRecvIntoMemoryviewRRRt_testRecvFromIntoBytearrayRt_testRecvFromIntoMemoryviewRR	R
t_testRecvFromIntoEmptyBuffer(((s,/usr/local/lib/python2.7/test/test_socket.pyRbs$											iiicCsttdstSytd}Wn;tk
r`}|jtjtjtjfkrZtSnX|)x!|D]}|j	drot
SqoWWdQXtS(sCheck if the TIPC module is loaded

    The TIPC module is not loaded automatically on Ubuntu and probably
    other Linux distros.
    tAF_TIPCs
/proc/modulesstipc N(RRRtopentIOErrorRtENOENTtEISDIRtEACCESRR(RRRw((s,/usr/local/lib/python2.7/test/test_socket.pytisTipcAvailables!
s6TIPC module is not loaded, please 'sudo modprobe tipc'tTIPCTestcBseZdZRS(cCstjtjtj}tjtjtj}|jtjtjdtjttt	f}|j
|tjttt	tddf}|jt
||jd\}}|j|j||j|t
dS(Niiii(RRRRRRtTIPC_ADDR_NAMESEQt
TIPC_STYPEt
TIPC_LOWERt
TIPC_UPPERRtTIPC_ADDR_NAMER|R'R.R]Rz(RRRJtsrvaddrtsendaddrR;trecvaddr((s,/usr/local/lib/python2.7/test/test_socket.pyttestRDMs	
	(RRR (((s,/usr/local/lib/python2.7/test/test_socket.pyRstTIPCThreadableTestcBs8eZddZdZdZdZdZRS(RHcCs'tjj|d|tj|dS(NRI(RURVR R(RRI((s,/usr/local/lib/python2.7/test/test_socket.pyR scCstjtjtj|_|jjtjtjdtjtt	t
f}|jj||jjd|j
|jj\|_|_dS(Nii(RRRRRRRRRRRRRR#RMROtconnaddr(RR((s,/usr/local/lib/python2.7/test/test_socket.pyRs	
cCsotjdtjtjtj|_tjttt	tddf}|jj
||jj|_dS(Ng?ii(
RNRORRRRJRRRRRQRztcliaddr(RRP((s,/usr/local/lib/python2.7/test/test_socket.pyR<s
	cCs<|jjd}|j|t|j|j|jdS(Ni(ROR&R]R'R#R"(RR;((s,/usr/local/lib/python2.7/test/test_socket.pyt
testStreamscCs!|jjt|jjdS(N(RJRR'R(R((s,/usr/local/lib/python2.7/test/test_socket.pyt_testStreams(RRR RR<R$R%(((s,/usr/local/lib/python2.7/test/test_socket.pyR!s
	
		cCstttttttttg	}|j	t
ttt
ttttttg
|jt|jt|j	ttgtj}tj|tj|dS(N(RXR%RIRRRRRDRtextendRTRcRRRRRRRRRRQRRR!Rtthreading_setuptrun_unittesttthreading_cleanup(tteststthread_info((s,/usr/local/lib/python2.7/test/test_socket.pyt	test_mains(	



t__main__(GRUttestRRRRRJRNRR*RR#RRRRRbRYRRR]RR
RRR'tIPV6_ENABLEDRR/R&RVRRRRGRKRLRTRXR"R%RDRIRRQRTRcRRRRRRRRRRRRRRRRRRRRRRR!R,R(((s,/usr/local/lib/python2.7/test/test_socket.pyt<module>s

		

	
bhehF?>D9U			$	

Zerion Mini Shell 1.0