Created
June 8, 2009 23:30
-
-
Save rtyler/126142 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class SuperDirective(OutputTest): | |
| def test1(self): | |
| tmpl1 = Template.compile(''' (99) | |
| #def foo: this is base foo | |
| #def bar(arg): super-''') | |
| tmpl2 = tmpl1.subclass(''' | |
| #implements dummy | |
| #def foo | |
| #super | |
| This is child foo | |
| #super(trans=trans) | |
| (1234) | |
| #end def | |
| #def bar(arg): #super() | |
| ''') | |
| expected = ('this is base foo ' | |
| 'This is child foo\nthis is base foo ' | |
| 'super-1234\n super-99') | |
| assert str(tmpl2()).strip()==expected | |
| def test_VarSetting(self): | |
| template = Template.compile(''' | |
| #def method(arg) | |
| #return [1,2] | |
| #end def | |
| ''') | |
| subtemplate = template.subclass(''' | |
| #def method(arg) | |
| #set sup = super(self.__class__, self).method(arg) | |
| $sup.extend([3,4]) | |
| #return sup | |
| #end def | |
| ''') | |
| subtemplate = subtemplate() | |
| rc = subtemplate.method('foo') | |
| assert rc == [1,2,3,4], (rc, 'fail') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment