Ϫf dddZddlmZddlmZddlmZGdd ZGd d ejZ Gd d ejZ Gdde Z Gdde Z Gdde Zy)z$Revision: 1.3 $ )htb)unittest) DummyConsumerc,eZdZdZdeddfdZdefdZy) DummyClockrwhenreturnNc||_yNtime)selfr s 7/usr/lib/python3/dist-packages/twisted/test/test_htb.pysetzDummyClock.set s  c|jSrrrs r__call__zDummyClock.__call__s yyr)__name__ __module__ __qualname__rintrrrrr r s& D#rr ceZdZdZdZy) SomeBucketdN)rrrmaxburstraterrrrrs H DrrceZdZddZddZy)TestBucketBaseNcvtj|_t|_|jt_yr)rr _realTimeFuncr clockrs rsetUpzTestBucketBase.setUps" XX\ ::rc.|jt_yr)r&rrrs rtearDownzTestBucketBase.tearDowns%%rr N)rrrr(r*rrrr$r$s  &rr$c$eZdZddZddZddZy) BucketTestsNc^t}|jd}|jd|y)z1 Testing the size of the bucket. rN)radd assertEqualrbfits rtestBucketSizezBucketTests.testBucketSize$s( LeeDk c"rct}|jd}|jjd|jd}|j d|y)z2 Testing the bucket's drain rate. r/ N)rr0r'rr1r2s rtestBucketDrainzBucketTests.testBucketDrain,sE LeeDk reeDk S!rc*t}|jd|jjd|j }|j ||jjd|j }|j |y)z\ L{htb.Bucket.drip} returns C{True} if the bucket is empty after that drip. r8 r7N)rr0r'rdrip assertFalse assertTrue)rr3emptys rtest_bucketEmptyzBucketTests.test_bucketEmpty6sf L b  q  r rr+)rrrr5r9r@rrrr-r-#s#" rr-c$eZdZddZddZddZy)BucketNestingTestsNctj|t|_t|j|_t|j|_yr)r$r(rparentchild1child2rs rr(zBucketNestingTests.setUpEs9T" l  -  - rc|jjd|jjd}|jd|y)NZr7)rEr0rFr1rr4s rtestBucketParentSizez'BucketNestingTests.testBucketParentSizeKs4 kkoob! S!rcd|j_|jjd|jj d|jjd}|j d|y)Nrrr7)rDr"rEr0r'rr1rIs rtestBucketParentRatez'BucketNestingTests.testBucketParentRateQsR   rkkooc" S!rr+)rrrr(rJrLrrrrBrBDs. " "rrBc$eZdZddZddZddZy)ConsumerShaperTestsNctj|t|_t |_t j|j|j |_yr) r$r(r underlyingrbucketrShapedConsumershapedrs rr(zConsumerShaperTests.setUpcs>T"'/ l (($++F rcrd}|jjd|jjd|jj ||jj |jt|jj||jjzy)Nr7rdxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx) rQr0rSwriter'rresumeProducingr1lenrPgetvaluer")rdelta_ts rtestRatezConsumerShaperTests.testRateis|  )$ w ##% T__5578'DKKDTDT:TUrc|j|jjd|jj |j|jjdy)Nrr)r1rQ _refcountrS stopProducingrs rtestBucketRefsz"ConsumerShaperTests.testBucketRefsssF ..2 !!# ..2rr+)rrrr(r[r_rrrrNrNbsG V3rrNN) __version__twisted.protocolsr twisted.trialrtest_pcprr BucketrTestCaser$r-rBrNrrrrfsm!B' !"#  &X&&&.B""<3.3r