当前位置: 首页>>代码示例>>Python>>正文


Python util.assert_raises_exactly函数代码示例

本文整理汇总了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')
开发者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


注:本文中的testing.util.assert_raises_exactly函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。