Skip to content

Commit e7a190e

Browse files
authored
REF: de-duplicate test_divmod_series_array (pandas-dev#54413)
1 parent be08e23 commit e7a190e

File tree

7 files changed

+36
-24
lines changed

7 files changed

+36
-24
lines changed

pandas/tests/extension/conftest.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,11 @@ def data():
2727

2828
@pytest.fixture
2929
def data_for_twos():
30-
"""Length-100 array in which all the elements are two."""
30+
"""
31+
Length-100 array in which all the elements are two.
32+
33+
Call pytest.skip in your fixture if the dtype does not support divmod.
34+
"""
3135
raise NotImplementedError
3236

3337

pandas/tests/extension/json/test_json.py

+5-6
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,11 @@ def data_for_grouping():
7878
)
7979

8080

81+
@pytest.fixture
82+
def data_for_twos(dtype):
83+
pytest.skip("Not a numeric dtype")
84+
85+
8186
class BaseJSON:
8287
pass
8388

@@ -313,12 +318,6 @@ def test_add_series_with_extension_array(self, data):
313318
with pytest.raises(TypeError, match="unsupported"):
314319
ser + data
315320

316-
@pytest.mark.xfail(reason="not implemented")
317-
def test_divmod_series_array(self):
318-
# GH 23287
319-
# skipping because it is not implemented
320-
super().test_divmod_series_array()
321-
322321

323322
class TestComparisonOps(BaseJSON, base.BaseComparisonOpsTests):
324323
pass

pandas/tests/extension/test_arrow.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -253,10 +253,16 @@ def data_missing_for_sorting(data_for_grouping):
253253
def data_for_twos(data):
254254
"""Length-100 array in which all the elements are two."""
255255
pa_dtype = data.dtype.pyarrow_dtype
256-
if pa.types.is_integer(pa_dtype) or pa.types.is_floating(pa_dtype):
256+
if (
257+
pa.types.is_integer(pa_dtype)
258+
or pa.types.is_floating(pa_dtype)
259+
or pa.types.is_decimal(pa_dtype)
260+
or pa.types.is_duration(pa_dtype)
261+
):
257262
return pd.array([2] * 100, dtype=data.dtype)
258263
# tests will be xfailed where 2 is not a valid scalar for pa_dtype
259264
return data
265+
# TODO: skip otherwise?
260266

261267

262268
@pytest.fixture

pandas/tests/extension/test_categorical.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ def data_missing_for_sorting():
7171
return Categorical(["A", None, "B"], categories=["B", "A"], ordered=True)
7272

7373

74+
@pytest.fixture
75+
def data_for_twos(dtype):
76+
pytest.skip("Not a numeric dtype")
77+
78+
7479
@pytest.fixture
7580
def na_value():
7681
return np.nan
@@ -263,11 +268,6 @@ def test_add_series_with_extension_array(self, data):
263268
with pytest.raises(TypeError, match="cannot perform|unsupported operand"):
264269
ser + data
265270

266-
def test_divmod_series_array(self):
267-
# GH 23287
268-
# skipping because it is not implemented
269-
pass
270-
271271

272272
class TestComparisonOps(base.BaseComparisonOpsTests):
273273
def _compare_other(self, s, data, op, other):

pandas/tests/extension/test_datetime.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@ def data_for_grouping(dtype):
7373
)
7474

7575

76+
@pytest.fixture
77+
def data_for_twos(dtype):
78+
pytest.skip("Not a numeric dtype.")
79+
80+
7681
@pytest.fixture
7782
def na_cmp():
7883
def cmp(a, b):
@@ -138,11 +143,6 @@ def test_add_series_with_extension_array(self, data):
138143
with pytest.raises(TypeError, match=msg):
139144
ser + data
140145

141-
def test_divmod_series_array(self):
142-
# GH 23287
143-
# skipping because it is not implemented
144-
pass
145-
146146

147147
class TestCasting(BaseDatetimeTests, base.BaseCastingTests):
148148
pass

pandas/tests/extension/test_numpy.py

+8-5
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,14 @@ def data_for_grouping(allow_in_pandas, dtype):
153153
)
154154

155155

156+
@pytest.fixture
157+
def data_for_twos(dtype):
158+
if dtype.kind == "O":
159+
pytest.skip("Not a numeric dtype")
160+
arr = np.ones(100) * 2
161+
return NumpyExtensionArray._from_sequence(arr, dtype=dtype)
162+
163+
156164
@pytest.fixture
157165
def skip_numpy_object(dtype, request):
158166
"""
@@ -278,11 +286,6 @@ class TestArithmetics(BaseNumPyTests, base.BaseArithmeticOpsTests):
278286
def test_divmod(self, data):
279287
super().test_divmod(data)
280288

281-
@skip_nested
282-
def test_divmod_series_array(self, data):
283-
ser = pd.Series(data)
284-
self._check_divmod_op(ser, divmod, data)
285-
286289
@skip_nested
287290
def test_arith_series_with_scalar(self, data, all_arithmetic_operators):
288291
super().test_arith_series_with_scalar(data, all_arithmetic_operators)

pandas/tests/extension/test_period.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def data(dtype):
4040

4141
@pytest.fixture
4242
def data_for_twos(dtype):
43-
return PeriodArray(np.ones(100) * 2, dtype=dtype)
43+
pytest.skip("Not a numeric dtype")
4444

4545

4646
@pytest.fixture

0 commit comments

Comments
 (0)