diff options
author | Inada Naoki <songofacandy@gmail.com> | 2019-12-03 20:53:11 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-03 20:53:11 +0900 |
commit | 83ebb63c447a99c81d043eb6808bbfb50697a751 (patch) | |
tree | 1f31aa6d43adccf27d236f3b63adeb71aa933a26 /test | |
parent | a0480c760256b4afc18beaebd5e3c79de1d4ce56 (diff) | |
download | msgpack-python-83ebb63c447a99c81d043eb6808bbfb50697a751.tar.gz |
Ressurect unicode_errors of the Packer. (#379)
Diffstat (limited to 'test')
-rw-r--r-- | test/test_pack.py | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/test/test_pack.py b/test/test_pack.py index 194b2c9..b6752e5 100644 --- a/test/test_pack.py +++ b/test/test_pack.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function, unicode_litera from collections import OrderedDict from io import BytesIO import struct +import sys import pytest from pytest import raises, xfail @@ -54,13 +55,24 @@ def testPackByteArrays(): for td in test_data: check(td) +@pytest.mark.skipif(sys.version_info < (3,0), reason="Python 2 passes invalid surrogates") +def testIgnoreUnicodeErrors(): + re = unpackb(packb(b'abc\xeddef', use_bin_type=False), + raw=False, unicode_errors='ignore') + assert re == "abcdef" + def testStrictUnicodeUnpack(): - packed = packb(b'abc\xeddef') + packed = packb(b'abc\xeddef', use_bin_type=False) with pytest.raises(UnicodeDecodeError): unpackb(packed, raw=False, use_list=1) +@pytest.mark.skipif(sys.version_info < (3,0), reason="Python 2 passes invalid surrogates") +def testIgnoreErrorsPack(): + re = unpackb(packb(u"abc\uDC80\uDCFFdef", use_bin_type=True, unicode_errors='ignore'), raw=False, use_list=1) + assert re == "abcdef" + def testDecodeBinary(): - re = unpackb(packb(b"abc"), encoding=None, use_list=1) + re = unpackb(packb(b"abc"), use_list=1) assert re == b"abc" def testPackFloat(): |