diff options
author | jfolz <theriddling@gmail.com> | 2017-04-29 19:33:20 +0200 |
---|---|---|
committer | INADA Naoki <methane@users.noreply.github.com> | 2017-04-30 02:33:20 +0900 |
commit | a8d9162ca6cff6101c1f6b9547e94749c6acae96 (patch) | |
tree | 151a0d023a43cb93e586a3a377d5c2e82bdced03 /test/test_sequnpack.py | |
parent | 3388e4a6ee6adea56789d97cc05ed610a4e5b4fc (diff) | |
download | msgpack-python-a8d9162ca6cff6101c1f6b9547e94749c6acae96.tar.gz |
Unpacker: add tell() (#227)
Diffstat (limited to 'test/test_sequnpack.py')
-rw-r--r-- | test/test_sequnpack.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/test_sequnpack.py b/test/test_sequnpack.py index 45f4cc7..59718f5 100644 --- a/test/test_sequnpack.py +++ b/test/test_sequnpack.py @@ -3,6 +3,7 @@ import io from msgpack import Unpacker, BufferFull +from msgpack import pack from msgpack.exceptions import OutOfData from pytest import raises @@ -96,3 +97,22 @@ def test_issue124(): unpacker.feed(b"!") assert tuple(unpacker) == (b'!',) assert tuple(unpacker) == () + + +def test_unpack_tell(): + stream = io.BytesIO() + messages = [2**i-1 for i in range(65)] + messages += [-(2**i) for i in range(1, 64)] + messages += [b'hello', b'hello'*1000, list(range(20)), + {i: bytes(i)*i for i in range(10)}, + {i: bytes(i)*i for i in range(32)}] + offsets = [] + for m in messages: + pack(m, stream) + offsets.append(stream.tell()) + stream.seek(0) + unpacker = Unpacker(stream) + for m, o in zip(messages, offsets): + m2 = next(unpacker) + assert m == m2 + assert o == unpacker.tell() |