Skip to content

Using recently added pytest.PY2 instead of str is bytes. #2396

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 14, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions tests/test_pytypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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")
Expand Down