readonly also prevents deletion
This commit is contained in:
parent
c50473fea5
commit
c58ebfa657
@ -264,6 +264,9 @@ class PropertyReadOnly(PropertyDelegator):
|
|||||||
def __setitem__(self, key, value):
|
def __setitem__(self, key, value):
|
||||||
raise PropertyWriteError(key)
|
raise PropertyWriteError(key)
|
||||||
|
|
||||||
|
def __delitem__(self, key):
|
||||||
|
raise PropertyWriteError(key)
|
||||||
|
|
||||||
|
|
||||||
class PropertyStack(PropertyManager):
|
class PropertyStack(PropertyManager):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
@ -13,3 +13,11 @@ class PropertyReadOnlyTest(TestCase):
|
|||||||
ro["otherkey"] = "testvalue"
|
ro["otherkey"] = "testvalue"
|
||||||
self.assertEqual(ro["testkey"], "initial value")
|
self.assertEqual(ro["testkey"], "initial value")
|
||||||
self.assertNotIn("otherkey", ro)
|
self.assertNotIn("otherkey", ro)
|
||||||
|
|
||||||
|
def testPreventsDeletes(self):
|
||||||
|
layer = PropertyLayer(testkey="some value")
|
||||||
|
ro = PropertyReadOnly(layer)
|
||||||
|
with self.assertRaises(PropertyWriteError):
|
||||||
|
del ro["testkey"]
|
||||||
|
self.assertEqual(ro["testkey"], "some value")
|
||||||
|
self.assertEqual(layer["testkey"], "some value")
|
||||||
|
Loading…
Reference in New Issue
Block a user