Fix #146588: raise exception when attempting invalid idproperty renaming in Python
Each name has to be unique within a group, so when renaming an idproperty, one has to make sure that the parent group does not contain duplicates afterwards. This patch raises a `NameError` when setting the name to one that exists already. Alternatively, one could delete the already-existing property, but that seems unexpected and the user should rather do that explicitly. This also adds a new unit test for this case. Pull Request: https://projects.blender.org/blender/blender/pulls/146892
This commit is contained in:
@@ -203,6 +203,14 @@ class TestIdPropertyCreation(TestHelper, unittest.TestCase):
|
||||
with self.assertRaises(TypeError):
|
||||
self.id[self.key_id] = self
|
||||
|
||||
def test_rename(self):
|
||||
self.id["foo"] = {"a": 1}
|
||||
self.id["bar"] = {"b": 2}
|
||||
self.id["foo"].name = "foo"
|
||||
self.id["bar"].name = "bar"
|
||||
with self.assertRaises(NameError):
|
||||
self.id["foo"].name = "bar"
|
||||
|
||||
|
||||
class TestIdPropertyUIData(TestHelper, unittest.TestCase):
|
||||
# Default testing idprop key identifier.
|
||||
|
||||
Reference in New Issue
Block a user