Skip to content
Snippets Groups Projects
Commit c0fdddd5 authored by Marco Clemencic's avatar Marco Clemencic
Browse files

Handle incompatible values for DataObjectHandleBase props (mr !654)

Backport of !650
parents e00bb2f2 f6ecadc9
No related branches found
No related tags found
No related merge requests found
Pipeline #
......@@ -385,6 +385,9 @@ class DataObjectHandleBasePropertyProxy(PropertyProxy):
return DataObjectHandleBase(value)
elif isinstance(value, DataObjectHandleBase):
return DataObjectHandleBase(value.__str__())
else:
raise ValueError("received an instance of %s, but %s expected" %
(type(value), 'str or DataObjectHandleBase'))
def PropertyProxyFactory(descr, doc, default):
......
# Prepare dummy configurables
from GaudiKernel.Configurable import ConfigurableAlgorithm, Configurable
from GaudiKernel.DataObjectHandleBase import DataObjectHandleBase
class MyAlg(ConfigurableAlgorithm):
__slots__ = {'Text': 'some text',
'Int': 23}
'Int': 23,
'DataHandle': DataObjectHandleBase('Location')}
def getDlls(self):
return 'Dummy'
......@@ -26,7 +28,10 @@ def test_correct():
a = MyAlg()
a.Int = 42
a.Text = 'value'
assert a.getValuedProperties() == {'Int': 42, 'Text': 'value'}
a.DataHandle = '/Event/X'
assert a.getValuedProperties() == {
'Int': 42, 'Text': 'value',
'DataHandle': DataObjectHandleBase('/Event/X')}
def test_invalid_value():
......@@ -53,6 +58,17 @@ def test_invalid_value():
assert False, 'ValueError exception expected, got %s' % type(
x).__name__
try:
a.DataHandle = [123]
assert False, 'exception expected'
except AssertionError:
raise
except ValueError:
pass
except Exception, x:
assert False, 'ValueError exception expected, got %s' % type(
x).__name__
def test_invalid_key():
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