Пример #1
0
def test_parse(_name, lines, start, stop):
    """'_get_message_range(lines)' should range from 'start' to 'stop'."""
    if isinstance(stop[0], int):
        assert _get_message_range(lines, start) == {"start": start, "stop": stop}
    else:
        ex, stop = stop
        with pytest.raises(ex) as e:
            _get_message_range(lines, start)
        if stop is not None:
            assert e.value.range[0] == stop
Пример #2
0
def test_parse(_name, lines, start, stop):
    """'_get_message_range(lines)' should range from 'start' to 'stop'."""
    if stop is not None:
        mrange = {"start": start, "stop": stop}
    else:
        mrange = None
    assert _get_message_range(lines, start) == mrange
Пример #3
0
def test_parse(
    _name: str,
    lines: ParseIn,
    start: ParseStart,
    stop_or_ex: ParseStop,
) -> None:
    """'_get_message_range(lines)' should range from 'start' to 'stop'."""
    if isinstance(stop_or_ex, tuple):
        assert _get_message_range(lines, start) == {
            "start": start,
            "stop": stop_or_ex
        }
    else:
        with pytest.raises(type(stop_or_ex)) as e:
            _get_message_range(lines, start)
        if isinstance(stop_or_ex, UnmatchedError):
            assert isinstance(e.value, UnmatchedError)
            assert str(e.value) == str(stop_or_ex)
            assert e.value.range == stop_or_ex.range