Tests: add ID-property TestRNAData.test_custom_properties_access

Ensures RNA/ID-property key lookups are compatible.
This commit is contained in:
Campbell Barton 2023-08-22 13:27:21 +10:00
parent f30ac938de
commit e044c5f12b
1 changed files with 21 additions and 0 deletions

View File

@ -266,6 +266,27 @@ if np is not None:
class TestRNAData(TestHelper, unittest.TestCase):
def test_custom_properties_access(self):
# Ensure the RNA path resolving behaves as expected & is compatible with ID-property keys.
keys_to_test = (
"test",
"\\"
'"',
'""',
'"""',
'[',
']',
'[]',
'["]',
'[""]',
'["""]',
'[""""]',
)
for key_id in keys_to_test:
self.id[key_id] = 1
self.assertEqual(self.id[key_id], self.id.path_resolve('["%s"]' % bpy.utils.escape_identifier(key_id)))
del self.id[key_id]
def test_custom_properties_none(self):
bpy.data.objects.new("test", None)
test_object = bpy.data.objects["test"]