Skip to content

TST: Fix test_str_encode on big endian machines #57394

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
Feb 13, 2024
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
14 changes: 11 additions & 3 deletions pandas/tests/extension/test_arrow.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import operator
import pickle
import re
import sys

import numpy as np
import pytest
Expand Down Expand Up @@ -2172,14 +2173,21 @@ def test_str_removeprefix(val):
@pytest.mark.parametrize(
"encoding, exp",
[
["utf8", b"abc"],
["utf32", b"\xff\xfe\x00\x00a\x00\x00\x00b\x00\x00\x00c\x00\x00\x00"],
("utf8", {"little": b"abc", "big": "abc"}),
(
"utf32",
{
"little": b"\xff\xfe\x00\x00a\x00\x00\x00b\x00\x00\x00c\x00\x00\x00",
"big": b"\x00\x00\xfe\xff\x00\x00\x00a\x00\x00\x00b\x00\x00\x00c",
},
),
],
ids=["utf8", "utf32"],
)
def test_str_encode(errors, encoding, exp):
ser = pd.Series(["abc", None], dtype=ArrowDtype(pa.string()))
result = ser.str.encode(encoding, errors)
expected = pd.Series([exp, None], dtype=ArrowDtype(pa.binary()))
expected = pd.Series([exp[sys.byteorder], None], dtype=ArrowDtype(pa.binary()))
tm.assert_series_equal(result, expected)


Expand Down