Exemplo n.º 1
0
def test_parser_lark(patch, parser):
    patch.init(Lark)
    patch.object(Grammar, 'grammar')
    patch.many(Parser, ['default_ebnf', 'indenter'])
    result = parser.lark()
    Grammar.grammar.assert_called_with(Parser.default_ebnf())
    Lark.__init__.assert_called_with(Grammar.grammar(),
                                     parser='lalr',
                                     postlex=Parser.indenter())
    assert isinstance(result, Lark)
Exemplo n.º 2
0
def test_parser_indenter(patch):
    patch.init(CustomIndenter)
    result = Parser.indenter()
    assert isinstance(result, CustomIndenter)