MCPcopy Create free account
hub / github.com/cdgriffith/Box / assign

Method assign

test/test_box_list.py:282–302  ·  view source on GitHub ↗
(list_type)

Source from the content-addressed store, hash-verified

280 @pytest.mark.parametrize("bounds", [(0, 4, 1), (3, -5, -2)])
281 def test_slice_bounds_are_evaluated_once_before_replacements(self, bounds):
282 def assign(list_type):
283 events = []
284
285 class Index:
286 def __init__(self, name, value):
287 self.name = name
288 self.value = value
289
290 def __index__(self):
291 events.append(self.name)
292 return self.value
293
294 class Replacements:
295 def __iter__(self):
296 events.append("iter")
297 return iter([8, 9])
298
299 selection = slice(*(Index(name, value) for name, value in zip(("start", "stop", "step"), bounds)))
300 data = list_type([0, 1, 2, 3])
301 data[selection] = Replacements()
302 return data, events
303
304 expected, expected_events = assign(list)
305 actual, actual_events = assign(BoxList)

Callers

nothing calls this directly

Calls 2

IndexClass · 0.85
ReplacementsClass · 0.85

Tested by

no test coverage detected