Skip to content

Commit

Permalink
Not checking UnicodeDecodeError message because it differs between CP…
Browse files Browse the repository at this point in the history
…ython and PyPy.

Checking is too much trouble for very little gain.

CPython:
'utf8' codec can't decode byte 0x80 in position 0: invalid start byte

PyPy:
'utf8' codec can't decode byte 0x80 in position 0: invalid utf-8
  • Loading branch information
Ralf W. Grosse-Kunstleve committed Aug 14, 2020
1 parent dfdb23b commit 1354a04
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions tests/test_pytypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,9 +262,8 @@ def test_pybind11_str_raw_str():

malformed_utf8 = b'\x80'
if pytest.PY2:
with pytest.raises(UnicodeDecodeError) as excinfo:
with pytest.raises(UnicodeDecodeError):
cvt(malformed_utf8)
assert "invalid start byte" in str(excinfo)
else:
malformed_cvt = cvt(malformed_utf8)
assert type(malformed_cvt) is unicode if pytest.PY2 else str # noqa: F821
Expand Down Expand Up @@ -420,6 +419,5 @@ def test_pass_bytes_or_unicode_to_string_types():
assert m.pass_to_std_string(u"Str") == 3

malformed_utf8 = b"\x80"
with pytest.raises(UnicodeDecodeError) as excinfo:
with pytest.raises(UnicodeDecodeError):
m.pass_to_pybind11_str(malformed_utf8)
assert 'invalid start byte' in str(excinfo.value)

0 comments on commit 1354a04

Please sign in to comment.