| 1816 | assert "_field" not in box |
| 1817 | |
| 1818 | def test_box_namespace(self): |
| 1819 | bx = Box(default_box=True) |
| 1820 | assert bx._box_config["box_namespace"] == () |
| 1821 | bx.a.b.c = 5 |
| 1822 | assert bx.a._box_config["box_namespace"] == ("a",) |
| 1823 | assert bx.a.b._box_config["box_namespace"] == ("a", "b") |
| 1824 | bx.x = {"y": {"z": 5}} |
| 1825 | assert bx.x._box_config["box_namespace"] == ("x",) |
| 1826 | assert bx.x.y._box_config["box_namespace"] == ("x", "y") |
| 1827 | bx[None][1][2] = 3 |
| 1828 | assert bx[None][1]._box_config["box_namespace"] == (None, 1) |
| 1829 | |
| 1830 | for modified_box in [ |
| 1831 | bx.a + bx.x, |
| 1832 | bx.a - bx.x, |
| 1833 | bx.a | bx.x, |
| 1834 | ]: |
| 1835 | assert modified_box._box_config["box_namespace"] == () |
| 1836 | assert modified_box.b._box_config["box_namespace"] == ("b",) |
| 1837 | assert modified_box.y._box_config["box_namespace"] == ("y",) |
| 1838 | |
| 1839 | bx.modified = {} |
| 1840 | assert bx.modified._box_config["box_namespace"] == ("modified",) |
| 1841 | bx.modified += bx.a |
| 1842 | assert bx.modified.b._box_config["box_namespace"] == ("modified", "b") |
| 1843 | bx.modified |= bx.x |
| 1844 | assert bx.modified.y._box_config["box_namespace"] == ("modified", "y") |
| 1845 | bx.modified -= bx.a |
| 1846 | assert bx.modified._box_config["box_namespace"] == ("modified",) |
| 1847 | |
| 1848 | bx2 = Box(box_namespace=False) |
| 1849 | assert bx2._box_config["box_namespace"] is False |
| 1850 | bx2["x"] = {"y": {"z": 5}} |
| 1851 | assert bx2._box_config["box_namespace"] is False |
| 1852 | assert bx2["x"]._box_config["box_namespace"] is False |
| 1853 | |
| 1854 | def test_union_frozen_box(self): |
| 1855 | my_box = Box(a=5, frozen_box=True) |