Example #1
0
def test_assert_raises_subclass():
    class MyClass(ValueError):
        pass

    with pytest.raises(AssertionError):
        with assert_raises_exactly(ValueError, 'herpderp'):
            raise MyClass('herpderp')
Example #2
0
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')
Example #3
0
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')
Example #4
0
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]')
Example #5
0
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(')
Example #6
0
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')
Example #7
0
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')
Example #8
0
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')
Example #9
0
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')
Example #10
0
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 +')
Example #11
0
def test_weird_close_call():
    with assert_raises_exactly(
            ParseError, '\n\n'
            "Expected a ')' before an end '}'\n"
            'Line 1, column 6\n'
            '\n'
            'Line|Cheetah Code\n'
            '----|-------------------------------------------------------------\n'
            '1   |$foo(}\n'
            '          ^\n'):
        compile_to_class('$foo(}')
Example #12
0
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(☃)')
Example #13
0
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')
Example #14
0
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')
Example #15
0
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(*)')
Example #16
0
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')
Example #17
0
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)')
Example #18
0
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')
Example #19
0
def test_def_without_arglist_invalid():
    with assert_raises_exactly(
            ParseError, '\n\n'
            '#def must contain an argspec (at least ())\n'
            'Line 1, column 9\n'
            '\n'
            'Line|Cheetah Code\n'
            '----|-------------------------------------------------------------\n'
            '1   |#def foo\n'
            '             ^\n'
            '2   |#end def\n'):
        compile_to_class('#def foo\n' '#end def\n')
Example #20
0
def test_block_with_an_argspec_invalid():
    with assert_raises_exactly(
            ParseError, '\n\n'
            '#block must not have an argspec, did you mean #def?\n'
            'Line 1, column 11\n'
            '\n'
            'Line|Cheetah Code\n'
            '----|-------------------------------------------------------------\n'
            '1   |#block foo(bar)\n'
            '               ^\n'
            '2   |#end block\n'):
        compile_to_class('#block foo(bar)\n' '#end block\n')
Example #21
0
def test_self_in_arglist_invalid():
    with assert_raises_exactly(
            ParseError, '\n\n'
            'Do not specify `self` in an arglist, it is assumed\n'
            'Line 1, column 10\n'
            '\n'
            'Line|Cheetah Code\n'
            '----|-------------------------------------------------------------\n'
            '1   |#def foo(self, bar)\n'
            '              ^\n'
            '2   |#end def\n'):
        compile_to_class('#def foo(self, bar)\n' '#end def\n')
Example #22
0
def test_def_with_dollar_sign_invalid():
    with assert_raises_exactly(
            ParseError, '\n\n'
            'use #def func() instead of #def $func()\n'
            'Line 1, column 6\n'
            '\n'
            'Line|Cheetah Code\n'
            '----|-------------------------------------------------------------\n'
            '1   |#def $foo()\n'
            '          ^\n'
            '2   |#end def\n'):
        compile_to_class('#def $foo()\n' '#end def\n')
Example #23
0
def test_non_ending_compiler_settings():
    with assert_raises_exactly(
            ParseError, '\n\n'
            "Unexpected EOF while searching for #end compiler-settings\n"
            'Line 2, column 24\n'
            '\n'
            'Line|Cheetah Code\n'
            '----|-------------------------------------------------------------\n'
            '1   |#compiler-settings\n'
            '2   |useDottedNotation = True\n'
            '                            ^\n'):
        compile_to_class('#compiler-settings\nuseDottedNotation = True')
Example #24
0
def test_invalid_syntax_in_super():
    # I'm not sure this error is actually correct
    with assert_raises_exactly(
            ParseError, '\n\n'
            '$ is not allowed here.\n'
            'Line 1, column 12\n'
            '\n'
            'Line|Cheetah Code\n'
            '----|-------------------------------------------------------------\n'
            '1   |#super(foo=${bar})\n'
            '                ^\n'):
        compile_to_class('#super(foo=${bar})')
