當前位置: 首頁>>代碼示例>>Python>>正文


Python simple.Simple類代碼示例

本文整理匯總了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!")
開發者ID:GbalsaC,項目名稱:bitnamiP,代碼行數:7,代碼來源:test_specloader.py

示例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
開發者ID:holizz,項目名稱:pystache,代碼行數:8,代碼來源:test_view.py

示例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')
開發者ID:holizz,項目名稱:pystache,代碼行數:8,代碼來源:test_view.py

示例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')
開發者ID:GbalsaC,項目名稱:bitnamiP,代碼行數:11,代碼來源:test_specloader.py

示例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")
開發者ID:jakearchibald,項目名稱:pystache,代碼行數:11,代碼來源:test_view.py

示例6: test_basic

 def test_basic(self):
     view = Simple("Hi {{thing}}!", { 'thing': 'world' })
     self.assertEquals(view.render(), "Hi world!")
開發者ID:enaeseth,項目名稱:pystache,代碼行數:3,代碼來源:test_view.py

示例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!")
開發者ID:enaeseth,項目名稱:pystache,代碼行數:6,代碼來源:test_view.py

示例8: test_non_callable_attributes

 def test_non_callable_attributes(self):
     view = Simple()
     view.thing = 'Chris'
     self.assertEquals(view.render(), "Hi Chris!")
開發者ID:enaeseth,項目名稱:pystache,代碼行數:4,代碼來源:test_view.py

示例9: test_basic_method_calls

 def test_basic_method_calls(self):
     view = Simple()
     self.assertEquals(view.render(), "Hi pizza!")
開發者ID:enaeseth,項目名稱:pystache,代碼行數:3,代碼來源:test_view.py

示例10: test_template_load

 def test_template_load(self):
     view = Simple(thing='world')
     self.assertEquals(view.render(), "Hi world!")
開發者ID:enaeseth,項目名稱:pystache,代碼行數:3,代碼來源:test_view.py

示例11: test_kwargs

 def test_kwargs(self):
     view = Simple("Hi {{thing}}!", thing='world')
     self.assertEquals(view.render(), "Hi world!")
開發者ID:enaeseth,項目名稱:pystache,代碼行數:3,代碼來源:test_view.py

示例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")
開發者ID:holizz,項目名稱:pystache,代碼行數:3,代碼來源:test_view.py

示例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'})
開發者ID:holizz,項目名稱:pystache,代碼行數:5,代碼來源:test_view.py

示例14: test_basic

 def test_basic(self):
     view = Simple("Hi {{thing}}!", {"thing": "world"})
     self.assertEquals(view.render(), "Hi world!")
開發者ID:nickretallack,項目名稱:pystache,代碼行數:3,代碼來源:test_view.py

示例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"})
開發者ID:nickretallack,項目名稱:pystache,代碼行數:5,代碼來源:test_view.py


注:本文中的examples.simple.Simple類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。