Use new libs in Msgpack tests
This commit is contained in:
parent
dc32556983
commit
c481d20ce8
1 changed files with 9 additions and 8 deletions
|
@ -1,24 +1,25 @@
|
||||||
import cStringIO as StringIO
|
import io
|
||||||
|
import os
|
||||||
|
|
||||||
import msgpack
|
import msgpack
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from Config import config
|
from Config import config
|
||||||
from util import StreamingMsgpack
|
from util import Msgpack
|
||||||
|
|
||||||
|
|
||||||
class TestMsgpack:
|
class TestMsgpack:
|
||||||
test_data = {"cmd": "fileGet", "params": {"site": "1Site"}, "utf8": b'\xc3\xa1rv\xc3\xadzt\xc5\xb1r\xc5\x91'.decode("utf8"), "bin": b'p\x81zDhL\xf0O\xd0\xaf', "list": [b'p\x81zDhL\xf0O\xd0\xaf', b'p\x81zDhL\xf0O\xd0\xaf']}
|
test_data = {"cmd": "fileGet", "params": {"site": "1Site"}, "utf8": b'\xc3\xa1rv\xc3\xadzt\xc5\xb1r\xc5\x91'.decode("utf8"), "bin": b'p\x81zDhL\xf0O\xd0\xaf', "list": [b'p\x81zDhL\xf0O\xd0\xaf', b'p\x81zDhL\xf0O\xd0\xaf']}
|
||||||
|
|
||||||
def testUnpackinkg(self):
|
def testUnpackinkg(self):
|
||||||
assert msgpack.unpackb(msgpack.packb(self.test_data)) == self.test_data
|
assert Msgpack.unpack(Msgpack.pack(self.test_data)) == self.test_data
|
||||||
|
|
||||||
@pytest.mark.parametrize("unpacker_class", [msgpack.Unpacker, msgpack.fallback.Unpacker])
|
@pytest.mark.parametrize("unpacker_class", [msgpack.Unpacker, msgpack.fallback.Unpacker])
|
||||||
def testUnpacker(self, unpacker_class):
|
def testUnpacker(self, unpacker_class):
|
||||||
unpacker = unpacker_class()
|
unpacker = unpacker_class(raw=False)
|
||||||
|
|
||||||
data = msgpack.packb(self.test_data)
|
data = msgpack.packb(self.test_data, use_bin_type=True)
|
||||||
data += msgpack.packb(self.test_data)
|
data += msgpack.packb(self.test_data, use_bin_type=True)
|
||||||
|
|
||||||
messages = []
|
messages = []
|
||||||
for char in data:
|
for char in data:
|
||||||
|
@ -36,8 +37,8 @@ class TestMsgpack:
|
||||||
|
|
||||||
data = {"cmd": "response", "params": f}
|
data = {"cmd": "response", "params": f}
|
||||||
|
|
||||||
out_buff = StringIO.StringIO()
|
out_buff = io.BytesIO()
|
||||||
StreamingMsgpack.stream(data, out_buff.write)
|
Msgpack.stream(data, out_buff.write)
|
||||||
out_buff.seek(0)
|
out_buff.seek(0)
|
||||||
|
|
||||||
data_packb = {"cmd": "response", "params": open("%s/users.json" % config.data_dir).read(10)}
|
data_packb = {"cmd": "response", "params": open("%s/users.json" % config.data_dir).read(10)}
|
||||||
|
|
Loading…
Reference in a new issue