Example #25
0
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')
Example #26
0
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 +')
Example #27
0
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')
Example #28
0
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')
Example #29
0
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')
Example #30
0
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(*)')
Example #31
0
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')
Example #32
0
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(')
Example #33
0
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')
Example #34
0
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')
Example #35
0
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('${"""}')
Example #36
0
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')
Example #37
0
def test_weird_close_call():
    with assert_raises_exactly(
        ParseError,
        '\n\n'
        "Expected a ')' before an end '}'\n"
        'Line 1, column 6\n'
        '\n'
        'Line|Cheetah Code\n'
        '----|-------------------------------------------------------------\n'
        '1   |$foo(}\n'
        '          ^\n'
    ):
        compile_to_class('$foo(}')
Example #38
0
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)')
Example #39
0
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]')
Example #40
0
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')
Example #41
0
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')
Example #42
0
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(☃)')
Example #43
0
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')
Example #44
0
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')
Example #45
0
def test_invalid_syntax_in_call():
    # I'm not sure this error is actually correct
    with assert_raises_exactly(
            ParseError, '\n\n'
            "Long-form placeholders - ${}, $(), $[], etc. are not valid inside "
            "expressions. Use them in top-level $placeholders only.\n"
            'Line 1, column 11\n'
            '\n'
            'Line|Cheetah Code\n'
            '----|-------------------------------------------------------------\n'
            '1   |$herp(foo=${bar})\n'
            '               ^\n'):
        compile_to_class('$herp(foo=${bar})')
Example #46
0
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('${"""}')
Example #47
0
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')
Example #48
0
def test_non_ending_compiler_settings():
    with assert_raises_exactly(
        ParseError,
        '\n\n'
        'Some #directives are missing their corresponding #end ___ tag: compiler-settings\n'
        'Line 2, column 26\n'
        '\n'
        'Line|Cheetah Code\n'
        '----|-------------------------------------------------------------\n'
        '1   |#compiler-settings\n'
        '2   |useLegacyImportMode = True\n'
        '                              ^\n'
    ):
        compile_to_class('#compiler-settings\nuseLegacyImportMode = True')
Example #49
0
def test_uncaught_syntax_error():
    with assert_raises_exactly(
        ParseError,
        '\n\n'
        "SyntaxError: can't assign to function call (<unknown>, line 1)\n\n"
        'Line 3, column 15\n\n'
        'Line|Cheetah Code\n'
        '----|-------------------------------------------------------------\n'
        '1   |Hello\n'
        '2   |World\n'
        '3   |#py x = $y = 1\n'
        '                   ^\n'
    ):
        compile_to_class('Hello\nWorld\n#py x = $y = 1\n')
Example #50
0
def test_errors_on_blinged_kwarg():
    with assert_raises_exactly(
        ParseError,
        '\n\n'
        'kwargs should not start with $\n'
        'Line 1, column 6\n\n'
        'Line|Cheetah Code\n'
        '----|-------------------------------------------------------------\n'
        '1   |$foo($bar=$baz)\n'
        '          ^\n'
    ):
        compile_to_class(
            '$foo($bar=$baz)'
        )
Example #51
0
def test_non_ending_compiler_settings():
    with assert_raises_exactly(
        ParseError,
        '\n\n'
        "Unexpected EOF while searching for #end compiler-settings\n"
        'Line 2, column 24\n'
        '\n'
        'Line|Cheetah Code\n'
        '----|-------------------------------------------------------------\n'
        '1   |#compiler-settings\n'
        '2   |useDottedNotation = True\n'
        '                            ^\n'
    ):
        compile_to_class('#compiler-settings\nuseDottedNotation = True')
Example #52
0
def test_invalid_syntax_in_super():
    # I'm not sure this error is actually correct
    with assert_raises_exactly(
        ParseError,
        '\n\n'
        '$ is not allowed here.\n'
        'Line 1, column 12\n'
        '\n'
        'Line|Cheetah Code\n'
        '----|-------------------------------------------------------------\n'
        '1   |#super(foo=${bar})\n'
        '                ^\n'
    ):
        compile_to_class('#super(foo=${bar})')
