summaryrefslogtreecommitdiff
path: root/pymemcache/test/utils.py
diff options
context:
space:
mode:
authorJianGuoPinterest <51248389+JianGuoPinterest@users.noreply.github.com>2019-06-07 15:29:14 -0700
committerJon Parise <jon@pinterest.com>2019-06-07 15:29:14 -0700
commitf23602c176f72cda367f618f20e0c89940431130 (patch)
treeac1a27ad3d600027f139e2123f18d3872844dd55 /pymemcache/test/utils.py
parent708fb55e2af6d5a58046f1ff5597f0024b5865e2 (diff)
downloadpymemcache-f23602c176f72cda367f618f20e0c89940431130.tar.gz
add encoding in client functions (#232)
Diffstat (limited to 'pymemcache/test/utils.py')
-rw-r--r--pymemcache/test/utils.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/pymemcache/test/utils.py b/pymemcache/test/utils.py
index a30e98c..826e052 100644
--- a/pymemcache/test/utils.py
+++ b/pymemcache/test/utils.py
@@ -27,7 +27,8 @@ class MockMemcacheClient(object):
no_delay=False,
ignore_exc=False,
default_noreply=True,
- allow_unicode_keys=False):
+ allow_unicode_keys=False,
+ encoding='ascii'):
self._contents = {}
@@ -41,6 +42,7 @@ class MockMemcacheClient(object):
self.timeout = timeout
self.no_delay = no_delay
self.ignore_exc = ignore_exc
+ self.encoding = encoding
def get(self, key, default=None):
if not self.allow_unicode_keys:
@@ -80,15 +82,15 @@ class MockMemcacheClient(object):
if isinstance(key, six.string_types):
try:
if isinstance(key, bytes):
- key = key.decode().encode('ascii')
+ key = key.decode().encode()
else:
- key = key.encode('ascii')
+ key = key.encode(self.encoding)
except (UnicodeEncodeError, UnicodeDecodeError):
raise MemcacheIllegalInputError
if (isinstance(value, six.string_types) and
not isinstance(value, six.binary_type)):
try:
- value = value.encode('ascii')
+ value = value.encode(self.encoding)
except (UnicodeEncodeError, UnicodeDecodeError):
raise MemcacheIllegalInputError