diff --git a/tests/__init__.py b/tests/__init__.py index 701e1757d..9227202f5 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,9 @@ 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"} +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 7b0cb0615..c405aa222 100644 --- a/tests/series/test_series.py +++ b/tests/series/test_series.py @@ -54,6 +54,8 @@ from pandas.core.dtypes.dtypes import CategoricalDtype # noqa F401 from tests import ( + LINUX, + MAC, PD_LTE_23, TYPE_CHECKING_INVALID_USAGE, WINDOWS, @@ -2624,13 +2626,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 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 '{target_type}' 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