def test_uneven_increments(self): with assert_raises(ValueError): _range_to_slice([1, 1, 2, 3, 5, 8, 13])
def test_negative_elements(self): with assert_raises(ValueError): _range_to_slice([-1, -2, -3, -4])
def test_zero_increments(self): with assert_raises(ValueError): _range_to_slice([1, 1, 1, 1])
def _check_slice(start, stop, step): s = slice(start, stop, step) length = max(start, 0 if stop is None else stop) + 1 r = slice_to_range(s, length) assert_equal(_range_to_slice(r), s)