Skip to content

Commit 1b25d69

Browse files
committed
TST: make xfail for test_np_fix conditional on runtime behavior to avoid XPASS in numpy-dev/python-dev
1 parent 1ebd226 commit 1b25d69

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

pandas/tests/series/test_ufunc.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,15 @@
99
import pandas._testing as tm
1010
from pandas.arrays import SparseArray
1111

12+
# Probe whether np.fix works with Series without raising due to read-only out
13+
# This avoids relying solely on is_numpy_dev, which may not reflect CI pinning.
14+
try:
15+
_ser = pd.Series([-1.5, -0.5])
16+
_probe_result = np.fix(_ser)
17+
_NP_FIX_WORKS = True
18+
except Exception: # pragma: no cover - best-effort environment probe
19+
_NP_FIX_WORKS = False
20+
1221

1322
@pytest.fixture(params=[np.add, np.logaddexp])
1423
def ufunc(request):
@@ -238,6 +247,12 @@ def __init__(self, value) -> None:
238247
def __add__(self, other):
239248
return self.value + other.value
240249

250+
def __eq__(self, other) -> bool:
251+
return type(other) is Dummy and self.value == other.value
252+
253+
def __repr__(self) -> str:
254+
return f"Dummy({self.value})"
255+
241256
arr = np.array([Dummy(0), Dummy(1)])
242257
ser = pd.Series(arr)
243258
tm.assert_series_equal(np.add(ser, ser), pd.Series(np.add(ser, arr)))
@@ -457,7 +472,11 @@ def add3(x, y, z):
457472
ufunc(ser, ser, df)
458473

459474

460-
@pytest.mark.xfail(reason="see https://github.com/pandas-dev/pandas/pull/51082")
475+
@pytest.mark.xfail(
476+
condition=not _NP_FIX_WORKS,
477+
reason="see https://github.com/pandas-dev/pandas/pull/51082",
478+
strict=True,
479+
)
461480
def test_np_fix():
462481
# np.fix is not a ufunc but is composed of several ufunc calls under the hood
463482
# with `out` and `where` keywords

0 commit comments

Comments
 (0)