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

Method test_extend_self

test/test_box_list.py:71–91  ·  view source on GitHub ↗
(self, values, monkeypatch)

Source from the content-addressed store, hash-verified

69
70 @pytest.mark.parametrize("values", [[], [1], [1, 2], [{"SomeKey": 3}, [4]]])
71 def test_extend_self(self, values, monkeypatch):
72 data = BoxList(values, camel_killer_box=True)
73 expected = data.to_list() * 2
74 append = data.append
75 remaining = len(data)
76
77 def bounded_append(item):
78 nonlocal remaining
79 assert remaining > 0, "extend revisited an appended element"
80 remaining -= 1
81 append(item)
82
83 # Bound the regression test even if extend iterates its growing destination.
84 monkeypatch.setattr(data, "append", bounded_append)
85 assert data.extend(data) is None
86 assert remaining == 0
87 assert data.to_list() == expected
88 if values and isinstance(values[0], dict):
89 assert isinstance(data[2], Box)
90 assert data[2].some_key == 3
91 assert isinstance(data[3], BoxList)
92
93 def test_extend_generator_preserves_partial_progress(self):
94 data = BoxList([0])

Callers

nothing calls this directly

Calls 3

to_listMethod · 0.95
extendMethod · 0.95
BoxListClass · 0.90

Tested by

no test coverage detected