۶eTc@s&ddlZddlZddlZddlZejdejdZZeefZdZ de fdYZ de fdYZ d ejfd YZd ejfd YZd ejfdYZdejfdYZdejfdYZedkr"ejndS(iNiicCstdkotdkS(sJ Python 2.3 is still supported by Cheetah, but doesn't support decorators ii(tmajorVertminorVer(((sH/opt/freeware/lib64/python2.7/site-packages/Cheetah/Tests/Regressions.pyt isPython23 stGetAttrExceptioncBseZRS((t__name__t __module__(((sH/opt/freeware/lib64/python2.7/site-packages/Cheetah/Tests/Regressions.pyRstCustomGetAttrClasscBseZdZRS(cCstd|dS(NsFAIL, %s(R(tselftname((sH/opt/freeware/lib64/python2.7/site-packages/Cheetah/Tests/Regressions.pyt __getattr__s(RRR (((sH/opt/freeware/lib64/python2.7/site-packages/Cheetah/Tests/Regressions.pyRst GetAttrTestcBs eZdZdZdZRS(s Test for an issue occurring when __getatttr__() raises an exception causing NameMapper to raise a NotFound exception cCsTt}y |jGHWn+tk r+}dS|jd|nX|jddS(NsInvalid exception raised: %ss#Should have had an exception raised(RtattrRtfail(Rtote((sH/opt/freeware/lib64/python2.7/site-packages/Cheetah/Tests/Regressions.pyttest_ValidExceptions  cCsld}tjjj|didt}|ditd6g}|sUtd|jt|jdS(NsJ #def raiseme() $obj.attr #end deftcompilerSettingstkeepRefToGeneratedCodet searchListtobjs-We should have a valid template object by now( tCheetahtTemplatetcompiletTrueRtAssertionErrortfailUnlessRaisesRtraiseme(Rttemplate((sH/opt/freeware/lib64/python2.7/site-packages/Cheetah/Tests/Regressions.pyttest_NotFoundException(s !(RRt__doc__RR(((sH/opt/freeware/lib64/python2.7/site-packages/Cheetah/Tests/Regressions.pyR s tInlineImportTestcBs5eZdZdZdZdZdZRS(cCsd}tjjj|ditd6dt}|dig}|sRtd|j}|dks|t|dfd S( s Verify that a bug introduced in v2.1.0 where an inline: #from module import class would result in the following code being generated: import class s #def myfunction() #if True #from os import path #return 17 Hello! #end if #end def RtuseLegacyImportModeRRs-We should have a valid template object by nowis Didn't get a proper return valueN(RRRtFalseRRt myfunction(RRtrc((sH/opt/freeware/lib64/python2.7/site-packages/Cheetah/Tests/Regressions.pyttest_FromFooImportThing6s ( cCsnd}tjjj|ditd6dt}|dig}|sRtdt|sjtddS(Ns #try #import invalidmodule #except #set invalidmodule = dict(FOO='BAR!') #end try $invalidmodule.FOO RRRRs-We should have a valid template object by nowsAWe weren't able to properly generate the result from the template(RRRR RRtstr(RR((sH/opt/freeware/lib64/python2.7/site-packages/Cheetah/Tests/Regressions.pyttest_ImportFailModuleNs (cCs9d}|jttjjj|ditd6dtdS(Nsf #from invalid import fail This should totally $fail RRR(Rt ImportErrorRRRR R(RR((sH/opt/freeware/lib64/python2.7/site-packages/Cheetah/Tests/Regressions.pyttest_ProperImportOfBadModule^scCs&d}|jttjjj|dS(Ns> #extends FakeyTemplate Boo! (RR&RRR(RR((sH/opt/freeware/lib64/python2.7/site-packages/Cheetah/Tests/Regressions.pyttest_AutoImportingfscCs9d}|jttjjj|ditd6dtdS(Ns< ### ### I like comments before import ### #extends Foo Bar RRR(RR&RRRR(RR((sH/opt/freeware/lib64/python2.7/site-packages/Cheetah/Tests/Regressions.pyttest_StuffBeforeImport_Legacyns(RRR#R%R'R(R)(((sH/opt/freeware/lib64/python2.7/site-packages/Cheetah/Tests/Regressions.pyR5s     tMantis_Issue_11_Regression_TestcBs eZdZdZdZRS(s Test case for bug outlined in Mantis issue #11: Output: Traceback (most recent call last): File "test.py", line 12, in t.respond() File "DynamicallyCompiledCheetahTemplate.py", line 86, in respond File "/usr/lib64/python2.6/cgi.py", line 1035, in escape s = s.replace("&", "&") # Must be done first! cCs[ddl}tjjddi|jd6dd6g}|sDt|jt|jdS(Nis$escape($request)Rtescapetfoobartrequest(tcgiRRR+RRtAttributeErrortrespond(RR.R((sH/opt/freeware/lib64/python2.7/site-packages/Cheetah/Tests/Regressions.pyttest_FailingBehaviors , cCsgddl}tjjddi|jd6dd6gditd6}|sQt|jsctdS( Nis$escape($request)RR+R,R-RtprioritizeSearchListOverSelf(R.RRR+RRR0(RR.R((sH/opt/freeware/lib64/python2.7/site-packages/Cheetah/Tests/Regressions.pyttest_FailingBehaviorWithSettings   (RRRR1R3(((sH/opt/freeware/lib64/python2.7/site-packages/Cheetah/Tests/Regressions.pyR*ys  tMantis_Issue_21_Regression_TestcBseZdZdZRS(s Test case for bug outlined in issue #21 Effectively @staticmethod and @classmethod decorated methods in templates don't properly define the _filter local, which breaks when using the NameMapper cCsPtr dSd}tjjj|}|s4t|jddsLtdS(Nsz #@staticmethod #def testMethod() This is my $output #end def toutputtbug(RRRRRt testMethod(RR((sH/opt/freeware/lib64/python2.7/site-packages/Cheetah/Tests/Regressions.pytrunTests   (RRRR8(((sH/opt/freeware/lib64/python2.7/site-packages/Cheetah/Tests/Regressions.pyR4stMantis_Issue_22_Regression_TestcBs eZdZdZdZRS(s Test case for bug outlined in issue #22 When using @staticmethod and @classmethod in conjunction with the #filter directive the generated code for the #filter is reliant on the `self` local, breaking the function cCsTdStrdSd}tjjj|}|s8t|jddsPtdS(Ns #@staticmethod #def testMethod() #filter None This is my $output #end filter #end def R5R6(RRRRRR7(RR((sH/opt/freeware/lib64/python2.7/site-packages/Cheetah/Tests/Regressions.pyttest_NoneFilters  cCsTdStrdSd}tjjj|}|s8t|jddsPtdS(Ns #@staticmethod #def testMethod() #filter Filter This is my $output #end filter #end def R5R6(RRRRRR7(RR((sH/opt/freeware/lib64/python2.7/site-packages/Cheetah/Tests/Regressions.pyttest_DefinedFilters   (RRRR:R;(((sH/opt/freeware/lib64/python2.7/site-packages/Cheetah/Tests/Regressions.pyR9s t__main__(tCheetah.NameMapperRtCheetah.Templatetsystunittestt version_infoRRt versionTupleRt ExceptionRtobjectRtTestCaseR RR*R4R9Rtmain(((sH/opt/freeware/lib64/python2.7/site-packages/Cheetah/Tests/Regressions.pyts      DK