Skip to content
Snippets Groups Projects
Commit 6d79dc03 authored by Frank Winklmeier's avatar Frank Winklmeier
Browse files

PropertyProxy: fix append to empty default HandleArray

Appending to an empty default HandleArray was not possible. Fix and add
unit test.
parent bab27eb2
No related branches found
No related tags found
1 merge request!1529PropertyProxy: fix append to empty default HandleArray
......@@ -207,8 +207,6 @@ class GaudiHandlePropertyProxyBase(PropertyProxy):
self._handleType = handleType
self._confTypeName = "Configurable" + handleType.componentType
# print "%s: %r (%s)" % (self.__class__.__name__,self._handleType,self._confTypeName)
def __get__(self, obj, type=None):
try:
return self.descr.__get__(obj, type)
......@@ -217,8 +215,9 @@ class GaudiHandlePropertyProxyBase(PropertyProxy):
try:
default = obj.__class__.getDefaultProperty(self.descr.__name__)
default = self.convertDefaultToBeSet(obj, default)
if default:
if default is not None:
self.__set__(obj, default)
except AttributeError as e:
# change type of exception to avoid false error message
raise RuntimeError(*e.args)
......
......@@ -11,6 +11,7 @@
import pytest
from GaudiKernel.Configurable import Configurable, ConfigurableAlgorithm
from GaudiKernel.DataHandle import DataHandle
from GaudiKernel.GaudiHandles import PublicToolHandleArray
# Prepare dummy configurables
......@@ -22,6 +23,7 @@ class MyAlg(ConfigurableAlgorithm):
"Dict": {},
"List": [],
"Set": set(),
"ToolHandleArray": PublicToolHandleArray(),
}
def getDlls(self):
......@@ -51,6 +53,7 @@ def test_correct():
a.Dict = {"a": 1}
a.List = [1, 2]
a.Set = {1, 2}
a.ToolHandleArray = ["foo/bar"]
assert a.getValuedProperties() == {
"Int": 42,
"Text": "value",
......@@ -58,6 +61,7 @@ def test_correct():
"Dict": {"a": 1},
"List": [1, 2],
"Set": {1, 2},
"ToolHandleArray": PublicToolHandleArray(["foo/bar"]),
}
......@@ -67,6 +71,12 @@ def test_str_from_datahandle():
assert a.getProp("Text") == "value"
def test_default_handle_append():
a = MyAlg()
a.ToolHandleArray += ["foo/bar"]
assert a.ToolHandleArray == PublicToolHandleArray(["foo/bar"])
def test_invalid_value():
a = MyAlg()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment