def test_parser_lark(patch, parser): patch.init(Lark) patch.many(Parser, ['indenter', 'grammar']) result = parser.lark() Lark.__init__.assert_called_with(parser.grammar(), parser=parser.algo, postlex=Parser.indenter()) assert isinstance(result, Lark)
def test_parser_lark(patch, parser): """ Ensures Parser.lark can produce the correct Lark instance. """ patch.init(Lark) patch.many(Parser, ["indenter", "grammar"]) result = parser._lark() kwargs = {"parser": parser.algo, "postlex": Parser.indenter()} Lark.__init__.assert_called_with(parser.grammar(), **kwargs) assert isinstance(result, Lark)
def test_parser_indenter(patch): patch.init(CustomIndenter) assert isinstance(Parser.indenter(), CustomIndenter)