Skip to content

Commit cfcaf41

Browse files
authored
TST: np.longlong can be tested on unaffected platforms (#1496)
* pandas-dev/pandas#54252 np.longlong can be tested on non-linux platforms * also bugged on Mac * fix error message
1 parent ad8cae5 commit cfcaf41

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

tests/__init__.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
nullcontext,
66
suppress,
77
)
8-
import os
9-
import platform
8+
import sys
109
from typing import (
1110
TYPE_CHECKING,
1211
Final,
@@ -94,7 +93,9 @@
9493
np_ndarray_td: TypeAlias = npt.NDArray[np.timedelta64]
9594

9695
TYPE_CHECKING_INVALID_USAGE: Final = TYPE_CHECKING
97-
WINDOWS = os.name == "nt" or "cygwin" in platform.system().lower()
96+
LINUX = sys.platform == "linux"
97+
WINDOWS = sys.platform in {"win32", "cygwin"}
98+
MAC = sys.platform == "darwin"
9899
PD_LTE_23 = Version(pd.__version__) < Version("2.3.999")
99100
NUMPY20 = np.lib.NumpyVersion(np.__version__) >= "2.0.0"
100101

tests/series/test_series.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@
5454
from pandas.core.dtypes.dtypes import CategoricalDtype # noqa F401
5555

5656
from tests import (
57+
LINUX,
58+
MAC,
5759
PD_LTE_23,
5860
TYPE_CHECKING_INVALID_USAGE,
5961
WINDOWS,
@@ -2624,13 +2626,14 @@ def test_astype_bool(cast_arg: BooleanDtypeArg, target_type: type) -> None:
26242626
def test_astype_int(cast_arg: IntDtypeArg, target_type: type) -> None:
26252627
s = pd.Series([1, 2, 3])
26262628

2627-
if cast_arg in (np.longlong, "longlong", "q"):
2628-
pytest.skip(
2629-
"longlong is bugged, for details, see"
2630-
"https://github.com/pandas-dev/pandas/issues/54252"
2631-
)
2632-
2633-
check(s.astype(cast_arg), pd.Series, target_type)
2629+
s_astype = s.astype(cast_arg)
2630+
if (LINUX or MAC) and cast_arg in {np.longlong, "longlong", "q"}:
2631+
# TODO: pandas-dev/pandas#54252 longlong is bugged on Linux and Mac
2632+
msg = rf"Expected type '{target_type}' but got '{type(s_astype.iloc[0])}'"
2633+
with pytest.raises(RuntimeError, match=msg):
2634+
check(s_astype, pd.Series, target_type)
2635+
else:
2636+
check(s_astype, pd.Series, target_type)
26342637

26352638
if TYPE_CHECKING:
26362639
# python int

0 commit comments

Comments
 (0)