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

Method test_set_default_box_dots

test/test_box.py:450–472  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

448 assert a.lister[0].gah == 7
449
450 def test_set_default_box_dots(self):
451 a = Box(box_dots=True)
452 a["x"] = {"y": 10}
453 a.setdefault("x.y", 20)
454 assert a["x.y"] == 10
455
456 a["lists"] = [[[{"test": "here"}], {1, 2}], (4, 5)]
457 assert list(_get_dot_paths(a)) == [
458 "x",
459 "x.y",
460 "lists",
461 "lists[0]",
462 "lists[0][0]",
463 "lists[0][0][0]",
464 "lists[0][0][0].test",
465 "lists[0][1]",
466 "lists[1]",
467 ]
468
469 t = Box({"a": 1}, default_box=True, box_dots=True, default_box_none_transform=False)
470 assert t.setdefault("b", [1, 2]) == [1, 2]
471 assert t == Box(a=1, b=[1, 2])
472 assert t.setdefault("c", [{"d": 2}]) == BoxList([{"d": 2}])
473
474 def test_from_json_file(self):
475 bx = Box.from_json(filename=data_json_file)

Callers

nothing calls this directly

Calls 4

setdefaultMethod · 0.95
BoxClass · 0.90
_get_dot_pathsFunction · 0.90
BoxListClass · 0.90

Tested by

no test coverage detected