diff --git a/owrx/property/__init__.py b/owrx/property/__init__.py index f04b115..88d80f4 100644 --- a/owrx/property/__init__.py +++ b/owrx/property/__init__.py @@ -264,6 +264,9 @@ class PropertyReadOnly(PropertyDelegator): def __setitem__(self, key, value): raise PropertyWriteError(key) + def __delitem__(self, key): + raise PropertyWriteError(key) + class PropertyStack(PropertyManager): def __init__(self): diff --git a/test/property/test_property_readonly.py b/test/property/test_property_readonly.py index a6e74f7..09d57ee 100644 --- a/test/property/test_property_readonly.py +++ b/test/property/test_property_readonly.py @@ -13,3 +13,11 @@ class PropertyReadOnlyTest(TestCase): ro["otherkey"] = "testvalue" self.assertEqual(ro["testkey"], "initial value") 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")