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

Method test_setdefault_dots_default

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

Source from the content-addressed store, hash-verified

1649 assert box.f[1] == 2
1650
1651 def test_setdefault_dots_default(self):
1652 box = Box({"a": 1}, box_dots=True, default_box=True)
1653 box.b.c.d.setdefault("e", 2)
1654 box.c.setdefault("e", "test")
1655 box.d.e.setdefault("f", {"g": True})
1656 box.e.setdefault("f", [1, 2])
1657
1658 assert box["b.c.d"].e == 2
1659 assert box.c.e == "test"
1660 assert isinstance(box["d.e.f"], Box)
1661 assert box.d.e["f.g"] is True
1662 assert isinstance(box["e.f"], BoxList)
1663 assert box.e.f[1] == 2
1664
1665 def test_box_slice(self):
1666 data = Box(qwe=123, asd=234, q=1)

Callers

nothing calls this directly

Calls 2

BoxClass · 0.90
setdefaultMethod · 0.80

Tested by

no test coverage detected