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

Method assign

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

Source from the content-addressed store, hash-verified

307 @pytest.mark.parametrize("bounds", [(0, 4, 1), (3, -5, -2)])
308 def test_slice_bounds_are_evaluated_once_before_replacements(self, bounds):
309 def assign(list_type):
310 events = []
311
312 class Index:
313 def __init__(self, name, value):
314 self.name = name
315 self.value = value
316
317 def __index__(self):
318 events.append(self.name)
319 return self.value
320
321 class Replacements:
322 def __iter__(self):
323 events.append("iter")
324 return iter([8, 9])
325
326 selection = slice(*(Index(name, value) for name, value in zip(("start", "stop", "step"), bounds)))
327 data = list_type([0, 1, 2, 3])
328 data[selection] = Replacements()
329 return data, events
330
331 expected, expected_events = assign(list)
332 actual, actual_events = assign(BoxList)

Callers

nothing calls this directly

Calls 2

IndexClass · 0.85
ReplacementsClass · 0.85

Tested by

no test coverage detected