def test_get_rate(pre_state, time, value, onwrap, expected):
    item_state.set_item_state("foo", pre_state)
    result = item_state.get_rate("foo",
                                 time,
                                 value,
                                 onwrap=onwrap,
                                 allow_negative=True)
    assert result == expected
def test_get_rate(pre_state, time, value, onwrap, expected):
    with _test_context({"foo": pre_state}):
        result = item_state.get_rate("foo",
                                     time,
                                     value,
                                     onwrap=onwrap,
                                     allow_negative=True)
    assert result == expected
def test_get_rate_raises(pre_state, time, value, errmsg):
    item_state.set_item_state("foo", pre_state)
    with pytest.raises(item_state.MKCounterWrapped, match=errmsg):
        item_state.get_rate("foo", time, value, onwrap=item_state.RAISE)
def test_get_rate_raises(pre_state, time, value, errmsg):
    with _test_context({"foo": pre_state}):
        with pytest.raises(item_state.MKCounterWrapped, match=errmsg):
            item_state.get_rate("foo", time, value, onwrap=item_state.RAISE)