ó úŠ/Qc@sØdZddlZddlZddlmZddlmZdejfd„ƒYZdefd„ƒYZd Z d efd „ƒYZ d efd „ƒYZ defd„ƒYZ defd„ƒYZ d„ZdS(ssTests for advice This module was adapted from 'protocols.tests.advice', part of the Python Enterprise Application Kit (PEAK). Please notify the PEAK authors (pje@telecommunity.com and tsarna@sarna.org) if bugs are found or Zope-specific changes are required, so that the PEAK version of this module can be kept in sync. PEAK is a Python application framework that interoperates with (but does not require) Zope 3 and Twisted. It provides tools for manipulating UML models, object-relational persistence, aspect-oriented programming, and more. Visit the PEAK home page at http://peak.telecommunity.com for more information. iÿÿÿÿN(t_skip_under_py2(t_skip_under_py3kt_SilencePy3DeprecationscBseZd„Zd„ZRS(cCs |j|ƒS(N(t assertTrue(tselftexpr((sD/usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyt failUnless&scCs |j|ƒS(N(t assertFalse(RR((sD/usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pytfailIf*s(t__name__t __module__RR(((sD/usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyR#s t FrameInfoTestcBs;eZd„Zed„ƒZd„Zd„Zd„ZRS(cCslddlm}|j\}}}}|j|dƒx0|j||fD]}|j||jkƒqHWdS(Niÿÿÿÿ(tadvisory_testingtmodule(tzope.interface.testsR tmoduleLevelFrameInfot assertEqualt__dict__Rt my_globals(RR tkindR tf_localst f_globalstd((sD/usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyt test_w_module1s cCs˜ddlm}|jdkr#dS|jj\}}}}|j|dƒ|j||jjkƒx-|j|fD]}|j||jkƒqtWdS(Niÿÿÿÿ(R tclass( RR t ClassicClasstNonetclassLevelFrameInfoRRRR(RR RR RRR((sD/usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyttest_w_ClassicClass9scCslddlm}|jj\}}}}|j|dƒx-|j|fD]}|j||jkƒqHWdS(Niÿÿÿÿ(R R(RR t NewStyleClassRRRRR(RR RR RRR((sD/usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyttest_w_NewStyleClassIs cCsˆddlm}|tjƒƒ\}}}}|j|dƒ|j|tƒkƒx-|j|fD]}|j|tƒkƒqdWdS(Niÿÿÿÿ(t getFrameInfos function call( tzope.interface.adviceRtsyst _getframeRRtlocalsRtglobals(RRRR RRR((sD/usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyttest_inside_function_callTs cBs‘ddlm}i|d6}i}e||fdU|j|ddƒ|j|d|kƒ|j|ddkƒ|j|d|kƒdS( Niÿÿÿÿ(RRRtexecRR R(R Rt _FUNKY_EXECRRR(RRt_globalst_locals((sD/usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyttest_inside_exec\s (R R RRRRR%R*(((sD/usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyR /s   sMimport sys kind, module, f_locals, f_globals = getFrameInfo(sys._getframe()) t AdviceTestscBsMeZed„ƒZd„Zed„ƒZed„ƒZed„ƒZRS(csddlm‰g‰dtf‡‡fd†ƒY}x-dD]%}|jt|tƒƒ|\}q<W|jˆd|fd|gfd|ggfgƒdS( Niÿÿÿÿ(tpingtFoocs/eZˆˆdƒˆˆdƒˆˆdƒRS(iii(R R ((tlogR,(sD/usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyR-rs  iii(iii(t%zope.interface.tests.advisory_testingR,tobjectRt isinstancetlistR(RR-ti((R.R,sD/usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyt test_orderns  cCsEddlm}y|gdƒWntk r4n Xtdƒ‚dS(Niÿÿÿÿ(R,is.Should have detected advice outside class body(R/R,t SyntaxErrortAssertionError(RR,((sD/usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pytTODOtest_outside~s cshddlm‰dtfd„ƒY‰dˆf‡‡fd†ƒY}|\}|j|jˆkƒdS(Niÿÿÿÿ(R,t MetaclasscBseZRS((R R (((sD/usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyR8ŽstConcretecseZˆZˆgdƒRS(i(R R t __metaclass__((R8R,(sD/usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyR9‘s(R/R,ttypeRt __class__(RR9((R8R,sD/usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyttest_single_explicit_metaŠs  cs%ddlm‰dtfd„ƒY‰dtfd„ƒY‰dd‡fd†ƒY}d d‡fd †ƒY}y#d ||f‡fd †ƒY}Wntk r¤n Xtd ƒ‚dˆˆfd„ƒY‰d ||f‡‡fd†ƒY}|jt|tƒƒ|\}|jt|ˆƒƒdS(Niÿÿÿÿ(R,t Metaclass1cBseZRS((R R (((sD/usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyR>st Metaclass2cBseZRS((R R (((sD/usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyR? stBase1cseZˆZRS((R R R:((R>(sD/usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyR@£stBase2cseZˆZRS((R R R:((R?(sD/usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyRA¦stDerivedcseZˆgdƒRS(i(R R ((R,(sD/usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyRBªss(Should have gotten incompatibility errort Metaclass3cBseZRS((R R (((sD/usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyRC²scseZˆZˆgdƒRS(i(R R R:((RCR,(sD/usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyRBµs(((R/R,R;t TypeErrorR6RR1R2(RR@RARB((R>R?RCR,sD/usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyttest_mixed_metas™s#  " csuddlm‰yddlm}Wntk r8dSXdd‡fd†ƒY}|\}|jt|ƒ|ƒdS(Niÿÿÿÿ(R,(t ClassTypetThingcseZˆgdƒRS(i(R R ((R,(sD/usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyRGÄs((R/R,ttypesRFt ImportErrorRR;(RRFRGtklass((R,sD/usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyttest_meta_no_bases½s  (R R RR4R7R=RERK(((sD/usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyR+ls  $tTest_isClassAdvisorcBs,eZd„Zd„Zd„Zd„ZRS(cOsddlm}|||ŽS(Niÿÿÿÿ(tisClassAdvisor(R RM(RtargstkwRM((sD/usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyt_callFUTÌscCs|j|j|ƒtƒdS(N(RRPtFalse(R((sD/usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyttest_w_non_functionÐscCs&d„}|j|j|ƒtƒdS(NcSsdS(N((((sD/usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pytfooÔs(RRPRQ(RRS((sD/usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyttest_w_normal_functionÓs cCs2d„}tƒ|_|j|j|ƒtƒdS(NcSsdS(N((((sD/usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pytbarÙs(R0tpreviousMetaclassRRPtTrue(RRU((sD/usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyttest_w_advisor_functionØs  (R R RPRRRTRX(((sD/usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyRLÊs   tTest_determineMetaclasscBsŒeZd„Zed„ƒZd„Zd„Zed„ƒZed„ƒZ ed„ƒZ ed„ƒZ ed„ƒZ ed „ƒZ RS( cOsddlm}|||ŽS(Niÿÿÿÿ(tdetermineMetaclass(R RZ(RRNRORZ((sD/usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyRPáscCs-ddlm}|j|jdƒ|ƒdS(Niÿÿÿÿ(RF((RHRFRRP(RRF((sD/usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyt test_emptyåscCs6dtfd„ƒY}|j|jd|ƒ|ƒdS(NtMetacBseZRS((R R (((sD/usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyR\ës((R;RRP(RR\((sD/usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyttest_empty_w_explicit_metatypeêscCs6dtfd„ƒY}|j|j|fƒtƒdS(NR\cBseZRS((R R (((sD/usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyR\ðs(R;RRP(RR\((sD/usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyt test_singleïscsUdtfd„ƒY‰dtf‡fd†ƒY}|j|j|tfƒˆƒdS(NtMetametacBseZRS((R R (((sD/usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyR_ösR\cseZˆZRS((R R R:((R_(sD/usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyR\ùs(R;RRP(RR\((R_sD/usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyttest_meta_of_classôscBsfdjddddgƒ}i}||fdU|d}|d}|j|j|efƒ|ƒdS(Ns sclass Metameta(type):s passs%class Meta(type, metaclass=Metameta):R\R_(tjoinRRPR;(RtEXECtglobsR\R_((sD/usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyttest_meta_of_class_py3kþs   cs‡dtfd„ƒY‰dˆfd„ƒY‰dtf‡fd†ƒY}dtf‡fd†ƒY}|j|j||fƒˆƒdS( NtMeta_AcBseZRS((R R (((sD/usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyRestMeta_BcBseZRS((R R (((sD/usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyRfstAcseZˆZRS((R R R:((Re(sD/usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyRgstBcseZˆZRS((R R R:((Rf(sD/usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyRhs(R;RRP(RRgRh((ReRfsD/usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyttest_multiple_in_hierarchys c Bs†djddddddddgƒ}i}||fdU|d}|d}|d }|d }|j|j||fƒ|ƒdS( Ns sclass Meta_A(type):s passsclass Meta_B(Meta_A):s class A(type, metaclass=Meta_A):s class B(type, metaclass=Meta_B):ReRfRgRh(RaRRP(RRbRcReRfRgRh((sD/usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyttest_multiple_in_hierarchy_py3ks      cs„dtfd„ƒY‰dtfd„ƒY‰dtf‡fd†ƒY}dtf‡fd†ƒY}|jt|j||fƒdS( NRecBseZRS((R R (((sD/usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyRe1sRfcBseZRS((R R (((sD/usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyRf3sRgcseZˆZRS((R R R:((Re(sD/usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyRg5sRhcseZˆZRS((R R R:((Rf(sD/usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyRh7s(R;t assertRaisesRDRP(RRgRh((ReRfsD/usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyttest_multiple_not_in_hierarchy/s c Bsƒdjddddddddgƒ}i}||fdU|d}|d}|d }|d }|je|j||fƒdS( Ns sclass Meta_A(type):s passsclass Meta_B(type):s class A(type, metaclass=Meta_A):s class B(type, metaclass=Meta_B):ReRfRgRh(RaRkRDRP(RRbRcReRfRgRh((sD/usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyt#test_multiple_not_in_hierarchy_py3k;s      (R R RPRR[R]R^R`RRdRiRjRlRm(((sD/usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyRYßs      tTest_minimalBasescBs\eZd„Zd„Zed„ƒZed„ƒZd„Zd„Zd„Z d„Z RS(cCsddlm}||ƒS(Niÿÿÿÿ(t minimalBases(R Ro(RtklassesRo((sD/usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyRPSscCs|j|jgƒgƒdS(N(RRP(R((sD/usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyR[WscCs9ddd„ƒY}|j|jt|ƒgƒgƒdS(NtCcBseZRS((R R (((sD/usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyRq\s((RRPR;(RRq((sD/usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyttest_w_oldstyle_metaZscCs6ddd„ƒY}|j|j|gƒ|gƒdS(NRqcBseZRS((R R (((sD/usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyRqbs((RRP(RRq((sD/usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyttest_w_oldstyle_class`scCs#|j|jtgƒtgƒdS(N(RRPR;(R((sD/usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyttest_w_newstyle_metafscCs9dtfd„ƒY}|j|j|gƒ|gƒdS(NRqcBseZRS((R R (((sD/usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyRqjs(R0RRP(RRq((sD/usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyttest_w_newstyle_classiscCsdtfd„ƒY}d|fd„ƒY}d|fd„ƒY}dtfd„ƒY}|j|j|||gƒ|gƒ|j|j||gƒ|gƒ|j|j||gƒ|gƒ|j|j||gƒ|gƒ|j|j|||gƒ||gƒdS( NRgcBseZRS((R R (((sD/usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyRgosRhcBseZRS((R R (((sD/usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyRhqsRqcBseZRS((R R (((sD/usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyRqsstDcBseZRS((R R (((sD/usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyRvus(R0RRP(RRgRhRqRv((sD/usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyt#test_simple_hierarchy_skips_impliedns%"""cCsXdtfd„ƒY}dtfd„ƒY}|j|j|||gƒ||gƒdS(NRgcBseZRS((R R (((sD/usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyRg~sRhcBseZRS((R R (((sD/usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyRh€s(R0RRP(RRgRh((sD/usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyt#test_repeats_kicked_to_end_of_queue}s( R R RPR[RRrRsRtRuRwRx(((sD/usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyRnQs     cCsItjtjtƒtjtƒtjtƒtjtƒtjtƒfƒS(N(tunittestt TestSuitet makeSuiteR R+RLRYRn(((sD/usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyt test_suite†s     (t__doc__RyR!tzope.interface._compatRRtTestCaseRR R'R+RLRYRnR|(((sD/usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyts   ;^r5