diff --git a/pandas/tests/extension/base/io.py b/pandas/tests/extension/base/io.py index c369ec8a16f2f..3a6f2eb5ba8b1 100644 --- a/pandas/tests/extension/base/io.py +++ b/pandas/tests/extension/base/io.py @@ -5,11 +5,31 @@ import pandas as pd import pandas._testing as tm +from pandas.core.arrays import ExtensionArray class BaseParsingTests: @pytest.mark.parametrize("engine", ["c", "python"]) - def test_EA_types(self, engine, data): + def test_EA_types(self, engine, data, request): + if isinstance(data.dtype, pd.CategoricalDtype): + # in parsers.pyx _convert_with_dtype there is special-casing for + # Categorical that pre-empts _from_sequence_of_strings + pass + elif isinstance(data.dtype, pd.core.dtypes.dtypes.NumpyEADtype): + # These get unwrapped internally so are treated as numpy dtypes + # in the parsers.pyx code + pass + elif ( + type(data)._from_sequence_of_strings.__func__ + is ExtensionArray._from_sequence_of_strings.__func__ + ): + # i.e. the EA hasn't overridden _from_sequence_of_strings + mark = pytest.mark.xfail( + reason="_from_sequence_of_strings not implemented", + raises=NotImplementedError, + ) + request.node.add_marker(mark) + df = pd.DataFrame({"with_dtype": pd.Series(data, dtype=str(data.dtype))}) csv_output = df.to_csv(index=False, na_rep=np.nan) result = pd.read_csv( diff --git a/pandas/tests/extension/test_datetime.py b/pandas/tests/extension/test_datetime.py index 5a7b15ddb01ce..efb88dc7bd4e1 100644 --- a/pandas/tests/extension/test_datetime.py +++ b/pandas/tests/extension/test_datetime.py @@ -113,12 +113,6 @@ def test_map(self, data, na_action): result = data.map(lambda x: x, na_action=na_action) tm.assert_extension_array_equal(result, data) - @pytest.mark.parametrize("engine", ["c", "python"]) - def test_EA_types(self, engine, data): - expected_msg = r".*must implement _from_sequence_of_strings.*" - with pytest.raises(NotImplementedError, match=expected_msg): - super().test_EA_types(engine, data) - def check_reduce(self, ser: pd.Series, op_name: str, skipna: bool): if op_name in ["median", "mean", "std"]: alt = ser.astype("int64") diff --git a/pandas/tests/extension/test_interval.py b/pandas/tests/extension/test_interval.py index b427c12d2d40c..98dd1c5cb615f 100644 --- a/pandas/tests/extension/test_interval.py +++ b/pandas/tests/extension/test_interval.py @@ -90,12 +90,6 @@ def _supports_reduction(self, ser: pd.Series, op_name: str) -> bool: def test_fillna_length_mismatch(self, data_missing): super().test_fillna_length_mismatch(data_missing) - @pytest.mark.parametrize("engine", ["c", "python"]) - def test_EA_types(self, engine, data): - expected_msg = r".*must implement _from_sequence_of_strings.*" - with pytest.raises(NotImplementedError, match=expected_msg): - super().test_EA_types(engine, data) - # TODO: either belongs in tests.arrays.interval or move into base tests. def test_fillna_non_scalar_raises(data_missing): diff --git a/pandas/tests/extension/test_sparse.py b/pandas/tests/extension/test_sparse.py index 8e46b90d4df1e..5ed8d13e1a7eb 100644 --- a/pandas/tests/extension/test_sparse.py +++ b/pandas/tests/extension/test_sparse.py @@ -446,11 +446,7 @@ def test_array_repr(self, data, size): class TestParsing(BaseSparseTests, base.BaseParsingTests): - @pytest.mark.parametrize("engine", ["c", "python"]) - def test_EA_types(self, engine, data): - expected_msg = r".*must implement _from_sequence_of_strings.*" - with pytest.raises(NotImplementedError, match=expected_msg): - super().test_EA_types(engine, data) + pass class TestNoNumericAccumulations(base.BaseAccumulateTests):