From 5588df075b6e3b22ff25a6b3034992d0e2a42b25 Mon Sep 17 00:00:00 2001 From: Federico Bond Date: Sun, 7 Dec 2025 12:02:41 +1100 Subject: [PATCH] fix: mimic the behavior of stdlib StrEnum.__str__ in backport Signed-off-by: Federico Bond --- openfeature/_backports/strenum.py | 3 ++- tests/test_exception.py | 5 +++++ tests/test_flag_evaluation.py | 4 ++++ 3 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 tests/test_exception.py diff --git a/openfeature/_backports/strenum.py b/openfeature/_backports/strenum.py index 6dcdfd7d..5e453e8a 100644 --- a/openfeature/_backports/strenum.py +++ b/openfeature/_backports/strenum.py @@ -11,4 +11,5 @@ class StrEnum(str, Enum): Backport StrEnum for Python <3.11 """ - pass + def __str__(self) -> str: + return str(self.value) diff --git a/tests/test_exception.py b/tests/test_exception.py new file mode 100644 index 00000000..d25d4440 --- /dev/null +++ b/tests/test_exception.py @@ -0,0 +1,5 @@ +from openfeature.exception import ErrorCode + + +def test_error_code_str(): + assert str(ErrorCode.GENERAL) == "GENERAL" diff --git a/tests/test_flag_evaluation.py b/tests/test_flag_evaluation.py index ec6d9411..11139b08 100644 --- a/tests/test_flag_evaluation.py +++ b/tests/test_flag_evaluation.py @@ -54,3 +54,7 @@ def test_evaluation_details_reason_should_be_a_string_when_set(): # Then assert Reason.STATIC == flag_details.reason # noqa: SIM300 + + +def test_reason_str(): + assert str(Reason.DEFAULT) == "DEFAULT"