App: fix restoring the attributes of a dynamic property
For more details see: https://forum.freecadweb.org/viewtopic.php?p=591465#p591465
This commit is contained in:
@@ -377,6 +377,30 @@ class DocumentBasicCases(unittest.TestCase):
|
||||
obj1.Link = obj2
|
||||
self.assertEqual(obj1.MustExecute, False)
|
||||
|
||||
def testAttributeOfDynamicProperty(self):
|
||||
obj = self.Doc.addObject("App::FeaturePython", "Obj")
|
||||
# Prop_NoPersist is the enum with the highest value
|
||||
max_value = FreeCAD.PropertyType.Prop_NoPersist
|
||||
list_of_types = []
|
||||
for i in range(0, max_value + 1):
|
||||
obj.addProperty("App::PropertyString", "String" + str(i), "", "", i)
|
||||
list_of_types.append(obj.getTypeOfProperty("String" + str(i)))
|
||||
|
||||
# saving and restoring
|
||||
SaveName = tempfile.gettempdir() + os.sep + "CreateTest.FCStd"
|
||||
self.Doc.saveAs(SaveName)
|
||||
FreeCAD.closeDocument("CreateTest")
|
||||
self.Doc = FreeCAD.open(SaveName)
|
||||
|
||||
obj = self.Doc.ActiveObject
|
||||
for i in range(0, max_value):
|
||||
types = obj.getTypeOfProperty("String" + str(i))
|
||||
self.assertEqual(list_of_types[i], types)
|
||||
|
||||
# A property with flag Prop_NoPersist won't be saved to the file
|
||||
with self.assertRaises(AttributeError):
|
||||
obj.getTypeOfProperty("String" + str(max_value))
|
||||
|
||||
def testNotification_Issue2902Part2(self):
|
||||
o = self.Doc.addObject("App::FeatureTest","test")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user