Skip to content

Commit bd873ad

Browse files
committed
fix: mimic the behavior of stdlib StrEnum.__str__ in backport
Signed-off-by: Federico Bond <federicobond@gmail.com>
1 parent 8fdd784 commit bd873ad

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

openfeature/_backports/strenum.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ class StrEnum(str, Enum):
1111
Backport StrEnum for Python <3.11
1212
"""
1313

14-
pass
14+
def __str__(self):
15+
return str(self.value)

tests/test_exception.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from openfeature.exception import ErrorCode
2+
3+
4+
def test_error_code_str():
5+
assert str(ErrorCode.GENERAL) == "GENERAL"

tests/test_flag_evaluation.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,7 @@ def test_evaluation_details_reason_should_be_a_string_when_set():
5454

5555
# Then
5656
assert Reason.STATIC == flag_details.reason # noqa: SIM300
57+
58+
59+
def test_reason_str():
60+
assert str(Reason.DEFAULT) == "DEFAULT"

0 commit comments

Comments
 (0)