"""Unit Tests for layout templates.""" __revision__ = "$Rev: 421 $" __author__ = "Daniel Miller " __copyright__ = "Copyright 2006, David Stanek" import kid def test_layout_error(): from kid.template_util import TemplateLayoutError try: kid.Template(""" """).serialize() except TemplateLayoutError, e: e = str(e) except Exception: e = 'wrong error' except: e = 'silent' assert "'no_layout'" in e assert 'not defined' in e assert 'while processing layout=' in e def test_dynamic_layout(): layout = kid.Template(""" ${body_content()} """) child = kid.Template(""" body content """, dynamic_layout=type(layout)) output = child.serialize() assert output.find("body content") > -1, \ "body_content function was not executed" def test_match_locals(): layout = kid.Template("""
""") child = kid.Template(""" test_var=${test_var} """, layout=type(layout), test_var="test value") output = child.serialize() assert output.find("test_var=test value") > -1, \ "match template was not executed" def test_def_locals(): layout = kid.Template(""" ${child_content()} """) child = kid.Template(""" test_var=${test_var} """, layout=type(layout), test_var="test value") output = child.serialize() assert output.find("test_var=test value") > -1, \ "child_content function was not executed"