{G_Tc@scddlZddlmZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl mZddlZddlZdejdZejZdZejoeddejZyddlZddlZWnek r6eZeZnXejZdZd ejfd YZd ejfd YZd fdYZdeefdYZ deefdYZ!de fdYZ"dejefdYZ#dejfdYZ$ej%edde"fdYZ&ej%edde!fdYZ'ej%edde fdYZ(ej%e)ed d!ej%edd"e#fd#YZ*ej%edd$e fd%YZ+ej%edd&e"fd'YZ,d(ejfd)YZ-d*e,fd+YZ.d,e,fd-YZ/d.e,fd/YZ0d0e1fd1YZ2d2e2e&fd3YZ3d4ejfd5YZ4ej%edd6eefd7YZ5ej%edd8eefd9YZ6d:ejfd;YZ7d<efd=YZ8d>efd?YZ9d@ejfdAYZ:ej%e j;dBkdCdDejfdEYZ<ej%eddFe"fdGYZ=dHZ>dIZ?dJZ@dKZAej%eAdLdMejfdNYZBej%eAdLdOejefdPYZCdQZDeEdRkr_eDndS(SiN(t test_support(tproxyicCs_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(tsockett SOCK_STREAMtbindterrortgaierrortFalsetclosetTrue(thosttporttfamilytsock((s,/usr/local/lib/python2.7/test/test_socket.pyt try_addresss sMichael Gilfix was here s::1R t SocketTCPTestcBseZdZdZRS(cCsDtjtjtj|_tj|j|_|jjddS(Ni(RtAF_INETRtservRt bind_portR tlisten(tself((s,/usr/local/lib/python2.7/test/test_socket.pytsetUp.scCs|jjd|_dS(N(RRtNone(R((s,/usr/local/lib/python2.7/test/test_socket.pyttearDown3s (t__name__t __module__RR(((s,/usr/local/lib/python2.7/test/test_socket.pyR,s t SocketUDPTestcBseZdZdZRS(cCs4tjtjtj|_tj|j|_dS(N(RRt SOCK_DGRAMRRRR (R((s,/usr/local/lib/python2.7/test/test_socket.pyR9scCs|jjd|_dS(N(RRR(R((s,/usr/local/lib/python2.7/test/test_socket.pyR=s (RRRR(((s,/usr/local/lib/python2.7/test/test_socket.pyR7s 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 preceeded 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__gs   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.pytserverExplicitReadynscCstj|_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 methodnametit test_method((s,/usr/local/lib/python2.7/test/test_socket.pyRus  cCsI|j|jj|jjsE|jj}|j|ndS(N(RR*R5R,temptytgettfail(Rtmsg((s,/usr/local/lib/python2.7/test/test_socket.pyR s   cCs~|jj|j|jjt|s?tdny |Wn#tk ro}|jj |nX|j dS(Ns&test_func must be a callable function.( R"R5t clientSetUpR)R#tcallablet TypeErrort ExceptionR,tputtclientTearDown(Rt test_functstrerror((s,/usr/local/lib/python2.7/test/test_socket.pyR2s     cCstddS(Ns clientSetUp must be implemented.(tNotImplementedError(R((s,/usr/local/lib/python2.7/test/test_socket.pyR=scCs|jjtjdS(N(R*R#R0texit(R((s,/usr/local/lib/python2.7/test/test_socket.pyRBs ( RRt__doc__R!R$RR R2R=RB(((s,/usr/local/lib/python2.7/test/test_socket.pyRAs$     tThreadedTCPSocketTestcBs&eZddZdZdZRS(trunTestcCs$tj|d|tj|dS(Nt methodName(RR!R(RRJ((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(RKRRRRB(R((s,/usr/local/lib/python2.7/test/test_socket.pyRBs  (RRR!R=RB(((s,/usr/local/lib/python2.7/test/test_socket.pyRHs  tThreadedUDPSocketTestcBs&eZddZdZdZRS(RIcCs$tj|d|tj|dS(NRJ(RR!R(RRJ((s,/usr/local/lib/python2.7/test/test_socket.pyR!scCstjtjtj|_dS(N(RRRRK(R((s,/usr/local/lib/python2.7/test/test_socket.pyR=scCs'|jjd|_tj|dS(N(RKRRRRB(R((s,/usr/local/lib/python2.7/test/test_socket.pyRBs  (RRR!R=RB(((s,/usr/local/lib/python2.7/test/test_socket.pyRLs  tSocketConnectedTestcBs8eZddZdZdZdZdZRS(RIcCstj|d|dS(NRJ(RHR!(RRJ((s,/usr/local/lib/python2.7/test/test_socket.pyR!scCs9tj||j|jj\}}||_dS(N(RHRR$Rtaccepttcli_conn(Rtconntaddr((s,/usr/local/lib/python2.7/test/test_socket.pyRs  cCs'|jjd|_tj|dS(N(RORRRHR(R((s,/usr/local/lib/python2.7/test/test_socket.pyRs  cCs6tj||jjt|jf|j|_dS(N(RHR=RKtconnecttHOSTR t serv_conn(R((s,/usr/local/lib/python2.7/test/test_socket.pyR=s cCs'|jjd|_tj|dS(N(RTRRRHRB(R((s,/usr/local/lib/python2.7/test/test_socket.pyRBs  (RRR!RRR=RB(((s,/usr/local/lib/python2.7/test/test_socket.pyRMs     tSocketPairTestcBs8eZddZdZdZdZdZRS(RIcCs'tjj|d|tj|dS(NRJ(tunittesttTestCaseR!R(RRJ((s,/usr/local/lib/python2.7/test/test_socket.pyR!scCstj\|_|_dS(N(Rt socketpairRRK(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(RKRRRRB(R((s,/usr/local/lib/python2.7/test/test_socket.pyRBs  (RRR!RRR=RB(((s,/usr/local/lib/python2.7/test/test_socket.pyRUs     tGeneralModuleTestscBseZdZdZdZdZdZeje e dddZ dZ d Z d Zd Zd Zeje ed ddZeje edddZeje edddZeje edddZeje edddZddZdZdZdZdZdZdZejejd kd!d"Z d#Z!d$Z"d%Z#d&Z$d'Z%e&j'd(Z(eje)d)d*Z*RS(+cCstjtjtj}t|}|j|j|j|jd}y|jWntk rqnX|j ddS(NsSocket proxy still exists( RRRRt assertEqualtfilenoRRtReferenceErrorR;(Rtstp((s,/usr/local/lib/python2.7/test/test_socket.pyt test_weakrefs   cCsad}d}d}|jtj|d|jtj|d|jtj|ddS(Nc_s tjdS(N(RR(targstkwargs((s,/usr/local/lib/python2.7/test/test_socket.pyt raise_errorsc_s tjdS(N(Rtherror(R`Ra((s,/usr/local/lib/python2.7/test/test_socket.pyt raise_herrorsc_s tjdS(N(RR(R`Ra((s,/usr/local/lib/python2.7/test/test_socket.pytraise_gaierror ssError raising socket exception.(t assertRaisesRR(RRbRdRe((s,/usr/local/lib/python2.7/test/test_socket.pyttestSocketErrors   cCstjtjtj}|j|j|jd |j}|jt|j d|WdQX|jt }|j d|WdQX|j dt |j |jt }|j ddWdQX|j dt |j |jt|j dd|WdQX|jt }|j dd|WdQX|j dt |j |jt }|j dddWdQX|j dt |j |jt }|j dd|WdQX|j d t |j |jt }|j dddWdQX|j d t |j |jt }|j dWdQX|j d t |j |jt }|j dd|d WdQX|j d t |j dS(Ntiu☠y@s not complextfoos not NoneTypetbarsan integer is requireds (1 given)is (4 given)(Rhi(RRRt addCleanupRRt getsocknameRftUnicodeEncodeErrortsendtoR?tassertIntstrt exceptionR(RR]tsocknametcm((s,/usr/local/lib/python2.7/test/test_socket.pyttestSendtoErrorss@  cCs<tjtjtjtjtjtjtjtjdS(N( RRRRtSOCK_RAWtSOCK_RDMtSOCK_SEQPACKETt SOL_SOCKETt SO_REUSEADDR(R((s,/usr/local/lib/python2.7/test/test_socket.pyttestCrucialConstants9scCstj}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)( Rt gethostnamet gethostbynameRtskipTestt assertTruetfindt gethostbyaddrtgetfqdnR;trepr(Rthostnametipthnametaliasestipaddrstall_host_namestfqhn((s,/usr/local/lib/python2.7/test/test_socket.pyttestHostnameResDs  t getrefcountstest needs sys.getrefcount()cCsWy#tjt}tjtdWn-tk rR|jtjt|dnXdS(Nis$socket.getnameinfo loses a reference(tsysRRRt getnameinfoR?RZ(Rtorig((s,/usr/local/lib/python2.7/test/test_socket.pyttestRefCountGetNameInfoWs  cCs/ytjddWntjk r*nXdS(Ntxi(Riii(RRR(R((s,/usr/local/lib/python2.7/test/test_socket.pyttestInterpreterCrashcscCsidtj6dtj6dtj6dtj6}x|jD]\}}d|>d}xKdddd ddd fD].}|j||@||||@|@qqW||}|j||@||jt|d q;WdS( Ni iliiiiigE#i2Tvi"il( RthtonltntohlthtonstntohstitemsRZRft OverflowError(RtsizestfunctsizetmaskR7tswapped((s,/usr/local/lib/python2.7/test/test_socket.pyttestNtoHks", cCsddddddg}ddd d d d g}xB|D]:}tj|tj|tj|tj|q7Wxf|D]^}|jttj||jttj||jttj||jttj|q|WdS( Niiillliiilll(RRRRRRfR(Rt good_valuest bad_valuestk((s,/usr/local/lib/python2.7/test/test_socket.pyttestNtoHErrorsys     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( RZRtplatformt startswithRt getservbynameRRt getservbyportRfR(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( RZRtgetdefaulttimeoutRt gettimeoutRtsetdefaulttimeoutRft ValueErrorR?(RR]((s,/usr/local/lib/python2.7/test/test_socket.pyttestDefaultTimeouts         t inet_atonstest needs socket.inet_aton()cCs6|jdtjd|jdtjddS(Ntis0.0.0.0ss255.255.255.255ts(RZRR(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.pytsRs0.0.0.0ss 255.0.255.0ss170.170.170.170ss1.2.3.4ss255.255.255.255(RRRRRZ(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.pyRsRis::s0::0tis1::sEvV $s$45ef:76cb:1a:56ef:afeb:bac:1924:aeaetRt(RRRRR}t ImportErrorRZ(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.pyRss1.0.1.0ss 170.85.170.85sUUs255.255.255.255ss1.2.3.4s(RRRRRZ(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.pyRss::Ris::1iss!aef:b01:506:1001:ffff:9997:55:170s UpRtt(RRRRR}RRZ(RRR((RRs,/usr/local/lib/python2.7/test/test_socket.pyttestStringToIPv6s 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(RRRlR(Rt bind_addressttempsockR R ((s,/usr/local/lib/python2.7/test/test_socket.pyt_get_unused_ports   cCs|j}tjtjtj}|j|j|jd|f|j}ytjtj }Wn!tj k r|j dnX|j |dd|fd|d|j |d|dS(Ns0.0.0.0sname lookup failureis %s invalidi(RRRRRkRRRlR|R{RR}RoRZ(RR R tnamet my_ip_addr((s,/usr/local/lib/python2.7/test/test_socket.pyt testSockName)s  %cCsZtjtjtj}|j|j|jtjtj}|j|dkddS(Nisinitial mode is reuse( RRRRkRt getsockoptRxRyt assertFalse(RR treuse((s,/usr/local/lib/python2.7/test/test_socket.pyttestGetSockOpt;scCsstjtjtj}|j|j|jtjtjd|jtjtj}|j |dkddS(Niisfailed to set reuse mode( RRRRkRt setsockoptRxRyRR(RR R((s,/usr/local/lib/python2.7/test/test_socket.pyttestSetSockOptCs cCsLtjtjtj}|jd|j|jtj|jddS(NiR(RRRt settimeoutRRfRtsend(RR ((s,/usr/local/lib/python2.7/test/test_socket.pyttestSendAfterCloseKs  cCsetjtjtj}|j|jtj|j|jtj|j|jd|jdS(Ni(RRRRZR ttypetprotoR(RR ((s,/usr/local/lib/python2.7/test/test_socket.pyttestNewAttributesRs cCsd}|jd|}|d}|d}tj}zO|jt|j||f|jt|j||f|j||fWd|jXdS(Ns0.0.0.0Ri(RRRfRRR(RR R tbig_porttneg_portR ((s,/usr/local/lib/python2.7/test/test_socket.pyttest_getsockaddrargZs   tntsWindows specificcCs|jttjd|jttd|jttd|jttd|jttdtj}|j|j|jt|jdd|jtj d dS( Ntioctlt SIO_RCVALLt RCVALL_ONt RCVALL_OFFtSIO_KEEPALIVE_VALSiiid(iidid( R~thasattrRRkRRfRRRR(RR]((s,/usr/local/lib/python2.7/test/test_socket.pyttest_sock_ioctlgs cCsWytjddWn;tjk rQ}|jtjkrK|jdnnXx0tjtdD]}|jt |dqeWtjddtjddtjddt rtjddntjtdtjtdtjtdtjtdtjtdtj }x0|D](\}}}}}|j|tj q-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(Rt getaddrinfoRterrnot EAI_SERVICER}RSRRZtlent SUPPORTS_IPV6RRtSOL_TCPt AI_PASSIVEt AF_UNSPECRR(RterrtinfotinfosR R&tsocktype((s,/usr/local/lib/python2.7/test/test_socket.pyttestGetaddrinfossB cs>ttd s ttd r0jdnfd}fd}tj\}}tjtj|}z|r|jdnjt&tj d|j dt j WdQX|rtjtj|tj djtj |j dt j nWdtjtj||j|jXdS( NtalarmRXs9signal.alarm and socket.socketpair required for this testcsjttjddS(Ni(RfRtmathtacosh(R`(R(s,/usr/local/lib/python2.7/test/test_socket.pyt ok_handlerscs"jttjddddS(Nii(RfRRR(R`(R(s,/usr/local/lib/python2.7/test/test_socket.pytraising_handlersg?iR(RtsignalRR}RXtSIGALRMRRftZeroDivisionErrorRtsendallRt SOCK_MAX_SIZEttimeoutR(Rt with_timeoutRRtcR]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(RRRRRSRR(Rtbacklogtsrv((s,/usr/local/lib/python2.7/test/test_socket.pyttest_listen_backlogs   cCsbddl}tjtjtj}|jtdf|jt|j|j d|j dS(Niii( t _testcapiRRRRRSRfRRtINT_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(RfRRRRRRR(RR]((s,/usr/local/lib/python2.7/test/test_socket.pyt test_flowinfos  (+RRR_RgRtRzRRVt skipUnlessRRRRRRRRRRRRRRRRRRRRRtosRRRRRRRRt cpython_onlyRRR(((s,/usr/local/lib/python2.7/test/test_socket.pyRYsJ  '     )        $ 1     s!Threading required for this test.t BasicTCPTestcBseZddZdZdZdZdZdZdZdZ d Z d Z d Z e jeed d dZdZdZdZdZdZejeZejdZRS(RIcCstj|d|dS(NRJ(RMR!(RRJ((s,/usr/local/lib/python2.7/test/test_socket.pyR!scCs&|jjd}|j|tdS(Ni(ROtrecvRZtMSG(RR<((s,/usr/local/lib/python2.7/test/test_socket.pyttestRecvscCs|jjtdS(N(RTRR(R((s,/usr/local/lib/python2.7/test/test_socket.pyt _testRecvscCsL|jjttd}|jjd}||}|j|tdS(Nii(RORRRRZ(Rtseg1tseg2R<((s,/usr/local/lib/python2.7/test/test_socket.pyttestOverFlowRecvs cCs|jjtdS(N(RTRR(R((s,/usr/local/lib/python2.7/test/test_socket.pyt_testOverFlowRecvscCs,|jjd\}}|j|tdS(Ni(ROtrecvfromRZR(RR<RQ((s,/usr/local/lib/python2.7/test/test_socket.pyt testRecvFromscCs|jjtdS(N(RTRR(R((s,/usr/local/lib/python2.7/test/test_socket.pyt _testRecvFromscCsX|jjttd\}}|jjd\}}||}|j|tdS(Nii(ROR$RRRZ(RR RQR!R<((s,/usr/local/lib/python2.7/test/test_socket.pyttestOverFlowRecvFroms" cCs|jjtdS(N(RTRR(R((s,/usr/local/lib/python2.7/test/test_socket.pyt_testOverFlowRecvFrom scCsJd}x)|jjd}|s%Pn||7}q |j|dddS(NRhiRi(RORRZ(RR<tread((s,/usr/local/lib/python2.7/test/test_socket.pyt testSendAll s cCsdd}|jj|dS(NRi(RTR(Rt big_chunk((s,/usr/local/lib/python2.7/test/test_socket.pyt _testSendAlls tfromfdssocket.fromfd not availblecCs]|jj}tj|tjtj}|j|j|jd}|j |t dS(Ni( ROR[RR-RRRkRRRZR(RtfdR R<((s,/usr/local/lib/python2.7/test/test_socket.pyt testFromFds cCs|jjtdS(N(RTRR(R((s,/usr/local/lib/python2.7/test/test_socket.pyt _testFromFd%scCsB|jj}|j|j|jd}|j|tdS(Ni(ROtdupRkRRRZR(RR R<((s,/usr/local/lib/python2.7/test/test_socket.pyttestDup(scCs|jjtdS(N(RTRR(R((s,/usr/local/lib/python2.7/test/test_socket.pyt_testDup/scCs3|jjd}|j|t|jjdS(Ni(RORRZRR*R5(RR<((s,/usr/local/lib/python2.7/test/test_socket.pyt testShutdown2scCs$|jjt|jjddS(Ni(RTRRtshutdown(R((s,/usr/local/lib/python2.7/test/test_socket.pyt _testShutdown;scCstddl}|jjt|jt|jj|jd|jt|jjd|jd|jjddS(Niii( RRTRRRfRR5RtUINT_MAX(RR((s,/usr/local/lib/python2.7/test/test_socket.pyt_testShutdown_overflowAs (RRR!RRR"R#R%R&R'R(R*R,RVRRRR/R0R2R3R4R6RRttestShutdown_overflowR8(((s,/usr/local/lib/python2.7/test/test_socket.pyRs(              t BasicUDPTestcBsJeZddZdZdZdZdZdZdZRS(RIcCstj|d|dS(NRJ(RLR!(RRJ((s,/usr/local/lib/python2.7/test/test_socket.pyR!OscCs,|jjtt}|j|tdS(N(RRRRRZ(RR<((s,/usr/local/lib/python2.7/test/test_socket.pyttestSendtoAndRecvRscCs#|jjtdt|jfdS(Ni(RKRnRRSR (R((s,/usr/local/lib/python2.7/test/test_socket.pyt_testSendtoAndRecvWscCs2|jjtt\}}|j|tdS(N(RR$RRRZ(RR<RQ((s,/usr/local/lib/python2.7/test/test_socket.pyR%ZscCs#|jjtdt|jfdS(Ni(RKRnRRSR (R((s,/usr/local/lib/python2.7/test/test_socket.pyR&_scCs|jt|jjddS(Ni(RfRRR$(R((s,/usr/local/lib/python2.7/test/test_socket.pyttestRecvFromNegativebscCs#|jjtdt|jfdS(Ni(RKRnRRSR (R((s,/usr/local/lib/python2.7/test/test_socket.pyt_testRecvFromNegativefs( RRR!R;R<R%R&R=R>(((s,/usr/local/lib/python2.7/test/test_socket.pyR:Ls      t TCPCloserTestcBseZdZdZRS(cCs||jj\}}|j|j}tj|gggd\}}}|j||g|j|jdddS(Ng?iRh(RRNRRKtselectRZR(RRPRQtsdR)twriteR((s,/usr/local/lib/python2.7/test/test_socket.pyt testClosels   $cCs*|jjt|jftjddS(Ng?(RKRRRSR ttimetsleep(R((s,/usr/local/lib/python2.7/test/test_socket.pyt _testCloseus(RRRCRF(((s,/usr/local/lib/python2.7/test/test_socket.pyR?is RXstest needs socket.socketpair()tBasicSocketPairTestcBs8eZddZdZdZdZdZRS(RIcCstj|d|dS(NRJ(RUR!(RRJ((s,/usr/local/lib/python2.7/test/test_socket.pyR!~scCs&|jjd}|j|tdS(Ni(RRRZR(RR<((s,/usr/local/lib/python2.7/test/test_socket.pyRscCs|jjtdS(N(RKRR(R((s,/usr/local/lib/python2.7/test/test_socket.pyRscCs|jjtdS(N(RRR(R((s,/usr/local/lib/python2.7/test/test_socket.pyttestSendscCs&|jjd}|j|tdS(Ni(RKRRZR(RR<((s,/usr/local/lib/python2.7/test/test_socket.pyt _testSends(RRR!RRRHRI(((s,/usr/local/lib/python2.7/test/test_socket.pyRGys     tNonBlockingTCPTestscBs}eZddZdZdZejdZejeZdZ dZ dZ dZ d Z d ZRS( RIcCstj|d|dS(NRJ(RHR!(RRJ((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.( Rt setblockingR t assertIsNoneRRRZRDRNRRR~(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( RR7t ULONG_MAXR}RRKRRZRRL(RR((s,/usr/local/lib/python2.7/test/test_socket.pyttestSetBlocking_overflows cCs|jjdy|jj\}}Wntjk r?nX|jdtj|jggg\}}}|j|kr|jj\}}|jn |jddS(Nis'Error trying to do non-blocking accept.s'Error trying to do accept after select.(RRKRNRRR;R@R(RRPRQR)RBR((s,/usr/local/lib/python2.7/test/test_socket.pyt testAccepts $ cCs*tjd|jjt|jfdS(Ng?(RDRERKRRRSR (R((s,/usr/local/lib/python2.7/test/test_socket.pyt _testAccepts cCs#|jj\}}|jdS(N(RRNR(RRPRQ((s,/usr/local/lib/python2.7/test/test_socket.pyt testConnectscCs-|jjd|jjt|jfdS(Ni (RKRRRRSR (R((s,/usr/local/lib/python2.7/test/test_socket.pyt _testConnectscCs|jj\}}|jdy|jtt}Wntjk rQnX|jdt j |ggg\}}}||kr|jtt}|j |j |tn |jddS(Nis%Error trying to do non-blocking recv.s0Error during select call to non-blocking socket.( RRNRKRRRRRR;R@RRZ(RRPRQR<R)RBR((s,/usr/local/lib/python2.7/test/test_socket.pyRs  !  cCs:|jjt|jftjd|jjtdS(Ng?(RKRRRSR RDRERR(R((s,/usr/local/lib/python2.7/test/test_socket.pyRs (RRR!RORPRRRRt_testSetBlocking_overflowRSRTRURVRR(((s,/usr/local/lib/python2.7/test/test_socket.pyRJs         tFileObjectClassTestCasecBseZdZddZdZdZdZdZdZdZ d Z d Z d Z d Z d ZdZdZdZdZdZdZdZRS(iRIcCstj|d|dS(NRJ(RMR!(RRJ((s,/usr/local/lib/python2.7/test/test_socket.pyR!scCs,tj||jjd|j|_dS(Ntrb(RMRROtmakefiletbufsizet serv_file(R((s,/usr/local/lib/python2.7/test/test_socket.pyRs cCs:|jj|j|jjtj|d|_dS(N(R\RR~tclosedRMRR(R((s,/usr/local/lib/python2.7/test/test_socket.pyRs  cCs&tj||jjd|_dS(Ntwb(RMR=RTRZtcli_file(R((s,/usr/local/lib/python2.7/test/test_socket.pyR=s cCs:|jj|j|jjd|_tj|dS(N(R_RR~R]RRMRB(R((s,/usr/local/lib/python2.7/test/test_socket.pyRBs  cCsL|jjttd}|jjd}||}|j|tdS(Ni(R\R)RRRZ(Rt first_segt second_segR<((s,/usr/local/lib/python2.7/test/test_socket.pyt testSmallReads cCs!|jjt|jjdS(N(R_RBRtflush(R((s,/usr/local/lib/python2.7/test/test_socket.pyt_testSmallRead scCs#|jj}|j|tdS(N(R\R)RZR(RR<((s,/usr/local/lib/python2.7/test/test_socket.pyt testFullReadscCs!|jjt|jjdS(N(R_RBRR(R((s,/usr/local/lib/python2.7/test/test_socket.pyt _testFullReadscCsFd}x)|jjd}|s%Pn||7}q |j|tdS(NRhi(R\R)RZR(Rtbuftchar((s,/usr/local/lib/python2.7/test/test_socket.pyttestUnbufferedReads cCs!|jjt|jjdS(N(R_RBRRc(R((s,/usr/local/lib/python2.7/test/test_socket.pyt_testUnbufferedRead!scCs#|jj}|j|tdS(N(R\treadlineRZR(Rtline((s,/usr/local/lib/python2.7/test/test_socket.pyt testReadline%scCs!|jjt|jjdS(N(R_RBRRc(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. (R\R)RRZRkR(Rt a_baloo_ist_a_bearRl((s,/usr/local/lib/python2.7/test/test_socket.pyttestReadlineAfterRead.scCsA|jjd|jjd|jjt|jjdS(NsA baloo is a bear sA BALOO IS A BEAR. (R_RBRRc(R((s,/usr/local/lib/python2.7/test/test_socket.pyt_testReadlineAfterRead:scCsK|jjtd}|jd||jj}|jd|dS(NsEnd Of tLine(R\R)RRZRk(Rtend_of_Rl((s,/usr/local/lib/python2.7/test/test_socket.pyttestReadlineAfterReadNoNewline@scCs|jjddS(Ns End Of Line(R_RB(R((s,/usr/local/lib/python2.7/test/test_socket.pyt_testReadlineAfterReadNoNewlineFscCs|j|jj dS(N(R~R\R](R((s,/usr/local/lib/python2.7/test/test_socket.pyttestClosedAttrIscCs|j|jj dS(N(R~R_R](R((s,/usr/local/lib/python2.7/test/test_socket.pyt_testClosedAttrLs(RRR[R!RRR=RBRbRdReRfRiRjRmRnRqRrRuRvRwRx(((s,/usr/local/lib/python2.7/test/test_socket.pyRXs(                tFileObjectInterruptedTestCasecBsreZdZdefdYZedZddZddZdZ dZ dd Z d 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!TscCs|jjS(N(R|tnext(RR((s,/usr/local/lib/python2.7/test/test_socket.pyRYs((RRR!R(((s,/usr/local/lib/python2.7/test/test_socket.pyRzSs cCstjtjdS(N(RRRtEINTR(((s,/usr/local/lib/python2.7/test/test_socket.pyt _raise_eintr\sicKsr|jdd|jddg}tj||}|j|j|d|j|j|ddS(NR}cSsdS(Ns"This is the first line And the sec((((s,/usr/local/lib/python2.7/test/test_socket.pyRbscSsdS(Nsond line is here ((((s,/usr/local/lib/python2.7/test/test_socket.pyRdscSsdS(NRh((((s,/usr/local/lib/python2.7/test/test_socket.pyRessThis is the first line sAnd the second line is here (RzRRt _fileobjectRZRk(RRRat mock_socktfo((s,/usr/local/lib/python2.7/test/test_socket.pyt_test_readline`s cKsY|jdd|jddg}tj||}|j|j|ddS(NR}cSsdS(Ns"This is the first line And the sec((((s,/usr/local/lib/python2.7/test/test_socket.pyRmscSsdS(Nsond line is here ((((s,/usr/local/lib/python2.7/test/test_socket.pyRoscSsdS(NRh((((s,/usr/local/lib/python2.7/test/test_socket.pyRpss3This is the first line And the second line is here (RzRRRRZR)(RRRaRR((s,/usr/local/lib/python2.7/test/test_socket.pyt _test_readks cCs8|j|jdd|j|jdddS(NRid(RR(R((s,/usr/local/lib/python2.7/test/test_socket.pyt test_defaultvs  cCsP|jdd|jdddd|jdd|jdddddS(NR[iRid(RR(R((s,/usr/local/lib/python2.7/test/test_socket.pyttest_with_1k_buffer|scCs|jdddd|jddg}tj|dd}|j|j|d |j|j|d dS( NR}cSsdS(Ntaa((((s,/usr/local/lib/python2.7/test/test_socket.pyRscSsdS(Ns ((((s,/usr/local/lib/python2.7/test/test_socket.pyRscSsdS(NtBB((((s,/usr/local/lib/python2.7/test/test_socket.pyRscSsdS(Ntbb((((s,/usr/local/lib/python2.7/test/test_socket.pyRscSsdS(NRh((((s,/usr/local/lib/python2.7/test/test_socket.pyRsR[isaa tBBbb(RzRRRRZRk(RRRR((s,/usr/local/lib/python2.7/test/test_socket.pyt_test_readline_no_buffers cCsD|j|jdd|jdd|jdddddS(NRiR[iid(RR(R((s,/usr/local/lib/python2.7/test/test_socket.pyttest_no_buffers ( RRRGtobjectRzt staticmethodRRRRRRR(((s,/usr/local/lib/python2.7/test/test_socket.pyRyPs    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. RYisB. (R\RkRZRRORZ(RRl((s,/usr/local/lib/python2.7/test/test_socket.pyttestUnbufferedReadlines cCs9|jjdt|jjdt|jjdS(NsA. sB. (R_RBRRc(R((s,/usr/local/lib/python2.7/test/test_socket.pyt_testUnbufferedReadlines(RRRGR[RR(((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(t_socktsent(RR ((s,/usr/local/lib/python2.7/test/test_socket.pyR!s icCs-|jj||}|jj|| |S(N(RRRtappend(Rtdatatflagstn((s,/usr/local/lib/python2.7/test/test_socket.pyRscCs'|jj|||jj|dS(N(RRRR(RRR((s,/usr/local/lib/python2.7/test/test_socket.pyRscCst|j|S(N(R/R(Rtattr((s,/usr/local/lib/python2.7/test/test_socket.pyt __getattr__scCs5g|jD]'}t|tr+|jn|^q S(N(Rt isinstancet memoryviewttobytes(Rte((s,/usr/local/lib/python2.7/test/test_socket.pytgetsents(RRRGR!RRRR(((s,/usr/local/lib/python2.7/test/test_socket.pyRs     cCs,tj||j|jj|j_dS(N(RXRRR\R(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(NRhs%s %s s %s %s %s s (RtstripR\RcRZRR(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 (RRR_RkRZ(RR<RRRtl1tl2tl3((s,/usr/local/lib/python2.7/test/test_socket.pyt_testLinebufferedWrites (RRR[RRRRR(((s,/usr/local/lib/python2.7/test/test_socket.pyRs   t$SmallBufferedFileObjectClassTestCasecBseZdZRS(i(RRR[(((s,/usr/local/lib/python2.7/test/test_socket.pyRstNetworkConnectionTestcBseZdZdZRS(sProve network connection.cCs+tjt|jf|_|j|_dS(N(Rtcreate_connectionRSR RKRT(R((s,/usr/local/lib/python2.7/test/test_socket.pyR=s(RRRGR=(((s,/usr/local/lib/python2.7/test/test_socket.pyRst BasicTCPTest2cBseZdZRS(sLTests that NetworkConnection does not break existing TCP functionality. (RRRG(((s,/usr/local/lib/python2.7/test/test_socket.pyRstNetworkConnectionNoServercBsNeZdejfdYZejdZdZdZdZ RS(RzcBseZdZRS(cGstjddS(Ns timed out(RR (RR`((s,/usr/local/lib/python2.7/test/test_socket.pyRRs(RRRR(((s,/usr/local/lib/python2.7/test/test_socket.pyRzsccs/tj}|jt_z dVWd|t_XdS(s*Return a socket which times out on connectN(RRz(Rt old_socket((s,/usr/local/lib/python2.7/test/test_socket.pytmocked_socket_modules    cCstj}tjtjtj}|j|j|jtj}|j t |fWdQX|j |j j t jdS(N(Rtfind_unused_portRRRRkRRfRRRRSRZRqRt ECONNREFUSED(RR RKRs((s,/usr/local/lib/python2.7/test/test_socket.pyt test_connects  cCstj}|jtj}tjt|fWdQXtjg}t tdrh|j tj n|j |j j|dS(Nt ENETUNREACH(RRRfRRRRSRRRRRRoRq(RR Rstexpected_errnos((s,/usr/local/lib/python2.7/test/test_socket.pyttest_create_connections  c CsC|j1|jtjtjtdfWdQXWdQXdS(Ni(RRfRR RRS(R((s,/usr/local/lib/python2.7/test/test_socket.pyttest_create_connection_timeout1s ( RRRRzt contextlibtcontextmanagerRRRR(((s,/usr/local/lib/python2.7/test/test_socket.pyRs   tNetworkConnectionAttributesTestcBseZddZdZdZdZeZdZeZdZ eZ dZ eZ dZ eZd ZeZd ZRS( RIcCs$tj|d|tj|dS(NRJ(RR!R(RRJ((s,/usr/local/lib/python2.7/test/test_socket.pyR!<scCstj|_dS(N(RRt source_port(R((s,/usr/local/lib/python2.7/test/test_socket.pyR=@scCs'|jjd|_tj|dS(N(RKRRRRB(R((s,/usr/local/lib/python2.7/test/test_socket.pyRBCs  cCs#|jj\}}|jdS(N(RRNR(RRPRQ((s,/usr/local/lib/python2.7/test/test_socket.pyt _justAcceptHscCsNtjt|jfdd|_|j|jj|j|jjddS(NR ii( RRRSR RKRkRRZR (R((s,/usr/local/lib/python2.7/test/test_socket.pyt _testFamilyMs!cCsgtjt|jfdddd|jf|_|j|jj|j|jj d|jdS(NR itsource_addressRhi( RRRSR RRKRkRRZRl(R((s,/usr/local/lib/python2.7/test/test_socket.pyt_testSourceAddressSscCs|jtjdktjdz2tjt|jf|_|j |jj WdtjdX|j |jj ddS(Ni*( R~RRRRRRSR RKRkRRZR(R((s,/usr/local/lib/python2.7/test/test_socket.pyt_testTimeoutDefault\s cCs|jtjdktjdz8tjt|jfdd|_|j |jj WdtjdX|j |jj ddS(NiR ( R~RRRRRRSR RKRkRRZR(R((s,/usr/local/lib/python2.7/test/test_socket.pyt_testTimeoutNonehs !cCs>tjt|jfdd|_|j|jjddS(NR i(RRRSR RKRZR(R((s,/usr/local/lib/python2.7/test/test_socket.pyt_testTimeoutValueNamedts!cCsNtjt|jfd|_|j|jj|j|jjddS(Ni( RRRSR RKRkRRZR(R((s,/usr/local/lib/python2.7/test/test_socket.pyt_testTimeoutValueNonamedys(RRR!R=RBRt testFamilyRttestSourceAddressRttestTimeoutDefaultRttestTimeoutNoneRttestTimeoutValueNamedRttestTimeoutValueNonamedR(((s,/usr/local/lib/python2.7/test/test_socket.pyR9s          tNetworkConnectionBehaviourTestcBsGeZddZdZdZdZeZdZdZRS(RIcCs$tj|d|tj|dS(NRJ(RR!R(RRJ((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(RKRRRRB(R((s,/usr/local/lib/python2.7/test/test_socket.pyRBs  cCsC|jj\}}|j|jtjd|jddS(Nisdone!(RRNRkRRDRER(RRPRQ((s,/usr/local/lib/python2.7/test/test_socket.pyttestInsideTimeouts cCsBtjt|jf|_}|jd}|j|ddS(Nisdone!(RRRSR RKRRZ(RR R((s,/usr/local/lib/python2.7/test/test_socket.pyt_testInsideTimeoutscsEtjt|jfdd|_|jtjfddS(NR ics jdS(Ni(R((R (s,/usr/local/lib/python2.7/test/test_socket.pyRs(RRRSR RKRfR (R((R s,/usr/local/lib/python2.7/test/test_socket.pyt_testOutsideTimeouts%( RRR!R=RBRttestOutsideTimeoutRR(((s,/usr/local/lib/python2.7/test/test_socket.pyR~s     tUrllib2FileobjectTestcBseZdZRS(cCsdddY}|}tj|}|j|j|j |}tj|dt}|j|j|jdS(NRzcBs eZeZdZdZRS(cSsdS(N((R((s,/usr/local/lib/python2.7/test/test_socket.pyRcscSs t|_dS(N(R R](R((s,/usr/local/lib/python2.7/test/test_socket.pyRs(RRRR]RcR(((s,/usr/local/lib/python2.7/test/test_socket.pyRzs R((RRRR~R]R (RRzR]R((s,/usr/local/lib/python2.7/test/test_socket.pyRCs    (RRRC(((s,/usr/local/lib/python2.7/test/test_socket.pyRstTCPTimeoutTestcBs>eZdZdZejeedddZRS(cs)fd}jtj|ddS(Ncs!jjdjjdS(Ng?(RRRN(R`Ra(R(s,/usr/local/lib/python2.7/test/test_socket.pyt raise_timeoutss*Error generating a timeout exception (TCP)(RfRR (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( RRRRNRR R;RR (RtokRi((s,/usr/local/lib/python2.7/test/test_socket.pyttestTimeoutZeros Rstest needs signal.alarm()cs2|jjddtfdYfd}tjtj|}zytjdzy|jj}Wn_tjk r|j dnLk rn<|j dt j d t j fnX|j dWdtjd XWnk r|j d nXWdtjtj|XdS( Ng@tAlarmcBseZRS((RR(((s,/usr/local/lib/python2.7/test/test_socket.pyRscs 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@RRRRNRR R;Rtexc_infot tracebackt format_exc(RRR Ri((Rs,/usr/local/lib/python2.7/test/test_socket.pyttestInterruptedTimeouts,   # ( RRRRRVRRRR(((s,/usr/local/lib/python2.7/test/test_socket.pyRs  tUDPTimeoutTestcBseZdZdZRS(cs)fd}jtj|ddS(Ncs$jjdjjddS(Ng?i(RRR(R`Ra(R(s,/usr/local/lib/python2.7/test/test_socket.pyRss*Error generating a timeout exception (UDP)(RfRR (RR((Rs,/usr/local/lib/python2.7/test/test_socket.pyttestUDPTimeoutscCst}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( RRRRRR R;RR (RRRi((s,/usr/local/lib/python2.7/test/test_socket.pyRs (RRRR(((s,/usr/local/lib/python2.7/test/test_socket.pyRs tTestExceptionscBseZdZRS(cCsq|jttjt|jttjtj|jttjtj|jttjtjdS(N(R~t issubclassRRR@RcRR (R((s,/usr/local/lib/python2.7/test/test_socket.pyttestExceptionTrees(RRR(((s,/usr/local/lib/python2.7/test/test_socket.pyRsRsLinux specific testtTestLinuxAbstractNamespacecBs)eZdZdZdZdZRS(ilcCsd}tjtjtj}|j||jdtjtjtj}|j|j|j|j|j||j|j |dS(Ntpython-test-helloi( RtAF_UNIXRRRRRRlRNRZt getpeername(Rtaddressts1ts2((s,/usr/local/lib/python2.7/test/test_socket.pyttestLinuxAbstractNamespaces   cCsTdd|jd}tjtjtj}|j||j|j|dS(NRthi(t UNIX_PATH_MAXRRRRRZRl(RRR]((s,/usr/local/lib/python2.7/test/test_socket.pyt testMaxNames cCsFdd|j}tjtjtj}|jtj|j|dS(NRR(RRRRRfRR(RRR]((s,/usr/local/lib/python2.7/test/test_socket.pyttestNameOverflow$s(RRRRRR(((s,/usr/local/lib/python2.7/test/test_socket.pyRs t BufferIOTestcBseZdZddZdZdZdZeZdZeZ dZ dZ d Z e Z d Ze Zd Zd Zd Ze ZRS(sF Test the buffer versions of socket.recv() and socket.send(). RIcCstj|d|dS(NRJ(RMR!(RRJ((s,/usr/local/lib/python2.7/test/test_socket.pyR!/scCshtjddd}|jj|}|j|tt|jtt }|j|tdS(NR t i(tarrayROt recv_intoRZRRttostring(RRgtnbytesR<((s,/usr/local/lib/python2.7/test/test_socket.pyttestRecvIntoArray2s cCs3tjtt}WdQX|jj|dS(N(Rtcheck_py3k_warningstbufferRRTR(RRg((s,/usr/local/lib/python2.7/test/test_socket.pyt_testRecvIntoArray9s cCsXtd}|jj|}|j|tt|tt }|j|tdS(Ni(t bytearrayRORRZRR(RRgRR<((s,/usr/local/lib/python2.7/test/test_socket.pyttestRecvIntoBytearray>s  cCs^td}|jjt|}|j|tt|tt }|j|tdS(Ni(RRORRRZRR(RRgRR<((s,/usr/local/lib/python2.7/test/test_socket.pyttestRecvIntoMemoryviewGs  cCsntjddd}|jj|\}}|j|tt|jtt }|j|tdS(NR Ri(RROt recvfrom_intoRZRRR(RRgRRQR<((s,/usr/local/lib/python2.7/test/test_socket.pyttestRecvFromIntoArrayPs cCs3tjtt}WdQX|jj|dS(N(RRRRRTR(RRg((s,/usr/local/lib/python2.7/test/test_socket.pyt_testRecvFromIntoArrayWs cCs^td}|jj|\}}|j|tt|tt }|j|tdS(Ni(RRORRZRR(RRgRRQR<((s,/usr/local/lib/python2.7/test/test_socket.pyttestRecvFromIntoBytearray\s  cCsdtd}|jjt|\}}|j|tt|tt }|j|tdS(Ni(RRORRRZRR(RRgRRQR<((s,/usr/local/lib/python2.7/test/test_socket.pyttestRecvFromIntoMemoryviewes  cCs,td}|jt|jj|ddS(Nii(RRfRROR(RRg((s,/usr/local/lib/python2.7/test/test_socket.pyttestRecvFromIntoSmallBufferns cCs3tjtt}WdQX|jj|dS(N(RRRRRTR(RRg((s,/usr/local/lib/python2.7/test/test_socket.pyt_testRecvFromIntoSmallBufferss cCs0t}|jj||jj|ddS(Ni(RROR(RRg((s,/usr/local/lib/python2.7/test/test_socket.pyttestRecvFromIntoEmptyBufferxs (RRRGR!RRRt_testRecvIntoBytearrayRt_testRecvIntoMemoryviewRRRt_testRecvFromIntoBytearrayRt_testRecvFromIntoMemoryviewRRRt_testRecvFromIntoEmptyBuffer(((s,/usr/local/lib/python2.7/test/test_socket.pyR*s$            iiicCsfttdstStjjds)tStd+}x!|D]}|jdr?tSq?WWdQXtS(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( RRRRtpathtisfiletopenRR (RRl((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 |tj ttt tddf}|j t ||jd\}}|j|j||j|t dS(Niiii(RRRvRRxRytTIPC_ADDR_NAMESEQt TIPC_STYPEt TIPC_LOWERt TIPC_UPPERRtTIPC_ADDR_NAMERnRR$RZRl(RRRKtsrvaddrtsendaddrR<trecvaddr((s,/usr/local/lib/python2.7/test/test_socket.pyttestRDMs    (RRR(((s,/usr/local/lib/python2.7/test/test_socket.pyR stTIPCThreadableTestcBs8eZddZdZdZdZdZRS(RIcCs'tjj|d|tj|dS(NRJ(RVRWR!R(RRJ((s,/usr/local/lib/python2.7/test/test_socket.pyR!scCstjtjtj|_|jjtjtjdtjtt t f}|jj ||jj d|j |jj\|_|_dS(Nii(RRRRRRxRyRRRRRRR$RNRPtconnaddr(RR((s,/usr/local/lib/python2.7/test/test_socket.pyRs   cCsotjdtjtjtj|_tjttt tddf}|jj ||jj |_ dS(Ng?ii( RDRERRRRKRRRRRRRltcliaddr(RRQ((s,/usr/local/lib/python2.7/test/test_socket.pyR=s   cCs<|jjd}|j|t|j|j|jdS(Ni(RPRRZRRR(RR<((s,/usr/local/lib/python2.7/test/test_socket.pyt testStreamscCs!|jjt|jjdS(N(RKRRR(R((s,/usr/local/lib/python2.7/test/test_socket.pyt _testStreams(RRR!RR=RR(((s,/usr/local/lib/python2.7/test/test_socket.pyRs   c Cstttttttttg }|j t t t t ttttttg |jt|jt|j ttgtj}tj|tj|dS(N(RYRR?RRRRR:RtextendRJRXRyRRRRRRRRRGRR RRtthreading_setupt run_unittesttthreading_cleanup(ttestst thread_info((s,/usr/local/lib/python2.7/test/test_socket.pyt test_mains(        t__main__(FRVttestRRRR@RDRR+RRRRtweakrefRRRRRRSRRRRR0R'RRRWRRRRHRLRMRURYRRR:R?RRGRJRXRyRRRRRRRRRRRRRRRRRRRR R RR"R(((s,/usr/local/lib/python2.7/test/test_socket.pyts                    bhWhF?:D9U     $