diff options
author | INADA Naoki <methane@users.noreply.github.com> | 2018-11-09 20:55:13 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-09 20:55:13 +0900 |
commit | 9e210bfc1a922031db67bf42e508b1b4550814c6 (patch) | |
tree | 1bbef6a155df89e6fef0a9b5efbae4928fa40772 /test/test_pack.py | |
parent | a8b3e97fe588a2411a8e869b52be1946ed9f0f86 (diff) | |
download | msgpack-python-9e210bfc1a922031db67bf42e508b1b4550814c6.tar.gz |
Add Packer.buffer() (#320)
Diffstat (limited to 'test/test_pack.py')
-rw-r--r-- | test/test_pack.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/test/test_pack.py b/test/test_pack.py index b447f9c..4608083 100644 --- a/test/test_pack.py +++ b/test/test_pack.py @@ -5,7 +5,7 @@ from __future__ import absolute_import, division, print_function, unicode_litera import struct from pytest import raises, xfail -from msgpack import packb, unpackb, Unpacker, Packer +from msgpack import packb, unpackb, Unpacker, Packer, pack from collections import OrderedDict from io import BytesIO @@ -148,3 +148,13 @@ def test_pairlist(): packed = packer.pack_map_pairs(pairlist) unpacked = unpackb(packed, object_pairs_hook=list) assert pairlist == unpacked + +def test_get_buffer(): + packer = Packer(autoreset=0, use_bin_type=True) + packer.pack([1, 2]) + strm = BytesIO() + strm.write(packer.getbuffer()) + written = strm.getvalue() + + expected = packb([1, 2], use_bin_type=True) + assert written == expected |