def test__parser__grammar_startswith_a(keyword, match_truthy, seg_list, fresh_ansi_dialect, caplog): """Test the StartsWith grammar simply.""" Keyword = StringParser(keyword, KeywordSegment) grammar = StartsWith(Keyword) with RootParseContext(dialect=fresh_ansi_dialect) as ctx: with caplog.at_level(logging.DEBUG, logger="sqlfluff.parser"): m = grammar.match(seg_list, parse_context=ctx) assert bool(m) is match_truthy
def test__parser__grammar_startswith_b( include_terminator, match_length, seg_list, fresh_ansi_dialect, caplog ): """Test the StartsWith grammar with a terminator (included & exluded).""" baar = KeywordSegment.make("baar") bar = KeywordSegment.make("bar") grammar = StartsWith(bar, terminator=baar, include_terminator=include_terminator) with RootParseContext(dialect=fresh_ansi_dialect) as ctx: with caplog.at_level(logging.DEBUG, logger="sqlfluff.parser"): m = grammar.match(seg_list, parse_context=ctx) assert len(m) == match_length