def test_accessing_properties_on_parent_object_from_child_objects(self): parent = Thing() parent.this = 'derp' parent.children = [Thing()] view = Simple(context={'parent': parent}) view.template = "{{#parent}}{{#children}}{{this}}{{/children}}{{/parent}}" self.assertEquals(view.render(), 'derp')
def test_template_load_from_multiple_path(self): path = Simple.template_path Simple.template_path = ('examples/nowhere','examples',) try: view = Simple(thing='world') self.assertEquals(view.render(), "Hi world!") finally: Simple.template_path = path
def test_render__partials(self): """ Test passing partials to View.__init__(). """ template = "{{>partial}}" partials = {"partial": "Loaded from dictionary"} view = Simple(template=template, partials=partials) actual = view.render() self.assertEquals(actual, "Loaded from dictionary")
def test_template_load(self): view = Simple(thing='world') self.assertEquals(view.render(), "Hi world!")
def test_kwargs(self): view = Simple("Hi {{thing}}!", thing='world') self.assertEquals(view.render(), "Hi world!")
def test_basic_sections(self): view = Simple("{{#x}}{{#x}}x{{/x}}{{/x}}", { 'x': [{'x':[1,2,3]},{'x':[4,5,6]}] }) self.assertEquals(view.render(), "xxxxxx")
def test_view_instances_as_attributes(self): other = Simple(name='chris') other.template = '{{name}}' view = Simple() view.thing = other self.assertEquals(view.render(), "Hi chris!")
def test_basic_method_calls(self): view = Simple() self.assertEquals(view.render(), "Hi pizza!")
def test_basic(self): view = Simple("Hi {{thing}}!", {'thing': 'world'}) self.assertEquals(view.render(), "Hi world!")
def test_non_callable_attributes(self): view = Simple() view.thing = 'Chris' self.assertEquals(view.render(), "Hi Chris!")
def test_basic(self): view = Simple("Hi {{thing}}!", { 'thing': 'world' }) self.assertEquals(view.render(), "Hi world!")
def test_basic(self): view = Simple("Hi {{thing}}!", {"thing": "world"}) self.assertEquals(view.render(), "Hi world!")