Skip to content

Commit

Permalink
Merge branch 'heckj-sortset'
Browse files Browse the repository at this point in the history
* heckj-sortset:
  force a possible set into a list
  • Loading branch information
jamesls committed Mar 19, 2014
2 parents 0e1a60a + d734ec0 commit 869bbd9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion fakeredis.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ def sort(self, name, start=None, num=None, by=None, get=None, desc=False,
raise redis.RedisError(
"RedisError: ``start`` and ``num`` must both be specified")
try:
data = self._db[name][:]
data = list(self._db[name])[:]
if by is not None:
# _sort_using_by_arg mutates data so we don't
# need need a return value.
Expand Down
6 changes: 6 additions & 0 deletions test_fakeredis.py
Original file line number Diff line number Diff line change
Expand Up @@ -1250,6 +1250,12 @@ def test_sort_with_hash(self):
self.redis.sort('foo', by='record_*->age', get='record_*->name'),
['baby', 'teen', 'adult'])

def test_sort_with_set(self):
self.redis.sadd('foo', '3')
self.redis.sadd('foo', '1')
self.redis.sadd('foo', '2')
self.assertEqual(self.redis.sort('foo'), ['1', '2', '3'])

def test_pipeline(self):
# The pipeline method returns an object for
# issuing multiple commands in a batch.
Expand Down

0 comments on commit 869bbd9

Please sign in to comment.