From e044c5f12be7de37715fca9f727b33c3da45f959 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 22 Aug 2023 13:27:21 +1000 Subject: [PATCH] Tests: add ID-property TestRNAData.test_custom_properties_access Ensures RNA/ID-property key lookups are compatible. --- tests/python/bl_pyapi_idprop.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/python/bl_pyapi_idprop.py b/tests/python/bl_pyapi_idprop.py index 374fc7ec361..bf4db9621c3 100644 --- a/tests/python/bl_pyapi_idprop.py +++ b/tests/python/bl_pyapi_idprop.py @@ -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"]