def test_parser_default_ebnf(patch): patch.many(os.path, ['dirname', 'join', 'realpath']) result = Parser.default_ebnf() os.path.join.assert_called_with(os.path.dirname(), '..', 'grammar', 'grammar.ebnf') os.path.realpath.assert_called_with(os.path.join()) assert result == os.path.realpath()
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)