Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes to support python3 #17

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions feature_ramp/Feature.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def _is_ramped(self, identifier):
if not.
"""
consistent_offset = hash(self.feature_name) % 100 if not self.feature_group_name else hash(self.feature_group_name)
identifier = identifier if isinstance(identifier, basestring) else str(identifier)
identifier = identifier if isinstance(identifier, str) else str(identifier)
ramp_ranking = (consistent_offset + hash(identifier)) % 100

return ramp_ranking < self.percentage
Expand Down Expand Up @@ -222,7 +222,7 @@ def _get_redis_key(self):
@classmethod
def _get_feature_name_from_redis_key(self, key):
""" Returns the feature name given the namespaced key used in Redis. """
return key.split('.')[-1]
return key.decode('utf-8').split('.')[-1]

@classmethod
def _get_redis_set_key(cls):
Expand Down
4 changes: 2 additions & 2 deletions tests/test_feature.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def tearDown(self):
def test_initialize_feature_with_default_percentage(self):
feature_test = Feature("testing", default_percentage=100)

self.assertEquals(feature_test.percentage, 100)
self.assertEqual(feature_test.percentage, 100)

def test_reset_settings(self):
""" Tests calling reset_settings resets the correct
Expand Down Expand Up @@ -277,7 +277,7 @@ def test_visible_ramp_using_string(self):
"""Tests calling is_visible when using string as identifier is
correct when partially ramped.
"""
identifiers = list(itertools.product(string.lowercase, repeat=3))
identifiers = list(itertools.product(string.ascii_lowercase, repeat=3))
total_number = len(identifiers)
expected_percentage = .10
self.feature_test.set_percentage(expected_percentage * 100)
Expand Down