from unittest import TestCase

from pymemcache.serde import (python_memcache_serializer,
                              python_memcache_deserializer)


class TestSerde(TestCase):

    def check(self, value):
        serialized, flags = python_memcache_serializer(b'key', value)
        deserialized = python_memcache_deserializer(b'key', serialized, flags)
        assert deserialized == value

    def test_str(self):
        self.check('value')

    def test_int(self):
        self.check(1)

    def test_long(self):
        self.check(123123123123123123123)

    def test_pickleable(self):
        self.check({'a': 'dict'})

@@ -142,17 +142,62 @@
 alizer)%0A
-%0A
+import pytest%0Aimport six%0A%0A%0A@pytest.mark.unit()
 %0Aclass T
@@ -315,16 +315,294 @@
  value)%0A
+%0A        # pymemcache stores values as byte strings, so we immediately the value%0A        # if needed so deserialized works as it would with a real server%0A        if not isinstance(serialized, six.binary_type):%0A            serialized = six.text_type(serialized).encode('ascii')%0A%0A
         
@@ -723,19 +723,79 @@
 ef test_
-str
+bytes(self):%0A        self.check(b'value')%0A%0A    def test_unicode
 (self):%0A
@@ -813,16 +813,17 @@
 f.check(
+u
 'value')

Use byte strings after serializing with serde