Skip to content

Commit

Permalink
Fix tests on Python 3
Browse files Browse the repository at this point in the history
  • Loading branch information
YannickJadoul authored and Ralf W. Grosse-Kunstleve committed Aug 17, 2020
1 parent bd8f366 commit 4fc3b1b
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions tests/test_pytypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,14 @@ def __repr__(self):
assert s1 == s2

malformed_utf8 = b"\x80"
with pytest.raises(UnicodeDecodeError) as excinfo:
assert m.str_from_object(malformed_utf8)
assert 'invalid start byte' in str(excinfo.value)
with pytest.raises(UnicodeDecodeError) as excinfo:
assert m.str_from_handle(malformed_utf8)
assert 'invalid start byte' in str(excinfo.value)
if env.PY2:
with pytest.raises(UnicodeDecodeError):
assert m.str_from_object(malformed_utf8)
with pytest.raises(UnicodeDecodeError):
assert m.str_from_handle(malformed_utf8)
else:
assert m.str_from_object(malformed_utf8) == "b'\\x80'"
assert m.str_from_handle(malformed_utf8) == "b'\\x80'"


def test_bytes(doc):
Expand Down

0 comments on commit 4fc3b1b

Please sign in to comment.