Пример #1
0
def test_line_info(sql_cmd, start, pos):
    state = State(sql_cmd,
                  "",
                  "",
                  None,
                  None, {}, {},
                  Reporter(),
                  ast_dispatcher=Dispatcher.from_module(
                      PARSER_MODULES['mssql']))
    try:
        state.do_test("failure message")
    except TF as tf:
        for ii, k in enumerate(pos_names):
            assert tf.payload[k] == pos[ii]
Пример #2
0
def test_state_line_info():
    state = State("\nSELECT x FROM y",
                  "SELECT x FROM y",
                  "",
                  None,
                  None, {}, {},
                  Reporter(),
                  ast_dispatcher=Dispatcher.from_module(
                      PARSER_MODULES['mssql']))

    with pytest.raises(TF):
        state.do_test("failure message")

    payload = state.reporter.build_payload()

    pos = [2, 1, 2, 15]
    pos_names = ['line_start', 'column_start', 'line_end', 'column_end']
    for ii, k in enumerate(pos_names):
        assert payload[k] == pos[ii]