Skip to content

Commit

Permalink
Changed Enum repr to match repr of structs, making copy and paste of …
Browse files Browse the repository at this point in the history
…printed structs back into python code easier
  • Loading branch information
ml31415 committed Apr 5, 2024
1 parent c90a7dd commit ec8a826
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions betfair_parser/strenums.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def _generate_next_value_(key, start, count, last_values):
return key

def __repr__(self):
return f"<{type(self).__name__}.{self.name}>"
return f"{type(self).__name__}.{self.name}"


class LowerStrEnum(StrEnum):
Expand Down Expand Up @@ -90,4 +90,4 @@ def __str__(self):
return self.name

def __repr__(self):
return f"<{type(self).__name__}.{self.name}>"
return f"{type(self).__name__}.{self.name}"
8 changes: 4 additions & 4 deletions tests/unit/test_strenums.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class SE(StrEnum):

assert SE.FIELD1 == "FIELD1"
assert SE.FIELD2 == "xyz"
assert repr(SE.FIELD2) == "<SE.FIELD2>"
assert repr(SE.FIELD2) == "SE.FIELD2"


def test_documented_enum():
Expand All @@ -22,15 +22,15 @@ class DE(DocumentedEnum):

assert DE.FIELD_AUTO.value == "FIELD_AUTO"
assert DE.FIELD_AUTO.__doc__ is None
assert repr(DE.FIELD_AUTO) == "<DE.FIELD_AUTO>"
assert repr(DE.FIELD_AUTO) == "DE.FIELD_AUTO"
assert DE.FIELD_DOC.value == "FIELD_DOC"
assert DE.FIELD_DOC.__doc__ == "This is a docstring"
assert DE.FIELD_DOC_VALUE.value == "doc_val"
assert DE.FIELD_DOC_VALUE.__doc__ == "This is another docstring"
assert repr(DE.FIELD_DOC) == "<DE.FIELD_DOC>"
assert repr(DE.FIELD_DOC) == "DE.FIELD_DOC"
assert DE.FIELD_VAL.value == "SOME_VALUE"
assert DE.FIELD_VAL.__doc__ is None
assert repr(DE.FIELD_VAL) == "<DE.FIELD_VAL>"
assert repr(DE.FIELD_VAL) == "DE.FIELD_VAL"

assert DE("FIELD_AUTO") == DE.FIELD_AUTO
assert set(DE._value2member_map_.keys()) == {"FIELD_AUTO", "FIELD_DOC", "doc_val", "SOME_VALUE"}
Expand Down

0 comments on commit ec8a826

Please sign in to comment.