Fix or skip tests that assume the wrong endianness
authorDebian Science Team <debian-science-maintainers@lists.alioth.debian.org>
Wed, 26 Aug 2020 21:34:50 +0000 (22:34 +0100)
committerRebecca N. Palmer <rebecca_palmer@zoho.com>
Wed, 26 Aug 2020 21:34:50 +0000 (22:34 +0100)
This is a bug in the tests not pandas itself -
the expected values explicitly specify little-endian

Author: Rebecca N. Palmer <rebecca_palmer@zoho.com>
Forwarded: no

Gbp-Pq: Name tests_dont_assume_endian.patch

pandas/tests/arrays/test_boolean.py
pandas/tests/frame/methods/test_to_records.py
pandas/tests/io/parser/test_c_parser_only.py
pandas/tests/scalar/timedelta/test_arithmetic.py

index cb9b07db4a0df41d9415160d322ff0282cc82fc9..64ba2fcc7d9d6fb270b2c5dec43cd39de3a412af 100644 (file)
@@ -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")
+    expected = np.array([True, False, pd.NA], dtype="<U5" if is_platform_little_endian() else ">U5")
     tm.assert_numpy_array_equal(result, expected)
 
     # no missing values -> can convert to bool, otherwise raises
index d0181f0309af1848daea51a7a6143b2e874b4267..5fb2a4f303b5108ccc2740b2a72721080959a36d 100644 (file)
@@ -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:
index 1737f14e7adf9d954410c4a4cb19ed86612373b8..ef79c95d4a0ac9ad3816593d10563273410fd8d4 100644 (file)
@@ -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"})),
+        ("the dtype [<>]U8 is not supported for parsing", dict(dtype={"A": "U8"})),
     ],
     ids=["dt64-0", "dt64-1", "td64", "<U8"],
 )
index 555b47c8dc0fc9a2a6f68e9ffd73c8a00e312d4d..0f0879807bc0c2983412203aacb40dbc61c84a9c 100644 (file)
@@ -272,7 +272,7 @@ class TestTimedeltaAdditionSubtraction:
         tm.assert_numpy_array_equal(np.array([2]) * td, expected)
         msg = (
             "ufunc '?multiply'? cannot use operands with types"
-            r" dtype\('<m8\[ns\]'\) and dtype\('<m8\[ns\]'\)"
+            r" dtype\('[<>]m8\[ns\]'\) and dtype\('[<>]m8\[ns\]'\)"
         )
         with pytest.raises(TypeError, match=msg):
             td * other