Skip to content

Commit 88e964d

Browse files
committed
fix tests and lint
Signed-off-by: gruebel <[email protected]>
1 parent 9988c08 commit 88e964d

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

openfeature/exception.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,3 @@ def to_exception(
190190
) -> OpenFeatureError:
191191
exc = cls.__exceptions__.get(error_code.value, GeneralError)
192192
return exc(error_message)
193-
194-
def __str__(self):
195-
return self.value

tests/features/steps/hooks_steps.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from unittest.mock import MagicMock
22

3-
from behave import then, given
3+
from behave import given, then
44

55
from openfeature.exception import ErrorCode
66
from openfeature.flag_evaluation import Reason
@@ -31,11 +31,8 @@ def step_impl_should_have_eval_details(context, hook_names):
3131
for row in context.table:
3232
flag_type, key, value = row
3333

34-
value = convert_value_from_flag_type(value, flag_type)
35-
34+
value = convert_value_from_key_and_flag_type(value, key, flag_type)
3635
actual = hook.call_args[1]["details"].__dict__[key]
37-
if isinstance(actual, ErrorCode) or isinstance(actual, Reason):
38-
actual = str(actual)
3936

4037
print("expected", value, "actual", actual)
4138
print("expected type", type(value), "actual type", type(actual))
@@ -55,13 +52,17 @@ def get_hook_from_name(context, hook_name):
5552
raise ValueError(str(hook_name) + " is not a valid hook name")
5653

5754

58-
def convert_value_from_flag_type(value, flag_type):
59-
if value == "None" or value == "null":
55+
def convert_value_from_key_and_flag_type(value, key, flag_type):
56+
if value in ("None", "null"):
6057
return None
6158
if flag_type.lower() == "boolean":
6259
return bool(value)
6360
elif flag_type.lower() == "integer":
6461
return int(value)
6562
elif flag_type.lower() == "float":
6663
return float(value)
64+
elif key == "reason":
65+
return Reason(value)
66+
elif key == "error_code":
67+
return ErrorCode(value)
6768
return value

0 commit comments

Comments
 (0)