diff --git a/pandas/tests/extension/conftest.py b/pandas/tests/extension/conftest.py index 85bbafbeb5129..9e1b44d3bac02 100644 --- a/pandas/tests/extension/conftest.py +++ b/pandas/tests/extension/conftest.py @@ -27,7 +27,11 @@ def data(): @pytest.fixture def data_for_twos(): - """Length-100 array in which all the elements are two.""" + """ + Length-100 array in which all the elements are two. + + Call pytest.skip in your fixture if the dtype does not support divmod. + """ raise NotImplementedError diff --git a/pandas/tests/extension/json/test_json.py b/pandas/tests/extension/json/test_json.py index 0c9abd45a51a5..011e44357c6b0 100644 --- a/pandas/tests/extension/json/test_json.py +++ b/pandas/tests/extension/json/test_json.py @@ -78,6 +78,11 @@ def data_for_grouping(): ) +@pytest.fixture +def data_for_twos(dtype): + pytest.skip("Not a numeric dtype") + + class BaseJSON: pass @@ -317,12 +322,6 @@ def test_add_series_with_extension_array(self, data): with pytest.raises(TypeError, match="unsupported"): ser + data - @pytest.mark.xfail(reason="not implemented") - def test_divmod_series_array(self): - # GH 23287 - # skipping because it is not implemented - super().test_divmod_series_array() - class TestComparisonOps(BaseJSON, base.BaseComparisonOpsTests): pass diff --git a/pandas/tests/extension/test_arrow.py b/pandas/tests/extension/test_arrow.py index 2438626cf0347..5c00189da48a1 100644 --- a/pandas/tests/extension/test_arrow.py +++ b/pandas/tests/extension/test_arrow.py @@ -253,10 +253,16 @@ def data_missing_for_sorting(data_for_grouping): def data_for_twos(data): """Length-100 array in which all the elements are two.""" pa_dtype = data.dtype.pyarrow_dtype - if pa.types.is_integer(pa_dtype) or pa.types.is_floating(pa_dtype): + if ( + pa.types.is_integer(pa_dtype) + or pa.types.is_floating(pa_dtype) + or pa.types.is_decimal(pa_dtype) + or pa.types.is_duration(pa_dtype) + ): return pd.array([2] * 100, dtype=data.dtype) # tests will be xfailed where 2 is not a valid scalar for pa_dtype return data + # TODO: skip otherwise? @pytest.fixture diff --git a/pandas/tests/extension/test_categorical.py b/pandas/tests/extension/test_categorical.py index 5de1debb21d93..c5a8a1c85ecfe 100644 --- a/pandas/tests/extension/test_categorical.py +++ b/pandas/tests/extension/test_categorical.py @@ -71,6 +71,11 @@ def data_missing_for_sorting(): return Categorical(["A", None, "B"], categories=["B", "A"], ordered=True) +@pytest.fixture +def data_for_twos(dtype): + pytest.skip("Not a numeric dtype") + + @pytest.fixture def na_value(): return np.nan @@ -263,11 +268,6 @@ def test_add_series_with_extension_array(self, data): with pytest.raises(TypeError, match="cannot perform|unsupported operand"): ser + data - def test_divmod_series_array(self): - # GH 23287 - # skipping because it is not implemented - pass - class TestComparisonOps(base.BaseComparisonOpsTests): def _compare_other(self, s, data, op, other): diff --git a/pandas/tests/extension/test_datetime.py b/pandas/tests/extension/test_datetime.py index ab21f768e6521..7183831329d27 100644 --- a/pandas/tests/extension/test_datetime.py +++ b/pandas/tests/extension/test_datetime.py @@ -73,6 +73,11 @@ def data_for_grouping(dtype): ) +@pytest.fixture +def data_for_twos(dtype): + pytest.skip("Not a numeric dtype.") + + @pytest.fixture def na_cmp(): def cmp(a, b): @@ -142,11 +147,6 @@ def test_add_series_with_extension_array(self, data): with pytest.raises(TypeError, match=msg): ser + data - def test_divmod_series_array(self): - # GH 23287 - # skipping because it is not implemented - pass - class TestCasting(BaseDatetimeTests, base.BaseCastingTests): pass diff --git a/pandas/tests/extension/test_numpy.py b/pandas/tests/extension/test_numpy.py index 13645065bce14..4e8d30f62278c 100644 --- a/pandas/tests/extension/test_numpy.py +++ b/pandas/tests/extension/test_numpy.py @@ -153,6 +153,14 @@ def data_for_grouping(allow_in_pandas, dtype): ) +@pytest.fixture +def data_for_twos(dtype): + if dtype.kind == "O": + pytest.skip("Not a numeric dtype") + arr = np.ones(100) * 2 + return NumpyExtensionArray._from_sequence(arr, dtype=dtype) + + @pytest.fixture def skip_numpy_object(dtype, request): """ @@ -278,11 +286,6 @@ class TestArithmetics(BaseNumPyTests, base.BaseArithmeticOpsTests): def test_divmod(self, data): super().test_divmod(data) - @skip_nested - def test_divmod_series_array(self, data): - ser = pd.Series(data) - self._check_divmod_op(ser, divmod, data) - @skip_nested def test_arith_series_with_scalar(self, data, all_arithmetic_operators): super().test_arith_series_with_scalar(data, all_arithmetic_operators) diff --git a/pandas/tests/extension/test_period.py b/pandas/tests/extension/test_period.py index 7b6bc98ee8c05..8fc4d739922a7 100644 --- a/pandas/tests/extension/test_period.py +++ b/pandas/tests/extension/test_period.py @@ -40,7 +40,7 @@ def data(dtype): @pytest.fixture def data_for_twos(dtype): - return PeriodArray(np.ones(100) * 2, dtype=dtype) + pytest.skip("Not a numeric dtype") @pytest.fixture