Conversation
|
Thank you for the contribution. I will have to sleep on this I think: Python enums have the duplicity between names and values which seem somewhat redundant and create problems everywhere were I have used them. I wish the default The reasoning for using names was that they seemed much more natural for things like The proposed option is to try both things, which is certainly possible, but is a minor departure from the "simplicity of implementation" goal. For one I would like to see if On a different note, I would prefer if tests remained inside the module. For one this allows to quickly check that it works when installing on a new machine (or e.g for a different python version) without having to go to the repository. |
I understand your concerns. But I see that in python, especially with EDIT: what about Flag combinations? The last 4 test cases below return class Attributes(enum.Flag):
READ = enum.auto()
WRITE = enum.auto()
EXECUTE = enum.auto()
RW = READ | WRITE
RX = READ | EXECUTE
flag_enum_tests = [
["READ", Attributes.READ],
["WRITE", Attributes.WRITE],
["EXECUTE", Attributes.EXECUTE],
["RW", Attributes.RW],
["RX", Attributes.RX],
["READ|WRITE", Attributes.RW],
["READ|EXECUTE", Attributes.RX],
["READ|WRITE|EXECUTE", Attributes.READ | Attributes.WRITE | Attributes.EXECUTE],
["RX|EXECUTE|RW|WRITE|READ", Attributes.READ | Attributes.WRITE | Attributes.EXECUTE],
]
@pytest.mark.parametrize(("value", "expected"), flag_enum_tests)
def test_flag_enum(value, expected) -> None:
"""Enums are built also from value."""
assert parse_input(value, Attributes) == expected
To me CI/CD (github actions) should take care of ensuring that everything works, and the package only should bring the code needed to work. |
|
Regarding flags, these work fine |
This will parse the Enums either by name or by value.
I also moved the tests outside the source and used
pytest'sparametrizedecorator to make eachbad_inpitem into a separate testcloses #2