本文整理汇总了Python中testing.util.assert_raises_exactly函数的典型用法代码示例。如果您正苦于以下问题:Python assert_raises_exactly函数的具体用法?Python assert_raises_exactly怎么用?Python assert_raises_exactly使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了assert_raises_exactly函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_assert_raises_subclass
def test_assert_raises_subclass():
class MyClass(ValueError):
pass
with pytest.raises(AssertionError):
with assert_raises_exactly(ValueError, 'herpderp'):
raise MyClass('herpderp')
开发者ID:Yelp,项目名称:yelp_cheetah,代码行数:7,代码来源:util_test.py
示例2: test_filter_with_variable
def test_filter_with_variable():
with assert_raises_exactly(
ParseError,
'\n\n'
"Filters should be in the filterLib\n"
'Line 1, column 9\n'
'\n'
'Line|Cheetah Code\n'
'----|-------------------------------------------------------------\n'
'1 |#filter $MyFilter\n'
' ^\n'
):
compile_to_class('#filter $MyFilter')
开发者ID:struys,项目名称:yelp_cheetah,代码行数:13,代码来源:Parser_test.py
示例3: test_invalid_identifier
def test_invalid_identifier():
with assert_raises_exactly(
ParseError,
'\n\n'
'Invalid identifier\n'
'Line 1, column 5\n'
'\n'
'Line|Cheetah Code\n'
'----|-------------------------------------------------------------\n'
'1 |#def\n'
' ^\n'
):
compile_to_class('#def\n')
开发者ID:struys,项目名称:yelp_cheetah,代码行数:13,代码来源:Parser_test.py
示例4: test_reach_eof
def test_reach_eof():
with assert_raises_exactly(
ParseError,
'\n\n'
"EOF was reached before a matching ')' was found for the '('\n"
'Line 1, column 7\n'
'\n'
'Line|Cheetah Code\n'
'----|-------------------------------------------------------------\n'
'1 |#super(\n'
' ^\n'
):
compile_to_class('#super(')
开发者ID:struys,项目名称:yelp_cheetah,代码行数:13,代码来源:Parser_test.py
示例5: test_invalid_line_continuation
def test_invalid_line_continuation():
with assert_raises_exactly(
ParseError,
'\n\n'
'Line ending expected\n'
'Line 1, column 21\n'
'\n'
'Line|Cheetah Code\n'
'----|-------------------------------------------------------------\n'
'1 |#set foo = "bar" + \\hi, not a new line\n'
' ^\n'
):
compile_to_class('#set foo = "bar" + \\hi, not a new line')
开发者ID:struys,项目名称:yelp_cheetah,代码行数:13,代码来源:Parser_test.py
示例6: test_set_with_dollar_signs_raises
def test_set_with_dollar_signs_raises():
with assert_raises_exactly(
ParseError,
'\n\n'
'lvalue of #set cannot contain `$`\n'
'Line 1, column 6\n'
'\n'
'Line|Cheetah Code\n'
'----|-------------------------------------------------------------\n'
'1 |#set $foo = 1\n'
' ^\n'
):
compile_to_class('#set $foo = 1\n')
开发者ID:struys,项目名称:yelp_cheetah,代码行数:13,代码来源:Parser_test.py
示例7: test_parse_error_on_attr_with_var
def test_parse_error_on_attr_with_var():
with assert_raises_exactly(
ParseError,
'\n\n'
'Invalid #attr directive. It should contain simple Python literals.\n'
'Line 1, column 13\n'
'\n'
'Line|Cheetah Code\n'
'----|-------------------------------------------------------------\n'
'1 |#attr foo = $bar\n'
' ^\n'
):
compile_to_class('#attr foo = $bar\n')
开发者ID:struys,项目名称:yelp_cheetah,代码行数:13,代码来源:Parser_test.py
示例8: test_parse_error_on_attr_with_dollar_sign
def test_parse_error_on_attr_with_dollar_sign():
with assert_raises_exactly(
ParseError,
'\n\n'
'#attr directive must not contain `$`\n'
'Line 1, column 7\n'
'\n'
'Line|Cheetah Code\n'
'----|-------------------------------------------------------------\n'
'1 |#attr $foo = "hai"\n'
' ^\n'
):
compile_to_class('#attr $foo = "hai"\n')
开发者ID:struys,项目名称:yelp_cheetah,代码行数:13,代码来源:Parser_test.py
示例9: test_parse_error_for_multiple_inheritance
def test_parse_error_for_multiple_inheritance():
with assert_raises_exactly(
ParseError,
'\n\n'
'yelp_cheetah does not support multiple inheritance\n'
'Line 1, column 33\n'
'\n'
'Line|Cheetah Code\n'
'----|-------------------------------------------------------------\n'
'1 |#extends Cheetah.Template, object\n'
' ^\n'
):
compile_to_class('#extends Cheetah.Template, object')
开发者ID:struys,项目名称:yelp_cheetah,代码行数:13,代码来源:Parser_test.py
示例10: test_unclosed_enclosure
def test_unclosed_enclosure():
with assert_raises_exactly(
ParseError,
'\n\n'
"EOF was reached before a matching '}' was found for the '{'\n"
'Line 1, column 2\n'
'\n'
'Line|Cheetah Code\n'
'----|-------------------------------------------------------------\n'
'1 |${hai +\n'
' ^\n'
):
compile_to_class('${hai +')
开发者ID:struys,项目名称:yelp_cheetah,代码行数:13,代码来源:Parser_test.py
示例11: test_parse_error_for_implements_argspec
def test_parse_error_for_implements_argspec():
with assert_raises_exactly(
ParseError,
'\n\n'
'yelp_cheetah does not support argspecs for #implements\n'
'Line 1, column 16\n'
'\n'
'Line|Cheetah Code\n'
'----|-------------------------------------------------------------\n'
'1 |#implements foo(bar)\n'
' ^\n'
):
compile_to_class('#implements foo(bar)')
开发者ID:struys,项目名称:yelp_cheetah,代码行数:13,代码来源:Parser_test.py
示例12: test_invalid_end_directive
def test_invalid_end_directive():
with assert_raises_exactly(
ParseError,
'\n\n'
'Invalid end directive\n'
'Line 1, column 5\n'
'\n'
'Line|Cheetah Code\n'
'----|-------------------------------------------------------------\n'
'1 |#end\n'
' ^\n'
):
compile_to_class('#end\n')
开发者ID:struys,项目名称:yelp_cheetah,代码行数:13,代码来源:Parser_test.py
示例13: test_end_but_nothing_to_end
def test_end_but_nothing_to_end():
with assert_raises_exactly(
ParseError,
'\n\n'
'#end found, but nothing to end\n'
'Line 1, column 8\n'
'\n'
'Line|Cheetah Code\n'
'----|-------------------------------------------------------------\n'
'1 |#end if\n'
' ^\n'
):
compile_to_class('#end if\n')
开发者ID:struys,项目名称:yelp_cheetah,代码行数:13,代码来源:Parser_test.py
示例14: test_set_with_dollar_signs_raises
def test_set_with_dollar_signs_raises():
with assert_raises_exactly(
ParseError,
'\n\n'
"SyntaxError: can't assign to function call (<unknown>, line 1)\n\n"
'Line 1, column 13\n'
'\n'
'Line|Cheetah Code\n'
'----|-------------------------------------------------------------\n'
'1 |#py $foo = 1\n'
' ^\n'
):
compile_to_class('#py $foo = 1\n')
开发者ID:skoslowski,项目名称:yelp_cheetah,代码行数:13,代码来源:Parser_test.py
示例15: test_close_wrong_enclosure
def test_close_wrong_enclosure():
with assert_raises_exactly(
ParseError,
'\n\n'
"A ']' was found at line 1, col 4 before a matching '}' was found for the '{'\n"
'Line 1, column 2\n'
'\n'
'Line|Cheetah Code\n'
'----|-------------------------------------------------------------\n'
'1 |${a]\n'
' ^\n'
):
compile_to_class('${a]')
开发者ID:struys,项目名称:yelp_cheetah,代码行数:13,代码来源:Parser_test.py
示例16: test_unknown_macro_name
def test_unknown_macro_name():
with assert_raises_exactly(
UnknownDirectiveError,
'\n\n'
'Bad macro name: "foo". You may want to escape that # sign?\n'
'Line 1, column 2\n'
'\n'
'Line|Cheetah Code\n'
'----|-------------------------------------------------------------\n'
'1 |#foo\n'
' ^\n',
):
compile_to_class('#foo\n')
开发者ID:struys,项目名称:yelp_cheetah,代码行数:13,代码来源:Parser_test.py
示例17: test_unexpected_character_parse_error
def test_unexpected_character_parse_error():
with assert_raises_exactly(
ParseError,
'\n\n'
'Unexpected character.\n'
'Line 1, column 8\n'
'\n'
'Line|Cheetah Code\n'
'----|-------------------------------------------------------------\n'
'1 |#super(☃)\n'
' ^\n'
):
compile_to_class('#super(☃)')
开发者ID:struys,项目名称:yelp_cheetah,代码行数:13,代码来源:Parser_test.py
示例18: test_malformed_triple_quotes
def test_malformed_triple_quotes():
with assert_raises_exactly(
ParseError,
'\n\n'
'Malformed triple-quoted string\n'
'Line 1, column 3\n'
'\n'
'Line|Cheetah Code\n'
'----|-------------------------------------------------------------\n'
'1 |${"""}\n'
' ^\n',
):
compile_to_class('${"""}')
开发者ID:struys,项目名称:yelp_cheetah,代码行数:13,代码来源:Parser_test.py
示例19: test_expected_identifier_after_star
def test_expected_identifier_after_star():
with assert_raises_exactly(
ParseError,
'\n\n'
'Expected an identifier.\n'
'Line 1, column 9\n'
'\n'
'Line|Cheetah Code\n'
'----|-------------------------------------------------------------\n'
'1 |#super(*)\n'
' ^\n'
):
compile_to_class('#super(*)')
开发者ID:struys,项目名称:yelp_cheetah,代码行数:13,代码来源:Parser_test.py
示例20: test_unclosed_directives
def test_unclosed_directives():
with assert_raises_exactly(
ParseError,
'\n\n'
'Some #directives are missing their corresponding #end ___ tag: if\n'
'Line 1, column 9\n'
'\n'
'Line|Cheetah Code\n'
'----|-------------------------------------------------------------\n'
'1 |#if True\n'
' ^\n'
):
compile_to_class('#if True\n')
开发者ID:struys,项目名称:yelp_cheetah,代码行数:13,代码来源:Parser_test.py
注:本文中的testing.util.assert_raises_exactly函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论