forked from msgpack/msgpack-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_unpack_raw.py
More file actions
29 lines (23 loc) · 793 Bytes
/
test_unpack_raw.py
File metadata and controls
29 lines (23 loc) · 793 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
"""Tests for cases where the user seeks to obtain packed msgpack objects"""
import six
from msgpack import Unpacker, packb
def test_write_bytes():
unpacker = Unpacker()
unpacker.feed(b'abc')
f = six.BytesIO()
assert unpacker.unpack(f.write) == ord('a')
assert f.getvalue() == b'a'
f = six.BytesIO()
assert unpacker.skip(f.write) is None
assert f.getvalue() == b'b'
f = six.BytesIO()
assert unpacker.skip() is None
assert f.getvalue() == b''
def test_write_bytes_multi_buffer():
long_val = (5) * 100
expected = packb(long_val)
unpacker = Unpacker(six.BytesIO(expected), read_size=3, max_buffer_size=3)
f = six.BytesIO()
unpacked = unpacker.unpack(f.write)
assert unpacked == long_val
assert f.getvalue() == expected