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

Method test_box_property_support

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

Source from the content-addressed store, hash-verified

1721 assert box3["a"]["b"]["c"] == "nested"
1722
1723 def test_box_property_support(self):
1724 class BoxWithProperty(Box):
1725 def __init__(self, *args, **kwargs):
1726 super().__init__(*args, **kwargs)
1727
1728 @property
1729 def field(self):
1730 return self._field
1731
1732 @field.setter
1733 def field(self, value):
1734 self._field = value
1735
1736 @field.deleter
1737 def field(self):
1738 """
1739 This is required to make `del box.field` work properly otherwise a `BoxKeyError` would be thrown.
1740 """
1741 del self._field
1742
1743 box = BoxWithProperty()
1744 box.field = 5
1745
1746 assert "field" not in box
1747 assert "_field" in box
1748 assert box.field == 5
1749 assert box._field == 5
1750 del box.field
1751 assert "_field" not in box
1752
1753 def test_box_namespace(self):
1754 bx = Box(default_box=True)

Callers

nothing calls this directly

Calls 1

BoxWithPropertyClass · 0.85

Tested by

no test coverage detected