Skip to content

Commit b25eace

Browse files
committed
Fix tests on Python 3
1 parent 64066d0 commit b25eace

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

tests/test_pytypes.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,14 @@ def __repr__(self):
109109
assert s1 == s2
110110

111111
malformed_utf8 = b"\x80"
112-
with pytest.raises(UnicodeDecodeError) as excinfo:
113-
assert m.str_from_object(malformed_utf8)
114-
assert 'invalid start byte' in str(excinfo.value)
115-
with pytest.raises(UnicodeDecodeError) as excinfo:
116-
assert m.str_from_handle(malformed_utf8)
117-
assert 'invalid start byte' in str(excinfo.value)
112+
if sys.version_info.major < 3:
113+
with pytest.raises(UnicodeDecodeError):
114+
assert m.str_from_object(malformed_utf8)
115+
with pytest.raises(UnicodeDecodeError):
116+
assert m.str_from_handle(malformed_utf8)
117+
else:
118+
assert m.str_from_object(malformed_utf8) == "b'\\x80'"
119+
assert m.str_from_handle(malformed_utf8) == "b'\\x80'"
118120

119121

120122
def test_bytes(doc):

0 commit comments

Comments
 (0)