You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It seems that setting a signal with type SubsetEnum allows strings that are not attributes of the enum. Passing other types, like an int, will raise a ValueError
ex: ValueError: 1 is not a valid TestEnums
Is this expected behaviour? And if so, should this be better documented in the SubsetEnum definition?
This is expected behaviour. EPICS enums can be address by string value or integer index, but the integer index is generally more liable to change than the string value. For this reason we make SubsetEnum a str, Enum, and allow any other str to be put. The only exception to this is 2 member enums that are effectively True/False. For these you can use bool rather than SubsetEnum.
I'm a little confused about the code above, it looks like it should work, does it fail?
Quick Note: Sorry, I've just edited the issue, as I mistakenly put signal.set("str") instead of signal.set("test_str") to show any str is accepted; although, I think you addressed this in your comment anyways @coretl
As discussed, setting a SubsetEnum signal to an arbitrary string will fail at runtime on real devices, but not in unit tests due to how mock mode works. We should include in a docstring that this behaviour is different in unit tests
It seems that setting a signal with type
SubsetEnum
allows strings that are not attributes of the enum. Passing other types, like an int, will raise a ValueErrorex:
ValueError: 1 is not a valid TestEnums
Is this expected behaviour? And if so, should this be better documented in the
SubsetEnum
definition?Steps To Reproduce
Steps to reproduce the behavior:
The text was updated successfully, but these errors were encountered: