Skip to content

Instantly share code, notes, and snippets.

@rtyler
Created June 8, 2009 23:30
Show Gist options
  • Select an option

  • Save rtyler/126142 to your computer and use it in GitHub Desktop.

Select an option

Save rtyler/126142 to your computer and use it in GitHub Desktop.
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