Skip to content

Commit 8e53b83

Browse files
committed
Fix tests on Python 3
1 parent 9e900fa commit 8e53b83

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
@@ -111,12 +111,14 @@ def __repr__(self):
111111
assert s1 == s2
112112

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

121123

122124
def test_bytes(doc):

0 commit comments

Comments
 (0)