fix command inheritance
Command.ownProperties must be definead in __init__ + add test for this Change-Id: I283331be6439a49ec61d28f04869a5b44704236f Reviewed-on: https://forge.frm2.tum.de/review/c/sine2020/secop/playground/+/27104 Tested-by: Jenkins Automated Tests <pedersen+jenkins@frm2.tum.de> Reviewed-by: Enrico Faulhaber <enrico.faulhaber@frm2.tum.de> Reviewed-by: Markus Zolliker <markus.zolliker@psi.ch>
This commit is contained in:
parent
b8e8d24b50
commit
796be752b7
@ -364,6 +364,7 @@ class Command(Accessible):
|
|||||||
self.description = inspect.cleandoc(argument.__doc__)
|
self.description = inspect.cleandoc(argument.__doc__)
|
||||||
self.name = self.func.__name__
|
self.name = self.func.__name__
|
||||||
self._inherit = inherit # save for __set_name__
|
self._inherit = inherit # save for __set_name__
|
||||||
|
self.ownProperties = self.propertyValues.copy()
|
||||||
|
|
||||||
def __set_name__(self, owner, name):
|
def __set_name__(self, owner, name):
|
||||||
self.name = name
|
self.name = name
|
||||||
@ -372,7 +373,6 @@ class Command(Accessible):
|
|||||||
(owner.__name__, name))
|
(owner.__name__, name))
|
||||||
|
|
||||||
self.datatype = CommandType(self.argument, self.result)
|
self.datatype = CommandType(self.argument, self.result)
|
||||||
self.ownProperties = self.propertyValues.copy()
|
|
||||||
if self.export is True:
|
if self.export is True:
|
||||||
predefined_cls = PREDEFINED_ACCESSIBLES.get(name, None)
|
predefined_cls = PREDEFINED_ACCESSIBLES.get(name, None)
|
||||||
if predefined_cls is Command:
|
if predefined_cls is Command:
|
||||||
|
@ -103,3 +103,30 @@ def test_Export():
|
|||||||
class Mod(HasAccessibles):
|
class Mod(HasAccessibles):
|
||||||
param = Parameter('description1', datatype=BoolType, default=False)
|
param = Parameter('description1', datatype=BoolType, default=False)
|
||||||
assert Mod.param.export == '_param'
|
assert Mod.param.export == '_param'
|
||||||
|
|
||||||
|
|
||||||
|
def test_Command_Inheritance():
|
||||||
|
class Base(HasAccessibles):
|
||||||
|
@Command(BoolType(), visibility=2)
|
||||||
|
def cmd(self, arg):
|
||||||
|
"""first"""
|
||||||
|
|
||||||
|
class Sub(Base):
|
||||||
|
@Command(group='grp')
|
||||||
|
def cmd(self, arg):
|
||||||
|
"""second"""
|
||||||
|
|
||||||
|
class Sub2(Base):
|
||||||
|
@Command(FloatRange())
|
||||||
|
def cmd(self, arg):
|
||||||
|
"""third"""
|
||||||
|
|
||||||
|
assert Sub.accessibles['cmd'].for_export() == {
|
||||||
|
'description': 'second', 'group': 'grp', 'visibility': 2,
|
||||||
|
'datainfo': {'type': 'command', 'argument': {'type': 'bool'}}
|
||||||
|
}
|
||||||
|
|
||||||
|
assert Sub2.accessibles['cmd'].for_export() == {
|
||||||
|
'description': 'third', 'visibility': 2,
|
||||||
|
'datainfo': {'type': 'command', 'argument': {'type': 'double'}}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user