本文整理汇总了Python中snippets.base.tests.SnippetFactory.build方法的典型用法代码示例。如果您正苦于以下问题:Python SnippetFactory.build方法的具体用法?Python SnippetFactory.build怎么用?Python SnippetFactory.build使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类snippets.base.tests.SnippetFactory
的用法示例。
在下文中一共展示了SnippetFactory.build方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_render_no_snippet_id
# 需要导入模块: from snippets.base.tests import SnippetFactory [as 别名]
# 或者: from snippets.base.tests.SnippetFactory import build [as 别名]
def test_render_no_snippet_id(self):
"""
If a snippet that hasn't been saved to the database yet is rendered, the snippet ID
shouldn't be included in the template context.
"""
snippet = SnippetFactory.build(template__code='<p>{{ snippet_id }}</p>')
snippet.template.render = Mock()
snippet.render()
snippet.template.render.assert_called_with({})
示例2: test_render_data_with_snippet_id
# 需要导入模块: from snippets.base.tests import SnippetFactory [as 别名]
# 或者: from snippets.base.tests.SnippetFactory import build [as 别名]
def test_render_data_with_snippet_id(self):
"""
Any strings included in the template context should have the
substring "<snippet_id>" replaced with the ID of the snippet.
"""
snippet = SnippetFactory.build(template__code='<p>{{ code }}</p>',
data='{"code": "snippet id <snippet_id>", "foo": true}')
snippet.template.render = Mock()
snippet.render()
snippet.template.render.assert_called_with({'code': 'snippet id 0', 'snippet_id': 0,
'foo': True})