def test_iter_by_slice():
    rd1 = RangeDictionary(10)
    rd1["g"] = "gamma"
    rd1["a"] = "alpha"
    rd1["b"] = [
        "bravo0", "bravo1", "bravo2", "bravo3", "bravo4", "bravo5", "bravo6",
        "bravo7", "bravo8+", "bravo9"
    ]

    slice_view1 = rd1[2:4]
    iterator = slice_view1.iter_all_values()
    assert {"a": "alpha", "b": "bravo2", "g": "gamma"} == next(iterator)
    assert {"a": "alpha", "b": "bravo3", "g": "gamma"} == next(iterator)
    with pytest.raises(StopIteration):
        next(iterator)

    iterator = slice_view1.iter_all_values(update_save=True)
    assert {"a": "alpha", "b": "bravo2", "g": "gamma"} == next(iterator)
    rd1["b"][3] = "new3"
    assert {"a": "alpha", "b": "new3", "g": "gamma"} == next(iterator)
    with pytest.raises(StopIteration):
        next(iterator)
    rd1["b"][3] = "bravo3"

    iterator = slice_view1.iter_all_values(key="b")
    assert "bravo2" == next(iterator)
    assert "bravo3" == next(iterator)
    with pytest.raises(StopIteration):
        next(iterator)

    iterator = slice_view1.iter_all_values(update_save=True, key="b")
    assert "bravo2" == next(iterator)
    rd1["b"][3] = "new3"
    assert "new3" == next(iterator)
    with pytest.raises(StopIteration):
        next(iterator)
    rd1["b"][3] = "bravo3"

    iterator = rd1.iter_values_by_slice(2, 4, key=["b", "a"])
    assert {"a": "alpha", "b": "bravo2"} == next(iterator)
    assert {"a": "alpha", "b": "bravo3"} == next(iterator)
    with pytest.raises(StopIteration):
        next(iterator)

    iterator = rd1.iter_values_by_slice(2, 4, key=["b", "a"], update_save=True)
    assert {"a": "alpha", "b": "bravo2"} == next(iterator)
    rd1["b"][3] = "new3"
    assert {"a": "alpha", "b": "new3"} == next(iterator)
    with pytest.raises(StopIteration):
        next(iterator)
    rd1["b"][3] = "bravo3"
def test_iter_by_slice():
    rd1 = RangeDictionary(10)
    rl = RangedList(10, "gamma")
    rd1["g"] = rl
    rd1["a"] = "alpha"
    rd1["b"] = [
        "bravo0", "bravo1", "bravo2", "bravo3", "bravo4", "bravo5", "bravo6",
        "bravo7", "bravo8+", "bravo9"
    ]

    iterator = rd1.iter_values_by_slice(2, 4)
    assert {"a": "alpha", "b": "bravo2", "g": "gamma"} == next(iterator)
    assert {"a": "alpha", "b": "bravo3", "g": "gamma"} == next(iterator)
    with pytest.raises(StopIteration):
        next(iterator)

    iterator = rd1.iter_values_by_slice(2, 4, update_save=True)
    assert {"a": "alpha", "b": "bravo2", "g": "gamma"} == next(iterator)
    rd1["b"][3] = "new3"
    assert {"a": "alpha", "b": "new3", "g": "gamma"} == next(iterator)
    with pytest.raises(StopIteration):
        next(iterator)
    rd1["b"][3] = "bravo3"

    iterator = rd1.iter_values_by_slice(2, 4, key="b")
    assert "bravo2" == next(iterator)
    assert "bravo3" == next(iterator)
    with pytest.raises(StopIteration):
        next(iterator)

    iterator = rd1.iter_values_by_slice(2, 4, key="b", update_save=True)
    assert "bravo2" == next(iterator)
    rd1["b"][3] = "new3"
    assert "new3" == next(iterator)
    with pytest.raises(StopIteration):
        assert "OVERFLOW" == next(iterator)
    rd1["b"][3] = "bravo3"

    iterator = rd1.iter_values_by_slice(2, 4, key=["b", "a"])
    assert {"a": "alpha", "b": "bravo2"} == next(iterator)
    assert {"a": "alpha", "b": "bravo3"} == next(iterator)
    with pytest.raises(StopIteration):
        next(iterator)

    iterator = rd1.iter_values_by_slice(2, 4, key=["b", "a"], update_save=True)
    assert {"a": "alpha", "b": "bravo2"} == next(iterator)
    rd1["b"][3] = "new3"
    assert {"a": "alpha", "b": "new3"} == next(iterator)
    with pytest.raises(StopIteration):
        next(iterator)
    rd1["b"][3] = "bravo3"