diff options
author | andy <andy@whiskeymedia.com> | 2013-06-06 11:30:23 -0700 |
---|---|---|
committer | andy <andy@whiskeymedia.com> | 2013-06-06 11:30:23 -0700 |
commit | 6a69aa50797f95b8fd426651ac0b27d7718036d9 (patch) | |
tree | 33bc095766d7193aabc2c7a903c00c52b64c0a8f /tests/test_encoding.py | |
parent | a207d76939b640634095a49c4790003839a0a669 (diff) | |
download | redis-py-6a69aa50797f95b8fd426651ac0b27d7718036d9.tar.gz |
encoding tests
Diffstat (limited to 'tests/test_encoding.py')
-rw-r--r-- | tests/test_encoding.py | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/test_encoding.py b/tests/test_encoding.py new file mode 100644 index 0000000..5a02736 --- /dev/null +++ b/tests/test_encoding.py @@ -0,0 +1,34 @@ +from __future__ import with_statement +import pytest + +from redis._compat import unichr, u, unicode +from redis.utils import HIREDIS_AVAILABLE +from .conftest import r as _redis_client + + +@pytest.fixture(scope="module") +def r(request): + return _redis_client(request=request, decode_responses=True) + + +class BaseEncodingTests(object): + def test_simple_encoding(self, r): + unicode_string = unichr(3456) + u('abcd') + unichr(3421) + r['unicode-string'] = unicode_string + cached_val = r['unicode-string'] + assert isinstance(cached_val, unicode) + assert unicode_string == cached_val + + def test_list_encoding(self, r): + unicode_string = unichr(3456) + u('abcd') + unichr(3421) + result = [unicode_string, unicode_string, unicode_string] + r.rpush('a', *result) + assert r.lrange('a', 0, -1) == result + + +class TestPythonParserEncoding(BaseEncodingTests): + pass + +if HIREDIS_AVAILABLE: + class TestHiredisParserEncoding(BaseEncodingTests): + pass |