diff options
| author | Victor Stinner <vstinner@redhat.com> | 2015-04-23 15:29:57 +0200 |
|---|---|---|
| committer | Victor Stinner <vstinner@redhat.com> | 2015-04-23 16:14:09 +0200 |
| commit | 04f1c78c13bd54050b1d2d3baa9e86d9e79b3629 (patch) | |
| tree | d29e8a7b87547857aa920dbc2c7aea5d89ff75f6 /tests | |
| parent | 48e882719c7b95213bc0eae92f0ebc7c7fabd480 (diff) | |
| download | python-memcached-04f1c78c13bd54050b1d2d3baa9e86d9e79b3629.tar.gz | |
Port memcache to Python 3
* travis: make python 3 tests voting (cannot fail anymore)
* setup.py: add Python 3 classifiers
* Encode unicode key to UTF-8: add _encode_key() method
* Add _encode_cmd() helper method to format a memcache command as a byte
string (bytes%args will only be supported in Python 3.5)
* Rewrite _map_and_prefix_keys() code converting keys
* _val_to_store_info() now accepts Unicode: Unicode is encoded to UTF-8
* _set('cas') doesn't call _val_to_store_info() anymore when it's not
needed: begin by checking if the key is in the cas_ids dictionary
* Process server reply as bytes
* _recv_value() now clears the _FLAG_COMPRESSED flag after decompressing
to simplify the code
* On Python 3, _recv_value() now decodes byte strings from UTF-8
* Simplify check_key(), _encode_key() now encodes Unicode to UTF-8
* Replace u'...' with six.u('...') in tests for Python 3.2
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_memcache.py | 6 | ||||
| -rw-r--r-- | tests/test_setmulti.py | 2 |
2 files changed, 5 insertions, 3 deletions
diff --git a/tests/test_memcache.py b/tests/test_memcache.py index c12c528..e5c833a 100644 --- a/tests/test_memcache.py +++ b/tests/test_memcache.py @@ -2,6 +2,8 @@ from __future__ import print_function from unittest import TestCase +import six + from memcache import Client, SERVER_MAX_KEY_LENGTH try: @@ -135,14 +137,14 @@ if __name__ == "__main__": print("Testing sending a unicode-string key...", end=" ") try: - x = mc.set(u'keyhere', 1) + x = mc.set(six.u('keyhere'), 1) except Client.MemcachedStringEncodingError as msg: print("OK", end=" ") else: print("FAIL", end=" ") failures += 1 try: - x = mc.set((u'a'*SERVER_MAX_KEY_LENGTH).encode('utf-8'), 1) + x = mc.set((six.u('a')*SERVER_MAX_KEY_LENGTH).encode('utf-8'), 1) except Client.MemcachedKeyError: print("FAIL", end=" ") failures += 1 diff --git a/tests/test_setmulti.py b/tests/test_setmulti.py index cd06b04..2f7108a 100644 --- a/tests/test_setmulti.py +++ b/tests/test_setmulti.py @@ -21,7 +21,7 @@ DEBUG = False class test_Memcached_Set_Multi(unittest.TestCase): def setUp(self): - RECV_CHUNKS = ['chunk1'] + RECV_CHUNKS = [b'chunk1'] class FakeSocket(object): def __init__(self, *args): |
