App: add documentation to PropertyCleaner

move global variables static variables of PropertyCleaner
add unit test for removal of property in onBeforeChange
This commit is contained in:
wmayer
2020-03-21 18:33:08 +01:00
parent 4566fb8538
commit a08435a53c
2 changed files with 41 additions and 7 deletions

View File

@@ -1358,6 +1358,21 @@ class DocumentPropertyCases(unittest.TestCase):
self.Doc.recompute()
self.assertTrue(not p2 in p1.InList)
def testRemovePropertyOnChange(self):
class Feature:
def __init__(self, fp):
fp.Proxy = self
fp.addProperty("App::PropertyString","Test")
def onBeforeChange(self, fp, prop):
if prop == "Test":
fp.removeProperty("Test")
def onChanged(self, fp, prop):
getattr(fp, prop)
obj = self.Doc.addObject("App::FeaturePython")
fea = Feature(obj)
obj.Test = "test"
def tearDown(self):
#closing doc
FreeCAD.closeDocument("PropertyTests")