Fix unit test with property name sanitize.

This commit is contained in:
sliptonic
2021-02-17 17:59:25 -06:00
parent 097b2c982e
commit 7c2962e119
3 changed files with 12 additions and 4 deletions

View File

@@ -22,6 +22,7 @@
import FreeCAD
import PySide
import re
__title__ = 'Generic property container to store some values.'
__author__ = 'sliptonic (Brad Collette)'
@@ -70,7 +71,7 @@ class PropertyBag(object):
def __sanitizePropertyName(self, name):
if(len(name) == 0):
return
clean = name[0].lower()
clean = name[0]
for i in range(1, len(name)):
if (name[i] == ' '):
clean += name[i + 1].upper()
@@ -96,6 +97,8 @@ class PropertyBag(object):
groups = self.obj.CustomPropertyGroups
name = self.__sanitizePropertyName(name)
if not re.match("^[A-Za-z0-9_]*$", name):
raise ValueError('Property Name can only contain letters and numbers')
if not group in groups:
groups.append(group)