From: Debian Science Team Date: Wed, 26 Aug 2020 21:34:50 +0000 (+0100) Subject: Fix or skip tests that assume the wrong endianness X-Git-Tag: archive/raspbian/1.0.5+dfsg-3+rpi1^2~20 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=b4cb52a3924192b11495c88175f7f53ea9f7043a;p=pandas.git 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 Forwarded: no Gbp-Pq: Name tests_dont_assume_endian.patch --- diff --git a/pandas/tests/arrays/test_boolean.py b/pandas/tests/arrays/test_boolean.py index cb9b07db..64ba2fcc 100644 --- a/pandas/tests/arrays/test_boolean.py +++ b/pandas/tests/arrays/test_boolean.py @@ -10,6 +10,7 @@ import pandas._testing as tm from pandas.arrays import BooleanArray from pandas.core.arrays.boolean import coerce_to_array from pandas.tests.extension.base import BaseOpsUtil +from pandas.compat import is_platform_little_endian def make_data(): @@ -295,7 +296,7 @@ def test_to_numpy(box): arr = con([True, False, None], dtype="boolean") result = arr.to_numpy(dtype="str") - expected = np.array([True, False, pd.NA], dtype="U5") tm.assert_numpy_array_equal(result, expected) # no missing values -> can convert to bool, otherwise raises diff --git a/pandas/tests/frame/methods/test_to_records.py b/pandas/tests/frame/methods/test_to_records.py index d0181f03..5fb2a4f3 100644 --- a/pandas/tests/frame/methods/test_to_records.py +++ b/pandas/tests/frame/methods/test_to_records.py @@ -5,6 +5,7 @@ import pytest from pandas import CategoricalDtype, DataFrame, MultiIndex, Series, date_range import pandas._testing as tm +from pandas.compat import is_platform_little_endian class TestDataFrameToRecords: @@ -239,6 +240,7 @@ class TestDataFrameToRecords: ), ], ) + @pytest.mark.xfail(condition=not is_platform_little_endian(),reason="expected values assume little-endian",strict=False) def test_to_records_dtype(self, kwargs, expected): # see GH#18146 df = DataFrame({"A": [1, 2], "B": [0.2, 1.5], "C": ["a", "bc"]}) @@ -312,11 +314,13 @@ class TestDataFrameToRecords: ), ], ) + @pytest.mark.xfail(condition=not is_platform_little_endian(),reason="expected values assume little-endian",strict=False) def test_to_records_dtype_mi(self, df, kwargs, expected): # see GH#18146 result = df.to_records(**kwargs) tm.assert_almost_equal(result, expected) + @pytest.mark.xfail(condition=not is_platform_little_endian(),reason="expected values assume little-endian",strict=False) def test_to_records_dict_like(self): # see GH#18146 class DictLike: diff --git a/pandas/tests/io/parser/test_c_parser_only.py b/pandas/tests/io/parser/test_c_parser_only.py index 1737f14e..ef79c95d 100644 --- a/pandas/tests/io/parser/test_c_parser_only.py +++ b/pandas/tests/io/parser/test_c_parser_only.py @@ -129,7 +129,7 @@ nan 2 "the dtype timedelta64 is not supported for parsing", dict(dtype={"A": "timedelta64", "B": "float64"}), ), - ("the dtype ]U8 is not supported for parsing", dict(dtype={"A": "U8"})), ], ids=["dt64-0", "dt64-1", "td64", "]m8\[ns\]'\) and dtype\('[<>]m8\[ns\]'\)" ) with pytest.raises(TypeError, match=msg): td * other