예제 #1
0
def test_result_list_contains_results_of_supplied_parser(runner):
    test_string = 'ab'
    parsing_result = runner(until(main_parser, delimiter), test_string)
    assert parsing_result.value == ('a', )
예제 #2
0
def test_until_returns_tuple(runner, n):
    test_string = 'a' * n + 'b'
    parsing_result = runner(until(main_parser, delimiter), test_string)
    assert isinstance(parsing_result.value, tuple)
예제 #3
0
def test_until_returns_n_elements_when_n_elements_are_found(runner, n):
    test_string = 'a' * n + 'b'
    parsing_result = runner(until(main_parser, delimiter), test_string)
    assert len(parsing_result.value) == n
예제 #4
0
def test_until_consumes_the_delimiter(runner):
    parsing_result = runner(until(main_parser, delimiter), 'b')
    assert not parsing_result.remaining_input
예제 #5
0
def test_until_returns_empty_tuple_when_only_delimiter_is_found(runner):
    assert runner(until(main_parser, delimiter), 'b').value == tuple()
예제 #6
0
def test_until_failes_if_parser_fails_and_delimiter_parser_fails(runner):
    with pytest.raises(ParsingFailed):
        runner(until(main_parser, delimiter), 'not_matching_string')