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.
This commit is contained in:
Ralf W. Grosse-Kunstleve 2020-08-14 13:53:41 -07:00 committed by GitHub
parent 5a3ff72348
commit cd85699212
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -224,7 +224,7 @@ def test_pybind11_str_raw_str():
# specifically to exercise pybind11::str::raw_str
cvt = m.convert_to_pybind11_str
assert cvt(u"Str") == u"Str"
assert cvt(b'Bytes') == u"Bytes" if str is bytes else "b'Bytes'"
assert cvt(b'Bytes') == u"Bytes" if pytest.PY2 else "b'Bytes'"
assert cvt(None) == u"None"
assert cvt(False) == u"False"
assert cvt(True) == u"True"
@ -237,8 +237,8 @@ def test_pybind11_str_raw_str():
assert cvt([28]) == u"[28]"
assert cvt({}) == u"{}"
assert cvt({3: 4}) == u"{3: 4}"
assert cvt(set()) == u"set([])" if str is bytes else "set()"
assert cvt({3, 3}) == u"set([3])" if str is bytes else "{3}"
assert cvt(set()) == u"set([])" if pytest.PY2 else "set()"
assert cvt({3, 3}) == u"set([3])" if pytest.PY2 else "{3}"
valid_orig = u"DZ"
valid_utf8 = valid_orig.encode("utf-8")