Remove Enum prefixes (#187)
Co-authored-by: nat <n@natn.me> Co-authored-by: Tim Schmidt <w4rum@users.noreply.github.com> Co-authored-by: Arun Babu Neelicattu <arun.neelicattu@gmail.com>
This commit is contained in:
committed by
GitHub
parent
d9b7608980
commit
bd7de203e1
@@ -15,3 +15,11 @@ enum Choice {
|
||||
FOUR = 4;
|
||||
THREE = 3;
|
||||
}
|
||||
|
||||
// A "C" like enum with the enum name prefixed onto members, these should be stripped
|
||||
enum ArithmeticOperator {
|
||||
ARITHMETIC_OPERATOR_NONE = 0;
|
||||
ARITHMETIC_OPERATOR_PLUS = 1;
|
||||
ARITHMETIC_OPERATOR_MINUS = 2;
|
||||
ARITHMETIC_OPERATOR_0_PREFIXED = 3;
|
||||
}
|
||||
|
@@ -1,4 +1,5 @@
|
||||
from tests.output_betterproto.enum import (
|
||||
ArithmeticOperator,
|
||||
Choice,
|
||||
Test,
|
||||
)
|
||||
@@ -102,3 +103,12 @@ def test_enum_mapped_on_parse():
|
||||
|
||||
# bonus: defaults after empty init are also mapped
|
||||
assert Test().choice.name == Choice.ZERO.name
|
||||
|
||||
|
||||
def test_renamed_enum_members():
|
||||
assert set(ArithmeticOperator.__members__) == {
|
||||
"NONE",
|
||||
"PLUS",
|
||||
"MINUS",
|
||||
"_0_PREFIXED",
|
||||
}
|
||||
|
Reference in New Issue
Block a user