Add raw_as_bytes option to Unpacker. (#265)

This commit is contained in:
INADA Naoki 2018-01-11 17:02:41 +09:00 committed by GitHub
parent 50ea49c86f
commit 5534d0c7af
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 199 additions and 93 deletions

View file

@ -39,11 +39,11 @@ def test_max_str_len():
d = 'x' * 3
packed = packb(d)
unpacker = Unpacker(max_str_len=3, encoding='utf-8')
unpacker = Unpacker(max_str_len=3, raw_as_bytes=False)
unpacker.feed(packed)
assert unpacker.unpack() == d
unpacker = Unpacker(max_str_len=2, encoding='utf-8')
unpacker = Unpacker(max_str_len=2, raw_as_bytes=False)
with pytest.raises(UnpackValueError):
unpacker.feed(packed)
unpacker.unpack()