Your IP : 172.28.240.42


Current Path : /usr/lib/python2.7/dist-packages/twisted/test/
Upload File :
Current File : //usr/lib/python2.7/dist-packages/twisted/test/test_banana.pyc


=Nc@sddlZddlZddlmZddlmZddlmZddlm	Z	m
Z
dejfdYZdejfd	YZ
d
ejfdYZdS(iN(tunittest(tbanana(tfailure(tprotocoltmaintMathTestCasecBseZdZRS(cCstddtddtddd
g}xj|D]b}tj}tj||j|j}tj|}||ks7td	||fq7WdS(NiidiiLi@BiBil
sy = %s; i = %sl(trangetStringIORtint2b128twritetgetvaluetb1282inttAssertionError(tselft	funkylisttitxtvty((s</usr/lib/python2.7/dist-packages/twisted/test/test_banana.pyttestInt2b128s0
(t__name__t
__module__R(((s</usr/lib/python2.7/dist-packages/twisted/test/test_banana.pyRstBananaTestCasecBseZejZdZdZdZdZdZ	dZ
dZdZdZ
d	Zd
ZdZdZd
ZdZdZdZdZdZdZdZdZdZdZRS(cCs]tj|_|j|_|jjtj|j|jjd|j|j_	dS(Ntnone(
RtiotencClasstenctmakeConnectionRtFileWrappert_selectDialectt	putResulttexpressionReceived(R
((s</usr/lib/python2.7/dist-packages/twisted/test/test_banana.pytsetUps
cCs
||_dS(N(tresult(R
R!((s</usr/lib/python2.7/dist-packages/twisted/test/test_banana.pyR#scCs&|jjtjtj|`dS(N(RtconnectionLostRtFailureRtCONNECTION_DONE(R
((s</usr/lib/python2.7/dist-packages/twisted/test/test_banana.pyttearDown&scCsH|jjdg}|jj|jj|jdksDtdS(Nthello(RtsendEncodedtdataReceivedRR
R!R(R
tl((s</usr/lib/python2.7/dist-packages/twisted/test/test_banana.pyt
testString*scCsdx]dD]U}|jj||jj|jj|j|jd|j|jtqWdS(s
        A positive integer less than 2 ** 32 should round-trip through
        banana without changing value and should come out represented
        as an C{int} (regardless of the type which was encoded).
        i'l'N(i'l'(	RR'R(RR
tassertEqualR!tassertIsInstancetint(R
tvalue((s</usr/lib/python2.7/dist-packages/twisted/test/test_banana.pyttest_int0s

cCsxd	D]}xd
D]}d||}x||dfD]}|jjd|jj||jj|jj|j|j||tj	ks|tj	dkr|j
|jtq:|j
|jtq:WqWqWdS(s
        Integers greater than 2 ** 32 and less than -2 ** 32 should
        round-trip through banana without changing value and should
        come out represented as C{int} instances if the value fits
        into that type on the receiving platform.
        i i@iiiiiN(i i@ii(ii(
RttruncateRR'R(R
R+R!tsystmaxintR,tlongR-(R
texptaddtmtn((s</usr/lib/python2.7/dist-packages/twisted/test/test_banana.pyttest_largeLong=s

#cCs2|jj}|d}d|d}|d}|S(Niii(RtprefixLimit(R
tbytestbitstlargesttsmallest((s</usr/lib/python2.7/dist-packages/twisted/test/test_banana.pyt_getSmallestRs


cCs,|j}|jtj|jj|dS(sz
        Test that a long above the implementation-specific limit is rejected
        as too large to be encoded.
        N(R>tassertRaisesRtBananaErrorRR'(R
R=((s</usr/lib/python2.7/dist-packages/twisted/test/test_banana.pyttest_encodeTooLargeLong_scCs|j}|jj|jjd|jj||jj}|jjd|jj|jjd|jt	j
|jj|dS(sz
        Test that a long above the implementation specific limit is rejected
        as too large to be decoded.
        iiN(R>RtsetPrefixLimitR9R'RR
R0R?RR@R((R
R=tencoded((s</usr/lib/python2.7/dist-packages/twisted/test/test_banana.pyttest_decodeTooLargeLonghscCs|jS(N(R>(R
((s</usr/lib/python2.7/dist-packages/twisted/test/test_banana.pyt_getLargestwscCs,|j}|jtj|jj|dS(s
        Test that a negative long below the implementation-specific limit is
        rejected as too small to be encoded.
        N(RER?RR@RR'(R
R<((s</usr/lib/python2.7/dist-packages/twisted/test/test_banana.pyttest_encodeTooSmallLong{scCs|j}|jj|jjd|jj||jj}|jjd|jj|jjd|jt	j
|jj|dS(s
        Test that a negative long below the implementation specific limit is
        rejected as too small to be decoded.
        iiN(RERRBR9R'RR
R0R?RR@R((R
R<RC((s</usr/lib/python2.7/dist-packages/twisted/test/test_banana.pyttest_decodeTooSmallLongscCsO|jjd|jj|jj|jdksKtd|jdS(Nlsshould be -1015l, got %s(RR'R(RR
R!R(R
((s</usr/lib/python2.7/dist-packages/twisted/test/test_banana.pyttestNegativeLongscCsO|jjd|jj|jj|jdksKtd|jdS(Nisshould be 1015, got %s(RR'R(RR
R!R(R
((s</usr/lib/python2.7/dist-packages/twisted/test/test_banana.pyttestIntegerscCsO|jjd|jj|jj|jdksKtd|jdS(Ni	sshould be -1015, got %s(RR'R(RR
R!R(R
((s</usr/lib/python2.7/dist-packages/twisted/test/test_banana.pyttestNegativescCsB|jjd|jj|jj|jdks>tdS(Ng@(RR'R(RR
R!R(R
((s</usr/lib/python2.7/dist-packages/twisted/test/test_banana.pyt	testFloatsc	Csddddgddgddd	d
dggdggg}|jj||jj|jj|j|kstd
t|jt|jfdS(Niiiig>@gD@itsixtseventeighti	i
s%s!=%s(RR'R(RR
R!Rtrepr(R
tfoo((s</usr/lib/python2.7/dist-packages/twisted/test/test_banana.pyttestLists<cCsddddgddgddd	d
dggdgtjd
tjdtjdg
}|jj|x'|jjD]}|jj|qwW|j|kstdt	|jt	|fdS(Niiiig>@gD@iRLRMRNi	i
llls%s!=%s(
R1R2RR'RR
R(R!RRO(R
RPtbyte((s</usr/lib/python2.7/dist-packages/twisted/test/test_banana.pyttestPartials$cCs%x|D]}|jj|qWdS(N(RR((R
tdataRR((s</usr/lib/python2.7/dist-packages/twisted/test/test_banana.pytfeeds
cCs#d}|jtj|j|dS(Ns(tfailUnlessRaisesRR@RU(R
RT((s</usr/lib/python2.7/dist-packages/twisted/test/test_banana.pyttestOversizedListscCs#d}|jtj|j|dS(Ns(RVRR@RU(R
RT((s</usr/lib/python2.7/dist-packages/twisted/test/test_banana.pyttestOversizedStringscCs5d}y|jj|Wntjk
r0nXdS(Nt(RR(RR@(R
tcrashString((s</usr/lib/python2.7/dist-packages/twisted/test/test_banana.pyttestCrashStrings
cCsO|jjd|jj|jj|jdksKtd|jdS(Nisshould be -2147483648, got %s(RR'R(RR
R!R(R
((s</usr/lib/python2.7/dist-packages/twisted/test/test_banana.pyttestCrashNegativeLongscsfd}d
}d}d}j||dd|j||dd|j||d	d
|d}j||dd|j||dd
|j||dd|d}j||dd|j||dd
|j||d	dd}j||dd
|j||dd|j||dd|dS(s
        Test that integers below the maximum C{INT} token size cutoff are
        serialized as C{INT} or C{NEG} and that larger integers are
        serialized as C{LONGINT} or C{LONGNEG}.
        cs:jjdjjjj|jjS(Ni(RtseekR0RR'R
(R7(R
(s</usr/lib/python2.7/dist-packages/twisted/test/test_banana.pyRCs
iisis}is~isttsissttsN(R+(R
RCt	baseIntInt	baseNegInt
baseIntOuttbaseLongIntOutt
baseNegOuttbaseLongNegOut((R
s</usr/lib/python2.7/dist-packages/twisted/test/test_banana.pyttest_sizedIntegerTypess&(RRRtBananaRR RR%R*R/R8R>RARDRERFRGRHRIRJRKRQRSRURWRXR[R\Rh(((s</usr/lib/python2.7/dist-packages/twisted/test/test_banana.pyRs2						
		
													
					
tGlobalCoderTestscBseZdZdZRS(sM
    Tests for the free functions L{banana.encode} and L{banana.decode}.
    cCsJddd}|jtjtj|d}|jtj|ddS(sW
        Test that state doesn't carry over between calls to L{banana.decode}.
        siAssiN(R?RR@tdecodeR+(R
tundecodablet	decodable((s</usr/lib/python2.7/dist-packages/twisted/test/test_banana.pyttest_statelessDecodes(RRt__doc__Rn(((s</usr/lib/python2.7/dist-packages/twisted/test/test_banana.pyRjs(RR1t
twisted.trialRttwisted.spreadRttwisted.pythonRttwisted.internetRRtTestCaseRRRj(((s</usr/lib/python2.7/dist-packages/twisted/test/test_banana.pyt<module>s