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 committed Aug 16, 2020
1 parent d073cf1 commit f7d376c
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 sys.version_info.major < 3:
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 f7d376c

Please sign in to comment.