async def test_get_set_alt_serializer_functions(self, cache): cache.serializer = StringSerializer() await cache.set(pytest.KEY, "value", dumps_fn=dumps) assert await cache.get(pytest.KEY) == "v4lu3" assert await cache.get(pytest.KEY, loads_fn=loads) == "value"
async def test_add_get_types(self, cache, obj): cache.serializer = StringSerializer() assert await cache.add(pytest.KEY, obj) is True assert await cache.get(pytest.KEY) == str(obj)
async def test_multi_set_multi_get_types(self, cache, obj): cache.serializer = StringSerializer() assert await cache.multi_set([(pytest.KEY, obj)]) is True assert await cache.multi_get([pytest.KEY]) == [str(obj)]
async def test_acquire(self, cache, lock): cache.serializer = StringSerializer() async with lock: assert await cache.get(pytest.KEY + '-lock') == lock._value
def test_loads(self): assert StringSerializer().loads("hi") == "hi"
def test_set_types(self, obj): assert StringSerializer().dumps(obj) == str(obj)
def test_init(self): serializer = StringSerializer() assert isinstance(serializer, BaseSerializer) assert serializer.DEFAULT_ENCODING == 'utf-8' assert serializer.encoding == 'utf-8'