ó O)|Pc@`sMdZddlmZmZddlmZmZmZddlm Z m Z ddl m Z ddl mZddl mZddlmZmZmZmZmZdd lmZd ejfd „ƒYZd ejfd „ƒYZdejfd„ƒYZdejfd„ƒYZdejfd„ƒYZ dej!fd„ƒYZ"de j#fd„ƒYZ$dej%fd„ƒYZ%de j#fd„ƒYZ&de j#fd„ƒYZ'dejej(fd„ƒYZ)d e j#fd!„ƒYZ*d"e j#fd#„ƒYZ+d$efd%„ƒYZ,d&ej-fd'„ƒYZ.d(e j#fd)„ƒYZ/d*S(+s Test code for policies. i(tdivisiontabsolute_import(t Interfacet implementert implementedBy(tNativeStringIOt_PY3(tunittest(tStringTransport(t StringTransportWithDisconnection(tprotocoltreactortaddresstdeferttask(tpoliciestSimpleProtocolcB`s<eZdZZdZd„Zd„Zd„Zd„ZRS(itcC`s"tjƒ|_tjƒ|_dS(N(R tDeferredt dConnectedt dDisconnected(tself((s>/usr/lib/python2.7/dist-packages/twisted/test/test_policies.pyt__init__scC`sd|_|jjdƒdS(NiR(t connectedRtcallback(R((s>/usr/lib/python2.7/dist-packages/twisted/test/test_policies.pytconnectionMades cC`sd|_|jjdƒdS(NiR(t disconnectedRR(Rtreason((s>/usr/lib/python2.7/dist-packages/twisted/test/test_policies.pytconnectionLost"s cC`s|j|7_dS(N(tbuffer(Rtdata((s>/usr/lib/python2.7/dist-packages/twisted/test/test_policies.pyt dataReceived&s( t__name__t __module__RRRRRRR(((s>/usr/lib/python2.7/dist-packages/twisted/test/test_policies.pyRs     t SillyFactorycB`seZd„Zd„ZRS(cC`s ||_dS(N(tp(RR#((s>/usr/lib/python2.7/dist-packages/twisted/test/test_policies.pyR-scC`s|jS(N(R#(Rtaddr((s>/usr/lib/python2.7/dist-packages/twisted/test/test_policies.pyt buildProtocol0s(R R!RR%(((s>/usr/lib/python2.7/dist-packages/twisted/test/test_policies.pyR"+s t EchoProtocolcB`s2eZeZd„Zd„Zd„Zd„ZRS(cC`s t|_dS(N(tTruetpaused(R((s>/usr/lib/python2.7/dist-packages/twisted/test/test_policies.pytpauseProducing7scC`s t|_dS(N(tFalseR((R((s>/usr/lib/python2.7/dist-packages/twisted/test/test_policies.pytresumeProducing:scC`sdS(N((R((s>/usr/lib/python2.7/dist-packages/twisted/test/test_policies.pyt stopProducing=scC`s|jj|ƒdS(N(t transporttwrite(RR((s>/usr/lib/python2.7/dist-packages/twisted/test/test_policies.pyR@s(R R!R*R(R)R+R,R(((s>/usr/lib/python2.7/dist-packages/twisted/test/test_policies.pyR&4s    tServercB`seZdZeZRS(s8 A simple server factory using L{EchoProtocol}. (R R!t__doc__R&R (((s>/usr/lib/python2.7/dist-packages/twisted/test/test_policies.pyR/EstTestableThrottlingFactorycB`s eZdZd„Zd„ZRS(sH L{policies.ThrottlingFactory} using a L{task.Clock} for tests. cO`s#tjj|||Ž||_dS(s˜ @param clock: object providing a callLater method that can be used for tests. @type clock: C{task.Clock} or alike. N(RtThrottlingFactoryRtclock(RR3targstkwargs((s>/usr/lib/python2.7/dist-packages/twisted/test/test_policies.pyRRscC`s|jj||ƒS(s0 Forward to the testable clock. (R3t callLater(Rtperiodtfunc((s>/usr/lib/python2.7/dist-packages/twisted/test/test_policies.pyR6\s(R R!R0RR6(((s>/usr/lib/python2.7/dist-packages/twisted/test/test_policies.pyR1Ms tTestableTimeoutFactorycB`s eZdZd„Zd„ZRS(sE L{policies.TimeoutFactory} using a L{task.Clock} for tests. cO`s#tjj|||Ž||_dS(s˜ @param clock: object providing a callLater method that can be used for tests. @type clock: C{task.Clock} or alike. N(RtTimeoutFactoryRR3(RR3R4R5((s>/usr/lib/python2.7/dist-packages/twisted/test/test_policies.pyRiscC`s|jj||ƒS(s0 Forward to the testable clock. (R3R6(RR7R8((s>/usr/lib/python2.7/dist-packages/twisted/test/test_policies.pyR6ss(R R!R0RR6(((s>/usr/lib/python2.7/dist-packages/twisted/test/test_policies.pyR9ds tWrapperTestCasecB`s•eZdZd„Zd„Zd„Zd„Zd„Zd„Zd„Z d„Z d „Z d „Z d „Z d „Zd „Zd„Zd„ZRS(s> Tests for L{WrappingFactory} and L{ProtocolWrapper}. cC`sPtƒ}tj|ƒ}|jtjdddƒƒ}|j|jj|ƒdS(sf Make sure protocol.factory is the wrapped factory, not the wrapping factory. tTCPs 127.0.0.1i#N( R/RtWrappingFactoryR%R t IPv4AddresstassertIdenticaltwrappedProtocoltfactory(RtftwfR#((s>/usr/lib/python2.7/dist-packages/twisted/test/test_policies.pyttest_protocolFactoryAttributes cC`s–dtfd„ƒY}t|ƒddd„ƒYƒ}ttjƒtjƒ}tjtjdƒ|ƒ}|j |ƒƒ|j |j |j ƒƒdS(s² The transport wrapper passed to the wrapped protocol's C{makeConnection} provides the same interfaces as are provided by the original transport. tIStubTransportcB`seZRS((R R!(((s>/usr/lib/python2.7/dist-packages/twisted/test/test_policies.pyREst StubTransportcB`seZRS((R R!(((s>/usr/lib/python2.7/dist-packages/twisted/test/test_policies.pyRF“sN(( RRRRtProtocolWrapperR tProtocolR=tNonetmakeConnectiont assertTruet providedByR-(RRERFtprototwrapper((s>/usr/lib/python2.7/dist-packages/twisted/test/test_policies.pyttest_transportInterfacesŠs  cC`s2tƒ}tj|ƒ}|jd|jƒƒdS(sƒ L{WrappingFactory.logPrefix} is customized to mention both the original factory and the wrapping factory. sServer (WrappingFactory)N(R/RR=t assertEqualt logPrefix(RtserverRA((s>/usr/lib/python2.7/dist-packages/twisted/test/test_policies.pyttest_factoryLogPrefix§s cC`sHdtfd„ƒY}|ƒ}tj|ƒ}|jd|jƒƒdS(s— If the wrapped factory doesn't have a L{logPrefix} method, L{WrappingFactory.logPrefix} falls back to the factory class name. t NoFactorycB`seZRS((R R!(((s>/usr/lib/python2.7/dist-packages/twisted/test/test_policies.pyRT¶ssNoFactory (WrappingFactory)N(tobjectRR=RPRQ(RRTRRRA((s>/usr/lib/python2.7/dist-packages/twisted/test/test_policies.pyttest_factoryLogPrefixFallback±s cC`sPtƒ}tj|ƒ}|jtjdddƒƒ}|jd|jƒƒdS(s{ L{ProtocolWrapper.logPrefix} is customized to mention both the original protocol and the wrapper. R<s 127.0.0.1i#sEchoProtocol (ProtocolWrapper)N(R/RR=R%R R>RPRQ(RRRRAR ((s>/usr/lib/python2.7/dist-packages/twisted/test/test_policies.pyttest_protocolLogPrefix¾s   cC`sodtfd„ƒY}tƒ}||_tj|ƒ}|jtjdddƒƒ}|jd|j ƒƒdS(s™ If the wrapped protocol doesn't have a L{logPrefix} method, L{ProtocolWrapper.logPrefix} falls back to the protocol class name. t NoProtocolcB`seZRS((R R!(((s>/usr/lib/python2.7/dist-packages/twisted/test/test_policies.pyRXÐsR<s 127.0.0.1i#sNoProtocol (ProtocolWrapper)N( RUR/R RR=R%R R>RPRQ(RRXRRRAR ((s>/usr/lib/python2.7/dist-packages/twisted/test/test_policies.pyttest_protocolLogPrefixFallbackËs   cC`s>tjtjtƒƒtjƒƒ}tƒ}|j|ƒ|S(sm Return L{policies.ProtocolWrapper} that has been connected to a L{StringTransport}. (RRGR=R/R RHRRJ(RRNR-((s>/usr/lib/python2.7/dist-packages/twisted/test/test_policies.pyt _getWrapperÜs   cC`s/|jƒ}|j|jƒ|jjƒƒdS(sk L{policies.ProtocolWrapper.getHost} calls C{getHost} on the underlying transport. N(RZRPtgetHostR-(RRN((s>/usr/lib/python2.7/dist-packages/twisted/test/test_policies.pyt test_getHostès cC`s/|jƒ}|j|jƒ|jjƒƒdS(sk L{policies.ProtocolWrapper.getPeer} calls C{getPeer} on the underlying transport. N(RZRPtgetPeerR-(RRN((s>/usr/lib/python2.7/dist-packages/twisted/test/test_policies.pyt test_getPeerñs cC`sR|jƒ}tƒ}|j|tƒ|j|jj|ƒ|j|jjƒdS(s} L{policies.ProtocolWrapper.registerProducer} calls C{registerProducer} on the underlying transport. N( RZRUtregisterProducerR'R?R-tproducerRKt streaming(RRNR`((s>/usr/lib/python2.7/dist-packages/twisted/test/test_policies.pyttest_registerProducerús   cC`s_|jƒ}tƒ}|j|tƒ|jƒ|j|jjdƒ|j|jj dƒdS(s L{policies.ProtocolWrapper.unregisterProducer} calls C{unregisterProducer} on the underlying transport. N( RZRUR_R'tunregisterProducerR?R-R`RIRa(RRNR`((s>/usr/lib/python2.7/dist-packages/twisted/test/test_policies.pyttest_unregisterProducers    c`sH|jƒ}g‰‡fd†|j_|jƒ|jˆtgƒdS(sw L{policies.ProtocolWrapper.stopConsuming} calls C{stopConsuming} on the underlying transport. c`s ˆjtƒS(N(tappendR'((tresult(s>/usr/lib/python2.7/dist-packages/twisted/test/test_policies.pytsN(RZR-t stopConsumingRPR'(RRN((Rfs>/usr/lib/python2.7/dist-packages/twisted/test/test_policies.pyttest_stopConsumings   c`sag‰dtf‡fd†ƒY}tj|ƒƒ}tƒ}|j|ƒ|jˆ|gƒdS(s} L{policies.WrappingFactory.startedConnecting} calls C{startedConnecting} on the underlying factory. tFactoryc`seZ‡fd†ZRS(c`sˆj|ƒdS(N(Re(Rt connector(Rf(s>/usr/lib/python2.7/dist-packages/twisted/test/test_policies.pytstartedConnecting&s(R R!Rl((Rf(s>/usr/lib/python2.7/dist-packages/twisted/test/test_policies.pyRj%sN(RURR=RlRP(RRjRNRk((Rfs>/usr/lib/python2.7/dist-packages/twisted/test/test_policies.pyttest_startedConnectings   c`ssg‰dtf‡fd†ƒY}tj|ƒƒ}tƒ}tƒ}|j||ƒ|jˆ||fgƒdS(sƒ L{policies.WrappingFactory.clientConnectionLost} calls C{clientConnectionLost} on the underlying factory. Rjc`seZ‡fd†ZRS(c`sˆj||fƒdS(N(Re(RRkR(Rf(s>/usr/lib/python2.7/dist-packages/twisted/test/test_policies.pytclientConnectionLost6s(R R!Rn((Rf(s>/usr/lib/python2.7/dist-packages/twisted/test/test_policies.pyRj5sN(RURR=RnRP(RRjRNRkR((Rfs>/usr/lib/python2.7/dist-packages/twisted/test/test_policies.pyttest_clientConnectionLost/s  c`ssg‰dtf‡fd†ƒY}tj|ƒƒ}tƒ}tƒ}|j||ƒ|jˆ||fgƒdS(s‡ L{policies.WrappingFactory.clientConnectionFailed} calls C{clientConnectionFailed} on the underlying factory. Rjc`seZ‡fd†ZRS(c`sˆj||fƒdS(N(Re(RRkR(Rf(s>/usr/lib/python2.7/dist-packages/twisted/test/test_policies.pytclientConnectionFailedGs(R R!Rp((Rf(s>/usr/lib/python2.7/dist-packages/twisted/test/test_policies.pyRjFsN(RURR=RpRP(RRjRNRkR((Rfs>/usr/lib/python2.7/dist-packages/twisted/test/test_policies.pyttest_clientConnectionFailed@s  (R R!R0RDRORSRVRWRYRZR\R^RbRdRiRmRoRq(((s>/usr/lib/python2.7/dist-packages/twisted/test/test_policies.pyR;{s     R=cB`seZd„Zd„ZRS(cC`s|S(N((tsRBR#((s>/usr/lib/python2.7/dist-packages/twisted/test/test_policies.pyRgSscC`s$tjj|ƒ|jjdƒdS(N(RR=t startFactorytdeferredRRI(R((s>/usr/lib/python2.7/dist-packages/twisted/test/test_policies.pyRsUs(R R!R Rs(((s>/usr/lib/python2.7/dist-packages/twisted/test/test_policies.pyR=Rs tThrottlingTestCasecB`s)eZdZd„Zd„Zd„ZRS(s2 Tests for L{policies.ThrottlingFactory}. c `smtƒ}gtdƒD]}tƒ^q\‰‰‰‰tj|dƒ‰tˆƒ}tjƒ|_t j d|ddƒ‰ˆj ƒj ‰‡‡‡‡fd†}‡‡‡‡‡fd†}‡fd†}‡‡fd †}‡‡fd †}‡‡‡fd †} |jj |ƒ|jj |ƒ|jj |ƒ|jj |ƒ|jj |ƒ|jj | ƒ|jS( sQ Full test using a custom server limiting number of connections. iiit interfaces 127.0.0.1c`sXtjdˆtˆƒƒˆjj‡‡fd†ƒˆjj‡‡fd†ƒˆjS(Ns 127.0.0.1c`stjdˆtˆƒƒS(Ns 127.0.0.1(R t connectTCPR"(tr(tc2tn(s>/usr/lib/python2.7/dist-packages/twisted/test/test_policies.pyRgqsc`stjdˆtˆƒƒS(Ns 127.0.0.1(R RwR"(Rx(tc3Rz(s>/usr/lib/python2.7/dist-packages/twisted/test/test_policies.pyRgss(R RwR"Rt addCallbackR(tresults(tc1RyR{Rz(s>/usr/lib/python2.7/dist-packages/twisted/test/test_policies.pyt _connect123ns   c`s“ˆjgˆˆˆfD]}|j^qdddgƒˆjgˆˆˆfD]}|j^qNdddgƒˆjtˆjjƒƒdƒ|S(Niii(RPRRtlent protocolstkeys(R}tc(R~RyR{RttServer(s>/usr/lib/python2.7/dist-packages/twisted/test/test_policies.pyt _check123vs88c`sˆjjƒˆjS(N(R-tloseConnectionR(R}(R~(s>/usr/lib/python2.7/dist-packages/twisted/test/test_policies.pyt_lose1|s c`s tjdˆtˆƒƒˆjS(Ns 127.0.0.1(R RwR"R(R}(tc4Rz(s>/usr/lib/python2.7/dist-packages/twisted/test/test_policies.pyt _connect4sc`s*ˆjˆjdƒˆjˆjdƒ|S(Nii(RPRR(R}(RˆR(s>/usr/lib/python2.7/dist-packages/twisted/test/test_policies.pyt_check4…sc`sLx!ˆˆfD]}|jjƒq WtjtjˆjƒˆjˆjgƒS(N(R-R†R t DeferredListt maybeDeferredt stopListeningR(R}Rƒ(RyRˆR#(s>/usr/lib/python2.7/dist-packages/twisted/test/test_policies.pyt_cleanupŠs (R/trangeRRR2R=R RRtR t listenTCPR[tportR|( RRRtit wrapTServerRR…R‡R‰RŠRŽ((R~RyR{RˆRzR#RR„s>/usr/lib/python2.7/dist-packages/twisted/test/test_policies.pyt test_limit`s( . cC`s3tƒ}ttjƒ|ddƒ}|jtjdddƒƒ}tƒ}||_|j |ƒ|j |_ |j dƒ|j dƒ|j |jƒdƒ|j |jd ƒ|j|j jƒ|jjd ƒ|j |jdƒ|j|j jƒ|jjd ƒ|j |jdƒ|j|j jƒd S( se Check the writeLimit parameter: write data, and check for the pause status. t writeLimiti R<s 127.0.0.1it 0123456789t abcdefghijt0123456789abcdefghijigÍÌÌÌÌÌð?N(R/R1RtClockR%R R>R R RJR@R`RRPtvaluetwrittenThisSecondt assertFalseR(R3tadvanceRK(RRRR„R‘ttr((s>/usr/lib/python2.7/dist-packages/twisted/test/test_policies.pyttest_writeLimit›s$       cC`sÍtƒ}ttjƒ|ddƒ}|jtjdddƒƒ}tƒ}||_|j |ƒ|j dƒ|j dƒ|j |j ƒdƒ|j |j d ƒ|jjd ƒ|j |j dƒ|j |jd ƒ|jjd ƒ|j |j dƒ|j |jd ƒ|jƒ|j dƒ|j dƒ|j |j ƒdƒ|j |j d ƒ|jjd ƒ|j |j dƒ|j |jd ƒ|jjd ƒ|j |j dƒ|j |jd ƒd S(sb Check the readLimit parameter: read data and check for the pause status. t readLimiti R<s 127.0.0.1iR–R—R˜igÍÌÌÌÌÌð?R(t producingN(R/R1RR™R%R R>R R RJRRPRštreadThisSecondR3Rt producerStatetclear(RRRR„R‘Rž((s>/usr/lib/python2.7/dist-packages/twisted/test/test_policies.pyttest_readLimitºs6         (R R!R0R”RŸR¥(((s>/usr/lib/python2.7/dist-packages/twisted/test/test_policies.pyRu[s ; tTimeoutTestCasecB`s2eZdZd„Zd„Zd„Zd„ZRS(s/ Tests for L{policies.TimeoutFactory}. cC`s’tjƒ|_tjƒ}t|_t|j|dƒ|_|jjt j dddƒƒ|_ t ƒ|_ |j |j _|j j|j ƒdS(sq Create a testable, deterministic clock, and a set of server factory/protocol/transport. iR<s 127.0.0.1i90N(RR™R3R t ServerFactoryRR9RAR%R R>RMR R-RJ(RtwrappedFactory((s>/usr/lib/python2.7/dist-packages/twisted/test/test_policies.pytsetUpès    cC`se|jjdddddgƒ|j|jjjƒ|jjddgƒ|j|jjjƒdS(s¶ Make sure that when a TimeoutFactory accepts a connection, it will time out that connection if no data is read or written within the timeout period. ggà?gð?gš™™™™™Ù?gš™™™™™É?N(R3tpumptfailIfRMR@Rt failUnless(R((s>/usr/lib/python2.7/dist-packages/twisted/test/test_policies.pyt test_timeoutøscC`sä|jjdddgƒ|j|jjjƒ|jjdƒ|jjdddgƒ|j|jjjƒ|jjdgdƒ|jjdddgƒ|j|jjjƒ|jjddgƒ|j|jjjƒdS( s’ Make sure that writing data to a transport from a protocol constructed by a TimeoutFactory resets the timeout countdown. ggà?gð?sbytes bytes bytestbytesig@N( R3RªR«RMR@RR.t writeSequenceR¬(R((s>/usr/lib/python2.7/dist-packages/twisted/test/test_policies.pyttest_sendAvoidsTimeoutscC`s¡|jjdddgƒ|j|jjjƒ|jjdƒ|jjdddgƒ|j|jjjƒ|jjdddgƒ|j|jjjƒdS(sR Make sure that receiving data also resets the timeout countdown. ggð?gà?sbytes bytes bytesN(R3RªR«RMR@RRR¬(R((s>/usr/lib/python2.7/dist-packages/twisted/test/test_policies.pyttest_receiveAvoidsTimeout$s(R R!R0R©R­R°R±(((s>/usr/lib/python2.7/dist-packages/twisted/test/test_policies.pyR¦ãs    t TimeoutTestercB`sSeZdZdZeZd„Zd„Zd„Zdd„Z d„Z d„Z RS( s” A testable protocol with timeout facility. @ivar timedOut: set to C{True} if a timeout has been detected. @type timedOut: C{bool} icC`s ||_dS(sF Initialize the protocol with a C{task.Clock} object. N(R3(RR3((s>/usr/lib/python2.7/dist-packages/twisted/test/test_policies.pyRDscC`s|j|jƒdS(s3 Upon connection, set the timeout. N(t setTimeoutttimeOut(R((s>/usr/lib/python2.7/dist-packages/twisted/test/test_policies.pyRKscC`s!|jƒtjj||ƒdS(s, Reset the timeout on data. N(t resetTimeoutR RHR(RR((s>/usr/lib/python2.7/dist-packages/twisted/test/test_policies.pyRRs cC`s|jdƒdS(sD On connection lost, cancel all timeout operations. N(R³RI(RR((s>/usr/lib/python2.7/dist-packages/twisted/test/test_policies.pyRZscC`s t|_dS(sX Flags the timedOut variable to indicate the timeout of the connection. N(R'ttimedOut(R((s>/usr/lib/python2.7/dist-packages/twisted/test/test_policies.pyttimeoutConnectionascO`s|jj||||ŽS(sD Override callLater to use the deterministic clock. (R3R6(RttimeoutR8R4R5((s>/usr/lib/python2.7/dist-packages/twisted/test/test_policies.pyR6hsN( R R!R0R´R*R¶RRRRIRR·R6(((s>/usr/lib/python2.7/dist-packages/twisted/test/test_policies.pyR²:s     t TestTimeoutcB`sMeZdZd„Zd„Zd„Zd„Zd„Zd„Zd„Z RS(s- Tests for L{policies.TimeoutMixin}. cC`s%tjƒ|_t|jƒ|_dS(sY Create a testable, deterministic clock and a C{TimeoutTester} instance. N(RR™R3R²RM(R((s>/usr/lib/python2.7/dist-packages/twisted/test/test_policies.pyR©uscC`s0|jjdƒ|jt|jjƒdƒdS(sg Test that the callLater of the clock is used instead of C{reactor.callLater}. i iN(RMR³RPR€R3tcalls(R((s>/usr/lib/python2.7/dist-packages/twisted/test/test_policies.pyttest_overriddenCallLater}scC`so|jjtƒƒ|jjddddgƒ|j|jjƒ|jjddgƒ|j|jjƒdS(sq Check that the protocol does timeout at the time specified by its C{timeOut} attribute. igà?gð?N(RMRJRR3RªR«R¶R¬(R((s>/usr/lib/python2.7/dist-packages/twisted/test/test_policies.pyR­†s cC`s®|jjtƒƒ|jjddddgƒ|j|jjƒ|jjdƒ|jjddddgƒ|j|jjƒ|jjddgƒ|j|jjƒdS(sV Check that receiving data is delaying the timeout of the connection. igà?gð?s hello thereN( RMRJRR3RªR«R¶RR¬(R((s>/usr/lib/python2.7/dist-packages/twisted/test/test_policies.pyttest_noTimeout”scC`s›d|j_|jjtƒƒ|jjdƒ|j|jjdƒ|jjddgƒ|j |jj ƒ|jjddgƒ|j |jj ƒdS(sy Check that setting a new value for timeout cancel the previous value and install a new timeout. iigÍÌÌÌÌÌì?gš™™™™™É?N( RIRMR´RJRR³RPR3RªR«R¶R¬(R((s>/usr/lib/python2.7/dist-packages/twisted/test/test_policies.pyttest_resetTimeout£s cC`sxd|j_|jjtƒƒ|jjdƒ|j|jjdƒ|jjddddgƒ|j |jj ƒdS(sO Setting the timeout to C{None} cancel any timeout operations. iiN( RMR´RJRR³RIRPR3RªR«R¶(R((s>/usr/lib/python2.7/dist-packages/twisted/test/test_policies.pyttest_cancelTimeout´s  cC`sŠd|j_|j|jjdƒdƒ|j|jjdƒdƒ|j|jjdƒdƒ|j|jjdƒ|jjdƒdS(sM setTimeout should return the value of the previous timeout. ii iN(RMR´RPR³RI(R((s>/usr/lib/python2.7/dist-packages/twisted/test/test_policies.pyt test_returnÂs  ( R R!R0R©R»R­R¼R½R¾R¿(((s>/usr/lib/python2.7/dist-packages/twisted/test/test_policies.pyR¹ps     t$LimitTotalConnectionsFactoryTestCasecB`s eZdZd„Zd„ZRS(s/Tests for policies.LimitTotalConnectionsFactorycC`s³tjƒ}tj|_|jd|jƒ|jdƒ}|jd|jƒ|jdƒ}|jd|jƒ|jdƒ|jd|jƒ|jdƒ|jd|jƒdS(Niii( RtLimitTotalConnectionsFactoryR RHRPtconnectionCountR%RIR(RRAtp1tp2((s>/usr/lib/python2.7/dist-packages/twisted/test/test_policies.pyttestConnectionCountingÔs    c`s6tjƒ‰tjˆ_dˆ_ˆjdƒ}|jd|ƒ|jdˆj ƒ|jdˆjdƒƒ|jdˆj ƒdtjf‡fd†ƒY}|ˆ_ t ˆ_ ˆjdƒ}|j dƒ|jtˆj ƒ|jdˆj ƒ|jdƒ|jdˆj ƒ|jdƒ|jdˆj ƒdS(NitOverflowProtocolc`seZ‡fd†ZRS(c`s tˆ_dS(N(R't overflowed(R(RA(s>/usr/lib/python2.7/dist-packages/twisted/test/test_policies.pyRús(R R!R((RA(s>/usr/lib/python2.7/dist-packages/twisted/test/test_policies.pyRÆùsii(RRÁR RHtconnectionLimitR%RItassertNotEqualRPRÂtoverflowProtocolR*RÇRJR'R(RR#RÆtop((RAs>/usr/lib/python2.7/dist-packages/twisted/test/test_policies.pyttestConnectionLimitingès&        (R R!R0RÅRÌ(((s>/usr/lib/python2.7/dist-packages/twisted/test/test_policies.pyRÀÒs tWriteSequenceEchoProtocolcB`seZd„ZRS(cC`s?|jdƒdkr+|jj|gƒntj||ƒdS(Nsvector!iÿÿÿÿ(tfindR-R¯R&R(RR®((s>/usr/lib/python2.7/dist-packages/twisted/test/test_policies.pyRs(R R!R(((s>/usr/lib/python2.7/dist-packages/twisted/test/test_policies.pyRÍstTestLoggingFactorycB`seZdZd„ZRS(cC`s.|jdkstdƒ‚tƒ|_|jS(Nsopen() called too many times(topenFileRItAssertionErrorR(Rtname((s>/usr/lib/python2.7/dist-packages/twisted/test/test_policies.pytopens N(R R!RIRÐRÓ(((s>/usr/lib/python2.7/dist-packages/twisted/test/test_policies.pyRÏstLoggingFactoryTestCasecB`s eZdZd„Zd„ZRS(s6 Tests for L{policies.TrafficLoggingFactory}. cC`s^tƒ}t|_tƒ}t|dƒ}|jd ƒ}||_|j|ƒ|jjƒ}|j d|ƒ|j |j ƒƒ|j dƒ|jjƒ}|j dd |ƒ|j dd|ƒ|j |j ƒdƒ|jƒ|j dƒ|jjƒ}|j d dgf|ƒ|j |j ƒdƒ|jƒ|jjƒ}|j d |ƒd S(sQ Check the output produced by L{policies.TrafficLoggingFactory}. ttests1.2.3.4i.t*shere are some bytessC 1: %rsS 1: %rs"prepare for vector! to the extremesSV 1: %rtConnectionDoneN(s1.2.3.4i.(shere are some bytes(shere are some bytes(R/RÍR R RÏR%RJRÐtgetvaluetassertInR«RšRRPR¤R†(RR¨ttRBR#tv((s>/usr/lib/python2.7/dist-packages/twisted/test/test_policies.pyttest_thingsGetLogged#s.         cC`s•tƒ}t|dƒ}|j|jdƒ|jd ƒ|j|jdƒd|_|jd ƒ|j|jdƒ|jƒ|j|jdƒdS( sG Test counter management with the resetCounter method. RÕis1.2.3.4i.ii/iN(s1.2.3.4i.(s1.2.3.4i/(R/RÏRPt_counterR%RIRÐt resetCounter(RR¨RB((s>/usr/lib/python2.7/dist-packages/twisted/test/test_policies.pyt test_counterFs     (R R!R0RÜRß(((s>/usr/lib/python2.7/dist-packages/twisted/test/test_policies.pyRÔs #N(0R0t __future__RRtzope.interfaceRRRttwisted.python.compatRRt twisted.trialRttwisted.test.proto_helpersRR ttwisted.internetR R R R Rttwisted.protocolsRRHRt ClientFactoryR"R&R§R/R2R1R:R9tTestCaseR;R=RuR¦t TimeoutMixinR²R¹RÀRÍtTrafficLoggingFactoryRÏRÔ(((s>/usr/lib/python2.7/dist-packages/twisted/test/test_policies.pyts0( × ˆW6b<