def test_buf_set_value_idx_negative(): lst = ['a', 'b', 'c'] buf = Buf(lst) with buf.record() as modifications: buf[-1] = 'hello' assert lst == ['a', 'b', 'hello'] buf.apply(modifications) assert lst == ['a', 'b', 'c']
def test_buf_insert_with_negative(): lst = ['a', 'b', 'c'] buf = Buf(lst) with buf.record() as modifications: buf.insert(-1, 'q') assert lst == ['a', 'b', 'q', 'c'] buf.apply(modifications) assert lst == ['a', 'b', 'c']
def test_buf_del_with_negative(): lst = ['a', 'b', 'c'] buf = Buf(lst) with buf.record() as modifications: del buf[-1] assert lst == ['a', 'b'] buf.apply(modifications) assert lst == ['a', 'b', 'c']
def test_buf_pop_idx(): lst = ['a', 'b', 'c'] buf = Buf(lst) with buf.record() as modifications: buf.pop(1) assert lst == ['a', 'c'] buf.apply(modifications) assert lst == ['a', 'b', 'c']
def test_buf_append(): lst = ['a', 'b', 'c'] buf = Buf(lst) with buf.record() as modifications: buf.append('q') assert lst == ['a', 'b', 'c', 'q'] buf.apply(modifications) assert lst == ['a', 'b', 'c']
def test_buf_multiple_modifications(): lst = ['a', 'b', 'c'] buf = Buf(lst) with buf.record() as modifications: buf[1] = 'hello' buf.insert(1, 'ohai') del buf[0] assert lst == ['ohai', 'hello', 'c'] buf.apply(modifications) assert lst == ['a', 'b', 'c']