simplify status type declaration
- StatusType: simpler inheritance (inherit from module instead of Enum) - StatusType: more robust for standard codes, give names only - <Module>.Status is automatically extended - Enum: accept duplicates with same name and value Change-Id: Iad1dacf14c31fe6f4ae48e7560b29e49838e4f23 Reviewed-on: https://forge.frm2.tum.de/review/c/secop/frappy/+/30716 Reviewed-by: Enrico Faulhaber <enrico.faulhaber@frm2.tum.de> Tested-by: Jenkins Automated Tests <pedersen+jenkins@frm2.tum.de> Reviewed-by: Markus Zolliker <markus.zolliker@psi.ch>
This commit is contained in:
@ -83,3 +83,12 @@ def test_Enum_bool():
|
||||
e = Enum('OffOn', off=0, on=1)
|
||||
assert bool(e(0)) is False
|
||||
assert bool(e(1)) is True
|
||||
|
||||
|
||||
def test_Enum_duplicate():
|
||||
e = Enum('x', a=1, b=2)
|
||||
Enum(e, b=2, c=3) # matching duplicate
|
||||
with pytest.raises(TypeError):
|
||||
Enum(e, b=3, c=4) # duplicate name with value mismatch
|
||||
with pytest.raises(TypeError):
|
||||
Enum(e, c=1) # duplicate value with name mismatch
|
||||
|
Reference in New Issue
Block a user