Skip to content

Commit cd85699

Browse files
authored
Using recently added pytest.PY2 instead of str is bytes. (#2396)
Important gain: uniformity & therefore easier cleanup when we drop PY2 support. Very slight loss: it was nice to have `str is bytes` as a reminder in this specific context.
1 parent 5a3ff72 commit cd85699

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

tests/test_pytypes.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ def test_pybind11_str_raw_str():
224224
# specifically to exercise pybind11::str::raw_str
225225
cvt = m.convert_to_pybind11_str
226226
assert cvt(u"Str") == u"Str"
227-
assert cvt(b'Bytes') == u"Bytes" if str is bytes else "b'Bytes'"
227+
assert cvt(b'Bytes') == u"Bytes" if pytest.PY2 else "b'Bytes'"
228228
assert cvt(None) == u"None"
229229
assert cvt(False) == u"False"
230230
assert cvt(True) == u"True"
@@ -237,8 +237,8 @@ def test_pybind11_str_raw_str():
237237
assert cvt([28]) == u"[28]"
238238
assert cvt({}) == u"{}"
239239
assert cvt({3: 4}) == u"{3: 4}"
240-
assert cvt(set()) == u"set([])" if str is bytes else "set()"
241-
assert cvt({3, 3}) == u"set([3])" if str is bytes else "{3}"
240+
assert cvt(set()) == u"set([])" if pytest.PY2 else "set()"
241+
assert cvt({3, 3}) == u"set([3])" if pytest.PY2 else "{3}"
242242

243243
valid_orig = u"DZ"
244244
valid_utf8 = valid_orig.encode("utf-8")

0 commit comments

Comments
 (0)