ó [Z-Lc@s“ddlZddlZddlZddlZddlZddlZddlZddlZddlm Z ej dej dZ Z e e fZ dejfd„ƒYZdefd„ƒYZd efd „ƒYZd efd „ƒYZd efd„ƒYZdefd„ƒYZdefd„ƒYZdefd„ƒYZdefd„ƒYZdefd„ƒYZedkrejƒndS(iÿÿÿÿN(tTemplateiit TemplateTestcBseZRS((t__name__t __module__(((sC/opt/freeware/lib/python2.7/site-packages/Cheetah/Tests/Template.pyRstClassMethods_compilecBs_eZdZd„Zd„Zd„Zd„Zd„Zd„Zd„Z d„Z d „Z RS( s‚I am using the same Cheetah source for each test to root out clashes caused by the compile caching in Template.compile(). cCsDtjddƒ}|didd6ƒ}t|ƒdks@t‚dS(Ntsources$foot namespacesiÒtfoot1234(RtcompiletstrtAssertionError(tselftklasstt((sC/opt/freeware/lib/python2.7/site-packages/Cheetah/Tests/Template.pyttest_basicUsagescCstjdddtƒ}|idd6ƒ}t|ƒdksCt‚tjddd|ƒ}|idd6ƒ}t|ƒdks†t‚tjddd|ƒ}|idd6ƒ}t|ƒdksÉt‚tjddddƒ}|idd6ƒ}t|ƒdks t‚dS( NRs$foot baseclassiÒRRs#implements dummy $bartdict(RR RR R (R R Rtklass2tklass3tklass4((sC/opt/freeware/lib/python2.7/site-packages/Cheetah/Tests/Template.pyttest_baseclassArgscCsºtdkrdStjƒ}z†tjj|ƒs7t‚tjdddt d|ƒ}t j |j }tjj|j ƒs€t‚tjj|j ƒ|ks¡t‚Wdtj|t ƒXdS(NiiRs$footcacheModuleFilesForTracebackstcacheDirForModuleFiles(ii(t versionTuplettempfiletmkdtemptostpathtexistsR RR tTruetsystmodulesRt__file__tdirnametshutiltrmtree(R ttmpDirR tmod((sC/opt/freeware/lib/python2.7/site-packages/Cheetah/Tests/Template.pyttest_moduleFileCaching.s   %cCs_tjddddƒ}|jdks-t‚|didd6ƒ}t|ƒdks[t‚dS( NRs$foot classNametfoo123RiÒRR(RR RR R (R R R((sC/opt/freeware/lib/python2.7/site-packages/Cheetah/Tests/Template.pyttest_classNameArg?scCsÚtjddddƒ}tjd}|jdks:t‚|didd6ƒ}t|ƒdksht‚tjdddd d d ƒ}tjd }|jd ks¨t‚|didd6ƒ}t|ƒdksÖt‚dS( NRs$foot moduleNametfoo99RiÒRRtfoo1R(tfoo2(RR RR RR R (R R R&R((sC/opt/freeware/lib/python2.7/site-packages/Cheetah/Tests/Template.pyttest_moduleNameArgEs   c Csÿtjddddddƒ}|jdks3t‚|didd 6ƒ}t|ƒd ksat‚|jƒd ksyt‚tjddd d ddddd tƒ}|jdks¸t‚|idd 6ƒ}t|ƒd ksãt‚|jƒd ksût‚dS(NRs$fooR(R)tmainMethodNamettestMethRiÒRRR+tfooXXXR(RR RR R R1R(R R R((sC/opt/freeware/lib/python2.7/site-packages/Cheetah/Tests/Template.pyttest_mainMethodNameArgVs   c Csátjdddidd6ƒ}|ƒ}t|ƒdks@t‚tjddddditd6ƒ}|idd6ƒ}t|ƒdkst‚tjddddditd6dd6ƒ}|ƒ}t|ƒdksÝt‚dS( NRs$foot moduleGlobalsiÒRRRtTest1(RR R R R(R R RRR((sC/opt/freeware/lib/python2.7/site-packages/Cheetah/Tests/Template.pyttest_moduleGlobalsArgms  c Cs%tjdddddtdtƒ}|didd 6ƒ}t|ƒd ksRt‚|jƒ set‚tjdddddtƒ}|didd 6ƒ}t|ƒd ks±t‚|jƒsÃt‚tjdddddtƒ}|didd 6ƒ}t|ƒd kst‚|jƒs!t‚dS( NRs$fooR(tunique58tcacheCompilationResultstkeepRefToGeneratedCodeRiÒRR(RR tFalseR R tgeneratedModuleCodeR(R R RRR((sC/opt/freeware/lib/python2.7/site-packages/Cheetah/Tests/Template.pyttest_keepRefToGeneratedCodeArg~s&   cCstjdddddtƒ}|didd6ƒ}t|ƒd ksLt‚|j s\t‚tjdddddtƒ}|didd6ƒ}t|ƒd ks¨t‚|js·t‚tjdddd ƒ}|didd6ƒ}t|ƒd ksýt‚|js t‚dS( NRs$fooR(t unique111R8RiÒRRt unique999099(RR R:R R t_CHEETAH_isInCompilationCacheR(R R R((sC/opt/freeware/lib/python2.7/site-packages/Cheetah/Tests/Template.pyttest_compilationCache˜s"   ( RRt__doc__RRR'R*R/R3R6R<R@(((sC/opt/freeware/lib/python2.7/site-packages/Cheetah/Tests/Template.pyRs        tClassMethods_subclasscBseZd„ZRS(cCsÁtjdddtƒ}|idd6ƒ}t|ƒdksCt‚|jddƒ}|idd6ƒ}t|ƒdks€t‚|jddƒ}|idd6ƒ}t|ƒdks½t‚dS(NRs$fooRiÒRRs#implements dummy $bar(RR RR R tsubclass(R R RRR((sC/opt/freeware/lib/python2.7/site-packages/Cheetah/Tests/Template.pyR³s(RRR(((sC/opt/freeware/lib/python2.7/site-packages/Cheetah/Tests/Template.pyRB±st PreprocessorscBs,eZd„Zd„Zd„Zd„ZRS(cCsƒd}djg|jƒD]}|jƒ^qƒ}idd6idd6d6}tj|d|ƒ}t|ƒƒd kst‚dS( Ns3 %set foo = @a $(@foo*10) @as s@ %ttokensictaRt preprocessorss990 99(tjoint splitlineststripRR R R (R tsrctlnRGR ((sC/opt/freeware/lib/python2.7/site-packages/Cheetah/Tests/Template.pyttest_basicUsage1Ãs . c Csd}ddd„ƒY}|ƒ}ddlm}tj|ƒ}||ƒ}d„}dtfd„ƒY}id d 6d d 6d d6}x€didd6i|d6i|d6id6idd6|d6|||gD]6} tj|d| ƒ} t| ƒƒdksÐt‚qÐWdS(Ns"%set foo = 12 %%comment $(@foo*10)t Settings1cBseZdZRS(s@ %(RRRE(((sC/opt/freeware/lib/python2.7/site-packages/Cheetah/Tests/Template.pyRNÒsiÿÿÿÿ(tTemplatePreprocessorcSsdS(Ns$(12*10)(s$(12*10)N(tNone(Rtfile((sC/opt/freeware/lib/python2.7/site-packages/Cheetah/Tests/Template.pyt preprocFuncÙstTemplateSubclasscBseZRS((RR(((sC/opt/freeware/lib/python2.7/site-packages/Cheetah/Tests/Template.pyRSÜst@tcheetahVarStartTokent%tdirectiveStartTokens%%tcommentStartTokens@ %REtcompilerSettingsttemplateInitArgsttemplateAPIClassRGt120((tCheetah.TemplateRORt_normalizePreprocessorSettingsR R R ( R RKRNROtsettingst preprocObjRRRSRYtargR ((sC/opt/freeware/lib/python2.7/site-packages/Cheetah/Tests/Template.pyt%test_normalizePreprocessorArgVariantsÏs.          cCs¯d}djg|jƒD]}|jƒ^qƒ}xtidd6idd6d6idd6idd6d6gD]<}tj|d|ƒ}|ƒ}t|ƒd kskt‚qkWdS( Nsž %set foo = @a %def func1: #def func(arg): $arg("***") %% comment $(@foo*10) @func1 $func(lambda x:c"--$x--@a")s s@ %REicRFRRGs 990 --***--99(RHRIRJRR R R (R RKRLRaR R((sC/opt/freeware/lib/python2.7/site-packages/Cheetah/Tests/Template.pyttest_complexUsageôs." cCs†d}djg|jƒD]}|jƒ^qƒ}tj|dddtƒ}|idd6ƒ}t|ƒdd d ks‚t‚dS( Ns %i18n: This is a $string that needs translation %i18n id="foo", domain="root": This is a $string that needs translation s RGs@ %Rs bit of texttstrings-This is a bit of text that needs translation iiÿÿÿÿ(RHRIRJRR RR R (R RKRLR R((sC/opt/freeware/lib/python2.7/site-packages/Cheetah/Tests/Template.pyt test_i18ns .(RRRMRbRcRe(((sC/opt/freeware/lib/python2.7/site-packages/Cheetah/Tests/Template.pyRDÁs % tTryExceptImportTestcBseZd„ZRS(cCs?d}tjd|ditd6ƒ}|didd6ƒ}dS( sE Test situation where an inline #import statement will get relocated sý #def myFunction() Ahoy! #try #import sys #except ImportError $print "This will never happen!" #end try #end def RRYtuseLegacyImportModeRiÒRN(RR R:(R RR R((sC/opt/freeware/lib/python2.7/site-packages/Cheetah/Tests/Template.pyt test_FailCases (RRRh(((sC/opt/freeware/lib/python2.7/site-packages/Cheetah/Tests/Template.pyRfstClassMethodSupportcBseZd„ZRS(cCs¢tjddkr/tjddkr/dGHdSd}tjd|ƒ}y4|jdd ƒ}|d kszt|d fƒ‚Wn tk r}|j|ƒnXdS( NiiiisAThis version of Python doesn't support decorators, skipping testss„ #@classmethod #def myClassMethod() #return '$foo = %s' % $foo #end def RRtbars $foo = bars3Template class method didn't return what I expected(Rt version_infoRR t myClassMethodR tAttributeErrortfail(R ttemplatetrctex((sC/opt/freeware/lib/python2.7/site-packages/Cheetah/Tests/Template.pyttest_BasicDecorator&s&"(RRRr(((sC/opt/freeware/lib/python2.7/site-packages/Cheetah/Tests/Template.pyRi%stStaticMethodSupportcBseZd„ZRS(cCs¢tjddkr/tjddkr/dGHdSd}tjd|ƒ}y4|jdd ƒ}|d kszt|d fƒ‚Wn tk r}|j|ƒnXdS( NiiiisAThis version of Python doesn't support decorators, skipping testss† #@staticmethod #def myStaticMethod() #return '$foo = %s' % $foo #end def RRRjs $foo = bars3Template class method didn't return what I expected(RRkRR tmyStaticMethodR RmRn(R RoRpRq((sC/opt/freeware/lib/python2.7/site-packages/Cheetah/Tests/Template.pyRr8s&"(RRRr(((sC/opt/freeware/lib/python2.7/site-packages/Cheetah/Tests/Template.pyRs7stUselesscBseZd„ZRS(cCs dddgS(Niii((R ((sC/opt/freeware/lib/python2.7/site-packages/Cheetah/Tests/Template.pytboinkJs(RRRv(((sC/opt/freeware/lib/python2.7/site-packages/Cheetah/Tests/Template.pyRuIstMultipleInheritanceSupportcBseZd„ZRS(cCsud}tj|ditd6ditd6ƒ}|ƒ}|jƒ}|dddd d gksqt|d fƒ‚dS( Ns… #extends Template, Useless #def foo() #return [4,5] + $boink() #end def R4RuRYtautoImportForExtendsDirectiveiiiiisUnexpected result(RR RuR:RR (R Rotresult((sC/opt/freeware/lib/python2.7/site-packages/Cheetah/Tests/Template.pytrunTestNs    (RRRz(((sC/opt/freeware/lib/python2.7/site-packages/Cheetah/Tests/Template.pyRwMstSubclassSearchListTestcBseZdZd„ZRS(sy Verify that if we subclass Template, we can still use attributes on that subclass in the searchList cCs<dtfd„ƒY}|dƒ}|jt|ƒdƒdS(NtSubcBseZdZRS(tHola(RRtgreeting(((sC/opt/freeware/lib/python2.7/site-packages/Cheetah/Tests/Template.pyR|bss!When we meet, I say "${greeting}"sWhen we meet, I say "Hola"(Rt assertEqualstunicode(R R|ttmpl((sC/opt/freeware/lib/python2.7/site-packages/Cheetah/Tests/Template.pyRzas (RRRARz(((sC/opt/freeware/lib/python2.7/site-packages/Cheetah/Tests/Template.pyR{\st__main__(tpdbRttypesRtos.pathRR#tunittestR]RRktmajorVertminorVerRtTestCaseRRRBRDRfRiRstobjectRuRwR{Rtmain(((sC/opt/freeware/lib/python2.7/site-packages/Cheetah/Tests/Template.pyts,         žS