From 0aea21036bda42718a842db0848dfe6a81c16b63 Mon Sep 17 00:00:00 2001 From: cmp0xff Date: Thu, 20 Nov 2025 13:11:53 +0100 Subject: [PATCH 1/3] pandas-dev/pandas#54252 np.longlong can be tested on non-linux platforms --- tests/__init__.py | 6 +++--- tests/series/test_series.py | 16 +++++++++------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/tests/__init__.py b/tests/__init__.py index 701e1757d..956f3e5c1 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -5,8 +5,7 @@ nullcontext, suppress, ) -import os -import platform +import sys from typing import ( TYPE_CHECKING, Final, @@ -94,7 +93,8 @@ np_ndarray_td: TypeAlias = npt.NDArray[np.timedelta64] TYPE_CHECKING_INVALID_USAGE: Final = TYPE_CHECKING -WINDOWS = os.name == "nt" or "cygwin" in platform.system().lower() +LINUX = sys.platform == "linux" +WINDOWS = sys.platform in {"win32", "cygwin"} PD_LTE_23 = Version(pd.__version__) < Version("2.3.999") NUMPY20 = np.lib.NumpyVersion(np.__version__) >= "2.0.0" diff --git a/tests/series/test_series.py b/tests/series/test_series.py index 7b0cb0615..ca7c71546 100644 --- a/tests/series/test_series.py +++ b/tests/series/test_series.py @@ -54,6 +54,7 @@ from pandas.core.dtypes.dtypes import CategoricalDtype # noqa F401 from tests import ( + LINUX, PD_LTE_23, TYPE_CHECKING_INVALID_USAGE, WINDOWS, @@ -2624,13 +2625,14 @@ def test_astype_bool(cast_arg: BooleanDtypeArg, target_type: type) -> None: def test_astype_int(cast_arg: IntDtypeArg, target_type: type) -> None: s = pd.Series([1, 2, 3]) - if cast_arg in (np.longlong, "longlong", "q"): - pytest.skip( - "longlong is bugged, for details, see" - "https://github.com/pandas-dev/pandas/issues/54252" - ) - - check(s.astype(cast_arg), pd.Series, target_type) + s_astype = s.astype(cast_arg) + if LINUX and cast_arg in (np.longlong, "longlong", "q"): + # TODO: pandas-dev/pandas#54252 longlong is bugged in Linux + msg = rf"Expected type '{type(cast_arg)}' but got '{type(s_astype.iloc[0])}'" + with pytest.raises(RuntimeError, match=msg): + check(s_astype, pd.Series, target_type) + else: + check(s_astype, pd.Series, target_type) if TYPE_CHECKING: # python int From 4146c2116b20eb42b06eda7cf72c4e024a31d6c0 Mon Sep 17 00:00:00 2001 From: cmp0xff Date: Thu, 20 Nov 2025 13:20:21 +0100 Subject: [PATCH 2/3] also bugged on Mac --- tests/__init__.py | 1 + tests/series/test_series.py | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/__init__.py b/tests/__init__.py index 956f3e5c1..9227202f5 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -95,6 +95,7 @@ TYPE_CHECKING_INVALID_USAGE: Final = TYPE_CHECKING LINUX = sys.platform == "linux" WINDOWS = sys.platform in {"win32", "cygwin"} +MAC = sys.platform == "darwin" PD_LTE_23 = Version(pd.__version__) < Version("2.3.999") NUMPY20 = np.lib.NumpyVersion(np.__version__) >= "2.0.0" diff --git a/tests/series/test_series.py b/tests/series/test_series.py index ca7c71546..b00a28623 100644 --- a/tests/series/test_series.py +++ b/tests/series/test_series.py @@ -55,6 +55,7 @@ from tests import ( LINUX, + MAC, PD_LTE_23, TYPE_CHECKING_INVALID_USAGE, WINDOWS, @@ -2626,9 +2627,9 @@ def test_astype_int(cast_arg: IntDtypeArg, target_type: type) -> None: s = pd.Series([1, 2, 3]) s_astype = s.astype(cast_arg) - if LINUX and cast_arg in (np.longlong, "longlong", "q"): - # TODO: pandas-dev/pandas#54252 longlong is bugged in Linux - msg = rf"Expected type '{type(cast_arg)}' but got '{type(s_astype.iloc[0])}'" + if (LINUX or MAC) and cast_arg in {np.longlong, "longlong", "q"}: + # TODO: pandas-dev/pandas#54252 longlong is bugged on Linux and Mac + msg = rf"Expected type '{cast_arg}' but got '{type(s_astype.iloc[0])}'" with pytest.raises(RuntimeError, match=msg): check(s_astype, pd.Series, target_type) else: From 4720e8fd96cafbe10c25946d9b808fe0b3557854 Mon Sep 17 00:00:00 2001 From: cmp0xff Date: Thu, 20 Nov 2025 13:26:39 +0100 Subject: [PATCH 3/3] fix error message --- tests/series/test_series.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/series/test_series.py b/tests/series/test_series.py index b00a28623..c405aa222 100644 --- a/tests/series/test_series.py +++ b/tests/series/test_series.py @@ -2629,7 +2629,7 @@ def test_astype_int(cast_arg: IntDtypeArg, target_type: type) -> None: s_astype = s.astype(cast_arg) if (LINUX or MAC) and cast_arg in {np.longlong, "longlong", "q"}: # TODO: pandas-dev/pandas#54252 longlong is bugged on Linux and Mac - msg = rf"Expected type '{cast_arg}' but got '{type(s_astype.iloc[0])}'" + msg = rf"Expected type '{target_type}' but got '{type(s_astype.iloc[0])}'" with pytest.raises(RuntimeError, match=msg): check(s_astype, pd.Series, target_type) else: