From f4ba7d8b42aced0f2a27ab8d7c33005be97c7dae Mon Sep 17 00:00:00 2001 From: Bohdan Dobrovolskyi Date: Wed, 13 Mar 2024 16:26:50 +0200 Subject: [PATCH] Add tests --- featureflags_client/http/conditions.py | 2 +- featureflags_client/tests/http/test_conditions.py | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/featureflags_client/http/conditions.py b/featureflags_client/http/conditions.py index 1bec2cb..2adeca9 100644 --- a/featureflags_client/http/conditions.py +++ b/featureflags_client/http/conditions.py @@ -17,7 +17,7 @@ def except_false(func: Callable) -> Callable: def wrapper(ctx: Dict[str, Any]) -> Any: try: return func(ctx) - except TypeError: + except (TypeError, ValueError): return False return wrapper diff --git a/featureflags_client/tests/http/test_conditions.py b/featureflags_client/tests/http/test_conditions.py index 287e245..4d42bb1 100644 --- a/featureflags_client/tests/http/test_conditions.py +++ b/featureflags_client/tests/http/test_conditions.py @@ -98,6 +98,9 @@ def test_percent(): assert check_op(_UNDEFINED, percent, 100) is False + assert check_op("foo", percent, '100') is True + assert check_op("foo", percent, 'not_number') is False + def test_regexp(): assert check_op("anything", regexp, ".") is True