diff --git a/pandas/tests/extension/base/methods.py b/pandas/tests/extension/base/methods.py index 7807ef366d280..dea43e53ffc40 100644 --- a/pandas/tests/extension/base/methods.py +++ b/pandas/tests/extension/base/methods.py @@ -345,13 +345,24 @@ def test_combine_add(self, data_repeated): orig_data1, orig_data2 = data_repeated(2) s1 = pd.Series(orig_data1) s2 = pd.Series(orig_data2) - result = s1.combine(s2, lambda x1, x2: x1 + x2) - with np.errstate(over="ignore"): - expected = pd.Series( - orig_data1._from_sequence( - [a + b for (a, b) in zip(list(orig_data1), list(orig_data2))] + + # Check if the operation is supported pointwise for our scalars. If not, + # we will expect Series.combine to raise as well. + try: + with np.errstate(over="ignore"): + expected = pd.Series( + orig_data1._from_sequence( + [a + b for (a, b) in zip(list(orig_data1), list(orig_data2))] + ) ) - ) + except TypeError: + # If the operation is not supported pointwise for our scalars, + # then Series.combine should also raise + with pytest.raises(TypeError): + s1.combine(s2, lambda x1, x2: x1 + x2) + return + + result = s1.combine(s2, lambda x1, x2: x1 + x2) tm.assert_series_equal(result, expected) val = s1.iloc[0] diff --git a/pandas/tests/extension/json/test_json.py b/pandas/tests/extension/json/test_json.py index 0c9abd45a51a5..b3967d33d7c1a 100644 --- a/pandas/tests/extension/json/test_json.py +++ b/pandas/tests/extension/json/test_json.py @@ -209,10 +209,6 @@ def test_sort_values_missing( def test_combine_le(self, data_repeated): super().test_combine_le(data_repeated) - @pytest.mark.xfail(reason="combine for JSONArray not supported") - def test_combine_add(self, data_repeated): - super().test_combine_add(data_repeated) - @pytest.mark.xfail( reason="combine for JSONArray not supported - " "may pass depending on random data", diff --git a/pandas/tests/extension/test_arrow.py b/pandas/tests/extension/test_arrow.py index 2438626cf0347..d945d7d495f22 100644 --- a/pandas/tests/extension/test_arrow.py +++ b/pandas/tests/extension/test_arrow.py @@ -821,19 +821,6 @@ def test_argreduce_series( _combine_le_expected_dtype = "bool[pyarrow]" - def test_combine_add(self, data_repeated, request): - pa_dtype = next(data_repeated(1)).dtype.pyarrow_dtype - if pa.types.is_temporal(pa_dtype) and not pa.types.is_duration(pa_dtype): - # analogous to datetime64, these cannot be added - orig_data1, orig_data2 = data_repeated(2) - s1 = pd.Series(orig_data1) - s2 = pd.Series(orig_data2) - with pytest.raises(TypeError): - s1.combine(s2, lambda x1, x2: x1 + x2) - - else: - super().test_combine_add(data_repeated) - class TestBaseArithmeticOps(base.BaseArithmeticOpsTests): divmod_exc = NotImplementedError diff --git a/pandas/tests/extension/test_datetime.py b/pandas/tests/extension/test_datetime.py index ab21f768e6521..654838ea11b67 100644 --- a/pandas/tests/extension/test_datetime.py +++ b/pandas/tests/extension/test_datetime.py @@ -113,10 +113,6 @@ class TestIndex(base.BaseIndexTests): class TestMethods(BaseDatetimeTests, base.BaseMethodsTests): - def test_combine_add(self, data_repeated): - # Timestamp.__add__(Timestamp) not defined - pass - @pytest.mark.parametrize("na_action", [None, "ignore"]) def test_map(self, data, na_action): result = data.map(lambda x: x, na_action=na_action) diff --git a/pandas/tests/extension/test_interval.py b/pandas/tests/extension/test_interval.py index 4ef303289ee5c..53835dfb45331 100644 --- a/pandas/tests/extension/test_interval.py +++ b/pandas/tests/extension/test_interval.py @@ -121,10 +121,6 @@ def test_reduce_series_numeric(self, data, all_numeric_reductions, skipna): class TestMethods(BaseInterval, base.BaseMethodsTests): - @pytest.mark.xfail(reason="addition is not defined for intervals") - def test_combine_add(self, data_repeated): - super().test_combine_add(data_repeated) - @pytest.mark.xfail( reason="Raises with incorrect message bc it disallows *all* listlikes " "instead of just wrong-length listlikes" diff --git a/pandas/tests/extension/test_period.py b/pandas/tests/extension/test_period.py index 7b6bc98ee8c05..9ef838f1988f5 100644 --- a/pandas/tests/extension/test_period.py +++ b/pandas/tests/extension/test_period.py @@ -93,10 +93,6 @@ class TestIndex(base.BaseIndexTests): class TestMethods(BasePeriodTests, base.BaseMethodsTests): - def test_combine_add(self, data_repeated): - # Period + Period is not defined. - pass - @pytest.mark.parametrize("periods", [1, -2]) def test_diff(self, data, periods): if is_platform_windows() and np_version_gte1p24: