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 15, 2020
1 parent 64066d0 commit 366f713
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions tests/test_pytypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,16 @@ 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) 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)
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 366f713

Please sign in to comment.