|
|
@ -4,10 +4,11 @@ from __future__ import (absolute_import, division, print_function,
|
|
|
|
|
|
|
|
|
|
|
|
import json
|
|
|
|
import json
|
|
|
|
import pickle
|
|
|
|
import pickle
|
|
|
|
|
|
|
|
import pickletools
|
|
|
|
import queue
|
|
|
|
import queue
|
|
|
|
import unittest
|
|
|
|
import unittest
|
|
|
|
|
|
|
|
|
|
|
|
from rq.serializers import resolve_serializer
|
|
|
|
from rq.serializers import DefaultSerializer, resolve_serializer
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TestSerializers(unittest.TestCase):
|
|
|
|
class TestSerializers(unittest.TestCase):
|
|
|
@ -15,7 +16,16 @@ class TestSerializers(unittest.TestCase):
|
|
|
|
"""Ensure function resolve_serializer works correctly"""
|
|
|
|
"""Ensure function resolve_serializer works correctly"""
|
|
|
|
serializer = resolve_serializer(None)
|
|
|
|
serializer = resolve_serializer(None)
|
|
|
|
self.assertIsNotNone(serializer)
|
|
|
|
self.assertIsNotNone(serializer)
|
|
|
|
self.assertEqual(serializer, pickle)
|
|
|
|
self.assertEqual(serializer, DefaultSerializer)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Test round trip with default serializer
|
|
|
|
|
|
|
|
test_data = {'test': 'data'}
|
|
|
|
|
|
|
|
serialized_data = serializer.dumps(test_data)
|
|
|
|
|
|
|
|
self.assertEqual(serializer.loads(serialized_data), test_data)
|
|
|
|
|
|
|
|
self.assertEqual(
|
|
|
|
|
|
|
|
next(pickletools.genops(serialized_data))[1],
|
|
|
|
|
|
|
|
pickle.HIGHEST_PROTOCOL
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
# Test using json serializer
|
|
|
|
# Test using json serializer
|
|
|
|
serializer = resolve_serializer(json)
|
|
|
|
serializer = resolve_serializer(json)
|
|
|
|