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

Method test_box_property_support

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

Source from the content-addressed store, hash-verified

1786 assert box3["a"]["b"]["c"] == "nested"
1787
1788 def test_box_property_support(self):
1789 class BoxWithProperty(Box):
1790 def __init__(self, *args, **kwargs):
1791 super().__init__(*args, **kwargs)
1792
1793 @property
1794 def field(self):
1795 return self._field
1796
1797 @field.setter
1798 def field(self, value):
1799 self._field = value
1800
1801 @field.deleter
1802 def field(self):
1803 """
1804 This is required to make `del box.field` work properly otherwise a `BoxKeyError` would be thrown.
1805 """
1806 del self._field
1807
1808 box = BoxWithProperty()
1809 box.field = 5
1810
1811 assert "field" not in box
1812 assert "_field" in box
1813 assert box.field == 5
1814 assert box._field == 5
1815 del box.field
1816 assert "_field" not in box
1817
1818 def test_box_namespace(self):
1819 bx = Box(default_box=True)

Callers

nothing calls this directly

Calls 1

BoxWithPropertyClass · 0.85

Tested by

no test coverage detected