fix missing import in change message
Transported values in a change must be converted first. As this is only relevant for the exotic "scaled" and "blob" datatypes, this was not detected yet. - add tests - suppress warning PytestUnhandledThreadExceptionWarning in tests + change import_value methods to raise no other exceptions than WrongTypeError and RangeError + simplify Command.do: as import_value already raises the appropriate error, no more try/except is needed Change-Id: I299e511468dc0fcecff4c20cf8a917da38b70786 Reviewed-on: https://forge.frm2.tum.de/review/c/secop/frappy/+/32743 Tested-by: Jenkins Automated Tests <pedersen+jenkins@frm2.tum.de> Reviewed-by: Enrico Faulhaber <enrico.faulhaber@frm2.tum.de> Reviewed-by: Alexander Zaft <a.zaft@fz-juelich.de> Reviewed-by: Markus Zolliker <markus.zolliker@psi.ch>
This commit is contained in:
@ -46,7 +46,6 @@ def test_DataType():
|
||||
with pytest.raises(NotImplementedError):
|
||||
dt('')
|
||||
dt.export_value('')
|
||||
dt.import_value('')
|
||||
|
||||
|
||||
def test_FloatRange():
|
||||
@ -62,8 +61,12 @@ def test_FloatRange():
|
||||
dt(-9) # convert, but do not check limits
|
||||
with pytest.raises(WrongTypeError):
|
||||
dt('XX')
|
||||
with pytest.raises(WrongTypeError):
|
||||
dt.import_value('XX')
|
||||
with pytest.raises(WrongTypeError):
|
||||
dt([19, 'X'])
|
||||
with pytest.raises(WrongTypeError):
|
||||
dt.import_value([19, 'X'])
|
||||
dt(1)
|
||||
dt(0)
|
||||
dt(13.14 - 10) # raises an error, if resolution is not handled correctly
|
||||
@ -115,12 +118,20 @@ def test_IntRange():
|
||||
dt(-9) # convert, but do not check limits
|
||||
with pytest.raises(WrongTypeError):
|
||||
dt('XX')
|
||||
with pytest.raises(WrongTypeError):
|
||||
dt.import_value('XX')
|
||||
with pytest.raises(WrongTypeError):
|
||||
dt([19, 'X'])
|
||||
with pytest.raises(WrongTypeError):
|
||||
dt.import_value([19, 'X'])
|
||||
with pytest.raises(WrongTypeError):
|
||||
dt(1.3)
|
||||
with pytest.raises(WrongTypeError):
|
||||
dt.import_value(1.3)
|
||||
with pytest.raises(WrongTypeError):
|
||||
dt('1.3')
|
||||
with pytest.raises(WrongTypeError):
|
||||
dt.import_value('1.3')
|
||||
dt(1)
|
||||
dt(0)
|
||||
with pytest.raises(ProgrammingError):
|
||||
@ -153,8 +164,12 @@ def test_ScaledInteger():
|
||||
dt(-9) # convert, but do not check limits
|
||||
with pytest.raises(WrongTypeError):
|
||||
dt('XX')
|
||||
with pytest.raises(WrongTypeError):
|
||||
dt.import_value('XX')
|
||||
with pytest.raises(WrongTypeError):
|
||||
dt([19, 'X'])
|
||||
with pytest.raises(WrongTypeError):
|
||||
dt.import_value([19, 'X'])
|
||||
dt(1)
|
||||
dt(0)
|
||||
with pytest.raises(ProgrammingError):
|
||||
@ -218,12 +233,20 @@ def test_EnumType():
|
||||
|
||||
with pytest.raises(RangeError):
|
||||
dt(9)
|
||||
with pytest.raises(RangeError):
|
||||
dt.import_value(9)
|
||||
with pytest.raises(RangeError):
|
||||
dt(-9)
|
||||
with pytest.raises(RangeError):
|
||||
dt.import_value(-9)
|
||||
with pytest.raises(RangeError):
|
||||
dt('XX')
|
||||
with pytest.raises(RangeError):
|
||||
dt.import_value('XX')
|
||||
with pytest.raises(WrongTypeError):
|
||||
dt([19, 'X'])
|
||||
with pytest.raises(WrongTypeError):
|
||||
dt.import_value([19, 'X'])
|
||||
|
||||
assert dt('a') == 3
|
||||
assert dt('stuff') == 1
|
||||
@ -266,6 +289,10 @@ def test_BLOBType():
|
||||
dt(b'abcdefghijklmno')
|
||||
with pytest.raises(WrongTypeError):
|
||||
dt('abcd')
|
||||
with pytest.raises(WrongTypeError):
|
||||
dt.import_value('ab')
|
||||
with pytest.raises(WrongTypeError):
|
||||
dt.import_value(b'xxx')
|
||||
assert dt(b'abcd') == b'abcd'
|
||||
|
||||
dt.setProperty('minbytes', 1)
|
||||
|
Reference in New Issue
Block a user