fix tests from mlz repo

- fix omit_unchanged
- names too short
+ other pylint complains
Change-Id: I3c277b461fad1a5fdf8e76ff1cc42b8742d1de16

Change-Id: I58fb64f91bcc2efef20df68f5c63a64315413286
This commit is contained in:
zolliker 2021-11-12 17:13:40 +01:00
parent 1eecc93f71
commit 77acda840a
5 changed files with 23 additions and 18 deletions

View File

@ -367,6 +367,7 @@ class Command(Accessible):
self.description = inspect.cleandoc(argument.__doc__) self.description = inspect.cleandoc(argument.__doc__)
self.name = self.func.__name__ # this is probably not needed self.name = self.func.__name__ # this is probably not needed
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
@ -375,7 +376,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:

View File

@ -57,7 +57,7 @@ import json
from secop.lib import getGeneralConfig from secop.lib import getGeneralConfig
from secop.datatypes import EnumType from secop.datatypes import EnumType
from secop.params import Parameter, Property, BoolType, Command from secop.params import Parameter, Property, Command
from secop.modules import HasAccessibles from secop.modules import HasAccessibles

View File

@ -71,7 +71,11 @@ class Data:
class DispatcherStub: class DispatcherStub:
OMIT_UNCHANGED_WITHIN = 0 # the first update from the poller comes a very short time after the
# initial value from the timestamp. However, in the test below
# the second update happens after the updates dict is cleared
# -> we have to inhibit the 'omit unchanged update' feature
omit_unchanged_within = 0
def __init__(self, updates): def __init__(self, updates):
self.updates = updates self.updates = updates
@ -108,6 +112,7 @@ def test_IOHandler():
group1 = Hdl('group1', 'SIMPLE?', '%g') group1 = Hdl('group1', 'SIMPLE?', '%g')
group2 = Hdl('group2', 'CMD?%(channel)d', '%g,%s,%d') group2 = Hdl('group2', 'CMD?%(channel)d', '%g,%s,%d')
class Module1(Module): class Module1(Module):
channel = Property('the channel', IntRange(), default=3) channel = Property('the channel', IntRange(), default=3)
loop = Property('the loop', IntRange(), default=2) loop = Property('the loop', IntRange(), default=2)

View File

@ -93,7 +93,7 @@ def test_Override():
assert id(Mod.p3) == id(Base.p3) assert id(Mod.p3) == id(Base.p3)
assert repr(Mod.p2) == repr(Base.p2) # must be a clone assert repr(Mod.p2) == repr(Base.p2) # must be a clone
assert repr(Mod.p3) == repr(Base.p3) # must be a clone assert repr(Mod.p3) == repr(Base.p3) # must be a clone
assert Mod.p1.default == True assert Mod.p1.default is True
# manipulating default makes Base.p1 and Mod.p1 match # manipulating default makes Base.p1 and Mod.p1 match
Mod.p1.default = False Mod.p1.default = False
assert repr(Mod.p1) == repr(Base.p1) assert repr(Mod.p1) == repr(Base.p1)

View File

@ -162,23 +162,23 @@ def test_Property_override():
def test_Properties_mro(): def test_Properties_mro():
class A(HasProperties): class Base(HasProperties):
p = Property('base', StringType(), 'base', export='always') prop = Property('base', StringType(), 'base', export='always')
class B(A): class SubA(Base):
pass pass
class C(A): class SubB(Base):
p = Property('sub', FloatRange(), extname='p') prop = Property('sub', FloatRange(), extname='prop')
class D(C, B): class FinalBA(SubB, SubA):
p = 1 prop = 1
class E(B, C): class FinalAB(SubA, SubB):
p = 2 prop = 2
assert B().exportProperties() == {'_p': 'base'} assert SubA().exportProperties() == {'_prop': 'base'}
assert D().exportProperties() == {'p': 1.0} assert FinalBA().exportProperties() == {'prop': 1.0}
# in an older implementation the following would fail, as B.p is constructed first # in an older implementation the following would fail, as SubA.p is constructed first
# and then B.p overrides C.p # and then SubA.p overrides SubB.p
assert E().exportProperties() == {'p': 2.0} assert FinalAB().exportProperties() == {'prop': 2.0}