diff options
author | INADA Naoki <inada-n@klab.com> | 2012-09-24 02:12:55 +0900 |
---|---|---|
committer | INADA Naoki <inada-n@klab.com> | 2012-09-24 02:38:54 +0900 |
commit | d503788e9537498ff2ed0da1f836dc4de6074981 (patch) | |
tree | 0b060a16d0b08ea4c22e7c057e41664acd00700c /test | |
parent | c3da8458681fc479233910d4c92dc84374e5efed (diff) | |
download | msgpack-python-d503788e9537498ff2ed0da1f836dc4de6074981.tar.gz |
Warn when use_list is not specified.
Conflicts:
test/test_sequnpack.py
Diffstat (limited to 'test')
-rw-r--r-- | test/test_buffer.py | 4 | ||||
-rw-r--r-- | test/test_format.py | 4 | ||||
-rw-r--r-- | test/test_pack.py | 12 | ||||
-rw-r--r-- | test/test_seq.py | 2 | ||||
-rw-r--r-- | test/test_sequnpack.py | 5 |
5 files changed, 13 insertions, 14 deletions
diff --git a/test/test_buffer.py b/test/test_buffer.py index 01310a0..785fb60 100644 --- a/test/test_buffer.py +++ b/test/test_buffer.py @@ -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() diff --git a/test/test_format.py b/test/test_format.py index c03b3e2..ac08709 100644 --- a/test/test_format.py +++ b/test/test_format.py @@ -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", diff --git a/test/test_pack.py b/test/test_pack.py index b216c46..dc77dfe 100644 --- a/test/test_pack.py +++ b/test/test_pack.py @@ -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 diff --git a/test/test_seq.py b/test/test_seq.py index d0f9ccc..72e935a 100644 --- a/test/test_seq.py +++ b/test/test_seq.py @@ -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): diff --git a/test/test_sequnpack.py b/test/test_sequnpack.py index b1b80b2..21fc3be 100644 --- a/test/test_sequnpack.py +++ b/test/test_sequnpack.py @@ -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') @@ -28,10 +28,9 @@ def test_foobar(): k += 1 assert k == len(b'foobar') - 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') |