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.name = self.func.__name__ # this is probably not needed
self._inherit = inherit # save for __set_name__
self.ownProperties = self.propertyValues.copy()
def __set_name__(self, owner, name):
self.name = name
@ -375,7 +376,6 @@ class Command(Accessible):
(owner.__name__, name))
self.datatype = CommandType(self.argument, self.result)
self.ownProperties = self.propertyValues.copy()
if self.export is True:
predefined_cls = PREDEFINED_ACCESSIBLES.get(name, None)
if predefined_cls is Command:

View File

@ -57,7 +57,7 @@ import json
from secop.lib import getGeneralConfig
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

View File

@ -71,7 +71,11 @@ class Data:
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):
self.updates = updates
@ -108,6 +112,7 @@ def test_IOHandler():
group1 = Hdl('group1', 'SIMPLE?', '%g')
group2 = Hdl('group2', 'CMD?%(channel)d', '%g,%s,%d')
class Module1(Module):
channel = Property('the channel', IntRange(), default=3)
loop = Property('the loop', IntRange(), default=2)

View File

@ -93,7 +93,7 @@ def test_Override():
assert id(Mod.p3) == id(Base.p3)
assert repr(Mod.p2) == repr(Base.p2) # 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
Mod.p1.default = False
assert repr(Mod.p1) == repr(Base.p1)

View File

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