models: Make sure del on attributes does not work
This commit is contained in:
parent
4faf4de7aa
commit
73415ce60f
@ -152,6 +152,9 @@ class ImmutableObject(object):
|
||||
return super(ImmutableObject, self).__setattr__(name, value)
|
||||
raise AttributeError('Object is immutable.')
|
||||
|
||||
def __delattr__(self, name):
|
||||
raise AttributeError('Object is immutable.')
|
||||
|
||||
def __repr__(self):
|
||||
kwarg_pairs = []
|
||||
for (key, value) in sorted(self.__dict__.items()):
|
||||
|
||||
@ -74,6 +74,12 @@ class RefTest(unittest.TestCase):
|
||||
with self.assertRaises(AttributeError):
|
||||
ref.name = None
|
||||
|
||||
# TODO: add these for the more of the models?
|
||||
def test_del_name(self):
|
||||
ref = Ref(name='foo')
|
||||
with self.assertRaises(AttributeError):
|
||||
del ref.name
|
||||
|
||||
def test_invalid_kwarg(self):
|
||||
with self.assertRaises(TypeError):
|
||||
Ref(foo='baz')
|
||||
|
||||
Loading…
Reference in New Issue
Block a user