mirror of
https://github.com/msgpack/msgpack-python.git
synced 2026-02-07 10:19:51 +00:00
Warn when use_list is not specified.
This commit is contained in:
parent
96ed236c1d
commit
60df5eadaf
7 changed files with 37 additions and 23 deletions
|
|
@ -9,8 +9,8 @@ def test_unpack_buffer():
|
|||
from array import array
|
||||
buf = array('b')
|
||||
buf.fromstring(packb(('foo', 'bar')))
|
||||
obj = unpackb(buf)
|
||||
assert_equal((b'foo', b'bar'), obj)
|
||||
obj = unpackb(buf, use_list=1)
|
||||
assert_equal([b'foo', b'bar'], obj)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@ from nose import main
|
|||
from nose.tools import *
|
||||
from msgpack import unpackb
|
||||
|
||||
def check(src, should):
|
||||
assert_equal(unpackb(src), should)
|
||||
def check(src, should, use_list=0):
|
||||
assert_equal(unpackb(src, use_list=use_list), should)
|
||||
|
||||
def testSimpleValue():
|
||||
check(b"\x93\xc0\xc2\xc3",
|
||||
|
|
|
|||
|
|
@ -11,8 +11,8 @@ from msgpack import packb, unpackb, Unpacker, Packer
|
|||
|
||||
from io import BytesIO
|
||||
|
||||
def check(data):
|
||||
re = unpackb(packb(data))
|
||||
def check(data, use_list=False):
|
||||
re = unpackb(packb(data), use_list=use_list)
|
||||
assert_equal(re, data)
|
||||
|
||||
def testPack():
|
||||
|
|
@ -34,7 +34,7 @@ def testPackUnicode():
|
|||
six.u(""), six.u("abcd"), (six.u("defgh"),), six.u("Русский текст"),
|
||||
]
|
||||
for td in test_data:
|
||||
re = unpackb(packb(td, encoding='utf-8'), encoding='utf-8')
|
||||
re = unpackb(packb(td, encoding='utf-8'), use_list=0, encoding='utf-8')
|
||||
assert_equal(re, td)
|
||||
packer = Packer(encoding='utf-8')
|
||||
data = packer.pack(td)
|
||||
|
|
@ -46,11 +46,11 @@ def testPackUTF32():
|
|||
test_data = [
|
||||
six.u(""),
|
||||
six.u("abcd"),
|
||||
(six.u("defgh"),),
|
||||
[six.u("defgh")],
|
||||
six.u("Русский текст"),
|
||||
]
|
||||
for td in test_data:
|
||||
re = unpackb(packb(td, encoding='utf-32'), encoding='utf-32')
|
||||
re = unpackb(packb(td, encoding='utf-32'), use_list=1, encoding='utf-32')
|
||||
assert_equal(re, td)
|
||||
except LookupError:
|
||||
raise SkipTest
|
||||
|
|
@ -110,7 +110,7 @@ class odict(dict):
|
|||
def test_odict():
|
||||
seq = [(b'one', 1), (b'two', 2), (b'three', 3), (b'four', 4)]
|
||||
od = odict(seq)
|
||||
assert_equal(unpackb(packb(od)), dict(seq))
|
||||
assert_equal(unpackb(packb(od), use_list=1), dict(seq))
|
||||
# After object_pairs_hook is implemented.
|
||||
#def pair_hook(seq):
|
||||
# return seq
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ def test_exceeding_unpacker_read_size():
|
|||
f = io.BytesIO(dumpf.getvalue())
|
||||
dumpf.close()
|
||||
|
||||
unpacker = msgpack.Unpacker(f, read_size=read_size)
|
||||
unpacker = msgpack.Unpacker(f, read_size=read_size, use_list=1)
|
||||
|
||||
read_count = 0
|
||||
for idx, o in enumerate(unpacker):
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ from msgpack import Unpacker, BufferFull
|
|||
import nose
|
||||
|
||||
def test_foobar():
|
||||
unpacker = Unpacker(read_size=3)
|
||||
unpacker = Unpacker(read_size=3, use_list=1)
|
||||
unpacker.feed(b'foobar')
|
||||
assert unpacker.unpack() == ord(b'f')
|
||||
assert unpacker.unpack() == ord(b'o')
|
||||
|
|
@ -29,7 +29,7 @@ def test_foobar():
|
|||
assert k == len(b'foobar')
|
||||
|
||||
def test_foobar_skip():
|
||||
unpacker = Unpacker(read_size=3)
|
||||
unpacker = Unpacker(read_size=3, use_list=1)
|
||||
unpacker.feed(b'foobar')
|
||||
assert unpacker.unpack() == ord(b'f')
|
||||
unpacker.skip()
|
||||
|
|
@ -45,7 +45,7 @@ def test_foobar_skip():
|
|||
|
||||
def test_maxbuffersize():
|
||||
nose.tools.assert_raises(ValueError, Unpacker, read_size=5, max_buffer_size=3)
|
||||
unpacker = Unpacker(read_size=3, max_buffer_size=3)
|
||||
unpacker = Unpacker(read_size=3, max_buffer_size=3, use_list=1)
|
||||
unpacker.feed(b'fo')
|
||||
nose.tools.assert_raises(BufferFull, unpacker.feed, b'ob')
|
||||
unpacker.feed(b'o')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue