示例#1
0
 def test_msgpack_loads(self):
     register_msgpack()
     pytest.importorskip('msgpack')
     res = loads(msgpack_data,
                 content_type='application/x-msgpack',
                 content_encoding='binary')
     assert res == msgpack_py_data
示例#2
0
 def test_msgpack_decode(self):
     register_msgpack()
     self.assertEqual(msgpack_py_data,
                       registry.decode(
                           msgpack_data,
                           content_type='application/x-msgpack',
                           content_encoding='binary'))
示例#3
0
 def test_msgpack_decode(self):
     register_msgpack()
     decoded = registry.decode(
         registry.encode(msgpack_py_data, serializer='msgpack')[-1],
         content_type='application/x-msgpack',
         content_encoding='binary',
     )
     self.assertEqual(msgpack_py_data, decoded)
示例#4
0
 def test_msgpack_decode(self):
     register_msgpack()
     decoded = registry.decode(
                 registry.encode(msgpack_py_data,
                     serializer='msgpack')[-1],
                 content_type='application/x-msgpack',
                 content_encoding='binary')
     self.assertEqual(msgpack_py_data, decoded)
示例#5
0
 def test_msgpack_encode(self):
     register_msgpack()
     self.assertEquals(registry.decode(
             registry.encode(msgpack_py_data, serializer="msgpack")[-1],
             content_type='application/x-msgpack',
             content_encoding='binary'),
             registry.decode(
                 msgpack_data,
                 content_type='application/x-msgpack',
                 content_encoding='binary'))
示例#6
0
 def test_msgpack_loads(self):
     register_msgpack()
     res = loads(msgpack_data,
                 content_type='application/x-msgpack',
                 content_encoding='binary')
     if sys.version_info[0] < 3:
         for k, v in res.items():
             if isinstance(v, str):
                 res[k] = v.encode()
             if isinstance(v, (list, tuple)):
                 res[k] = [i.encode() for i in v]
     assert res == msgpack_py_data
示例#7
0
 def test_msgpack_loads(self):
     register_msgpack()
     res = loads(msgpack_data,
                 content_type='application/x-msgpack',
                 content_encoding='binary')
     if sys.version_info[0] < 3:
         for k, v in res.items():
             if isinstance(v, text_t):
                 res[k] = v.encode()
             if isinstance(v, (list, tuple)):
                 res[k] = [i.encode() for i in v]
     assert res == msgpack_py_data
示例#8
0
 def test_msgpack_dumps(self):
     register_msgpack()
     a = loads(
         dumps(msgpack_py_data, serializer='msgpack')[-1],
         content_type='application/x-msgpack',
         content_encoding='binary',
     )
     b = loads(
         msgpack_data,
         content_type='application/x-msgpack',
         content_encoding='binary',
     )
     assert a == b
示例#9
0
 def test_msgpack_decode(self):
     register_msgpack()
     try:
         __import__("msgpack")
     except ImportError:
         say("* msgpack-python not installed, will not execute "
             "related tests.")
         raise SkipTest("msgpack-python not installed")
     self.assertEquals(msgpack_py_data,
                       registry.decode(
                           msgpack_data,
                           content_type='application/x-msgpack',
                           content_encoding='binary'))
示例#10
0
 def test_msgpack_dumps(self):
     register_msgpack()
     a = loads(
         dumps(msgpack_py_data, serializer='msgpack')[-1],
         content_type='application/x-msgpack',
         content_encoding='binary',
     )
     b = loads(
         msgpack_data,
         content_type='application/x-msgpack',
         content_encoding='binary',
     )
     assert a == b
示例#11
0
 def test_msgpack_decode(self):
     register_msgpack()
     try:
         __import__("msgpack")
     except ImportError:
         say("* msgpack-python not installed, will not execute "
             "related tests.")
         raise SkipTest("msgpack-python not installed")
     self.assertEquals(
         msgpack_py_data,
         registry.decode(msgpack_data,
                         content_type='application/x-msgpack',
                         content_encoding='binary'))
示例#12
0
 def test_msgpack_decode(self):
     register_msgpack()
     res = registry.decode(msgpack_data,
                           content_type='application/x-msgpack',
                           content_encoding='binary')
     if sys.version_info[0] < 3:
         for k, v in res.items():
             if isinstance(v, text_t):
                 res[k] = v.encode()
             if isinstance(v, (list, tuple)):
                 res[k] = [i.encode() for i in v]
     self.assertEqual(
         msgpack_py_data,
         res,
     )
示例#13
0
    def test_msgpack_decode(self):
        register_msgpack()
        res = registry.decode(msgpack_data, content_type="application/x-msgpack", content_encoding="binary")
        if sys.version_info[0] < 3:
            for k, v in res.items():
                if isinstance(v, str_t):
                    res[k] = v.encode()
                if isinstance(v, (list, tuple)):
                    res[k] = [i.encode() for i in v]

        # On Python 3.2 (or some msgpack versions maybe? lists are magically
        # transformed into tuples...
        if isinstance(res["list"], tuple):
            msgpack_py_data["list"] = tuple(msgpack_py_data["list"])
        self.assertEqual(msgpack_py_data, res)
示例#14
0
    def test_msgpack_decode(self):
        register_msgpack()
        res = registry.decode(msgpack_data,
                              content_type='application/x-msgpack',
                              content_encoding='binary')
        if sys.version_info[0] < 3:
            for k, v in res.items():
                if isinstance(v, str_t):
                    res[k] = v.encode()
                if isinstance(v, (list, tuple)):
                    res[k] = [i.encode() for i in v]

        # On Python 3.2 (or some msgpack versions maybe? lists are magically
        # transformed into tuples...
        if isinstance(res['list'], tuple):
            msgpack_py_data['list'] = tuple(msgpack_py_data['list'])
        self.assertEqual(
            msgpack_py_data,
            res,
        )
示例#15
0
 def test_register_msgpack__no_msgpack(self):
     register_msgpack()
     with self.assertRaises(SerializerNotInstalled):
         decode('foo', 'application/x-msgpack', 'utf-8')
示例#16
0
 def test_register_msgpack__no_msgpack(self):
     register_msgpack()
     with self.assertRaises(SerializerNotInstalled):
         decode('foo', 'application/x-msgpack', 'utf-8')
示例#17
0
 def test_register_msgpack__no_msgpack(self):
     register_msgpack()
     with pytest.raises(SerializerNotInstalled):
         loads('foo', 'application/x-msgpack', 'utf-8')
示例#18
0
 def test_register_msgpack__no_msgpack(self, mask_modules):
     register_msgpack()
     with pytest.raises(SerializerNotInstalled):
         loads('foo', 'application/x-msgpack', 'utf-8')
示例#19
0
 def test_register_msgpack__no_msgpack(self):
     register_msgpack()
     self.assertRaises(SerializerNotInstalled,
                       decode, "foo", "application/x-msgpack", "utf-8")
示例#20
0
 def test_register_msgpack__no_msgpack(self):
     register_msgpack()
     self.assertRaises(SerializerNotInstalled, decode, "foo",
                       "application/x-msgpack", "utf-8")