Remove encoding/unicode_errors options from Packer (#378)

This commit is contained in:
Inada Naoki 2019-12-03 18:54:01 +09:00 committed by GitHub
parent cc3a8665d6
commit e1ed0044bf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 93 deletions

View file

@ -40,21 +40,6 @@ def testPackUnicode():
re = Unpacker(BytesIO(data), raw=False, use_list=1).unpack()
assert re == td
def testPackUTF32(): # deprecated
try:
test_data = [
"",
"abcd",
["defgh"],
"Русский текст",
]
for td in test_data:
with pytest.deprecated_call():
re = unpackb(packb(td, encoding='utf-32'), use_list=1, encoding='utf-32')
assert re == td
except LookupError as e:
xfail(e)
def testPackBytes():
test_data = [
b"", b"abcd", (b"defgh",),
@ -69,26 +54,11 @@ def testPackByteArrays():
for td in test_data:
check(td)
def testIgnoreUnicodeErrors(): # deprecated
with pytest.deprecated_call():
re = unpackb(packb(b'abc\xeddef'), encoding='utf-8', unicode_errors='ignore', use_list=1)
assert re == "abcdef"
def testStrictUnicodeUnpack():
packed = packb(b'abc\xeddef')
with pytest.raises(UnicodeDecodeError):
unpackb(packed, raw=False, use_list=1)
def testStrictUnicodePack(): # deprecated
with raises(UnicodeEncodeError):
with pytest.deprecated_call():
packb("abc\xeddef", encoding='ascii', unicode_errors='strict')
def testIgnoreErrorsPack(): # deprecated
with pytest.deprecated_call():
re = unpackb(packb("abcФФФdef", encoding='ascii', unicode_errors='ignore'), raw=False, use_list=1)
assert re == "abcdef"
def testDecodeBinary():
re = unpackb(packb(b"abc"), encoding=None, use_list=1)
assert re == b"abc"