def test_non_callable_attributes(self): view = Simple() view.thing = 'Chris' renderer = Renderer() actual = renderer.render(view) self.assertEqual(actual, "Hi Chris!")
def test_accessing_properties_on_parent_object_from_child_objects(self): parent = Thing() parent.this = 'derp' parent.children = [Thing()] view = Simple() view.template = "{{#parent}}{{#children}}{{this}}{{/children}}{{/parent}}" renderer = Renderer() actual = renderer.render(view, {'parent': parent}) self.assertString(actual, 'derp')
def test_render__view(self): """ Test rendering a View instance. """ renderer = Renderer() view = Simple() actual = renderer.render(view) self.assertEqual('Hi pizza!', actual)
def test_basic_method_calls(self): renderer = Renderer() actual = renderer.render(Simple()) self.assertString(actual, "Hi pizza!")
def test_non_existent_value_renders_blank(self): view = Simple() template = '{{not_set}} {{blank}}' self.assertEqual(pystache.Renderer().render(template), ' ')