Skip to content

Commit

Permalink
Merge pull request #15909 from Dr15Jones/delattrEDAlias
Browse files Browse the repository at this point in the history
Add __delattr__ to EDAlias to work with Modifier
  • Loading branch information
cmsbuild committed Sep 20, 2016
2 parents 1d48204 + cb21b03 commit b54e7df
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions FWCore/ParameterSet/python/Types.py
Expand Up @@ -1132,6 +1132,11 @@ def __addParameter(self, name, value):
self.__dict__[name]=value
self.__parameterNames.append(name)

def __delattr__(self,attr):
if attr in self.__parameterNames:
self.__parameterNames.remove(attr)
return super(EDAlias,self).__delattr__(attr)

def __setParameters(self,parameters):
for name,value in parameters.iteritems():
self.__addParameter(name, value)
Expand Down Expand Up @@ -1376,6 +1381,10 @@ def testVPSet(self):
self.assertRaises(SyntaxError, lambda : VPSet(foo=PSet()))
def testEDAlias(self):
aliasfoo2 = EDAlias(foo2 = VPSet(PSet(type = string("Foo2"))))
self.assert_(hasattr(aliasfoo2,"foo2"))
del aliasfoo2.foo2
self.assert_(not hasattr(aliasfoo2,"foo2"))
self.assert_("foo2" not in aliasfoo2.parameterNames_())

def testFileInPath(self):
f = FileInPath("FWCore/ParameterSet/python/Types.py")
Expand Down

0 comments on commit b54e7df

Please sign in to comment.