Skip to content

Commit

Permalink
fix - py3 encode case
Browse files Browse the repository at this point in the history
  • Loading branch information
oakbani committed Oct 24, 2018
1 parent e2c2c59 commit eec24be
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
6 changes: 3 additions & 3 deletions optimizely/helpers/condition.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import math
import numbers

from six import string_types
from six import string_types, PY2
from nose.tools import set_trace

CUSTOM_ATTRIBUTE_CONDITION_TYPE = 'custom_attribute'
Expand Down Expand Up @@ -153,13 +153,13 @@ def is_value_valid_for_exact_conditions(self, value):

def exact_evaluator(self, condition):
condition_value = self.condition_data[condition][1]
if isinstance(condition_value, string_types):
if PY2 and isinstance(condition_value, unicode):
condition_value = condition_value.encode()

condition_value_type = type(condition_value)

user_value = self.attributes.get(self.condition_data[condition][0])
if isinstance(user_value, string_types):
if PY2 and isinstance(user_value, unicode):
user_value = user_value.encode()

user_value_type = type(user_value)
Expand Down
6 changes: 0 additions & 6 deletions tests/helpers_tests/test_condition.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,12 +374,6 @@ def test_exists__returns_true__when_user_provided_value_is_number(self):

self.assertStrictTrue(evaluator.evaluate(0))

evaluator = condition_helper.CustomAttributeConditionEvaluator(
self.exists_condition_list, {'input_value': 10L}
)

self.assertStrictTrue(evaluator.evaluate(0))

def test_exists__returns_true__when_user_provided_value_is_boolean(self):

evaluator = condition_helper.CustomAttributeConditionEvaluator(
Expand Down

0 comments on commit eec24be

Please sign in to comment.