۶eTc@sddlZddlZddlZddlZddlZddlZddlZddlZddlm Z ej dej dZ Z e e fZ dejfdYZdefdYZd efd YZd efd YZd efdYZdefdYZdefdYZdefdYZdefdYZdefdYZedkrejndS(iN(tTemplateiit TemplateTestcBseZRS((t__name__t __module__(((sE/opt/freeware/lib64/python2.7/site-packages/Cheetah/Tests/Template.pyRstClassMethods_compilecBs_eZdZdZdZdZdZdZdZdZ dZ d Z RS( sI am using the same Cheetah source for each test to root out clashes caused by the compile caching in Template.compile(). cCs,tjdd}|didd6}dS(Ntsources$foot namespacesitfoo(Rtcompile(tselftklasstt((sE/opt/freeware/lib64/python2.7/site-packages/Cheetah/Tests/Template.pyttest_basicUsagescCstjdddt}|idd6}tjddd|}|idd6}tjddd|}|idd6}tjdddd}|idd6}dS(NRs$foot baseclassiRs#implements dummy $bartdict(RRR(R R R tklass2tklass3tklass4((sE/opt/freeware/lib64/python2.7/site-packages/Cheetah/Tests/Template.pyttest_baseclassArgscCsftdkrdStj}z2tjdddtd|}tj|j}Wdt j |tXdS(NiiRs$footcacheModuleFilesForTracebackstcacheDirForModuleFiles(ii( t versionTuplettempfiletmkdtempRRtTruetsystmodulesRtshutiltrmtree(R ttmpDirR tmod((sE/opt/freeware/lib64/python2.7/site-packages/Cheetah/Tests/Template.pyttest_moduleFileCaching.s   cCs2tjdddd}|didd6}dS(NRs$foot classNametfoo123RiR(RR(R R R ((sE/opt/freeware/lib64/python2.7/site-packages/Cheetah/Tests/Template.pyttest_classNameArg?scCstjdddd}tjd}|didd6}tjddddd d }tjd}|didd6}dS( NRs$foot moduleNametfoo99RiRtfoo1R tfoo2(RRRR(R R RR ((sE/opt/freeware/lib64/python2.7/site-packages/Cheetah/Tests/Template.pyttest_moduleNameArgEs   c Csutjdddddd}|didd 6}tjddd d ddddd t}|idd 6}dS( NRs$fooR R!tmainMethodNamettestMethRiRR#tfooXXXR (RRR(R R R ((sE/opt/freeware/lib64/python2.7/site-packages/Cheetah/Tests/Template.pyttest_mainMethodNameArgVs  c Cstjdddidd6}|}tjddddditd6}|idd6}tjddddditd6dd6}|}dS(NRs$foot moduleGlobalsiRR tTest1(RRR(R R R RR((sE/opt/freeware/lib64/python2.7/site-packages/Cheetah/Tests/Template.pyttest_moduleGlobalsArgms  c Cstjdddddtdt}|didd 6}tjdddddt}|didd 6}tjdddddt}|didd 6}dS( NRs$fooR tunique58tcacheCompilationResultstkeepRefToGeneratedCodeRiR(RRtFalseR(R R R RR((sE/opt/freeware/lib64/python2.7/site-packages/Cheetah/Tests/Template.pyttest_keepRefToGeneratedCodeArg~s   cCstjdddddt}|didd6}tjdddddt}|didd6}tjdddd }|didd6}dS( NRs$fooR t unique111R0RiRt unique999099(RRR2R(R R R ((sE/opt/freeware/lib64/python2.7/site-packages/Cheetah/Tests/Template.pyttest_compilationCaches   ( RRt__doc__R RRR"R'R+R.R3R6(((sE/opt/freeware/lib64/python2.7/site-packages/Cheetah/Tests/Template.pyRs        tClassMethods_subclasscBseZdZRS(cCsytjdddt}|idd6}|jdd}|idd6}|jdd}|idd6}dS(NRs$fooR iRs#implements dummy $bar(RRRtsubclass(R R R RR((sE/opt/freeware/lib64/python2.7/site-packages/Cheetah/Tests/Template.pyR s(RRR (((sE/opt/freeware/lib64/python2.7/site-packages/Cheetah/Tests/Template.pyR8st PreprocessorscBs,eZdZdZdZdZRS(cCshd}djg|jD]}|j^q}idd6idd6d6}tj|d|}dS( Ns3 %set foo = @a $(@foo*10) @as s@ %ttokensictaRt preprocessors(tjoint splitlineststripRR(R tsrctlnR=R ((sE/opt/freeware/lib64/python2.7/site-packages/Cheetah/Tests/Template.pyttest_basicUsage1s . c Csd}dddY}|}ddlm}tj|}||}d}dtfdY}id d 6d d 6d d6}xedidd6i|d6i|d6id6idd6|d6|||gD]} tj|d| } qWdS(Ns"%set foo = 12 %%comment $(@foo*10)t Settings1cBseZdZRS(s@ %(RRR;(((sE/opt/freeware/lib64/python2.7/site-packages/Cheetah/Tests/Template.pyRDsi(tTemplatePreprocessorcSsdS(Ns$(12*10)(s$(12*10)N(tNone(Rtfile((sE/opt/freeware/lib64/python2.7/site-packages/Cheetah/Tests/Template.pyt preprocFuncstTemplateSubclasscBseZRS((RR(((sE/opt/freeware/lib64/python2.7/site-packages/Cheetah/Tests/Template.pyRIst@tcheetahVarStartTokent%tdirectiveStartTokens%%tcommentStartTokens@ %R;tcompilerSettingsttemplateInitArgsttemplateAPIClassR=((tCheetah.TemplateRERt_normalizePreprocessorSettingsR( R RARDREtsettingst preprocObjRHRIROtargR ((sE/opt/freeware/lib64/python2.7/site-packages/Cheetah/Tests/Template.pyt%test_normalizePreprocessorArgVariantss.          cCsd}djg|jD]}|j^q}x\idd6idd6d6idd6idd6d6gD]$}tj|d|}|}qkWdS( Ns %set foo = @a %def func1: #def func(arg): $arg("***") %% comment $(@foo*10) @func1 $func(lambda x:c"--$x--@a")s s@ %R;icR<RR=(R>R?R@RR(R RARBRVR R ((sE/opt/freeware/lib64/python2.7/site-packages/Cheetah/Tests/Template.pyttest_complexUsages." cCsfd}djg|jD]}|j^q}tj|dddt}|idd6}dS(Ns %i18n: This is a $string that needs translation %i18n id="foo", domain="root": This is a $string that needs translation s R=s@ %R s bit of texttstring(R>R?R@RRR(R RARBR R ((sE/opt/freeware/lib64/python2.7/site-packages/Cheetah/Tests/Template.pyt test_i18ns .(RRRCRWRXRZ(((sE/opt/freeware/lib64/python2.7/site-packages/Cheetah/Tests/Template.pyR:s % tTryExceptImportTestcBseZdZRS(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 RROtuseLegacyImportModeRiRN(RRR2(R RR R ((sE/opt/freeware/lib64/python2.7/site-packages/Cheetah/Tests/Template.pyt test_FailCases (RRR](((sE/opt/freeware/lib64/python2.7/site-packages/Cheetah/Tests/Template.pyR[stClassMethodSupportcBseZdZRS(cCstjddkr/tjddkr/dGHdSd}tjd|}y|jdd }Wn tk r}|j|nXdS( NiiiisAThis version of Python doesn't support decorators, skipping testss #@classmethod #def myClassMethod() #return '$foo = %s' % $foo #end def RRtbar(Rt version_infoRRt myClassMethodtAttributeErrortfail(R ttemplatetrctex((sE/opt/freeware/lib64/python2.7/site-packages/Cheetah/Tests/Template.pyttest_BasicDecorator&s&(RRRg(((sE/opt/freeware/lib64/python2.7/site-packages/Cheetah/Tests/Template.pyR^%stStaticMethodSupportcBseZdZRS(cCstjddkr/tjddkr/dGHdSd}tjd|}y|jdd }Wn tk r}|j|nXdS( NiiiisAThis version of Python doesn't support decorators, skipping testss #@staticmethod #def myStaticMethod() #return '$foo = %s' % $foo #end def RRR_(RR`RRtmyStaticMethodRbRc(R RdReRf((sE/opt/freeware/lib64/python2.7/site-packages/Cheetah/Tests/Template.pyRg8s&(RRRg(((sE/opt/freeware/lib64/python2.7/site-packages/Cheetah/Tests/Template.pyRh7stUselesscBseZdZRS(cCs dddgS(Niii((R ((sE/opt/freeware/lib64/python2.7/site-packages/Cheetah/Tests/Template.pytboinkJs(RRRk(((sE/opt/freeware/lib64/python2.7/site-packages/Cheetah/Tests/Template.pyRjIstMultipleInheritanceSupportcBseZdZRS(cCsHd}tj|ditd6ditd6}|}|j}dS(Ns #extends Template, Useless #def foo() #return [4,5] + $boink() #end def R,RjROtautoImportForExtendsDirective(RRRjR2R(R Rdtresult((sE/opt/freeware/lib64/python2.7/site-packages/Cheetah/Tests/Template.pytrunTestNs    (RRRo(((sE/opt/freeware/lib64/python2.7/site-packages/Cheetah/Tests/Template.pyRlMstSubclassSearchListTestcBseZdZdZRS(sy Verify that if we subclass Template, we can still use attributes on that subclass in the searchList cCs<dtfdY}|d}|jt|ddS(NtSubcBseZdZRS(tHola(RRtgreeting(((sE/opt/freeware/lib64/python2.7/site-packages/Cheetah/Tests/Template.pyRqbss!When we meet, I say "${greeting}"sWhen we meet, I say "Hola"(Rt assertEqualstunicode(R Rqttmpl((sE/opt/freeware/lib64/python2.7/site-packages/Cheetah/Tests/Template.pyRoas (RRR7Ro(((sE/opt/freeware/lib64/python2.7/site-packages/Cheetah/Tests/Template.pyRp\st__main__(tpdbRttypestostos.pathRRtunittestRRRR`tmajorVertminorVerRtTestCaseRRR8R:R[R^RhtobjectRjRlRpRtmain(((sE/opt/freeware/lib64/python2.7/site-packages/Cheetah/Tests/Template.pyts,         S