fix DataType.copy for nested types

all nested types need a specific copy method, as some information
of EnumType (its name) and TextType are not visible in the
exported form

Change-Id: I3ef765ca35cda11b10798c68a3e2115502554c2e
Reviewed-on: https://forge.frm2.tum.de/review/c/sine2020/secop/playground/+/21441
Tested-by: JenkinsCodeReview <bjoern_pedersen@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:
2019-10-18 16:32:12 +02:00
parent 536c798699
commit 0700ddc455
2 changed files with 22 additions and 0 deletions

View File

@ -195,6 +195,7 @@ def test_EnumType():
dt = EnumType('dt', a=3, c=7, stuff=1)
copytest(dt)
assert dt.export_datatype() == {'type': 'enum', 'members': dict(a=3, c=7, stuff=1)}
with pytest.raises(ValueError):
@ -396,6 +397,9 @@ def test_ArrayOf():
with pytest.raises(ConfigError):
dt.checkProperties()
dt = ArrayOf(EnumType('myenum', single=0), 5)
copytest(dt)
def test_TupleOf():
# test constructor catching illegal arguments
with pytest.raises(ValueError):
@ -417,6 +421,9 @@ def test_TupleOf():
assert dt.format_value([3,0]) == "(3, False)"
dt = TupleOf(EnumType('myenum', single=0))
copytest(dt)
def test_StructOf():
# test constructor catching illegal arguments
@ -449,6 +456,9 @@ def test_StructOf():
assert dt.format_value({'an_int':2, 'a_string':'Z'}) == "{a_string='Z', an_int=2}"
dt = StructOf(['optionalmember'], optionalmember=EnumType('myenum', single=0))
copytest(dt)
def test_Command():
dt = CommandType()