本文整理汇总了Python中pystache.Renderer._make_render_engine方法的典型用法代码示例。如果您正苦于以下问题:Python Renderer._make_render_engine方法的具体用法?Python Renderer._make_render_engine怎么用?Python Renderer._make_render_engine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pystache.Renderer
的用法示例。
在下文中一共展示了Renderer._make_render_engine方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test__resolve_partial__not_found
# 需要导入模块: from pystache import Renderer [as 别名]
# 或者: from pystache.Renderer import _make_render_engine [as 别名]
def test__resolve_partial__not_found(self):
"""
Check that resolve_partial returns the empty string when a template is not found.
"""
renderer = Renderer()
engine = renderer._make_render_engine()
resolve_partial = engine.resolve_partial
self.assertString(resolve_partial('foo'), '')
示例2: test__load_partial__not_found__default
# 需要导入模块: from pystache import Renderer [as 别名]
# 或者: from pystache.Renderer import _make_render_engine [as 别名]
def test__load_partial__not_found__default(self):
"""
Check that load_partial provides a nice message when a template is not found.
"""
renderer = Renderer()
engine = renderer._make_render_engine()
load_partial = engine.load_partial
self.assertException(TemplateNotFoundError, "File 'foo.mustache' not found in dirs: ['.']",
load_partial, "foo")
示例3: test__literal__handles_unicode
# 需要导入模块: from pystache import Renderer [as 别名]
# 或者: from pystache.Renderer import _make_render_engine [as 别名]
def test__literal__handles_unicode(self):
"""
Test that interpolate(..., 'literal') doesn't try to "double decode" unicode.
"""
renderer = Renderer()
renderer.string_encoding = 'ascii'
engine = renderer._make_render_engine()
interpolate = engine.interpolate
self.assertEqual(interpolate("foo", 'literal', None), "foo")
示例4: test__escape__uses_renderer_escape
# 需要导入模块: from pystache import Renderer [as 别名]
# 或者: from pystache.Renderer import _make_render_engine [as 别名]
def test__escape__uses_renderer_escape(self):
"""
Test that escape uses the renderer's escape function.
"""
renderer = Renderer()
renderer.escape = lambda s: "**" + s
engine = renderer._make_render_engine()
escape = engine.escape
self.assertEqual(escape("foo"), "**foo")
示例5: test__literal__handles_unicode
# 需要导入模块: from pystache import Renderer [as 别名]
# 或者: from pystache.Renderer import _make_render_engine [as 别名]
def test__literal__handles_unicode(self):
"""
Test that literal doesn't try to "double decode" unicode.
"""
renderer = Renderer()
renderer.string_encoding = 'ascii'
engine = renderer._make_render_engine()
literal = engine.literal
self.assertEqual(literal("foo"), "foo")
示例6: test__literal__uses_renderer_unicode
# 需要导入模块: from pystache import Renderer [as 别名]
# 或者: from pystache.Renderer import _make_render_engine [as 别名]
def test__literal__uses_renderer_unicode(self):
"""
Test that literal uses the renderer's unicode function.
"""
renderer = Renderer()
renderer.unicode = lambda s: s.upper()
engine = renderer._make_render_engine()
literal = engine.literal
self.assertEquals(literal("foo"), "FOO")
示例7: test__escape__uses_renderer_unicode
# 需要导入模块: from pystache import Renderer [as 别名]
# 或者: from pystache.Renderer import _make_render_engine [as 别名]
def test__escape__uses_renderer_unicode(self):
"""
Test that escape uses the renderer's unicode function.
"""
renderer = Renderer()
renderer.unicode = lambda s: s.upper()
engine = renderer._make_render_engine()
escape = engine.escape
self.assertEquals(escape("foo"), "FOO")
示例8: test__interpolate__uses_renderer_escape
# 需要导入模块: from pystache import Renderer [as 别名]
# 或者: from pystache.Renderer import _make_render_engine [as 别名]
def test__interpolate__uses_renderer_escape(self):
"""
Test that interpolate uses the renderer's interpolate function.
"""
renderer = Renderer()
renderer.escape = lambda s: "**" + s
engine = renderer._make_render_engine()
interpolate = engine.interpolate
self.assertEqual(interpolate("foo", '', None), "**foo")
示例9: test__escape__uses_renderer_unicode
# 需要导入模块: from pystache import Renderer [as 别名]
# 或者: from pystache.Renderer import _make_render_engine [as 别名]
def test__escape__uses_renderer_unicode(self):
"""
Test that escape uses the renderer's unicode function.
"""
renderer = Renderer()
renderer.str = mock_unicode
engine = renderer._make_render_engine()
escape = engine.escape
b = "foo".encode('ascii')
self.assertEqual(escape(b), "FOO")
示例10: test__resolve_context
# 需要导入模块: from pystache import Renderer [as 别名]
# 或者: from pystache.Renderer import _make_render_engine [as 别名]
def test__resolve_context(self):
"""
Check resolve_context(): default arguments.
"""
renderer = Renderer()
engine = renderer._make_render_engine()
stack = ContextStack({'foo': 'bar'})
self.assertEqual('bar', engine.resolve_context(stack, 'foo'))
self.assertString('', engine.resolve_context(stack, 'missing'))
示例11: test__resolve_partial__not_found__missing_tags_strict
# 需要导入模块: from pystache import Renderer [as 别名]
# 或者: from pystache.Renderer import _make_render_engine [as 别名]
def test__resolve_partial__not_found__missing_tags_strict(self):
"""
Check that resolve_partial provides a nice message when a template is not found.
"""
renderer = Renderer()
renderer.missing_tags = 'strict'
engine = renderer._make_render_engine()
resolve_partial = engine.resolve_partial
self.assertException(TemplateNotFoundError, "File 'foo.mustache' not found in dirs: ['.']",
resolve_partial, "foo")
示例12: test__load_partial__not_found__dict
# 需要导入模块: from pystache import Renderer [as 别名]
# 或者: from pystache.Renderer import _make_render_engine [as 别名]
def test__load_partial__not_found__dict(self):
"""
Check that load_partial provides a nice message when a template is not found.
"""
renderer = Renderer()
renderer.partials = {}
engine = renderer._make_render_engine()
load_partial = engine.load_partial
# Include dict directly since str(dict) is different in Python 2 and 3:
# <type 'dict'> versus <class 'dict'>, respectively.
self.assertException(TemplateNotFoundError, "Name 'foo' not found in partials: %s" % dict,
load_partial, "foo")
示例13: test__resolve_context__missing_tags_strict
# 需要导入模块: from pystache import Renderer [as 别名]
# 或者: from pystache.Renderer import _make_render_engine [as 别名]
def test__resolve_context__missing_tags_strict(self):
"""
Check resolve_context(): missing_tags 'strict'.
"""
renderer = Renderer()
renderer.missing_tags = 'strict'
engine = renderer._make_render_engine()
stack = ContextStack({'foo': 'bar'})
self.assertEqual('bar', engine.resolve_context(stack, 'foo'))
self.assertException(KeyNotFoundError, "Key 'missing' not found: first part",
engine.resolve_context, stack, 'missing')
示例14: test__load_partial__not_found
# 需要导入模块: from pystache import Renderer [as 别名]
# 或者: from pystache.Renderer import _make_render_engine [as 别名]
def test__load_partial__not_found(self):
"""
Check that load_partial provides a nice message when a template is not found.
"""
renderer = Renderer()
renderer.partials = {}
engine = renderer._make_render_engine()
load_partial = engine.load_partial
try:
load_partial("foo")
raise Exception("Shouldn't get here")
except Exception, err:
self.assertEquals(str(err), "Partial not found with name: 'foo'")
示例15: test__escape__has_access_to_original_unicode_subclass
# 需要导入模块: from pystache import Renderer [as 别名]
# 或者: from pystache.Renderer import _make_render_engine [as 别名]
def test__escape__has_access_to_original_unicode_subclass(self):
"""
Test that escape receives strings with the unicode subclass intact.
"""
renderer = Renderer()
renderer.escape = lambda s: str(type(s).__name__)
engine = renderer._make_render_engine()
escape = engine.escape
class MyUnicode(str):
pass
self.assertEqual(escape("foo".encode('ascii')), str.__name__)
self.assertEqual(escape("foo"), str.__name__)
self.assertEqual(escape(MyUnicode("foo")), MyUnicode.__name__)