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

Method test_box_list

test/test_box_list.py:32–51  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

30 shutil.rmtree(str(tmp_dir), ignore_errors=True)
31
32 def test_box_list(self):
33 new_list = BoxList({"item": x} for x in range(0, 10))
34 new_list.extend([{"item": 22}])
35 assert new_list[-1].item == 22
36 new_list.append([{"bad_item": 33}])
37 assert new_list[-1][0].bad_item == 33
38 new_list[-1].append([{"bad_item": 33}])
39 assert new_list[-1, -1, 0].bad_item == 33
40 bx = Box({0: {1: {2: {3: 3}}}, (0, 1, 2, 3): 4})
41 assert bx[0, 1, 2, 3] == 4
42 assert repr(new_list).startswith("BoxList(")
43 for x in new_list.to_list():
44 assert not isinstance(x, (BoxList, Box))
45 new_list.insert(0, {"test": 5})
46 new_list.insert(1, ["a", "b"])
47 new_list.append("x")
48 assert new_list[0].test == 5
49 assert isinstance(str(new_list), str)
50 assert isinstance(new_list[1], BoxList)
51 assert not isinstance(new_list.to_list(), BoxList)
52
53 def test_frozen_list(self):
54 bl = BoxList([5, 4, 3], frozen_box=True)

Callers

nothing calls this directly

Calls 6

extendMethod · 0.95
appendMethod · 0.95
to_listMethod · 0.95
insertMethod · 0.95
BoxListClass · 0.90
BoxClass · 0.90

Tested by

no test coverage detected