diff options
author | INADA Naoki <songofacandy@gmail.com> | 2012-06-19 14:20:56 +0900 |
---|---|---|
committer | INADA Naoki <songofacandy@gmail.com> | 2012-06-19 14:20:56 +0900 |
commit | 636f4529aa8426f4ee3e25e0b4931bb37384df1e (patch) | |
tree | 4ed83eea4ae197c61cd3793305fc7856fbb8e6f8 /test/test_seq.py | |
parent | 0b38e86534130f625cbea2f9446e8e52ef5f5a06 (diff) | |
download | msgpack-python-636f4529aa8426f4ee3e25e0b4931bb37384df1e.tar.gz |
Fix tests to pass.
Diffstat (limited to 'test/test_seq.py')
-rw-r--r-- | test/test_seq.py | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/test/test_seq.py b/test/test_seq.py index 993a59e..d0f9ccc 100644 --- a/test/test_seq.py +++ b/test/test_seq.py @@ -1,21 +1,22 @@ #!/usr/bin/env python # coding: utf-8 +import six from nose import main from nose.tools import * -import StringIO +import io import msgpack -binarydata = [chr(i) for i in xrange(256)] -binarydata = "".join(binarydata) +binarydata = [chr(i) for i in range(256)] +binarydata = six.b("".join(binarydata)) def gen_binary_data(idx): data = binarydata[:idx % 300] return data def test_exceeding_unpacker_read_size(): - dumpf = StringIO.StringIO() + dumpf = io.BytesIO() packer = msgpack.Packer() @@ -26,18 +27,18 @@ def test_exceeding_unpacker_read_size(): # 40 ok for read_size=1024, while 50 introduces errors # 7000 ok for read_size=1024*1024, while 8000 leads to glibc detected *** python: double free or corruption (!prev): - for idx in xrange(NUMBER_OF_STRINGS): + for idx in range(NUMBER_OF_STRINGS): data = gen_binary_data(idx) dumpf.write(packer.pack(data)) - f = StringIO.StringIO(dumpf.getvalue()) + f = io.BytesIO(dumpf.getvalue()) dumpf.close() unpacker = msgpack.Unpacker(f, read_size=read_size) read_count = 0 for idx, o in enumerate(unpacker): - assert_equal(type(o), str) + assert_equal(type(o), bytes) assert_equal(o, gen_binary_data(idx)) read_count += 1 @@ -45,5 +46,5 @@ def test_exceeding_unpacker_read_size(): if __name__ == '__main__': - # main() - test_exceeding_unpacker_read_size() + main() + #test_exceeding_unpacker_read_size() |