mirror of
https://github.com/msgpack/msgpack-python.git
synced 2025-10-19 20:03:16 +00:00

The following steps have been taken: 1. Black was updated to latest version. The code has been formatted with the new version. 2. The pyupgrade utility is installed. This helped to remove all the code that was needed to support Python < 3.7. Fix #541. Co-authored-by: Inada Naoki <songofacandy@gmail.com>
31 lines
755 B
Python
31 lines
755 B
Python
#!/usr/bin/env python
|
|
|
|
import sys
|
|
import pytest
|
|
from msgpack import packb, unpackb
|
|
|
|
|
|
def test_unpack_buffer():
|
|
from array import array
|
|
|
|
buf = array("b")
|
|
buf.frombytes(packb((b"foo", b"bar")))
|
|
obj = unpackb(buf, use_list=1)
|
|
assert [b"foo", b"bar"] == obj
|
|
|
|
|
|
def test_unpack_bytearray():
|
|
buf = bytearray(packb((b"foo", b"bar")))
|
|
obj = unpackb(buf, use_list=1)
|
|
assert [b"foo", b"bar"] == obj
|
|
expected_type = bytes
|
|
assert all(type(s) == expected_type for s in obj)
|
|
|
|
|
|
def test_unpack_memoryview():
|
|
buf = bytearray(packb((b"foo", b"bar")))
|
|
view = memoryview(buf)
|
|
obj = unpackb(view, use_list=1)
|
|
assert [b"foo", b"bar"] == obj
|
|
expected_type = bytes
|
|
assert all(type(s) == expected_type for s in obj)
|