Your IP : 172.28.240.42


Current Path : /usr/lib/python2.7/dist-packages/zope/interface/tests/
Upload File :
Current File : //usr/lib/python2.7/dist-packages/zope/interface/tests/test_interface.pyc


Kc@szdZddlZddlZddlZdejfdYZejddfkrddZndZd	Z	dS(
sTest Interface implementation
iNtInterfaceTestscBseZdZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZ
dZd
ZdZdZdZdZdZRS(csddlm}ddlmd|ffdY}d|fdY}d|fd	Y}d
|fdY}|S(Ni(t	Interface(t	Attributet_I1cs/eZdZdZdZde_RS(sThis is an attributecSsdS(N((((sG/usr/lib/python2.7/dist-packages/zope/interface/tests/test_interface.pytf11scSsdS(N((((sG/usr/lib/python2.7/dist-packages/zope/interface/tests/test_interface.pytf12si(t__name__t
__module__ta1RRtoptional((R(sG/usr/lib/python2.7/dist-packages/zope/interface/tests/test_interface.pyRs		t_I1_cBseZRS((RR(((sG/usr/lib/python2.7/dist-packages/zope/interface/tests/test_interface.pyR
#st_I1__cBseZRS((RR(((sG/usr/lib/python2.7/dist-packages/zope/interface/tests/test_interface.pyR&st_I2cBs eZdZdZeZRS(cSsdS(N((((sG/usr/lib/python2.7/dist-packages/zope/interface/tests/test_interface.pytf21*scSsdS(N((((sG/usr/lib/python2.7/dist-packages/zope/interface/tests/test_interface.pytf22,s(RRR
Rtf23(((sG/usr/lib/python2.7/dist-packages/zope/interface/tests/test_interface.pyR)s		(tzope.interfaceRR(tselfRRR
RR((RsG/usr/lib/python2.7/dist-packages/zope/interface/tests/test_interface.pyt_makeDerivedInterfaces
cCsBddlm}|j|dj||j|dj|dS(Ni(tFooInterfacetfoobartaMethod(t!zope.interface.tests.unitfixturesRtassertEqualt	interface(RR((sG/usr/lib/python2.7/dist-packages/zope/interface/tests/test_interface.pyttestInterfaceSetOnAttributes2s
c	Csdddlm}ddlm}ddlm}ddlm}ddlm}ddlm}ddlm}dd	lm}|j	|j
||j	|j
||j	|j
||j	|j
||j	|j
||j	|j
||j	|j
||j	|j
||j	|j
||j	|j
|dS(
Ni(tA(tB(tC(tD(tE(tI1(tI2(tIC(RRRRRRRR R!tassert_t
implementedBy(	RRRRRRRR R!((sG/usr/lib/python2.7/dist-packages/zope/interface/tests/test_interface.pyttestClassImplements9s$c	Csddlm}ddlm}ddlm}ddlm}ddlm}ddlm}ddlm}dd	lm	}|j
|||k|j
|||k|j
|||k|j
|||k|j
|||k|j
|||k|j
|||k|j
|||k|j
|||k|j
|||kdS(
Ni(R#(t
providedBy(R(R(R(R(R (R!(RR#R%RRRRRR R!R"(	RR#R%RRRRR R!((sG/usr/lib/python2.7/dist-packages/zope/interface/tests/test_interface.pyttestUtilSs$c	Csddlm}ddlm}ddlm}ddlm}ddlm}ddlm}ddlm}dd	lm}|j	|j
||j	|j
||j	|j
||j	|j
||j	|j
||j	|j
||j	|j
||j	|j
||j	|j
||j	|j
|dS(
Ni(R(R(R(R(R(R(R (R!(RRRRRRRR R!R"R%(	RRRRRRRR R!((sG/usr/lib/python2.7/dist-packages/zope/interface/tests/test_interface.pyttestObjectImplementsis$cCs@ddlm}ddlm}|}|j||jdS(Ni(R(tBrokenImplementation(RRtzope.interface.exceptionsR(tassertRaisestma(RRR(ta((sG/usr/lib/python2.7/dist-packages/zope/interface/tests/test_interface.pyttestDeferredClasss	cCsddlm}ddlm}ddlm}ddlm}|j|j||j|j||j|j||j|j||j|j||j|j||j|j|dS(Ni(tBazInterface(tBarInterface(tBobInterface(tFunInterface(RR.R/R0R1R"textends(RR.R/R0R1((sG/usr/lib/python2.7/dist-packages/zope/interface/tests/test_interface.pyttestInterfaceExtendsInterfacescCsddlm}ddlm}ddlm}ddlm}ddlm}|j||||j|j	|dS(Ni(tverifyClass(R(tFoo(R(R(
tzope.interface.verifyR4RRRR5RRR"R%(RR4RR5RR((sG/usr/lib/python2.7/dist-packages/zope/interface/tests/test_interface.pyttestVerifyImplementationscCs|j}t|j}|j|j|dddgt|jdt}|j|j|ddddddgdS(NR
RRtallRRR(RtlisttnamestsortRtTrue(RtifaceR:R8((sG/usr/lib/python2.7/dist-packages/zope/interface/tests/test_interface.pyt
test_namess

cCs|j}g|jD]}|d^q}|j|j|dddgg|jdD]}|d^qb}|j|j|ddddddgx0|jdD]\}}|j||jqWdS(	NiR
RRiRRR(RtnamesAndDescriptionsR;RR(RR=tndR:tnametd((sG/usr/lib/python2.7/dist-packages/zope/interface/tests/test_interface.pyttest_namesAndDescriptionss#
&
"cCsz|j}|j|jdjd|j|jdjd|j|jd|||jt|jddS(NRRtf33(RRtgetDescriptionForRtqueryDescriptionForR*tKeyError(RR=((sG/usr/lib/python2.7/dist-packages/zope/interface/tests/test_interface.pyttest_getDescriptionFors
cCsp|j}|j|djd|j|djd|j|jd|||jt|jddS(NRRRD(RRRtgetR*RGt__getitem__(RR=((sG/usr/lib/python2.7/dist-packages/zope/interface/tests/test_interface.pyttest___getitem__s
cCs6|j}|jd|k|jd|kdS(NRRD(Rt
failUnlesstfailIf(RR=((sG/usr/lib/python2.7/dist-packages/zope/interface/tests/test_interface.pyttest___contains__scCsN|j}tt|}|j|j|ddddddgdS(NRRRR
RR(RR9titerR;R(RR=R:((sG/usr/lib/python2.7/dist-packages/zope/interface/tests/test_interface.pyt
test___iter__s
cCsE|j}|jd}|j|jd|j|jddS(NRsThis is an attribute(RRERRt__doc__(RR=tdescription((sG/usr/lib/python2.7/dist-packages/zope/interface/tests/test_interface.pyttestAttrscCsMddlm}d|fdY}|d}|j|jdddS(Ni(RtITestcBseZdZde_RS(cSsdS(N((((sG/usr/lib/python2.7/dist-packages/zope/interface/tests/test_interface.pytmethodsi(RRRUR	(((sG/usr/lib/python2.7/dist-packages/zope/interface/tests/test_interface.pyRTs	RUR	i(RRRtgetTaggedValue(RRRTRU((sG/usr/lib/python2.7/dist-packages/zope/interface/tests/test_interface.pyttestFunctionAttributess
c
sddlmddlm}ddlm}ddlm}ddlmddlm}ddlm	}|}||dfd	}|jjd
|g|jj
|dd|_|jj
|dd|_|jj
|d|`|||d
dg|j|jd
|g|}|||d|_|||d
dg|d|_d
|_|||d
dg|d
|_d|_|||dddg|d
|_d|_|jj
|d|}||d|_jd
}|}	|	j|jd
|	|||d
dgd|_d
|_|||d
dgd
|_d|_|||dddgd
|_d|_|jj
|djd
|dS(Ni(tInvalid(tdirectlyProvides(tBarGreaterThanFoo(tifFooThenBar(t
IInvariant(t
InvariantC(t
ISubInvariantc	s|dkr}n|j|j|g}y|j||Wn*k
rq}|j|jd|nX|jd|jt||g|D]}|jd^q}|jx'|D]}|j||jdqWdS(Ni(	tNoneR*tvalidateInvariantstassertEqualstargst_asserttlenR;tpop(	Rtot	error_lent
error_msgsR=teterrortmsgstmsg(RXR\(sG/usr/lib/python2.7/dist-packages/zope/interface/tests/test_interface.pyterrorsEquals	
 

t
invariantsii*isIf Foo, then Bar!is%Please, Boo MUST be greater than Foo!i(R)RXRRYRRZR[R\R]R^R_RaRVR`tbartfootappendtsetTaggedValue(
RRYRZR[R]R^RfRmtold_invariantsRn((RXR\sG/usr/lib/python2.7/dist-packages/zope/interface/tests/test_interface.pyt
testInvariantsp	

		
	
								
	
				
		csddlm}ddlmd|fdY}|j|jd|jt|gd|ffdY}|j|jd|jt|d	gdS(
Ni(R(RtIcBseZdZRS(txxx(RRRQ(((sG/usr/lib/python2.7/dist-packages/zope/interface/tests/test_interface.pyRuDsRvcseZdZdZRS(Rvsthe doc(RRRQ((R(sG/usr/lib/python2.7/dist-packages/zope/interface/tests/test_interface.pyRuJstRQ(RRRRRQR9(RRRu((RsG/usr/lib/python2.7/dist-packages/zope/interface/tests/test_interface.pyttest___doc___elementAscCsjddlm}tjddkr'dSd|fdY}dd	dY}|jt|j|dS(
Ni(Rit3RucBseZdZRS(Rv(RRRQ(((sG/usr/lib/python2.7/dist-packages/zope/interface/tests/test_interface.pyRuXstBadcBseZdZRS(N(RRR_t__providedBy__(((sG/usr/lib/python2.7/dist-packages/zope/interface/tests/test_interface.pyRzZs((RRtsystversiontfailUnlessRaisestAttributeErrorR%(RRRuRz((sG/usr/lib/python2.7/dist-packages/zope/interface/tests/test_interface.pyttestIssue228Rs(RRRRR$R&R'R-R3R7R>RCRHRKRNRPRSRWRtRxR(((sG/usr/lib/python2.7/dist-packages/zope/interface/tests/test_interface.pyRs&							
												b	iicCsdS(snInvaiants can be deined in line

          >>> from zope.interface.exceptions import Invalid
          >>> from zope.interface import Interface
          >>> from zope.interface import Attribute
          >>> from zope.interface import implements
          >>> from zope.interface import invariant
          >>> class IRange(Interface):
          ...     min = Attribute("Lower bound")
          ...     max = Attribute("Upper bound")
          ...
          ...     @invariant
          ...     def range_invariant(ob):
          ...         if ob.max < ob.min:
          ...             raise Invalid('max < min')


          >>> class Range(object):
          ...     implements(IRange)
          ...
          ...     def __init__(self, min, max):
          ...         self.min, self.max = min, max

          >>> from zope.interface.exceptions import Invalid
          >>> IRange.validateInvariants(Range(1,2))
          >>> IRange.validateInvariants(Range(1,1))
          >>> try:
          ...     IRange.validateInvariants(Range(2,1))
          ... except Invalid, e:
          ...     str(e)
          'max < min'


        N((((sG/usr/lib/python2.7/dist-packages/zope/interface/tests/test_interface.pyttest_invariant_as_decoratorcscCsdS(s See https://bugs.launchpad.net/zope.interface/+bug/185974

There was a bug where the cache used by Specification.get() was not
cleared when the bases were changed.

    >>> from zope.interface import Interface
    >>> from zope.interface import Attribute
    >>> class I1(Interface):
    ...     a = Attribute('a')

    >>> class I2(I1):
    ...     pass

    >>> class I3(I2):
    ...     pass

    >>> I3.get('a') is I1.get('a')
    True
    >>> I2.__bases__ = (Interface,)
    >>> I3.get('a') is None
    True
    N((((sG/usr/lib/python2.7/dist-packages/zope/interface/tests/test_interface.pyt!test_description_cache_managementscCstjt}|jtjdtjd
krJ|jtjn|jtjddidd6dtj	tj
B|jtjd	didd6dtj	tj
B|S(Nszope.interface.interfaceiis
../README.txttglobst__main__Rtoptionflagss../README.ru.txt(ii(tunittestt	makeSuiteRtaddTesttdoctesttDocTestSuiteR|tversion_infotDocFileSuitetNORMALIZE_WHITESPACEtELLIPSIS(tsuite((sG/usr/lib/python2.7/dist-packages/zope/interface/tests/test_interface.pyt
test_suites

(
RQRRR|tTestCaseRRRRR(((sG/usr/lib/python2.7/dist-packages/zope/interface/tests/test_interface.pyt<module>sN%