当前位置: 首页>>代码示例>>Python>>正文


Python pystache.TemplateSpec类代码示例

本文整理汇总了Python中pystache.TemplateSpec的典型用法代码示例。如果您正苦于以下问题:Python TemplateSpec类的具体用法?Python TemplateSpec怎么用?Python TemplateSpec使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了TemplateSpec类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_load__template__correct_loader

    def test_load__template__correct_loader(self):
        """
        Test that reader.unicode() is called correctly.

        This test tests that the correct reader is called with the correct
        arguments.  This is a catch-all test to supplement the other
        test cases.  It tests SpecLoader.load() independent of reader.unicode()
        being implemented correctly (and tested).

        """
        class MockLoader(Loader):

            def __init__(self):
                self.s = None
                self.encoding = None

            # Overrides the existing method.
            def unicode(self, s, encoding=None):
                self.s = s
                self.encoding = encoding
                return u"foo"

        loader = MockLoader()
        custom_loader = SpecLoader()
        custom_loader.loader = loader

        view = TemplateSpec()
        view.template = "template-foo"
        view.template_encoding = "encoding-foo"

        # Check that our unicode() above was called.
        self._assert_template(custom_loader, view, u'foo')
        self.assertEqual(loader.s, "template-foo")
        self.assertEqual(loader.encoding, "encoding-foo")
开发者ID:tobiasandtobias,项目名称:pystache,代码行数:34,代码来源:test_specloader.py

示例2: test_find__template_path

 def test_find__template_path(self):
     """Test _find() with TemplateSpec.template_path."""
     loader = self._make_specloader()
     custom = TemplateSpec()
     custom.template_path = "path/foo"
     actual = loader._find(custom)
     self.assertPaths(actual, "path/foo")
开发者ID:SvetlanaM,项目名称:EnabledCityPaloAlto,代码行数:7,代码来源:test_specloader.py

示例3: __init__

 def __init__(self, graph, desc, params, cookie, agent,
              openidProxyHeader, forwardedFor):
     TemplateSpec.__init__(self)
     self.graph = graph
     self.desc = desc
     self.params, self.cookie, self.agent = params, cookie, agent
     self.openidProxyHeader = openidProxyHeader
     self.forwardedFor = forwardedFor
开发者ID:,项目名称:,代码行数:8,代码来源:

示例4: test_load__template__unicode_non_ascii

    def test_load__template__unicode_non_ascii(self):
        """
        Test the template attribute: non-ascii unicode string.

        """
        custom = TemplateSpec()
        custom.template = u"é"

        self._assert_template(SpecLoader(), custom, u"é")
开发者ID:clach04,项目名称:pystache,代码行数:9,代码来源:test_template_spec.py

示例5: test_load__template__type_unicode

    def test_load__template__type_unicode(self):
        """
        Test the template attribute: unicode string.

        """
        custom = TemplateSpec()
        custom.template = u"abc"

        self._assert_template(SpecLoader(), custom, u"abc")
开发者ID:clach04,项目名称:pystache,代码行数:9,代码来源:test_template_spec.py

示例6: test_load__template__type_str

    def test_load__template__type_str(self):
        """
        Test the template attribute: str string.

        """
        custom = TemplateSpec()
        custom.template = "abc"

        spec_loader = self._make_specloader()
        self._assert_template(spec_loader, custom, u"abc")
开发者ID:tobiasandtobias,项目名称:pystache,代码行数:10,代码来源:test_specloader.py

示例7: test_load__template__unicode_non_ascii

    def test_load__template__unicode_non_ascii(self):
        """
        Test the template attribute: non-ascii unicode string.

        """
        custom = TemplateSpec()
        custom.template = "é"

        spec_loader = self._make_specloader()
        self._assert_template(spec_loader, custom, "é")
开发者ID:phihag,项目名称:py3stache,代码行数:10,代码来源:test_specloader.py

示例8: test_load__template__with_template_encoding

    def test_load__template__with_template_encoding(self):
        """
        Test the template attribute: with template encoding attribute.

        """
        custom = TemplateSpec()
        custom.template = u'é'.encode('utf-8')

        self.assertRaises(UnicodeDecodeError, self._assert_template, SpecLoader(), custom, u'é')

        custom.template_encoding = 'utf-8'
        self._assert_template(SpecLoader(), custom, u'é')
开发者ID:clach04,项目名称:pystache,代码行数:12,代码来源:test_template_spec.py

示例9: test_template_path_for_partials

    def test_template_path_for_partials(self):
        """
        Test that View.template_rel_path is respected for partials.

        """
        spec = TemplateSpec()
        spec.template = "Partial: {{>tagless}}"

        renderer1 = Renderer()
        renderer2 = Renderer(search_dirs=EXAMPLES_DIR)

        self.assertRaises(IOError, renderer1.render, spec)

        actual = renderer2.render(spec)
        self.assertEqual(actual, "Partial: No tags...")
开发者ID:tobiasandtobias,项目名称:pystache,代码行数:15,代码来源:test_specloader.py

示例10: test_load__template__with_template_encoding

    def test_load__template__with_template_encoding(self):
        """
        Test the template attribute: with template encoding attribute.

        """
        custom = TemplateSpec()
        custom.template_encoding = 'ascii'
        custom.template = 'é'.encode('utf-8')

        spec_loader = self._make_specloader()

        self.assertRaises(UnicodeDecodeError, self._assert_template, spec_loader, custom, 'é')

        custom.template_encoding = 'utf-8'
        self._assert_template(spec_loader, custom, 'é')
开发者ID:GaloisInc,项目名称:echronos,代码行数:15,代码来源:test_specloader.py


注:本文中的pystache.TemplateSpec类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。