Skip to content

Commit 366f713

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

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

tests/test_pytypes.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,16 @@ 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) as excinfo:
114+
assert m.str_from_object(malformed_utf8)
115+
assert 'invalid start byte' in str(excinfo.value)
116+
with pytest.raises(UnicodeDecodeError) as excinfo:
117+
assert m.str_from_handle(malformed_utf8)
118+
assert 'invalid start byte' in str(excinfo.value)
119+
else:
120+
assert m.str_from_object(malformed_utf8) == "b'\\x80'"
121+
assert m.str_from_handle(malformed_utf8) == "b'\\x80'"
118122

119123

120124
def test_bytes(doc):

0 commit comments

Comments
 (0)