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

Method test_setdefault_simple

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

Source from the content-addressed store, hash-verified

1336 assert out2 == BoxList()
1337
1338 def test_setdefault_simple(self):
1339 box = Box({"a": 1})
1340 box.setdefault("b", 2)
1341 box.setdefault("c", "test")
1342 box.setdefault("d", {"e": True})
1343 box.setdefault("f", [1, 2])
1344
1345 assert box["b"] == 2
1346 assert box["c"] == "test"
1347 assert isinstance(box["d"], Box)
1348 assert box["d"]["e"] == True
1349 assert isinstance(box["f"], BoxList)
1350 assert box["f"][1] == 2
1351
1352 def test_setdefault_dots(self):
1353 box = Box({"a": 1}, box_dots=True)

Callers

nothing calls this directly

Calls 2

setdefaultMethod · 0.95
BoxClass · 0.90

Tested by

no test coverage detected