Skip to content

Commit c0670f1

Browse files
QuLogicpmhatre1
authored andcommitted
TST: Fix test_str_encode on big endian machines (pandas-dev#57394)
I couldn't find a way to specify the endianness when creating the `ArrowDtype`, so just pick the right result based on native byte order.
1 parent 6f9b788 commit c0670f1

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

pandas/tests/extension/test_arrow.py

+11-3
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import operator
2727
import pickle
2828
import re
29+
import sys
2930

3031
import numpy as np
3132
import pytest
@@ -2172,14 +2173,21 @@ def test_str_removeprefix(val):
21722173
@pytest.mark.parametrize(
21732174
"encoding, exp",
21742175
[
2175-
["utf8", b"abc"],
2176-
["utf32", b"\xff\xfe\x00\x00a\x00\x00\x00b\x00\x00\x00c\x00\x00\x00"],
2176+
("utf8", {"little": b"abc", "big": "abc"}),
2177+
(
2178+
"utf32",
2179+
{
2180+
"little": b"\xff\xfe\x00\x00a\x00\x00\x00b\x00\x00\x00c\x00\x00\x00",
2181+
"big": b"\x00\x00\xfe\xff\x00\x00\x00a\x00\x00\x00b\x00\x00\x00c",
2182+
},
2183+
),
21772184
],
2185+
ids=["utf8", "utf32"],
21782186
)
21792187
def test_str_encode(errors, encoding, exp):
21802188
ser = pd.Series(["abc", None], dtype=ArrowDtype(pa.string()))
21812189
result = ser.str.encode(encoding, errors)
2182-
expected = pd.Series([exp, None], dtype=ArrowDtype(pa.binary()))
2190+
expected = pd.Series([exp[sys.byteorder], None], dtype=ArrowDtype(pa.binary()))
21832191
tm.assert_series_equal(result, expected)
21842192

21852193

0 commit comments

Comments
 (0)