本文整理汇总了Python中test.assert_raises_message函数的典型用法代码示例。如果您正苦于以下问题:Python assert_raises_message函数的具体用法?Python assert_raises_message怎么用?Python assert_raises_message使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了assert_raises_message函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_names_on_context
def test_names_on_context(self):
for name in ('context', 'loop', 'UNDEFINED'):
assert_raises_message(
exceptions.NameConflictError,
r"Reserved words passed to render\(\): %s" % name,
Template("x").render, **{name:'foo'}
)
开发者ID:SvenDowideit,项目名称:clearlinux,代码行数:7,代码来源:test_template.py
示例2: test_names_in_template
def test_names_in_template(self):
for name in ('context', 'loop', 'UNDEFINED'):
assert_raises_message(
exceptions.NameConflictError,
r"Reserved words declared in template: %s" % name,
Template, "<%% %s = 5 %%>" % name
)
开发者ID:SvenDowideit,项目名称:clearlinux,代码行数:7,代码来源:test_template.py
示例3: test_load_plugin_failure
def test_load_plugin_failure(self):
loader = util.PluginLoader("fakegroup")
assert_raises_message(
exceptions.RuntimeException,
"Can't load plugin fakegroup fake",
loader.load, "fake"
)
开发者ID:JasonZengJ,项目名称:puzzle,代码行数:7,代码来源:test_util.py
示例4: test_out_of_context_access
def test_out_of_context_access(self):
template = Template("""${loop.index}""")
assert_raises_message(
errors.RuntimeException,
"No loop context is established",
template.render
)
开发者ID:whiteclover,项目名称:Choco,代码行数:7,代码来源:test_loop.py
示例5: test_dont_accept_relative_outside_of_root
def test_dont_accept_relative_outside_of_root(self):
"""test the mechanics of an include where
the include goes outside of the path"""
tl = lookup.TemplateLookup(directories=[os.path.join(template_base, "subdir")])
index = tl.get_template("index.html")
ctx = runtime.Context(FastEncodingBuffer())
ctx._with_template=index
assert_raises_message(
errors.TemplateLookupException,
"Template uri \"../index.html\" is invalid - it "
"cannot be relative outside of the root path",
runtime._lookup_template, ctx, "../index.html", index.uri
)
assert_raises_message(
errors.TemplateLookupException,
"Template uri \"../othersubdir/foo.html\" is invalid - it "
"cannot be relative outside of the root path",
runtime._lookup_template, ctx, "../othersubdir/foo.html", index.uri
)
# this is OK since the .. cancels out
t = runtime._lookup_template(ctx, "foo/../index.html", index.uri)
开发者ID:whiteclover,项目名称:Choco,代码行数:25,代码来源:test_lookup.py
示例6: test_names_on_context
def test_names_on_context(self):
for name in ("context", "loop", "UNDEFINED"):
assert_raises_message(
exceptions.NameConflictError,
r"Reserved words passed to render\(\): %s" % name,
Template("x").render,
**{name: "foo"}
)
开发者ID:JasonZengJ,项目名称:puzzle,代码行数:8,代码来源:test_template.py
示例7: test_no_named_in_def
def test_no_named_in_def(self):
assert_raises_message(
exceptions.CompileException,
"Named block 'y' not allowed inside of def 'q'",
Template,
"""
<%def name="q()">
<%block name="y">
</%block>
</%def>
""")
开发者ID:2013Commons,项目名称:HUE-SHARK,代码行数:11,代码来源:test_block.py
示例8: test_unmatched_control_2
def test_unmatched_control_2(self):
template = """
% if foo:
% for x in range(1,5):
% endfor
"""
assert_raises_message(
exceptions.SyntaxException, "Unterminated control keyword: 'if' at line: 3 char: 1", Lexer(template).parse
)
开发者ID:anmnsg,项目名称:webapp-improved,代码行数:11,代码来源:test_lexer.py
示例9: test_unmatched_control
def test_unmatched_control(self):
template = """
% if foo:
% for x in range(1,5):
% endif
"""
assert_raises_message(
errors.SyntaxException,
"Keyword 'endif' doesn't match keyword 'for' at line: 5 char: 1",
Lexer(template).parse
)
开发者ID:whiteclover,项目名称:Choco,代码行数:12,代码来源:test_lexer.py
示例10: test_anonymous_block_namespace_raises
def test_anonymous_block_namespace_raises(self):
assert_raises_message(
exceptions.CompileException,
"Can't put anonymous blocks inside <%namespace>",
Template, """
<%namespace name="foo">
<%block>
block
</%block>
</%namespace>
"""
)
开发者ID:2013Commons,项目名称:HUE-SHARK,代码行数:12,代码来源:test_block.py
示例11: test_nested_dupe_names_raise
def test_nested_dupe_names_raise(self):
assert_raises_message(
exceptions.CompileException,
"%def or %block named 'header' already exists in this template.",
Template,
"""
<%inherit file="base"/>
<%block name="header">
<%block name="header">
inner header
</%block>
</%block>
"""
)
开发者ID:2013Commons,项目名称:HUE-SHARK,代码行数:14,代码来源:test_block.py
示例12: test_name_collision_blocks_toplevel
def test_name_collision_blocks_toplevel(self):
assert_raises_message(
exceptions.CompileException,
"%def or %block named 'x' already exists in this template",
Template,
"""
<%block name="x">
block
</%block>
foob
<%block name="x">
block
</%block>
"""
)
开发者ID:2013Commons,项目名称:HUE-SHARK,代码行数:17,代码来源:test_block.py
示例13: test_dont_accept_relative_outside_of_root
def test_dont_accept_relative_outside_of_root(self):
assert_raises_message(
exceptions.TemplateLookupException,
"Template uri \"../../foo.html\" is invalid - it "
"cannot be relative outside of the root path",
Template, "test", uri="../../foo.html",
)
assert_raises_message(
exceptions.TemplateLookupException,
"Template uri \"/../../foo.html\" is invalid - it "
"cannot be relative outside of the root path",
Template, "test", uri="/../../foo.html",
)
# normalizes in the root is OK
t = Template("test", uri="foo/bar/../../foo.html")
eq_(t.uri, "foo/bar/../../foo.html")
开发者ID:SvenDowideit,项目名称:clearlinux,代码行数:18,代码来源:test_template.py
示例14: test_named_block_in_call
def test_named_block_in_call(self):
assert_raises_message(
exceptions.CompileException,
"Named block 'y' not allowed inside of <%call> tag",
Template,"""
<%self:foo x="5">
<%block name="y">
this is the block
</%block>
</%self:foo>
<%def name="foo(x)">
foo:
${caller.body()}
${caller.y()}
</%def>
""")
开发者ID:2013Commons,项目名称:HUE-SHARK,代码行数:18,代码来源:test_block.py
示例15: test_name_collision_blocks_nested_def
def test_name_collision_blocks_nested_def(self):
assert_raises_message(
exceptions.CompileException,
"Named block 'x' not allowed inside of def 'foo'",
Template,
"""
<%def name="foo()">
<%block name="x">
block
</%block>
foob
<%block name="x">
block
</%block>
</%def>
"""
)
开发者ID:2013Commons,项目名称:HUE-SHARK,代码行数:19,代码来源:test_block.py
注:本文中的test.assert_raises_message函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论