Ϫf|dZddlZddlZddlZddlmZddlmZmZddl m Z ddl m Z ddl Z ddlmZmZmZmZmZddlmZdd lmZmZdd lmZdd lmZdd lmZdd lm Z m!Z!ddl"m#Z#ddl$m%Z%m&Z&dcdZ'Gddej4Z(GddejRZ*GddZ+Gdde+ejRZ,Gdde+ejZZ.Gdde&Z/Gdde&Z0Gdd ejbZ2Gd!d"e.Z3Gd#d$e&Z4Gd%d&e&Z5Gd'd(ejZZ6Gd)d*e&Z7Gd+d,ej4Z8Gd-d.ej4Z9Gd/d0ejZZ:Gd1d2e&Z;Gd3d4ej4Z<Gd5d6ej4Z=Gd7d8ej4Z>Gd9d:e>Z?Gd;d<Z@Gd=d>e&e@ZAGd?d@ejZCGdAdBejZEGdCdDe&ZFGdEdFej4ZGGdGdHej4ZHGdIdJejZZIGdKdLejZJGdMdNejZKGdOdPe&ZLe eGdQdReZMGdSdTejRZNGdUdVe&ZOGdWdXe&ZPGdYdZe&ZQGd[d\e&ZRGd]d^e&ZSGd_d`e&ZT ddlUZUeUjeUjddazZXeYeAdbeXy#eZ$rYywxYw)dz. Tests for implementations of L{IReactorTCP}. Nwraps)CallableOptional)skipIf) implementer)defererror interfacesprotocolreactor) IPv4Address)IHalfCloseableProtocol IPullProducer)Protocol)AccumulatingProtocol)policies)errmsg)platform)SkipTestTestCasecddlm}tjfd}|j |fd}j |j |}|jjS)z Poor excuse for an event notification helper. This polls a condition and calls back a Deferred when it is seen to be true. Do not use this function. r)taskc<}|rj|yyNcallback)resd predicates 7/usr/lib/python3/dist-packages/twisted/test/test_tcp.pycheckzloopUntil..check*sk  JJsO c(j|Sr)stop)resultcalls r"r&zloopUntil..stop1s  r$) twisted.internetrr Deferred LoopingCall addCallbackstart addErrbackerrback)r!intervalrr#r&d2r(r s` @@r" loopUntilr2sa& A   E "DMM$ H BMM!)) Hr$ceZdZdZdZy)ClosingProtocolcNtd|jjy)NzClosingProtocol.connectionMader transportloseConnectionselfs r"connectionMadezClosingProtocol.connectionMade<s ,- %%'r$cXtd|jtjy)NzClosingProtocol.connectionLost)rtrapr ConnectionDoner:reasons r"connectionLostzClosingProtocol.connectionLost@s ,- E(()r$N__name__ __module__ __qualname__r;rAr$r"r4r4;s (*r$r4c eZdZdZdZdZdZy)ClosingFactoryz/ Factory that closes port immediately. NcT|jj|_tSr)port stopListening _cleanerUpperr4)r:conns r" buildProtocolzClosingFactory.buildProtocolLs !YY446  r$cf|j|jjS|jS)zL Clean-up for tests to wait for the port to stop listening. )rLrJrKr9s r"cleanUpzClosingFactory.cleanUpPs/    %99**, ,!!!r$)rCrDrE__doc__rLrNrPrFr$r"rHrHEsM!"r$rHcLeZdZUdZeZdZdZdZe e ge fe d<dZ dZdZy)MyProtocolFactoryMixina Mixin for factories which create L{AccumulatingProtocol} instances. @type protocolFactory: no-argument callable @ivar protocolFactory: Factory for protocols - takes the place of the typical C{protocol} attribute of factories (but that name is used by this class for something else). @type protocolConnectionMade: L{None} or L{defer.Deferred} @ivar protocolConnectionMade: When an instance of L{AccumulatingProtocol} is connected, if this is not L{None}, the L{Deferred} will be called back with the protocol instance and the attribute set to L{None}. @type protocolConnectionLost: L{None} or L{defer.Deferred} @ivar protocolConnectionLost: When an instance of L{AccumulatingProtocol} is created, this will be set as its C{closedDeferred} attribute and then this attribute will be set to L{None} so the L{defer.Deferred} is not used by more than one protocol. @ivar protocol: The most recently created L{AccumulatingProtocol} instance which was returned from C{buildProtocol}. @type called: C{int} @ivar called: A counter which is incremented each time C{buildProtocol} is called. @ivar peerAddresses: A C{list} of the addresses passed to C{buildProtocol}. Nr rcg|_yr) peerAddressesr9s r"__init__zMyProtocolFactoryMixin.__init__~s r$c|jj||xjdz c_|j}||_|j |_d|_||_|S)zi Create a L{AccumulatingProtocol} and set it up to be able to perform callbacks. N)rUappendcalledprotocolFactoryfactoryprotocolConnectionLostclosedDeferredr r:addrps r"rNz$MyProtocolFactoryMixin.buildProtocols] !!$' q  " 66&*# r$)rCrDrErQrr[protocolConnectionMader]r rrr__annotations__rZrVrNrFr$r"rSrSYsA:+O!!15HhxH -.5 F  r$rSceZdZdZy)MyServerFactoryzI Server factory which creates L{AccumulatingProtocol} instances. N)rCrDrErQrFr$r"reresr$rec0eZdZdZdZdZdZdZdZdZ y)MyClientFactoryzI Client factory which creates L{AccumulatingProtocol} instances. rctj|tj|_tj|_yr)rSrVr r*deferred failDeferredr9s r"rVzMyClientFactory.__init__s-''-( !NN,r$cVd|_||_|jjdyNrX)failedr@rjrr: connectorr@s r"clientConnectionFailedz&MyClientFactory.clientConnectionFaileds$   ""4(r$cH||_|jjdyr) lostReasonrirrns r"clientConnectionLostz$MyClientFactory.clientConnectionLosts  t$r$cd|_yrlstoppedr9s r" stopFactoryzMyClientFactory.stopFactorys  r$N) rCrDrErQrmrvrVrprsrwrFr$r"rgrgs'FG- ) %r$rgcHeZdZdZdZdZdZdZdZdZ dZ d Z d Z y ) ListeningTestsct}tjd|d}|j|j|j t jj|y)zf L{IReactorTCP.listenTCP} returns an object which provides L{IListeningPort}. r 127.0.0.1 interfaceN) rer listenTCP addCleanuprK assertTruer IListeningPort providedByr:fp1s r" test_listenzListeningTests.test_listensO     q!{ ; (()  11<.cbStopListenings&$$Q[AD%%' 'r$) rer r~getHostrJr maybeDeferredrKr,)r:rJrr rrs @@r"testStopListeningz ListeningTests.testStopListenings`    A= LLN   (    2 2 3 o&r$cft}tjd|d}|jSNrr{r|)rer r~rKrs r"testNumberedInterfacez$ListeningTests.testNumberedInterfaces-     q!{ ;!!r$cTt}tjd|tj j j tjdk(fd}tjj}|j|S)Nrc^jtjdk7y)Nr) assertFalsereprfind)ignraportNor:s r"stoppedListeningz5ListeningTests.testPortRepr..stoppedListenings#   T!W\\&1R7 8r$) rer r~strrrJrrrr rrKr,)r:rrr rars` @@r" testPortReprzListeningTests.testPortReprs~     a #QYY[%%& af-34 9    0}}-..r$ct}tjx}|_t j d|j jt}tjx}|_t jdjj|}j |jfd}tj||gj|S)z Check that the repr string of the server transport get the good port number if the server listens on 0. rr{c|\}}jj}jt|jd|d|jj |jj y)Nz)rrJ assertEqualrr7r8)r' serverProto clientProto portNumberrJr:s r"r#z-ListeningTests.test_serverRepr..checksl'- $K,,J   [**+.zl!<   ! ! 0 0 2  ! ! 0 0 2r$)rer r*rbr r~rrKrg connectTCPrrJ disconnect gatherResultsr,)r:serverserverConnMadeclientclientConnMaderor#rJs` @r"test_serverReprzListeningTests.test_serverReprs !"9>9II6  F+ **+ "9>9II6&&{DLLN4G4GP   ,,- 3""NN#CDPPQVWWr$cttjddjjfd}dt j j}|j||S)z Stop and then try to restart a L{tcp.Port}: after a restart, the server should be able to handle client connections. rr{r|cjt}tj_tj|_t j djj|}j|jtjj|jgjSNr{) startListeningrgr r*rbr rrrJrrrr,rrrocloserJr: serverFactorys r"rz=ListeningTests.test_restartListening..cbStopListenings    !$&F38>>3CM 0,1NN,.close0'- $K  ! ! 0 0 2  ! ! 0 0 2r$)rer r~rrKr rr,)r:rr rrJrs` @@@r"test_restartListeningz$ListeningTests.test_restartListeningsf ()   M[I **+ ! 3    2 2 3 o&r$ct}d}||_tjd|d}|j |j t S)z If the server factory raises an exception in C{stopFactory}, the deferred returned by L{tcp.Port.stopListening} should fail with the corresponding error. ctdNzAn error RuntimeErrorrFr$r"raiseExceptionz8ListeningTests.test_exceptInStop..raiseException" z* *r$rr{r|)rerwr r~ assertFailurerKrr:rrrJs r"test_exceptInStopz ListeningTests.test_exceptInStopsK ()  +%3 !  M[I!!$"4"4"6 EEr$ctd}|_tjddj j fd}dj j tj|S)z Even if the server factory raise an exception in C{stopFactory}, the corresponding C{tcp.Port} instance should be in a sane state and can be restarted. ctdrrrFr$r"rz>ListeningTests.test_restartAfterExcept..raiseException2rr$rr{r|c`jt}tj_tj|_t jdjj|}j|jtjj |j gjSr)rwrrgr r*rbr rrrJrrrr,rs r"rz?ListeningTests.test_restartAfterExcept..cbStopListening9s)    !$&F38>>3CM 0,1NN,.closeFrr$) rerwr r~rrKrrr,)r:rrrrJrs` @@@r"test_restartAfterExceptz&ListeningTests.test_restartAfterExcept*sz ()  +%3 !  M[I **+ ! 3 !!$"4"4"6 EQQ   r$ct}tjd|d}|jj}|j dt tj|_ tj_ tjd|fd}jj|S)z If C{connectionLost} is called directly on a port object, it succeeds (and doesn't expect the presence of a C{deferred} attribute). C{connectionLost} is called by L{reactor.disconnectAll} at shutdown. rr{r|NcXjjtjyrr@r=r ConnectionRefusedError)rrs r"r#z;ListeningTests.test_directConnectionLostCall..check`s MM  u;; .raiseExceptionorr$rr{r|N)rerwr r~ assertRaisesrrArs r"test_exceptInConnectionLostCallz.ListeningTests.test_exceptInConnectionLostCallesG()  +%3 !  M[I ,(;(;TBr$N) rCrDrErrrrrrrrrrrFr$r"ryrys9B(" /X6<F # J6,Cr$rycFeZdZdZdZdZdZdZdZdZ dZ d Z d Z y ) LoopbackTestsz$ Test loopback connections. cJt}tjd|d|_j |j j j}ttjd|fd}jj|S)zz A port created with L{IReactorTCP.listenTCP} can be connected to with L{IReactorTCP.connectTCP}. rr{r|cjjjjjjj t jyr)rr made disconnectedrrr=r r>)xclientFrJr:s r"r#z.checksG OOG,,11 2 OOD-- .    # #E$8$8 9r$) rHr r~rJrrPrrgrrir,)r:rrr#rrJs` @@r"test_closePortInProtocolFactoryz-LoopbackTests.test_closePortInProtocolFactory|s    A=  "\\^(( !#; G< : ++E22r$cHt|ddtjy)Nr=cyrrF)rs r"z,LoopbackTests._trapCnxDone..sr$)getattrr r>)r:objs r" _trapCnxDonezLoopbackTests._trapCnxDones,V^,U-A-ABr$ct}tj}||_t j d|d}|j |j|jj}t}tj}||_t jd||tj||g}fd} |j| |S)z Invoke the given callback with a client protocol and a server protocol which have been connected to each other. rr{r|c|\}}|||jj|jjyrr)r'serverProtocolclientProtocolrs r" connectedz>LoopbackTests._connectedClientAndServerTest..connecteds;-3 *NN ^^ 4  $ $ 3 3 5  $ $ 3 3 5r$)rer r*rbr r~rrKrrJrgrrr,) r:rrrrJrrr connsMaders ` r"_connectedClientAndServerTestz+LoopbackTests._connectedClientAndServerTests () )/= ,  M[I **+\\^(( !#))7&; G<''(HI  6 i(r$c0fd}j|S)a The transport of a protocol connected with L{IReactorTCP.connectTCP} or L{IReactor.TCP.listenTCP} can have its I{TCP_NODELAY} state inspected and manipulated with L{ITCPTransport.getTcpNoDelay} and L{ITCPTransport.setTcpNoDelay}. c4||fD]}|j}j|jd|jdj|jd|jdj|jdyNrrX)r7r getTcpNoDelay setTcpNoDelayrrrar7r:s r"r#z,LoopbackTests.test_tcpNoDelay..checks$n5 ?KK   !8!8!:A>''*  !8!8!:A>''*  !8!8!:A>  ?r$rr:r#s` r"test_tcpNoDelayzLoopbackTests.test_tcpNoDelays ?11%88r$c0fd}j|S)a The transport of a protocol connected with L{IReactorTCP.connectTCP} or L{IReactor.TCP.listenTCP} can have its I{SO_KEEPALIVE} state inspected and manipulated with L{ITCPTransport.getTcpKeepAlive} and L{ITCPTransport.setTcpKeepAlive}. c4||fD]}|j}j|jd|jdj|jd|jdj|jdyr)r7rgetTcpKeepAlivesetTcpKeepAlivers r"r#z.LoopbackTests.test_tcpKeepAlive..checks$n5 AKK   !:!:!.checks NN   < < =r$)rgr rrjr,)r:r#rs @r" testFailingzLoopbackTests.testFailings=!#;GQ? >##//66r$cgtdD]I}tj}|jd|jdj |Kt j tjttjfd}j|tjfd}|j|fd}|j||S)z Assert that the error number of the ConnectionRefusedError is ECONNREFUSED, and not some other socket related error. r{rrXcfd}j}|j\}}|jj||}|j ||S)Ncn|jjrSjdy)z\ Darn. Kill it and try again, if there are any tries left. z?Could not fail to connect - could not test errno for that case.N)r7r8fail)protor: serverSocketstryConnectFailures r"rz]LoopbackTests.test_connectionRefusedErrorNumber..tryConnectFailure..connecteds0..0 ,.. Ur$)pop getsocknamerrr,) r serverSocket serverHost serverPortconnectDeferred clientCreatorr:rrs r"rzJLoopbackTests.test_connectionRefusedErrorNumber..tryConnectFailures] ),,.L%1%=%=%? "J    +66z:NO  ' ' 2" "r$cZj|jtjyr)rosErrorerrno ECONNREFUSED)excr:s r" connRefusedzDLoopbackTests.test_connectionRefusedErrorNumber..connRefuseds   S[[%*<*< =r$cNr!jjr!|Sr)rr) passthroughrs r"cleanupz@LoopbackTests.test_connectionRefusedErrorNumber..cleanups&!!#))+  r$)rangesocketbindlistenrYrandomshuffler ClientCreatorr rrr rr,addBoth) r:irrefusedDeferredrrr rrs ` @@@r"!test_connectionRefusedErrorNumberz/LoopbackTests.test_connectionRefusedErrorNumbers2 r /A!==?L   . /    "   .  / }% ..w8I8IJ  #(,- ?E,H,HI > ##K0  (r$cv|jtjtjddt y)zu Connecting to a named service which does not exist raises L{error.ServiceNameUnknownError}. r{thisbetternotexistN)rr ServiceNameUnknownErrorr rrgr9s r"test_connectByServiceFailz'LoopbackTests.test_connectByServiceFail&s0   ) )        r$c t tj}| _t j d d}j |j|jjt}tj}||_fd}jtd|t jdd|tj||g} fd}|j||S)z L{IReactorTCP.connectTCP} accepts the name of a service instead of a port number and connects to the port number associated with that service, as defined by L{socket.getservbyname}. rr{r|c|dk(r|dk(rSy)NhttptcprrF) serviceName protocolNamers r"fakeGetServicePortByNamezELoopbackTests.test_connectByService..fakeGetServicePortByNameCsf$)>!!r$ getservbynamer$c|\}}jjd|jj|jjy)Nz7Server factory was not called upon to build a protocol.)rrZr7r8)r'rrr:rs r"rz6LoopbackTests.test_connectByService..connectedNsK-3 *NN OO$$I   $ $ 3 3 5  $ $ 3 3 5r$)rer r*rbr r~rrKrrJrgpatchrrrr,) r:rrJ clientFactoryrr(connMaderrrs ` @@r"test_connectByServicez#LoopbackTests.test_connectByService3s () )/= ,  M[I **+\\^(( ') )/= ,  6?,DE; >&&'GH 6 Y'r$N) rCrDrErQrrrrrrrr!r.rFr$r"rrws73(C89&9&7EN  %r$rc eZdZdZdZdZdZy)StartStopFactoryrcN|js |jrtd|_yrlstartedrvrr9s r" startFactoryzStartStopFactory.startFactory_ <<4<<  r$cN|jr |jrtd|_yrlr2r9s r"rwzStartStopFactory.stopFactoryds||t||  r$N)rCrDrEr3rvr4rwrFr$r"r0r0[sGG r$r0c&eZdZdZdZdZdZdZy)ClientStartStopFactoryrchtj|g|i|tj|_yr)rgrVr r* whenStopped)r:akws r"rVzClientStartStopFactory.__init__ns)  00R0 >>+r$cN|js |jrtd|_yrlr2r9s r"r4z#ClientStartStopFactory.startFactoryrr5r$c|jr |jrtd|_|jj dy)NrXT)r3rvrr:rr9s r"rwz"ClientStartStopFactory.stopFactoryws0||t||   !!$'r$N)rCrDrEr3rvrVr4rwrFr$r"r8r8jsGG, (r$r8ceZdZdZdZdZy) FactoryTestszTests for factories.c ttjdd}j|jj j jfdtjdd}tjdd j j jfdtj|j}tj|j}tj||g} fd}|j|fd}|j||S)a The factory passed to L{IReactorTCP.listenTCP} should be started only when it transitions from being used on no ports to being used on one port and should be stopped only when it transitions from being used on one port to being used on no ports. rr{r|rXrctjjjfdjS)NrB)rr3rvrK)rrp3r:s r"cbClosedz3FactoryTests.test_serverStartStop..cbCloseds/   aii3V <##% %r$cVjjjfdy)N)rXrX)rr3rv)rrr:s r" cbClosedAllz6FactoryTests.test_serverStartStop..cbClosedAlls   aii3V .s r$) rHr r~rJrrPrr8rrr3r2)r:rrarr\s @r"test_clientStartStopz!FactoryTests.test_clientStartStops     ak :  "YY[%% (*; G< (011r$N)rCrDrErQrJrMrFr$r"r@r@~s+Z2r$r@c"eZdZdZdZdZdZy)CannotBindTestsz] Tests for correct behavior when a reactor cannot bind to the required TCP port. ct}tjd|d}|j|j|j j }|j }|j|jd|j|jd|j|j ||jtjtj||dy)z L{IReactorTCP.listenTCP} raises L{error.CannotListenError} if the address to listen on is already in use. rr{r|TCPN) rer r~rrKrrJrtypehostrr CannotListenError)r:rrrdests r"test_cannotBindzCannotBindTests.test_cannotBinds     q!{ ; (() JJL  zz| E* K0 A&   # #W%6%61   r$c2tfd}|S)z>Returns closure that when called calls f and then callbacks d.c:|i|}jd|S)Nr)argsr<rtnr rs r"newfz/CannotBindTests._fireWhenDoneFunc..newfs T.R.C JJrNJr$r)r:r rr\s `` r"_fireWhenDoneFuncz!CannotBindTests._fireWhenDoneFuncs" q     r$cr tj}t}j||j|_t j d|d j j fd}fd fdfdfdfd  fd |j||S) z L{IReactorTCP.connectTCP} calls C{Factory.clientConnectionFailed} with L{error.ConnectBindError} if the bind address specified is already in use. rr{r|c tj}t}j||j|_t j djj|d|j||S)Nr{r bindAddress) r r*rgr]rNr rrrJr,)resultsr cf1_conmaderar:s r" _connect1z2CannotBindTests.test_clientBind.._connect1sk A!#C $ 6 6q#:K:K LC    QYY[--s@P  MM(C (Hr$ctj}j||jj|j_|j ||Sr)r r*r]r r;r,)rbrcr _check1connect2r:s r"rdz1CannotBindTests.test_clientBind.._conmadesJ A*.*@*@3<<..+CLL ' MM/3 /Hr$c j|jjdtj}tj}|jj j j}t} j||j|_ j||j|_ tjd j j|d|f|j|||j||tj||g}|j |||S)NrXr{r`)rr rr r*r7rrJrgr]rprwr rr, DeferredList) rbrcrIr1rJcf2dl _check2failed_check2stopped_stoprar:s r"rgz8CannotBindTests.test_clientBind.._check1connect2s   S\\.. 2!B!B<<))11388D!#C)-)?)?C..*C &#44RICO   QYY[--sd@S  NN=#s 3 NN>3 4##RH-B NN5#s +Ir$cj|jd|jjtj j |jjtj |Srl)rrmr@r=r ConnectBindErrorrr#rbrcrjr:s r"rlz6CannotBindTests.test_clientBind.._check2failedsS   SZZ + JJOOE22 3 OOCJJ,,U-C-CD ENr$c@j|jd|Srlrrvrqs r"rmz7CannotBindTests.test_clientBind.._check2stoppeds   S[[! ,Nr$ctj}|j|j||j|_|j j j|Sr)r r*r,r]rwr r7r8)rbrcrjr _check1cleanupr:s r"rnz.CannotBindTests.test_clientBind.._stop sP A MM.# ."44QHCO LL " " 1 1 3Hr$c>j|jdyrlrs)rbrcr:s r"ruz7CannotBindTests.test_clientBind.._check1cleanup's   S[[! ,r$) r r*rer]r4r r~rrKr,) r: theDeferredsfrerurgrlrmrdrnras ` @@@@@@@r"test_clientBindzCannotBindTests.test_clientBinds nn&  00booN   a{ ; (    (     -  *r$N)rCrDrErQrVr]ryrFr$r"rOrOs  ( Gr$rOceZdZdZy)MyOtherClientFactorycF||_t|_|jSr)addressrr )r:r}s r"rNz"MyOtherClientFactory.buildProtocol/s ,. }}r$N)rCrDrErNrFr$r"r{r{.sr$r{ceZdZdZdZy)LocalRemoteAddressTestszo Tests for correct getHost/getPeer values and that the correct address is passed to buildProtocol. c t}tj|_|j t j d|dj jjj}ttjx}_ t jd|fd}|j| fd}|j||S)z L{IListeningPort.getHost} returns the same address as a client connection's L{ITCPTransport.getPeer}. rr{r|cjjgjjjjjj yr)rrrUr r7getPeer)rr,rJr:s r"r#z7LocalRemoteAddressTests.test_hostAddress..checkKsM   dlln-}/J/J K   T\\^]-C-C-M-M-U-U-W Xr$c(jSr)r)rroserverConnectionLosts r"rz9LocalRemoteAddressTests.test_hostAddress..cleanupQs  "' 'r$)rer r*r]r r~rrKrrJrgrbrr,) r:rr onConnectionr#rr,rorJrs ` @@@@r"test_hostAddressz(LocalRemoteAddressTests.test_hostAddress;s () /4~~/? ,,CC  M[I **+ LLN  ') >Cnn>NN };&&{A}E  Y   ' (   )r$N)rCrDrErQrrFr$r"rr5s  r$rceZdZdZy)WriterProtocolc|jjdgd}|jj||jj}|jdk7rt d|d|j _|jj}|jdk7rt d|d|j _d|j _ |jjy)NHello Cleveland! )Goodbye cruel world rQz!getPeer returned non-TCP socket: rXz!getHost returned non-TCP socket: ) r7write writeSequencerrRrr\problemrdoner8)r:seqpeeruss r"r;zWriterProtocol.connectionMade^s 237 $$S)~~%%' 99  3D6: ;#$DLL ^^ # # % 77e  3B48 9#$DLL   %%'r$NrCrDrEr;rFr$r"rr]s(r$rceZdZdZdZy)ReaderProtocolcB|jxj|z c_yr)r\datar:rs r" dataReceivedzReaderProtocol.dataReceivedus T!r$c&d|j_yrlr\rr?s r"rAzReaderProtocol.connectionLostx r$NrCrDrErrArFr$r"rrts "r$rceZdZdZdZy)WriterClientFactoryc d|_d|_y)Nrr$)rrr9s r"rVzWriterClientFactory.__init__}s  r$c6t}||_||_|Sr)rr\r r_s r"rNz!WriterClientFactory.buildProtocols    r$NrCrDrErVrNrFr$r"rr|s r$rceZdZdZdZdZy)WriteDataTestszw Test that connected TCP sockets can actually write data. Try to exercise the entire ITransport interface. ctjt_d_d_t }t jd|d}j|j|jj}tt }t jd||fd}tj|j |j g}|j#|S)z L{ITCPTransport.write} and L{ITCPTransport.writeSequence} send bytes to the other end of the connection. rr{r|cjjdjjdk(djjddjgd}jj|k(dy)N&writer didn't finish, it probably diedrzwriter indicated an error$client didn't see connection droppedr$)rrrrrz.client didn't receive all the data it expected)rrrjoinr)rexpectedrrr:s r"r#z)WriteDataTests.test_writer..checksn OOAFF$L M OOAIIN,G H OOGLL*P QxxPH OO (@ r$)r Factoryrrr WiredFactoryr r~rrKrrJrrr r onDisconnectr,) r:wrappedFrarwrappedClientFr#r rrs ` @@r" test_writerzWriteDataTests.test_writers    #  ?   a[ A ( IIK  %'%g.;>:    !6!68S8S T U}}U##r$cl tjjdk(r tdt j t j G fddt j}t j}||_tjd|d}|j|j|j}ttGdd G fd d t j}t | _ j"} fd }|j%|t'd |j(d|j*tj,|j(|j* t'd|j/|t0j2S)a$ A TCP transport which is written to after the connection has been shut down should notify its protocol that the connection has been lost, even if the TCP transport is not actively being monitored for read events (ie, pauseProducing was called on it). IOCPReactora(iocpreactor does not, in fact, stop reading immediately after pauseProducing is called. This results in a bonus disconnection notification. Under some circumstances, it might be possible to not receive this notifications (specifically, pauseProducing, deliver some data, proceed with this test). c&eZdZdZfdZfdZy)JWriteDataTests.test_writeAfterShutdownWithoutReading..Disconnecterz Protocol for the server side of the connection which disconnects itself in a callback on clientPaused and publishes notification when its connection is actually lost. cJtdfd}j|y)z[ Set up a callback on clientPaused to lose the connection. zDisconnector.connectionMadecftdjjtdy)Nz&Disconnector.connectionMade disconnectzloseConnection calledr6)rr:s r"rzmWriteDataTests.test_writeAfterShutdownWithoutReading..Disconnecter.connectionMade..disconnects%@ANN113/0r$N)rr,)r:r clientPauseds` r"r;zYWriteDataTests.test_writeAfterShutdownWithoutReading..Disconnecter.connectionMades#121 ((4r$cTtdjdtdy)zt Notify observers that the server side of the connection has ended. zDisconnecter.connectionLostNzserverLost called back)rr)r:r@ serverLosts r"rAzYWriteDataTests.test_writeAfterShutdownWithoutReading..Disconnecter.connectionLosts% 12##D),-r$N)rCrDrErQr;rA)rrsr" Disconnecterrs  5 .r$rrr{r|c"eZdZdZdZdZdZy)FWriteDataTests.test_writeAfterShutdownWithoutReading..Infinitez A producer which will write to its consumer as long as resumeProducing is called. @ivar consumer: The L{IConsumer} which will be written to. c||_yr)consumer)r:rs r"rVzOWriteDataTests.test_writeAfterShutdownWithoutReading..Infinite.__init__s ( r$cftd|jjdtdy)NzInfinite.resumeProducingxz*Infinite.resumeProducing wrote to consumer)rrrr9s r"resumeProducingzVWriteDataTests.test_writeAfterShutdownWithoutReading..Infinite.resumeProducings&./ ##D)@Ar$ctdy)NzInfinite.stopProducing)rr9s r" stopProducingzTWriteDataTests.test_writeAfterShutdownWithoutReading..Infinite.stopProducings ,-r$N)rCrDrErQrVrrrFr$r"Infiniters  ) B  .r$rc eZdZdZfdZy)MWriteDataTests.test_writeAfterShutdownWithoutReading..UnreadingWriterz Trivial protocol which pauses its transport immediately and then writes some bytes to it. ctdjjjdtdfd}j |y)NzUnreadingWriter.connectionMadezclientPaused called backctdj}tdjj|dtdy)Nz$UnreadingWriter.connectionMade writez5UnreadingWriter.connectionMade write created producerFz8UnreadingWriter.connectionMade write registered producer)rr7registerProducer)rproducerrr:s r"rzkWriteDataTests.test_writeAfterShutdownWithoutReading..UnreadingWriter.connectionMade..writesB>? (7HOPNN33HeDRSr$)rr7pauseProducingrr,)r:rrrrs` r"r;z\WriteDataTests.test_writeAfterShutdownWithoutReading..UnreadingWriter.connectionMade sI45--/%%d+./T$&&u-r$N)rCrDrErQr;)rrrsr"UnreadingWriterrs    .r$rc2tdjS)N cbClientLost)rrr)rrs r"rzJWriteDataTests.test_writeAfterShutdownWithoutReading..cbClientLost,s  $$ $r$zConnecting to :zReturning Deferred)r __class__rCrr r*r r ServerFactoryr~rrKrrrrgr[rir,rrSrJrrr ConnectionLost) r:rrrJr`rrsrrrrrs @@@@r"%test_writeAfterShutdownWithoutReadingz4WriteDataTests.test_writeAfterShutdownWithoutReadingsb    % % 6? ~~' ^^%  .8,, .<'')&  FkB **+||~ ] # . . $ .& . .h// .B!"!0% % ((6 nTYYKq 45499dii8 !!!"68L8LMMr$N)rCrDrErQrrrFr$r"rrs $@INr$rceZdZdZy)ConnectionLosingProtocolc|jjd|jj|jj |jj j |jy)N1)r7rr8master_connectionMadeportsrYr9s r"r;z'ConnectionLosingProtocol.connectionMade;sP T" %%' ##%   0r$NrrFr$r"rr:s1r$rceZdZdZdZy) NoopProtocolctj|_|jjj |jyr)r r*r r serverConnsrYr9s r"r;zNoopProtocol.connectionMadeCs,! &&tvv.r$c:|jjdyNT)r rr?s r"rAzNoopProtocol.connectionLostGs r$NrBrFr$r"rrBs /r$rceZdZdZdZdZy)ConnectionLostNotifyingProtocolac Protocol which fires a Deferred which was previously passed to its initializer when the connection is lost. @ivar onConnectionLost: The L{Deferred} which will be fired in C{connectionLost}. @ivar lostConnectionReason: L{None} until the connection is lost, then a reference to the reason passed to C{connectionLost}. c d|_||_yr)lostConnectionReasononConnectionLost)r:rs r"rVz(ConnectionLostNotifyingProtocol.__init__Ws$(! 0r$cH||_|jj|yr)rrrr?s r"rAz.ConnectionLostNotifyingProtocol.connectionLost[s$*! &&t,r$N)rCrDrErQrVrArFr$r"rrKs 1-r$rceZdZdZdZy)HandleSavingProtocolz Protocol which grabs the platform-specific socket handle and saves it as an attribute on itself when the connection is established. cl|j|_tjj ||S)z\ Save the platform-specific socket handle for future introspection. ) getHandlehandler rmakeConnection)r:r7s r"rz#HandleSavingProtocol.makeConnectiongs-  ))+   //i@@r$N)rCrDrErQrrFr$r"rr`s  Ar$rc.eZdZdZdZdZdZdZdZy)ProperlyCloseFilesMixinzA Tests for platform resources properly being cleaned up. ct)z Bind a server port to which connections will be made. The server should use the given protocol factory. @return: The L{IListeningPort} for the server created. NotImplementedErrorr:r}rr\s r" createServerz$ProperlyCloseFilesMixin.createServeru "##r$ct)z Establish a connection to the given address using the given L{ClientCreator} instance. @return: A Deferred which will fire with the connected protocol instance. rr:r}rr s r" connectClientz%ProperlyCloseFilesMixin.connectClient~rr$ct)z Return the exception class which will be raised when an operation is attempted on a closed platform handle. rr9s r"getHandleExceptionTypez.ProperlyCloseFilesMixin.getHandleExceptionTypes "##r$ctjr#tjtj Stjtj S)z Return a L{hamcrest.core.matcher.Matcher} that matches the errno expected to result from writing to a closed platform socket handle. )r isWindowshamcrestequal_tor  WSAENOTSOCKEBADFr9s r"getHandleErrorCodeMatcherz1ProperlyCloseFilesMixin.getHandleErrorCodeMatchers<    $$U%6%67 7  --r$c tj tj} fd|_j dd| tj j }tj tfd}j|j|j|} fd}|j|fd}|j| fd}|j||S)zp Test that lost connections properly have their underlying socket resources cleaned up. ctSr)r)onServerConnectionLostsr"rzAProperlyCloseFilesMixin.test_properlyCloseFiles..s)H "* r$r{rctSr)r)onClientConnectionLostsr"rzAProperlyCloseFilesMixin.test_properlyCloseFiles..s12HIr$c|jjd|jjtjgS)z Disconnect the client. Return a Deferred which fires when both the client and the server have received disconnect notification. s0some bytes to make sure the connection is set up)r7rr8r r)rrrs r"clientConnectedzHProperlyCloseFilesMixin.test_properlyCloseFiles..clientConnectedsD    " "#V W    + + -&&(>@V'WX Xr$c|\}}|jjtjst |jd|jjtjst |jdj }j j|jjd}tj|jd|y)zl Verify that the underlying platform socket handle has been cleaned up. z,Client lost connection for unexpected reasonz,Server lost connection for unexpected reasonsbytesrN) rr#r ConnectionClosedrrrrrsendr assert_thatrZ)r'rrerrorCodeMatcher exceptionr:s r"clientDisconnectedzKProperlyCloseFilesMixin.test_properlyCloseFiles..clientDisconnecteds $NFF..44U5K5KL//B..44U5K5KL//B $==? ))++-v}}/A/A8I  q!  r$cptjj}|jfd|S)zx Shut down the server port. Return a Deferred which fires when this has completed. cSrrF)rrs r"rzRProperlyCloseFilesMixin.test_properlyCloseFiles..cleanup..s;r$)r rrKr,)rr'rs` r"rz@ProperlyCloseFilesMixin.test_properlyCloseFiles..cleanups/ (()A)ABF   6 7Mr$) r r*r rrrrr rrSrJr,r) r:r serverAddrr clientDeferredr rrrrrs ` @@@r"test_properlyCloseFilesz/ProperlyCloseFilesMixin.test_properlyCloseFiless "'!1 ..0 " &&{A}E !&!1'')  .. I ++ OOZ__m  Y ""?3 2 ""#56  w'r$N) rCrDrErQrrrrrrFr$r"rrps!$$$ .Fr$rc"eZdZdZdZdZdZy)ProperlyCloseFilesTestsz Test that the sockets created by L{IReactorTCP.connectTCP} are cleaned up when the connection they are associated with is closed. c2tj|||S)zE Create a TCP server using L{IReactorTCP.listenTCP}. r|)r r~rs r"rz$ProperlyCloseFilesTests.createServers  WHHr$c&|j||S)zF Create a TCP client using L{IReactorTCP.connectTCP}. )rrs r"rz%ProperlyCloseFilesTests.connectClients''<.RememberingWrappera Simple wrapper factory which records the addresses which are passed to its L{buildProtocol} method and delegates actual protocol creation to another factory. @ivar addresses: A list of the objects passed to buildProtocol. @ivar factory: The wrapped factory to which protocol creation is delegated. c g|_||_yr) addressesr\)r:r\s r"rVz7AddressTests.setUp..RememberingWrapper.__init__.s!#& r$cn|jj||jj|S)z Append the given address to C{self.addresses} and forward the call to C{self.factory}. )r/rYr\rN)r:r`s r"rNz.RememberingWrapper.buildProtocol5s+ %%d+||11$77r$N)rCrDrErQrVrNrFr$r"RememberingWrapperr-#s  ' 8r$r1rr{r|)r ClientFactoryrerr r*rrbserverConnLostr] serverWrapperrgrrclientConnLost clientWrapperr r~rJrrrSror)r:r1s r"setUpzAddressTests.setUpsA 8!7!7 8:&' CH>>CSSdkk@CH>>CSSdkk@0 <&' CH>>CSSdkk@CH>>CSSdkk@/ <%%a););{S  ++ II    $ $dii&7&7&9&>&>@R@R ""D$7$79L9L#MNNr$c|jjtj|j|j tj |jjgS)zf Disconnect the client/server pair and shutdown the port created in L{setUp}. ) rorr rr3r5rrJrKr9s r"tearDownzAddressTests.tearDownTsV !!#""######DII$;$;<   r$c|jjjj}|jjjj }|j |jjtd|j|jg|j |jjtd|j|jgy)ae L{ClientFactory.buildProtocol} should be invoked with the address of the server to which a connection has been established, which should be the same as the address reported by the C{getHost} method of the transport of the server protocol and as the C{getPeer} method of the transport of the client protocol. rQN) rr r7rrrrr6r/rrSrJ)r:r clientPeers r"test_buildProtocolClientz%AddressTests.test_buildProtocolClientbs[[))33;;= [[))33;;=      ( (   A B      ( (   A B r$N)rCrDrErQr7r9r<rFr$r"r*r*s9Ov   r$r*ceZdZdZy)LargeBufferWriterProtocolcjjdjjdz zfd}t j d|y)NXrXcjjddj_jj y)Nr@rX)r7rr\rr8r9sr"finishz8LargeBufferWriterProtocol.connectionMade..finishs1 NN  & !DLL  NN ) ) +r$gMbP?)r7rr\lenr callLater)r:rBs` r"r;z(LargeBufferWriterProtocol.connectionMade}s@ TT\\%5%5%9:; , %(r$NrrFr$r"r>r>ws )r$r>ceZdZdZdZy)LargeBufferReaderProtocolcT|jxjt|z c_yr)r\rCrs r"rz&LargeBufferReaderProtocol.dataReceiveds CI%r$c&d|j_yrlrr?s r"rAz(LargeBufferReaderProtocol.connectionLostrr$NrrFr$r"rFrFs &r$rFceZdZdZdZy)LargeBufferReaderClientFactoryc d|_d|_yNr)rrCr9s r"rVz'LargeBufferReaderClientFactory.__init__s r$c6t}||_||_|Sr)rFr\r r_s r"rNz,LargeBufferReaderClientFactory.buildProtocols % '  r$NrrFr$r"rJrJs r$rJceZdZdZdZy) FireOnClosezaA wrapper around a protocol that makes it fire a deferred when connectionLost is called. ctjj|||jjj dyr)rrrAr\rirr?s r"rAzFireOnClose.connectionLosts0  //f= &&t,r$N)rCrDrErQrArFr$r"rOrOs -r$rOceZdZeZdZy)FireOnCloseFactorycvtjj||tj|_yr)rr&rVr r*rir's r"rVzFireOnCloseFactory.__init__s&  ))$?( r$N)rCrDrErOr rVrFr$r"rRrRs H)r$rRceZdZdZdZdZy)LargeBufferTestsz0Test that buffering large amounts of data works.ictjt_d_d_j _t}tjd|d}j|j|jj}tt}tjd||t!j"|j$|j$g}fd}|j'|S)Nrr{r|c~jjdjjjk\djjfzjjjkdjjfzjjdy)Nrz9client didn't receive all the data it expected (%d != %d)z8client did receive more data than it expected (%d != %d)r)rrrCdatalen)rrrr:s r"r#z*LargeBufferTests.testWriter..checks OOAFF$L M OO t||+ ' T\\:;  OO t||+ ' T\\:;  OOGLL*P Qr$)r rr>rrrXrCrRr r~rrKrrJrJrr rrir,) r:rrarrr r#rrs ` @@r" testWriterzLargeBufferTests.testWriters    .   %a(   a[ A ( IIK  02+G4;>:   !2!2N4K4K L M R}}U##r$N)rCrDrErQrXrYrFr$r"rUrUs:G$r$rUc eZdZdZdZdZdZy) MyHCProtocolFcNd|_|jr|jdyyr)readHalfClosedwriteHalfClosedrAr9s r"readConnectionLostzMyHCProtocol.readConnectionLosts&"       % r$cNd|_|jr|jdyyr)r^r]rAr9s r"writeConnectionLostz MyHCProtocol.writeConnectionLosts&#       % r$N)rCrDrEr]r^r_rarFr$r"r[r[sNO& &r$r[ceZdZdZdZdZy) MyHCFactoryrNc`|xjdz c_t}||_||_|Srl)rZr[r\r r_s r"rNzMyHCFactory.buildProtocols* q N  r$)rCrDrErZrbrNrFr$r"rcrcs F!r$rcc4eZdZdZdZdZdZdZdZdZ y) HalfCloseTestszTest half-closing connections.cbtx_}tjd|dx_j j tfd}tjtt_ |jfd|jj|S)Nrr{r|cjSr)r)rasr"rz&HalfCloseTests.setUp..s akkr$cjjjjjjSr)cfrrrSrJ)_rar:s r"rz&HalfCloseTests.setUp..s0 2 2199;3C3CQYY[EUEU Vr$)rcrr r~rarrKr2r rr[rjr,_setUp)r:rr ras` @r"r7zHalfCloseTests.setUps} ]"&&q!{CC ( ) *((,? VW dkk"r$c|_tjx_j_j jj jdtfdS)NrXc6tjddduS)Nr )rrr9sr"rz'HalfCloseTests._setUp..sT!B$!Nr$) rr r*clientProtoConnectionLostr^rr7rr2r:rs` r"rlzHalfCloseTests._setUpsQ FKnnFVV&)C ..88!<NOOr$cLjjjdjjj t j jj}|jfd|jj|S)NrcjSr)ro)rr:s r"rz)HalfCloseTests.tearDown.. s $"@"@r$) rrclosedr7r8r rrarKr, _tearDown)r:r s` r"r9zHalfCloseTests.tearDownso ++Q/ ,,.    4 4 5 @A dnn%r$cjjjdjjjjdt j fd}|jj_jjjjjfdS)NrXrc^djj_jdyrl)rr rsr)r@r r:s r"_connectionLostz1HalfCloseTests._tearDown.._connectionLosts%&DFFOO " JJt r$cdjjjjdSrl)rrr rsrr:s r"rz*HalfCloseTests._tearDown..s" 0 01G1G Kr$) rrrsrr r r*rAr7r8r,)r:rrwr s` @r"rtzHalfCloseTests._tearDowns ++Q/ //3 NN  *9& !!002 KLr$cjjjjdt fd}fd}fd}fd}|j |j |j |S)Nhelloc4tjdk(SrL)rC_tempDataBuffertsr"rz5HalfCloseTests.testCloseWriteCloser..&sc!"3"349r$c@jtfdS)NcjSr)_writeDisconnectedr~sr"rzHHalfCloseTests.testCloseWriteCloser..loseWrite..*s Q%9%9r$)loseWriteConnectionr2)rrs r" loseWritez6HalfCloseTests.testCloseWriteCloser..loseWrite(s ! ! #9: :r$cjjjjjjt fdS)Nc0jjSr)r r]rsr"rzDHalfCloseTests.testCloseWriteCloser..check..0sQZZ%>%>r$)rrsrr^r]r2)rrrr:s r"r#z2HalfCloseTests.testCloseWriteCloser..check,sG   V]] + OOF22 3   V22 3>? ?r$cjj}|d|djdtjjjj j djj jjj jy)Nrslalala fooled yourr{) r7rrrCr}r rrrsrr])rwrrr:s r"rz2HalfCloseTests.testCloseWriteCloser..write2s  &&A iL " #   QF$4$4$D$D E F   QZZ__h 7   QZZ.. / OOAJJ55 6r$)rrr7rr2r,)r:r rr#rrrrs` @@@r"testCloseWriteCloserz#HalfCloseTests.testCloseWriteCloser sn FF     9 : ; @  7}}Y'33E:FFuMMr$cjjjjt j t fdt fdg}|jfd|S)Nc0jjSr)r r^rsr"rz;HalfCloseTests.testWriteCloseNotification..Cs!**"<"<r$c0jjSr)rr]r9sr"rz;HalfCloseTests.testWriteCloseNotification..Ds$++"<"<r$cPjjjdS)NF)rr r])rkrr:s r"rz;HalfCloseTests.testWriteCloseNotification..Gs 0 01J1JE Rr$)rr r7rr rr2r,)r:r rs` @r"testWriteCloseNotificationz)HalfCloseTests.testWriteCloseNotification=s] FF 002   <=<=   RSr$N) rCrDrErQr7rlr9rtrrrFr$r"rfrfs%( P N: r$rfc*eZdZdZdZdZdZdZy)0HalfCloseNoNotificationAndShutdownExceptionTestsctx|_}tj|j_t j d|dx|_}tjt tj|jj|jj}|j|j |Sr)rerr r*rbr r~rar rrrrrSrJr, _gotClient)r:rrar s r"r7z6HalfCloseNoNotificationAndShutdownExceptionTests.setUpLs$&&(-(8%&&q!{CC  " "7,@ A L L IIK  aiik..  doo&r$c<||_|jjSr)rrrbrps r"rz;HalfCloseNoNotificationAndShutdownExceptionTests._gotClientXs vv,,,r$c~|jjj|jj Sr)rr7r8rarKr9s r"r9z9HalfCloseNoNotificationAndShutdownExceptionTests.tearDown_s+ ,,.vv##%%r$cjjjdjjjt j xj j_}t j xj_}|jfd|jfdt j||gS)z TCP protocols support half-close connections, but not all of them support being notified of write closes. In this case, test that half-closing the connection causes the peer's connection to be closed. r{cdjjjjdS)Nr{)rrr rrys r"rzUHalfCloseNoNotificationAndShutdownExceptionTests.testNoNotification..ns" 0 01E1Ex Pr$cbjjjjSrrrr rsrys r"rzUHalfCloseNoNotificationAndShutdownExceptionTests.testNoNotification..o0F0F Gr$) rr7rrr r*rr r^r,rr:r r1s` r"testNoNotificationzCHalfCloseNoNotificationAndShutdownExceptionTests.testNoNotificationcs ##H- 113-2^^-==&*/..*:: "R PQ GH""Ar7++r$cjjjjjjj djjj tjxjj_ }tjxj_ }|jfdtj||gS)zx If the other side has already closed its connection, loseWriteConnection should pass silently. r@cbjjjjSrrrys r"rzXHalfCloseNoNotificationAndShutdownExceptionTests.testShutdownException..|rr$) rr r7r8rrrr r*r^r,rrs` r"testShutdownExceptionzFHalfCloseNoNotificationAndShutdownExceptionTests.testShutdownExceptionrs !!002 ##D) 113-2^^-==&*/..*:: "R GH""Ar7++r$N)rCrDrEr7rr9rrrFr$r"rrKs -& , ,r$rc.eZdZdZdZdZdZdZdZy)HalfCloseBuggyApplicationTestszI Test half-closing connections where notification code has bugs. c>t_tjj_t j djd_jjjjj}tjt t}|j|j|j}fd}|j!|tj"jj|gS)z| Set up a server and connect a client to it. Return a Deferred which only fires once this is done. rr{r|c|_yr)r)rr:s r" setClientz7HalfCloseBuggyApplicationTests.setUp..setClients "0D r$)rcrr r*rbr r~rJrrKrr rr[rrSr,r)r:r`creatorrrs` r"r7z$HalfCloseBuggyApplicationTests.setUps )]49NN4D1%%a););{S   //0yy  "((,? ++DIItyyA 1 ""9-""    6 6 G  r$ctd)z` Fake implementation of a callback which illegally raises an exception. zONO I AM BUGGY CODEr)r:rZs r"aBugz#HalfCloseBuggyApplicationTests.aBugs 011r$ctjx}j_jjj fd}|j ||S)z~ Helper for testing that an exception is logged by the time the client protocol loses its connection. cfjt}jt|dyrl)flushLoggedErrorsrrrC)rerrorsr:s r"r#zEHalfCloseBuggyApplicationTests._notificationRaisesTest..checks'++L9F   S[! ,r$)r r*rr^r7rr,)r:rsr#s` r"_notificationRaisesTestz6HalfCloseBuggyApplicationTests._notificationRaisesTestsQ 7##6++--r$cX|j|j_|jS)z If C{writeConnectionLost} raises an exception when the transport calls it to notify the protocol of that event, the exception should be logged and the protocol should be disconnected completely. )rrrarr9s r"test_writeNotificationRaisesz;HalfCloseBuggyApplicationTests.test_writeNotificationRaisess% 37))/++--r$N) rCrDrErQr7rrrrrFr$r"rrs  *2 ..r$rceZdZdZdZy)LogTestsz4 Test logging facility of TCP base classes. c0t}t}tj|_t j d|d}j|jt j|jj|jj|jjjjj dfd}|jj#||jS)zx Check that the log customization of the client transport happens once the client is connected. rr{r| UninitializedcRjjjdy)NzAccumulatingProtocol,client)rr7logstr)rror:s r"cbz+LogTests.test_logstrClientSetup..cbs   Y00779V Wr$)rergr r*rbr r~rrKrrrSrJrrr7rr,)r:rrrJrros` @r"test_logstrClientSetupzLogTests.test_logstrClientSetups !" "(-(8%  FkB **+&&t||~':':DLLN.checkInConnectionMadesB MM"g002W5G5G5II J OO * * ,   R!3!3!58J8J8L!L M A MM2 3   aU 3Hr$c|j}j|tjtjzyr)r7rr rr)rrr:s r"rzYPauseProducingTests.test_pauseProducingInConnectionMade..checkAfterConnectionMades3B   R!3!3!58J8J8L!L Mr$)rergr r*rbr r~rrKrrrSrJrr,)r:rrrJrorrs` @r"#test_pauseProducingInConnectionMadez7PauseProducingTests.test_pauseProducingInConnectionMades!" "(-(8%  FkB **+&&t||~':':DLLN.s$//%//*H*HIr$cntjdjjjy)z: protocol.connectionMade callback rN)r rDr r7r8)rrs r"_cbCMz0CallBackOrderTests.test_loseOrder.._cbCM"s%   a!:!:!I!I Jr$rr{r|cy)z? factory.clientConnectionLost callback CCLrFrs r"_cbCCLz1CallBackOrderTests.test_loseOrder.._cbCCL0sr$cy)z: protocol.connectionLost callback CLrFrs r"_cbCLz0CallBackOrderTests.test_loseOrder.._cbCL6sr$c.j|ddgy)Nrr)r)rr:s r" _cbGatherz4CallBackOrderTests.test_loseOrder.._cbGather<s   S4- 0r$)rer r*r,rbrgr]r r~rrKrrrSrJrrri) r:rrrJrorrrr rs ` @r"test_loseOrderz!CallBackOrderTests.test_loseOrders0 !"(-(8(D(D I) %!"(-(8%(-(8% K %%11%8  FkB **+&&t||~':':DLLNrFrJrOrRrUr[rcrfrrrrrresource getrlimit RLIMIT_NOFILE numRoundssetattr ImportErrorrFr$r"rs.  %&HH0M.9&'+5 8*h''*"X++"(44n,h.D.D ,h.D.D4DCXDCNaHaH x'' (_((>28>2Blhl^811%h%P(X&&(.X&& (00 oNXoNd1x0018$$-h&7&7-* A: A ppfh(?6 100 1-8++-` 8` F) 1 1)" 1 1 X%;%; -(**-)11)#$x#$L #$&'&%&" ((( VXVr2,x2,j@.X@.F-x->*-(*-Z6(6(r@#""8#9#9:1=BI #^Y?   sL33L;:L;