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

Support decode_responses for string ops #118

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

romanlevin
Copy link

@romanlevin romanlevin commented Feb 13, 2017

Addresses #97


This change is Reviewable

@romanlevin
Copy link
Author

@srikalyan Could this and/or #119 ever be merged?

@linuxmaniac
Copy link

@romanlevin It seems something is still missing, if you use hgetall() with decode_responses = True you will get bytes not strings:

--- a/mockredis/tests/test_hash.py
+++ b/mockredis/tests/test_hash.py
@@ -25,6 +25,13 @@ class TestRedisHash(object):
         self.redis.hset(hashkey, "key", "value")
         eq_({b"key": b"value"}, self.redis.hgetall(hashkey))
 
+    def test_hgetall_decode_responses(self):
+        self.redis.decode_responses = True
+        hashkey = "hash"
+        eq_({}, self.redis.hgetall(hashkey))
+        self.redis.hset(hashkey, "key", "value")
+        eq_({"key": "value"}, self.redis.hgetall(hashkey))
+
     def test_hdel(self):
         hashkey = "hash"
         self.redis.hmset(hashkey, {1: 1, 2: 2, 3: 3})
tox -e py35
GLOB sdist-make: /home/vseva/projects/mockredis/setup.py
py35 create: /home/vseva/projects/mockredis/.tox/py35
py35 inst: /home/vseva/projects/mockredis/.tox/dist/mockredispy-2.9.3.zip
py35 installed: mockredispy==2.9.3,pkg-resources==0.0.0
py35 runtests: PYTHONHASHSEED='3169646320'
py35 runtests: commands[0] | python setup.py nosetests
running nosetests
running egg_info
writing entry points to mockredispy.egg-info/entry_points.txt
writing mockredispy.egg-info/PKG-INFO
writing dependency_links to mockredispy.egg-info/dependency_links.txt
writing requirements to mockredispy.egg-info/requires.txt
writing top-level names to mockredispy.egg-info/top_level.txt
reading manifest file 'mockredispy.egg-info/SOURCES.txt'
writing manifest file 'mockredispy.egg-info/SOURCES.txt'
Searching for redis>=2.9.0
Reading https://pypi.python.org/simple/redis/
Downloading https://pypi.python.org/packages/09/8d/6d34b75326bf96d4139a2ddd8e74b80840f800a0a79f9294399e212cb9a7/redis-2.10.6.tar.gz#md5=048348d8cfe0b5d0bba2f4d835005c3b
Best match: redis 2.10.6
Processing redis-2.10.6.tar.gz
Writing /tmp/easy_install-7ihbyknp/redis-2.10.6/setup.cfg
Running redis-2.10.6/setup.py -q bdist_egg --dist-dir /tmp/easy_install-7ihbyknp/redis-2.10.6/egg-dist-tmp-aoz8fgls
warning: no previously-included files found matching '__pycache__'
warning: no previously-included files matching '*.pyc' found under directory 'tests'
zip_safe flag not set; analyzing archive contents...
Moving redis-2.10.6-py3.5.egg to /home/vseva/projects/mockredis/.eggs

Installed /home/vseva/projects/mockredis/.eggs/redis-2.10.6-py3.5.egg
.........F.....................................................................................SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS....................................................................................................
======================================================================
FAIL: mockredis.tests.test_hash.TestRedisHash.test_hgetall_decode_responses
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/vseva/projects/mockredis/.eggs/nose-1.3.7-py3.5.egg/nose/case.py", line 197, in runTest
    self.test(*self.arg)
  File "/home/vseva/projects/mockredis/mockredis/tests/test_hash.py", line 33, in test_hgetall_decode_responses
    eq_({"key": "value"}, self.redis.hgetall(hashkey))
AssertionError: {'key': 'value'} != {b'key': b'value'}

----------------------------------------------------------------------
Ran 228 tests in 3.107s

FAILED (SKIP=33, failures=1)
ERROR: InvocationError: '/home/vseva/projects/mockredis/.tox/py35/bin/python setup.py nosetests'
________________________________________________________________________________________________________________________________________ summary _________________________________________________________________________________________________________________________________________
ERROR:   py35: commands failed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants