Skip to content

Commit b4cb52a

Browse files
Debian Science Teamrebecca-palmer
Debian Science Team
authored andcommitted
Fix or skip tests that assume the wrong endianness
This is a bug in the tests not pandas itself - the expected values explicitly specify little-endian Author: Rebecca N. Palmer <[email protected]> Forwarded: no Gbp-Pq: Name tests_dont_assume_endian.patch
1 parent 5d43366 commit b4cb52a

File tree

4 files changed

+8
-3
lines changed

4 files changed

+8
-3
lines changed

pandas/tests/arrays/test_boolean.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from pandas.arrays import BooleanArray
1111
from pandas.core.arrays.boolean import coerce_to_array
1212
from pandas.tests.extension.base import BaseOpsUtil
13+
from pandas.compat import is_platform_little_endian
1314

1415

1516
def make_data():
@@ -295,7 +296,7 @@ def test_to_numpy(box):
295296

296297
arr = con([True, False, None], dtype="boolean")
297298
result = arr.to_numpy(dtype="str")
298-
expected = np.array([True, False, pd.NA], dtype="<U5")
299+
expected = np.array([True, False, pd.NA], dtype="<U5" if is_platform_little_endian() else ">U5")
299300
tm.assert_numpy_array_equal(result, expected)
300301

301302
# no missing values -> can convert to bool, otherwise raises

pandas/tests/frame/methods/test_to_records.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
from pandas import CategoricalDtype, DataFrame, MultiIndex, Series, date_range
77
import pandas._testing as tm
8+
from pandas.compat import is_platform_little_endian
89

910

1011
class TestDataFrameToRecords:
@@ -239,6 +240,7 @@ def test_to_records_with_categorical(self):
239240
),
240241
],
241242
)
243+
@pytest.mark.xfail(condition=not is_platform_little_endian(),reason="expected values assume little-endian",strict=False)
242244
def test_to_records_dtype(self, kwargs, expected):
243245
# see GH#18146
244246
df = DataFrame({"A": [1, 2], "B": [0.2, 1.5], "C": ["a", "bc"]})
@@ -312,11 +314,13 @@ def test_to_records_dtype(self, kwargs, expected):
312314
),
313315
],
314316
)
317+
@pytest.mark.xfail(condition=not is_platform_little_endian(),reason="expected values assume little-endian",strict=False)
315318
def test_to_records_dtype_mi(self, df, kwargs, expected):
316319
# see GH#18146
317320
result = df.to_records(**kwargs)
318321
tm.assert_almost_equal(result, expected)
319322

323+
@pytest.mark.xfail(condition=not is_platform_little_endian(),reason="expected values assume little-endian",strict=False)
320324
def test_to_records_dict_like(self):
321325
# see GH#18146
322326
class DictLike:

pandas/tests/io/parser/test_c_parser_only.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ def test_dtype_and_names_error(c_parser_only):
129129
"the dtype timedelta64 is not supported for parsing",
130130
dict(dtype={"A": "timedelta64", "B": "float64"}),
131131
),
132-
("the dtype <U8 is not supported for parsing", dict(dtype={"A": "U8"})),
132+
("the dtype [<>]U8 is not supported for parsing", dict(dtype={"A": "U8"})),
133133
],
134134
ids=["dt64-0", "dt64-1", "td64", "<U8"],
135135
)

pandas/tests/scalar/timedelta/test_arithmetic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ def test_ops_ndarray(self):
272272
tm.assert_numpy_array_equal(np.array([2]) * td, expected)
273273
msg = (
274274
"ufunc '?multiply'? cannot use operands with types"
275-
r" dtype\('<m8\[ns\]'\) and dtype\('<m8\[ns\]'\)"
275+
r" dtype\('[<>]m8\[ns\]'\) and dtype\('[<>]m8\[ns\]'\)"
276276
)
277277
with pytest.raises(TypeError, match=msg):
278278
td * other

0 commit comments

Comments
 (0)