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

Method test_setdefault_dots_default

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

Source from the content-addressed store, hash-verified

1714 assert box.f[1] == 2
1715
1716 def test_setdefault_dots_default(self):
1717 box = Box({"a": 1}, box_dots=True, default_box=True)
1718 box.b.c.d.setdefault("e", 2)
1719 box.c.setdefault("e", "test")
1720 box.d.e.setdefault("f", {"g": True})
1721 box.e.setdefault("f", [1, 2])
1722
1723 assert box["b.c.d"].e == 2
1724 assert box.c.e == "test"
1725 assert isinstance(box["d.e.f"], Box)
1726 assert box.d.e["f.g"] is True
1727 assert isinstance(box["e.f"], BoxList)
1728 assert box.e.f[1] == 2
1729
1730 def test_box_slice(self):
1731 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