From cd856992121b0a98bbe6e15d9a886f2b43f3d972 Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Fri, 14 Aug 2020 13:53:41 -0700 Subject: [PATCH] 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. --- tests/test_pytypes.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test_pytypes.py b/tests/test_pytypes.py index e5d8355d7..289b4aab4 100644 --- a/tests/test_pytypes.py +++ b/tests/test_pytypes.py @@ -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")