Your IP : 172.28.240.42


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


lONc@sdZddlmZmZmZddlmZddlmZddl	m
Z
ddlmZm
Z
mZdejfdYZd	e
jfd
YZdefdYZd
efdYZde
jfdYZde
jfdYZde
jfdYZdefdYZdefdYZdefdYZdefdYZdefdYZdefd YZd!e
jfd"YZd#dZd$YZ d%e!fd&YZ"d'eje"fd(YZ#d)ejfd*YZ$d+efd,YZ%d-e
jfd.YZ&d/e
jfd0YZ'd1d[d2YZ(d3d\d4YZ)d5d]d6YZ*d7e
jfd8YZ+d9e
jfd:YZ,d;e,fd<YZ-d=e,fd>YZ.d?efd@YZ/dAefdBYZ0dCd^dDYZ1dEd_dFYZ2dGe"ejfdHYZ3dIe"ejfdJYZ4dKefdLYZ5dMe5fdNYZ6dOe!fdPYZ7dQe!fdRYZ8dSefdTYZ9dUe!fdVYZ:dWejfdXYZ;dYS(`s0
Test cases for Twisted component architecture.
i(t	Interfacet
implementst	Attribute(tAdapterRegistry(tunittest(t
components(t_addHookt_removeHooktproxyForInterfacetInterfacesTestCasecBseZdZRS(sTest interfaces.(t__name__t
__module__t__doc__(((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyR	stCompocBseZdZdZRS(icCs|jd|_|jS(Ni(tnum(tself((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pytincs(R
RRR(((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyR
stIAdeptcBseZdZRS(cCs
tdS(N(tNotImplementedError(((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pytadaptorFuncs(R
RR(((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyRstIElapsedcBseZdZRS(cCsdS(s
        1!
        N((((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pytelapsedFuncs(R
RR(((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyRstAdeptcBs$eZeedZdZRS(cCs||_d|_dS(Ni(toriginalR(Rtorig((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyt__init__&s	cCs&|jd|_|j|jjfS(Ni(RRR(R((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyR)s(R
RRRRR(((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyR$s
	tElapsedcBseZeedZRS(cCsdS(Ni((R((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyR/s(R
RRRR(((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyR-s
tACompcBseZRS((R
R(((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyR2stBCompcBseZRS((R
R(((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyR4stCCompcBseZRS((R
R(((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyR6stITestcBseZRS((R
R(((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyR9stITest2cBseZRS((R
R(((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyR;stITest3cBseZRS((R
R(((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyR =stITest4cBseZRS((R
R(((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyR!?stTestcBs!eZeeeedZRS(cCsdS(N((RR((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyRCs(R
RRRR R!R(((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyR"AstTest2cBs!eZeedZdZRS(icCsdS(N((RR((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyRHs(R
RRRttemporaryAdapterR(((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyR#Es
tRegistryUsingMixincBseZdZdZRS(sH
    Mixin for test cases which modify the global registry somehow.
    cCs<t}|jtd|t|}|jt|dS(s
        Configure L{twisted.python.components.registerAdapter} to mutate an
        alternate registry to improve test isolation.
        tglobalRegistryN(RtpatchRRt
addCleanupR(RtscratchRegistrythook((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pytsetUpQs	(R
RRR+(((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyR%MstComponentizedTestCasecBs;eZdZdZdZdZdZdZRS(s8
    Simple test case for caching in Componentized.
    cCsJtj|tjttttjttttjttt	dS(N(
R%R+RtregisterAdapterR"RRR R#R(R((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyR+fs
cCstjttttjtttt}|jtjdksPt	|jtjdksqt	tt|j
dkst	dS(Nii(ii(ii(RR-RR
RRRtgetComponentRtAssertionErrorR(Rtc((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyttestComponentizedns	!!cCst}|jt}|jt}|jt}|jt}||ksWt||k	sit|j||jt}|jt}||kst||k	stdS(N(RR.RRR/tremoveComponent(RR0tco1tco2tco3tco4tco5tco6((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyttestInheritanceAdaptationws	
cCsit}|jt}|jt}|jt}|jt}|jd||j||dS(N(RR.RRR R!tassertIdenticaltNone(RR0R3R4R5R6((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyttestMultiAdapters	cCsmtj}t}|j|jt|||j|jtd|||j|jtddS(s
        Test that a default value specified to Componentized.getComponent if
        there is no component for the requested interface.
        tdefaultN(Rt
ComponentizedtobjectR:R.RR;(Rt
componentizedR=((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyttest_getComponentDefaultss	(R
RRR+R1R9R<RA(((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyR,bs					
tAdapterTestCasecBseZdZdZRS(sTest adapters.cCsHt}t|}|jtjt||jt|dddS(N(R?RtassertRaisesRtCannotAdaptRtassertEqualR;(Rtota((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyttestAdapterGetComponents	(R
RRRH(((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyRBstIMetacBseZRS((R
R(((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyRIst	MetaAddercBseZeedZRS(cCs|jj|S(N(RR(RR((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pytadds(R
RRRIRK(((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyRJs
tBackwardsAddercBseZeedZRS(cCs|jj|S(N(RR(RR((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyRKs(R
RRRIRK(((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyRLs
t
MetaNumbercBseZdZRS(cCs
||_dS(N(R(RR((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyRs(R
RR(((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyRMst	FakeAddercBseZdZRS(cCs|dS(Ni((RR((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyRKs(R
RRK(((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyRNst
FakeNumbercBseZdZRS(i(R
RR(((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyROstComponentNumbercBseZdZRS(cCsd|_tjj|dS(Ni(RRR>R(R((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyRs	(R
RR(((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyRPst
ComponentMetacBseZeedZRS(cCs&tjj|||jj|_dS(N(RtAdapterRRR(RR((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyRs(R
RRRIR(((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyRQs
tComponentAddercBseZdZRS(cCs|j|7_|jS(N(R(RR((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyRKs(R
RRK(((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyRSstComponentDoublercBseZdZRS(cCs|j|d7_|jjS(Ni(RR(RR((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyRKs(R
RRK(((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyRTstIAttrXcBseZdZRS(cCsdS(N((((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pytxs(R
RRV(((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyRUstIAttrXXcBseZdZRS(cCsdS(N((((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pytxxs(R
RRX(((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyRWstXcellentcBseZeedZRS(cCsdS(Nsx!((R((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyRVs(R
RRRURV(((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyRYs
tDoubleXAdaptercBs)eZdZdZdZdZRS(i*cCs
||_dS(N(R(RR((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyRscCs|jj|jjfS(N(RRV(R((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyRXscCst|j|jS(N(tcmpR(Rtother((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyt__cmp__s(R
RRRRXR](((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyRZs		tTestMetaInterfacecBs#eZdZdZdZRS(cCsBtjttttd}|jt|jdddS(Nii(RR-RJRMRIRERK(Rtn((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyt	testBasicscCsetjtttt}t|jdt|jd|jt|jdddS(Nii(RR-RSRPRIRKRE(RR0((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyttestComponentizedInteractions
	cCs<tjttttt}|jd|jdS(Nsx!(sx!sx!(RR-RZRURWRYRERX(RRX((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyttestAdapterWithCmps(R
RR`RaRb(((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyR^s		tRegistrationTestCasecBseZdZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZ
dZd
ZdZdZRS(s)
    Tests for adapter registration.
    cCs?d}tj||t|jtj|td|dS(s
        Register an adapter with L{components.registerAdapter} for the given
        class or interface and verify that the adapter can be looked up with
        L{components.getAdapterFactory}.
        cSsdS(N(R;(RF((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyt<lambda>sN(RR-RR:tgetAdapterFactoryR;(RRtadapter((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyt#_registerAdapterForClassOrInterface	s
	cCs#dtfdY}|j|S(sa
        Test that an adapter from a class can be registered and then looked
        up.
        tTheOriginalcBseZRS((R
R(((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyRhs(R?Rg(RRh((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyttest_registerAdapterForClassscCs
|jtS(sf
        Test that an adapter from an interface can be registered and then
        looked up.
        (RgR(R((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyt test_registerAdapterForInterface scCsdd}d}tj||t|jttj||t|jtj|td|dS(s
        Verify that L{components.registerAdapter} raises L{ValueError} if the
        from-type/interface and to-interface pair is not unique.
        cSstS(N(tFalse(RF((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyRd-scSstS(N(tTrue(RF((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyRd.sN(RR-RRCt
ValueErrorR:ReR;(RRtfirstAdaptert
secondAdapter((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyt$_duplicateAdapterForClassOrInterface(s		
cCs#dtfdY}|j|S(sz
        Test that attempting to register a second adapter from a class
        raises the appropriate exception.
        RhcBseZRS((R
R(((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyRh?s(R?Rp(RRh((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyttest_duplicateAdapterForClass:scCs
|jtS(s
        Test that attempting to register a second adapter from an interface
        raises the appropriate exception.
        (RpR(R((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyt!test_duplicateAdapterForInterfaceDscCsd}d}dtfdY}tj|||tt_z6tj||||jtj||d|Wdtt_X|j	t
tj||||jtj||d|dS(s
        Verify that when C{components.ALLOW_DUPLICATES} is set to C{True}, new
        adapter registrations for a particular from-type/interface and
        to-interface pair replace older registrations.
        cSstS(N(Rk(RF((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyRdRscSstS(N(Rl(RF((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyRdSstTheInterfacecBseZRS((R
R(((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyRsTsN(RRR-RltALLOW_DUPLICATESR:ReR;RkRCRm(RRRnRoRs((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyt+_duplicateAdapterForClassOrInterfaceAllowedLs$			

cCs#dtfdY}|j|S(s
        Test that when L{components.ALLOW_DUPLICATES} is set to a true
        value, duplicate registrations from classes are allowed to override
        the original registration.
        RhcBseZRS((R
R(((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyRhqs(R?Ru(RRh((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyt$test_duplicateAdapterForClassAllowedkscCs#dtfdY}|j|S(s
        Test that when L{components.ALLOW_DUPLICATES} is set to a true
        value, duplicate registrations from interfaces are allowed to
        override the original registration.
        RhcBseZRS((R
R(((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyRh|s(RRu(RRh((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyt(test_duplicateAdapterForInterfaceAllowedvscCsad}tj||tt|jtj|td||jtj|td|dS(sh
        Verify that an adapter can be registered for multiple to-interfaces at a
        time.
        cSsdS(N(R;(RF((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyRdsN(RR-RRR:ReR;(RRRf((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyt&_multipleInterfacesForClassOrInterfaces	cCs#dtfdY}|j|S(si
        Test the registration of an adapter from a class to several
        interfaces at once.
        RhcBseZRS((R
R(((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyRhs(R?Rx(RRh((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyttest_multipleInterfacesForClassscCs
|jtS(sn
        Test the registration of an adapter from an interface to several
        interfaces at once.
        (RxR (R((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyt#test_multipleInterfacesForInterfacescCsd}d}d|fdY}tj||ttj||t|jtj|td||jtj|td|dS(s 
        Verify that a new adapter can be registered for a particular
        to-interface from a subclass of a type or interface which already has an
        adapter registered to that interface and that the subclass adapter takes
        precedence over the base class adapter.
        cSstS(N(Rl(RF((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyRdscSstS(N(Rk(RF((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyRdstTheSubclasscBseZRS((R
R(((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyR{sN(RR-RR:ReR;(RRRnRoR{((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyt/_subclassAdapterRegistrationForClassOrInterfaces		cCs#dtfdY}|j|S(s~
        Test that an adapter to a particular interface can be registered
        from both a class and its subclass.
        RhcBseZRS((R
R(((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyRhs(R?R|(RRh((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyt(test_subclassAdapterRegistrationForClassscCs
|jtS(s
        Test that an adapter to a particular interface can be registered
        from both an interface and its subclass.
        (R|R(R((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyt,test_subclassAdapterRegistrationForInterfaces(R
RRRgRiRjRpRqRrRuRvRwRxRyRzR|R}R~(((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyRcs 	
	
			
					
	
			
tIProxiedInterfacecBs#eZdZedZdZRS(s=
    An interface class for use by L{proxyForInterface}.
    s@
        An example declared attribute, which should be proxied.cOsdS(s:
        A sample method which should be proxied.
        N((RGtkw((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pytyays(R
RRRtifaceAttributeR(((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyRs	tIProxiedSubInterfacecBseZdZdZRS(sS
    An interface that derives from another for use with L{proxyForInterface}.
    cCsdS(sD
        A different sample method which should be proxied.
        N((R((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pytboos(R
RRR(((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyRstYayablecBs*eZdZeedZdZRS(s
    A provider of L{IProxiedInterface} which increments a counter for
    every call to C{yay}.

    @ivar yays: The number of times C{yay} has been called.
    cCsd|_g|_dS(Ni(tyaystyayArgs(R((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyRs	cOs,|jd7_|jj||f|jS(s)
        Increment C{self.yays}.
        i(RRtappend(RRGR((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyRs(R
RRRRRR(((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyRs
	tBooablecBs6eZdZeeeZeZdZdZ	RS(s3
    An implementation of IProxiedSubInterface
    cCs
t|_dS(s;
        Mark the fact that 'yay' has been called.
        N(Rltyayed(R((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyRscCs
t|_dS(s<
        Mark the fact that 'boo' has been called.1
        N(Rltbooed(R((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyRs(
R
RRRRRkRRRR(((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyRs
	tIMultipleMethodscBs eZdZdZdZRS(s-
    An interface with multiple methods.
    cCsdS(s4
        The first method. Should return 1.
        N((((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyt	methodOnescCsdS(s5
        The second method. Should return 2.
        N((((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyt	methodTwos(R
RRRR(((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyR
s	tMultipleMethodImplementorcBs eZdZdZdZRS(s:
    A precise implementation of L{IMultipleMethods}.
    cCsdS(s
        @return: 1
        i((R((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyR#scCsdS(s
        @return: 2
        i((R((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyR*s(R
RRRR(((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyRs	tProxyForInterfaceTestscBseZdZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZ
dZd
ZRS(s)
    Tests for L{proxyForInterface}.
    cCs2t}tt|}|j|j|dS(s
        Proxy objects should have an C{original} attribute which refers to the
        original object passed to the constructor.
        N(R?RRR:R(RRtproxy((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyt
test_original7s	cCsXtt}t}||}|j|j|jd|j|jddS(s
        The class created from L{proxyForInterface} passes methods on an
        interface to the object which is passed to its constructor.
        iN(RRRRRER(RtklasstyayableR((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyttest_proxyMethodAs	
csZt}t|_tt||jj|j|jtfddS(sc
        Proxy objects should proxy declared attributes, but not other
        attributes.
        csjS(N(R((R(sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyRdWsN(RR?RRRR:RCtAttributeError(RR((RsG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyttest_proxyAttributeNs
	cCsDt}tt|}t}||_|j|j|dS(sv
        The attributes that proxy objects proxy should be assignable and affect
        the original object.
        N(RRRR?RR:(RRRtthingy((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyttest_proxySetAttributeZs
			cCsDt}d|_tt|}|`|jt|ddS(su
        The attributes that proxy objects proxy should be deletable and affect
        the original object.
        RN(RR;RRRtassertFalsethasattr(RRR((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyttest_proxyDeleteAttributefs
		cCsKt}tt|}|j|jd|j|jddS(s
        [Regression test] The proxy should send its method calls to the correct
        method, not the incorrect one.
        iiN(RRRRERR(RtmultiR((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyttest_multipleMethodsrs	cCsedttfdY}t}||}|j|jd|j|j|jddS(sP
        It is possible to subclass the result of L{proxyForInterface}.
        tSpecializedProxycBseZdZdZRS(sU
            A specialized proxy which can decrement the number of yays.
            cSs|jjd8_dS(s?
                Decrement the number of yays.
                iN(RR(R((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyRs(R
RRR(((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyRsiiN(RRRRERR(RRRtspecial((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyttest_subclassing}s
	
cCs#tt}|j|jddS(sQ
        The name of a proxy class indicates which interface it proxies.
        sA(Proxy for twisted.python.test.test_components.IProxiedInterface)N(RRRER
(RR((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyttest_proxyNamescCs&tt}|jtj|dS(sO
        The resulting proxy implements the interface that it proxies.
        N(RRt
assertTruet
implementedBy(RR((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyttest_implementsscCsdddY}|}|}||_tjdd}|j|j||j|jd}|||j|jdS(s\
        _ProxyDescriptor's __get__ method should return the appropriate
        attribute of its argument's 'original' attribute if it is invoked with
        an object.  If it is invoked with None, it should return a false
        class-method emulator instead.

        For some reason, Python's documentation recommends to define
        descriptors' __get__ methods with the 'type' parameter as optional,
        despite the fact that Python itself never actually calls the descriptor
        that way.  This is probably do to support 'foo.__get__(bar)' as an
        idiom.  Let's make sure that the behavior is correct.  Since we don't
        actually use the 'type' argument at all, this test calls it the
        idiomatic way to ensure that signature works; test_proxyInheritance
        verifies the how-Python-actually-calls-it signature.
        tSamplecBseZeZdZRS(cSs
t|_dS(N(Rltcalled(R((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pythellos(R
RRkRR(((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyRsRRN((	RRt_ProxyDescriptorREt__get__RR;t
failUnlessR(RRt	fakeProxyt
testObjecttpdtfakeClassMethod((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyttest_proxyDescriptorGets			
csdttfdYdffdY}t}||}|j|jddddd	d
d|j|jd
tddd	d
fgdS(s
        Subclasses of the class returned from L{proxyForInterface} should be
        able to upcall methods by reference to their superclass, as any normal
        Python class can.
        tYayableWrappercBseZdZRS(sI
            This class does not override any functionality.
            (R
RR(((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyRstEnhancedWrappercs#eZdZdZfdZRS(s@
            This class overrides the 'yay' method.
            ics&|jd7_j|||dS(Nii(twrappedYaysR(RRGtk(R(sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyRs(R
RRRR((R(sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyRsiiRVityiiN(ii(RRRRERRtdict(RRRtwrapper((RsG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyttest_proxyInheritances		(cCsYtt}t}||}|j|j|j|j|j|jdS(s
        Proxies of subinterfaces generated with proxyForInterface should allow
        access to attributes of both the child and the base interfaces.
        N(RRRRRRRR(Rt
proxyClasstbooableR((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyttest_interfaceInheritances	

cCst}t|_ttdd|}|j|j||j|jd|j|j|jt}||_|j|j||`|j	t
|ddS(s
        The original attribute name can be customized via the
        C{originalAttribute} argument of L{proxyForInterface}: the attribute
        should change, but the methods of the original object should still be
        callable, and the attributes still accessible.
        toriginalAttributetfooiRN(RR?RRRR:RRERRR(RRRR((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyttest_attributeCustomizations			(R
RRRRRRRRRRRRRRR(((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyR2s	
	
										N(((((((<Rtzope.interfaceRRRtzope.interface.adapterRt
twisted.trialRttwisted.pythonRttwisted.python.componentsRRRtTestCaseR	R>R
RRRRRRRRRRRR R!R"R#R?R%R,RBRIRJRLRMRNRORPRQRSRTRURWRYRZR^RcRRRRRRR(((sG/usr/lib/python2.7/dist-packages/twisted/python/test/test_components.pyt<module>s\	@