本文整理汇总了Python中examples.simple.Simple类的典型用法代码示例。如果您正苦于以下问题:Python Simple类的具体用法?Python Simple怎么用?Python Simple使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Simple类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_non_callable_attributes
def test_non_callable_attributes(self):
view = Simple()
view.thing = 'Chris'
renderer = Renderer()
actual = renderer.render(view)
self.assertEqual(actual, "Hi Chris!")
示例2: test_template_load_from_multiple_path
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
示例3: test_accessing_properties_on_parent_object_from_child_objects
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')
示例4: test_accessing_properties_on_parent_object_from_child_objects
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, u'derp')
示例5: test_render__partials
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")
示例6: test_basic
def test_basic(self):
view = Simple("Hi {{thing}}!", { 'thing': 'world' })
self.assertEquals(view.render(), "Hi world!")
示例7: test_view_instances_as_attributes
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!")
示例8: test_non_callable_attributes
def test_non_callable_attributes(self):
view = Simple()
view.thing = 'Chris'
self.assertEquals(view.render(), "Hi Chris!")
示例9: test_basic_method_calls
def test_basic_method_calls(self):
view = Simple()
self.assertEquals(view.render(), "Hi pizza!")
示例10: test_template_load
def test_template_load(self):
view = Simple(thing='world')
self.assertEquals(view.render(), "Hi world!")
示例11: test_kwargs
def test_kwargs(self):
view = Simple("Hi {{thing}}!", thing='world')
self.assertEquals(view.render(), "Hi world!")
示例12: test_basic_sections
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")
示例13: test_context_returns_a_flattened_dict
def test_context_returns_a_flattened_dict(self):
view = Simple()
view.context_list = [{'one':'1'}, {'two':'2'}, object()]
self.assertEqual(view.context, {'one': '1', 'two': '2'})
示例14: test_basic
def test_basic(self):
view = Simple("Hi {{thing}}!", {"thing": "world"})
self.assertEquals(view.render(), "Hi world!")
示例15: test_context_returns_a_flattened_dict
def test_context_returns_a_flattened_dict(self):
view = Simple()
view.context_list = [{"one": "1"}, {"two": "2"}, object()]
self.assertEqual(view.context, {"one": "1", "two": "2"})