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

Method test_box_namespace

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

Source from the content-addressed store, hash-verified

1751 assert "_field" not in box
1752
1753 def test_box_namespace(self):
1754 bx = Box(default_box=True)
1755 assert bx._box_config["box_namespace"] == ()
1756 bx.a.b.c = 5
1757 assert bx.a._box_config["box_namespace"] == ("a",)
1758 assert bx.a.b._box_config["box_namespace"] == ("a", "b")
1759 bx.x = {"y": {"z": 5}}
1760 assert bx.x._box_config["box_namespace"] == ("x",)
1761 assert bx.x.y._box_config["box_namespace"] == ("x", "y")
1762 bx[None][1][2] = 3
1763 assert bx[None][1]._box_config["box_namespace"] == (None, 1)
1764
1765 for modified_box in [
1766 bx.a + bx.x,
1767 bx.a - bx.x,
1768 bx.a | bx.x,
1769 ]:
1770 assert modified_box._box_config["box_namespace"] == ()
1771 assert modified_box.b._box_config["box_namespace"] == ("b",)
1772 assert modified_box.y._box_config["box_namespace"] == ("y",)
1773
1774 bx.modified = {}
1775 assert bx.modified._box_config["box_namespace"] == ("modified",)
1776 bx.modified += bx.a
1777 assert bx.modified.b._box_config["box_namespace"] == ("modified", "b")
1778 bx.modified |= bx.x
1779 assert bx.modified.y._box_config["box_namespace"] == ("modified", "y")
1780 bx.modified -= bx.a
1781 assert bx.modified._box_config["box_namespace"] == ("modified",)
1782
1783 bx2 = Box(box_namespace=False)
1784 assert bx2._box_config["box_namespace"] is False
1785 bx2["x"] = {"y": {"z": 5}}
1786 assert bx2._box_config["box_namespace"] is False
1787 assert bx2["x"]._box_config["box_namespace"] is False
1788
1789 def test_union_frozen_box(self):
1790 my_box = Box(a=5, frozen_box=True)

Callers

nothing calls this directly

Calls 1

BoxClass · 0.90

Tested by

no test coverage detected