add more tests and fixes for command inheritance
- fix CommandType.__repr__ - secop/modules.py: command properties are allowed to be configured: - section 2: remove comment and rename - section 3: all accessible properties should be checked - command description should be inherited also when taken from docstring - move test for command inheritance to test_modules.py - added tests to check for valid properties of commands Change-Id: Ic7795e305048625558e415ece099e6824df6e2c4 Reviewed-on: https://forge.frm2.tum.de/review/c/sine2020/secop/playground/+/27135 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:
@ -346,6 +346,9 @@ class Command(Accessible):
|
||||
|
||||
def __init__(self, argument=False, *, result=None, inherit=True, **kwds):
|
||||
super().__init__()
|
||||
if 'datatype' in kwds:
|
||||
# self.init will complain about invalid keywords except 'datatype', as this is a property
|
||||
raise ProgrammingError("Command() got an invalid keyword 'datatype'")
|
||||
self.init(kwds)
|
||||
if result or kwds or isinstance(argument, DataType) or not callable(argument):
|
||||
# normal case
|
||||
@ -362,7 +365,7 @@ class Command(Accessible):
|
||||
self.func = argument # this is the wrapped method!
|
||||
if argument.__doc__:
|
||||
self.description = inspect.cleandoc(argument.__doc__)
|
||||
self.name = self.func.__name__
|
||||
self.name = self.func.__name__ # this is probably not needed
|
||||
self._inherit = inherit # save for __set_name__
|
||||
self.ownProperties = self.propertyValues.copy()
|
||||
|
||||
@ -397,6 +400,7 @@ class Command(Accessible):
|
||||
"""called when used as decorator"""
|
||||
if 'description' not in self.propertyValues and func.__doc__:
|
||||
self.description = inspect.cleandoc(func.__doc__)
|
||||
self.ownProperties['description'] = self.description
|
||||
self.func = func
|
||||
return self
|
||||
|
||||
|
Reference in New Issue
Block a user