Example #53
0
def test_invalid_syntax_in_call():
    # I'm not sure this error is actually correct
    with assert_raises_exactly(
        ParseError,
        '\n\n'
        "Long-form placeholders - ${}, $(), $[], etc. are not valid inside "
        "expressions. Use them in top-level $placeholders only.\n"
        'Line 1, column 11\n'
        '\n'
        'Line|Cheetah Code\n'
        '----|-------------------------------------------------------------\n'
        '1   |$herp(foo=${bar})\n'
        '               ^\n'
    ):
        compile_to_class('$herp(foo=${bar})')
Example #54
0
def test_classmethod_staticmethod_not_allowed(decorator):
    with assert_raises_exactly(
            ParseError, '\n\n'
            '@classmethod / @staticmethod are not supported\n'
            'Line 1, column 2\n'
            '\n'
            'Line|Cheetah Code\n'
            '----|-------------------------------------------------------------\n'
            '1   |#{0}\n'
            '      ^\n'
            '2   |#def foo(bar)\n'
            '3   |    #return bar + 1\n'
            '4   |#end def\n'.format(decorator)):
        compile_to_class('#{0}\n'
                         '#def foo(bar)\n'
                         '    #return bar + 1\n'
                         '#end def\n'.format(decorator))
Example #55
0
def test_def_without_arglist_invalid():
    with assert_raises_exactly(
        ParseError,
        '\n\n'
        '#def must contain an argspec (at least ())\n'
        'Line 1, column 9\n'
        '\n'
        'Line|Cheetah Code\n'
        '----|-------------------------------------------------------------\n'
        '1   |#def foo\n'
        '             ^\n'
        '2   |#end def\n'
    ):
        compile_to_class(
            '#def foo\n'
            '#end def\n'
        )
Example #56
0
def test_block_with_an_argspec_invalid():
    with assert_raises_exactly(
        ParseError,
        '\n\n'
        '#block must not have an argspec, did you mean #def?\n'
        'Line 1, column 11\n'
        '\n'
        'Line|Cheetah Code\n'
        '----|-------------------------------------------------------------\n'
        '1   |#block foo(bar)\n'
        '               ^\n'
        '2   |#end block\n'
    ):
        compile_to_class(
            '#block foo(bar)\n'
            '#end block\n'
        )
Example #57
0
def test_self_in_arglist_invalid():
    with assert_raises_exactly(
        ParseError,
        '\n\n'
        'Do not specify `self` in an arglist, it is assumed\n'
        'Line 1, column 10\n'
        '\n'
        'Line|Cheetah Code\n'
        '----|-------------------------------------------------------------\n'
        '1   |#def foo(self, bar)\n'
        '              ^\n'
        '2   |#end def\n'
    ):
        compile_to_class(
            '#def foo(self, bar)\n'
            '#end def\n'
        )
Example #58
0
def test_parse_error_long_file():
    with assert_raises_exactly(
            ParseError, '\n\n'
            "EOF was reached before a matching ')' was found for the '('\n"
            'Line 5, column 5\n'
            '\n'
            'Line|Cheetah Code\n'
            '----|-------------------------------------------------------------\n'
            '2   |2\n'
            '3   |3\n'
            '4   |4\n'
            '5   |$foo(\n'
            '         ^\n'
            '6   |6\n'
            '7   |7\n'
            '8   |8\n'):
        compile_to_class('1\n2\n3\n4\n$foo(\n6\n7\n8\n')
Example #59
0
def test_malformed_compiler_settings():
    with assert_raises_exactly(
            ParseError, '\n\n'
            'An error occurred while parsing the settings:\n'
            '---------------------------------------------\n'
            '==\n'
            '---------------------------------------------\n'
            'Line 3, column 23\n'
            '\n'
            'Line|Cheetah Code\n'
            '----|-------------------------------------------------------------\n'
            '1   |#compiler-settings\n'
            '2   |==\n'
            '3   |#end compiler-settings\n'
            '                           ^\n'):
        compile_to_class('#compiler-settings\n'
                         '==\n'
                         '#end compiler-settings\n')