Skip to content

Commit daf19f3

Browse files
committed
moar tests, moar ipy fixes
1 parent 4864edf commit daf19f3

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/compas_fab/robots/configuration.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ def __setitem__(self, key, value):
4949

5050
def __setslice__(self, i, j, sequence):
5151
# for ironpython
52-
slice_length = j - i
52+
slice_end = min(j, self.__len__())
53+
slice_length = slice_end - i
5354
value_length = len(sequence)
5455
if slice_length != value_length:
5556
raise TypeError('Cannot change length of FixedLengthList')

tests/robots/test_configuration.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ def validator(fixed_length_list, key=None, value=None):
163163
if key is not None and value is not None:
164164
new_fixed_length_list.__setitem__(key, value)
165165
if len(new_fixed_length_list) != len(set(new_fixed_length_list)):
166-
raise ValueError('joint_names cannot have repeated values.')
166+
raise ValueError('This list cannot have repeated values.')
167167
fll = FixedLengthList([1, 2, 3], validator=validator)
168168
with pytest.raises(ValueError):
169169
_ = FixedLengthList([1, 1, 1], validator=validator)
@@ -175,6 +175,12 @@ def validator(fixed_length_list, key=None, value=None):
175175
assert fll[2] == -1
176176
with pytest.raises(TypeError):
177177
fll[1:1] = range(10)
178+
with pytest.raises(TypeError):
179+
fll[1:] = [1]
180+
with pytest.raises(TypeError):
181+
fll[:] = [1, 2]
182+
with pytest.raises(TypeError):
183+
fll[:1] = [1, 2]
178184
with pytest.raises(ValueError):
179185
fll[1] = 1
180186
with pytest.raises(ValueError):

0 commit comments

Comments
 (0)