本文整理汇总了Python中testing.util.assert_raises_exactly函数的典型用法代码示例。如果您正苦于以下问题:Python assert_raises_exactly函数的具体用法?Python assert_raises_exactly怎么用?Python assert_raises_exactly使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了assert_raises_exactly函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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')
示例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')
示例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')
示例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(')
示例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')
示例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')
示例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')
示例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')
示例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')
示例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 +')
示例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)')
示例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')
示例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')
示例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')
示例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]')