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 7eee06e
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions tests/test_pytypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,17 @@ 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 7eee06e

Please sign in to comment.