Attribute read methods broken in 9.4.0 for derived devices
SKA's testing showed failure for some attributes. Just reading an attribute from this device leads to a failure like this:
def __check_read_attribute(dev_attr):
if dev_attr.has_failed:
> raise DevFailed(*dev_attr.get_err_stack())
E PyTango.DevFailed: DevFailed[
E DevError[
E desc = TypeError: SKABaseDevice.read_longRunningCommandResult() missing 1 required positional argument: 'attr'
E
E origin = Traceback (most recent call last):
E File "/usr/local/lib/python3.10/dist-packages/tango/server.py", line 110, in read_attr
E ret = worker.execute(read_method, self)
E File "/usr/local/lib/python3.10/dist-packages/tango/green.py", line 98, in execute
E return fn(*args, **kwargs)
E TypeError: SKABaseDevice.read_longRunningCommandResult() missing 1 required positional argument: 'attr'
E
E reason = PyDs_PythonError
E severity = ERR]
E
E DevError[
E desc = Failed to read_attribute on device test/lrccontroller/1, attribute longRunningCommandResult
E origin = virtual Tango::DeviceAttribute Tango::DeviceProxy::read_attribute(const string&) at (/src/cppTango/cppapi/client/devapi_base.cpp:5621)
E reason = API_AttributeFailed
E severity = ERR]
E ]
The problem is due to the wrapping of read attribute methods, most likely in !522 (merged). They get wrapped again, in every derived class.
A simple unit test that shows this for attribute reads (we need to check read, write and isallowed methods for attributes, and the wrapping for commands):
def test_inheritance_without_decorator_syntax():
class A(Device):
attr = attribute(access=AttrWriteType.READ_WRITE)
def read_attr(self):
return self.attr_value
def write_attr(self, value):
self.attr_value = value
class B(A):
pass
with DeviceTestContext(B) as proxy:
proxy.attr = 1.5
assert proxy.attr == 1.5