fix bug when overriding a property with bare value
the bare value must be converted to a updated property. add also a test for this Change-Id: I261daaaa8e12d7f739d8b2e8389c1b871b26c5b3 Reviewed-on: https://forge.frm2.tum.de/review/c/secop/frappy/+/34985 Reviewed-by: Markus Zolliker <markus.zolliker@psi.ch> Tested-by: Jenkins Automated Tests <pedersen+jenkins@frm2.tum.de>
This commit is contained in:
parent
142add9109
commit
e8cd193d0d
@ -143,6 +143,7 @@ class HasProperties(HasDescriptors):
|
||||
try:
|
||||
# try to apply bare value to Property
|
||||
po.value = po.datatype.validate(value)
|
||||
setattr(cls, pn, po) # replace bare value by updated Property
|
||||
except BadValueError:
|
||||
if callable(value):
|
||||
raise ProgrammingError(f'method {cls.__name__}.{pn} collides with property of {base.__name__}') from None
|
||||
|
@ -148,6 +148,8 @@ def test_Property_override():
|
||||
o2 = co()
|
||||
assert o1.a == 1
|
||||
assert o2.a == 3
|
||||
o2.setProperty('a', 4)
|
||||
assert o2.a == 4
|
||||
|
||||
with pytest.raises(ProgrammingError) as e:
|
||||
class cx(c): # pylint: disable=unused-variable
|
||||
|
Loading…
x
Reference in New Issue
Block a user