Skip to content

Commit dd2dbcd

Browse files
TST (string dtype): follow-up on GH-59329 fixing new xfails (#59352)
* TST (string dtype): follow-up on GH-59329 fixing new xfails * add missing strict
1 parent 9c8c685 commit dd2dbcd

25 files changed

+78
-16
lines changed

pandas/_testing/asserters.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -578,13 +578,19 @@ def raise_assert_detail(
578578

579579
if isinstance(left, np.ndarray):
580580
left = pprint_thing(left)
581-
elif isinstance(left, (CategoricalDtype, NumpyEADtype, StringDtype)):
581+
elif isinstance(left, (CategoricalDtype, NumpyEADtype)):
582582
left = repr(left)
583+
elif isinstance(left, StringDtype):
584+
# TODO(infer_string) this special case could be avoided if we have
585+
# a more informative repr https://github.com/pandas-dev/pandas/issues/59342
586+
left = f"StringDtype(storage={left.storage}, na_value={left.na_value})"
583587

584588
if isinstance(right, np.ndarray):
585589
right = pprint_thing(right)
586-
elif isinstance(right, (CategoricalDtype, NumpyEADtype, StringDtype)):
590+
elif isinstance(right, (CategoricalDtype, NumpyEADtype)):
587591
right = repr(right)
592+
elif isinstance(right, StringDtype):
593+
right = f"StringDtype(storage={right.storage}, na_value={right.na_value})"
588594

589595
msg += f"""
590596
[left]: {left}

pandas/tests/arrays/interval/test_interval_pyarrow.py

+3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import numpy as np
22
import pytest
33

4+
from pandas._config import using_string_dtype
5+
46
import pandas as pd
57
import pandas._testing as tm
68
from pandas.core.arrays import IntervalArray
@@ -80,6 +82,7 @@ def test_arrow_array_missing():
8082
assert result.storage.equals(expected)
8183

8284

85+
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)")
8386
@pytest.mark.filterwarnings(
8487
"ignore:Passing a BlockManager to DataFrame:DeprecationWarning"
8588
)

pandas/tests/arrays/masked/test_arrow_compat.py

+9-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
import numpy as np
22
import pytest
33

4+
from pandas._config import using_string_dtype
5+
46
import pandas as pd
57
import pandas._testing as tm
68

7-
pytestmark = pytest.mark.filterwarnings(
8-
"ignore:Passing a BlockManager to DataFrame:DeprecationWarning"
9-
)
9+
pytestmark = [
10+
pytest.mark.filterwarnings(
11+
"ignore:Passing a BlockManager to DataFrame:DeprecationWarning"
12+
),
13+
pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)", strict=False),
14+
]
15+
1016

1117
pa = pytest.importorskip("pyarrow")
1218

pandas/tests/arrays/masked/test_function.py

-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import numpy as np
22
import pytest
33

4-
from pandas._config import using_string_dtype
5-
64
from pandas.core.dtypes.common import is_integer_dtype
75

86
import pandas as pd
@@ -60,7 +58,6 @@ def test_tolist(data):
6058
tm.assert_equal(result, expected)
6159

6260

63-
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)")
6461
def test_to_numpy():
6562
# GH#56991
6663

pandas/tests/arrays/period/test_arrow_compat.py

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import pytest
22

3+
from pandas._config import using_string_dtype
4+
35
from pandas.compat.pyarrow import pa_version_under10p1
46

57
from pandas.core.dtypes.dtypes import PeriodDtype
@@ -77,6 +79,7 @@ def test_arrow_array_missing():
7779
assert result.storage.equals(expected)
7880

7981

82+
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)")
8083
def test_arrow_table_roundtrip():
8184
from pandas.core.arrays.arrow.extension_types import ArrowPeriodType
8285

@@ -96,6 +99,7 @@ def test_arrow_table_roundtrip():
9699
tm.assert_frame_equal(result, expected)
97100

98101

102+
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)")
99103
def test_arrow_load_from_zero_chunks():
100104
# GH-41040
101105

pandas/tests/arrays/string_/test_string.py

+4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
import numpy as np
99
import pytest
1010

11+
from pandas._config import using_string_dtype
12+
1113
from pandas.compat.pyarrow import pa_version_under12p0
1214

1315
from pandas.core.dtypes.common import is_dtype_equal
@@ -511,6 +513,7 @@ def test_arrow_array(dtype):
511513
assert arr.equals(expected)
512514

513515

516+
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)", strict=False)
514517
@pytest.mark.filterwarnings("ignore:Passing a BlockManager:DeprecationWarning")
515518
def test_arrow_roundtrip(dtype, string_storage2, request, using_infer_string):
516519
# roundtrip possible from arrow 1.0.0
@@ -539,6 +542,7 @@ def test_arrow_roundtrip(dtype, string_storage2, request, using_infer_string):
539542
assert result.loc[2, "a"] is result["a"].dtype.na_value
540543

541544

545+
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)", strict=False)
542546
@pytest.mark.filterwarnings("ignore:Passing a BlockManager:DeprecationWarning")
543547
def test_arrow_load_from_zero_chunks(
544548
dtype, string_storage2, request, using_infer_string

pandas/tests/arrays/test_array.py

+3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
import numpy as np
66
import pytest
77

8+
from pandas._config import using_string_dtype
9+
810
import pandas as pd
911
import pandas._testing as tm
1012
from pandas.api.extensions import register_extension_dtype
@@ -285,6 +287,7 @@ def test_array_copy():
285287
assert tm.shares_memory(a, b)
286288

287289

290+
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)", strict=False)
288291
@pytest.mark.parametrize(
289292
"data, expected",
290293
[

pandas/tests/dtypes/test_common.py

+3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import numpy as np
44
import pytest
55

6+
from pandas._config import using_string_dtype
7+
68
import pandas.util._test_decorators as td
79

810
from pandas.core.dtypes.astype import astype_array
@@ -128,6 +130,7 @@ def test_dtype_equal(name1, dtype1, name2, dtype2):
128130
assert not com.is_dtype_equal(dtype1, dtype2)
129131

130132

133+
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)", strict=False)
131134
@pytest.mark.parametrize("name,dtype", list(dtypes.items()), ids=lambda x: str(x))
132135
def test_pyarrow_string_import_error(name, dtype):
133136
# GH-44276

pandas/tests/frame/methods/test_astype.py

+3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import numpy as np
44
import pytest
55

6+
from pandas._config import using_string_dtype
7+
68
import pandas.util._test_decorators as td
79

810
import pandas as pd
@@ -742,6 +744,7 @@ def test_astype_tz_object_conversion(self, tz):
742744
result = result.astype({"tz": "datetime64[ns, Europe/London]"})
743745
tm.assert_frame_equal(result, expected)
744746

747+
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)")
745748
def test_astype_dt64_to_string(
746749
self, frame_or_series, tz_naive_fixture, using_infer_string
747750
):

pandas/tests/frame/test_arithmetic.py

+1
Original file line numberDiff line numberDiff line change
@@ -2097,6 +2097,7 @@ def test_enum_column_equality():
20972097
tm.assert_series_equal(result, expected)
20982098

20992099

2100+
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)")
21002101
def test_mixed_col_index_dtype():
21012102
# GH 47382
21022103
df1 = DataFrame(columns=list("abc"), data=1.0, index=[0])

pandas/tests/groupby/test_apply.py

+3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
import numpy as np
77
import pytest
88

9+
from pandas._config import using_string_dtype
10+
911
import pandas as pd
1012
from pandas import (
1113
DataFrame,
@@ -920,6 +922,7 @@ def test_func_returns_object():
920922
tm.assert_series_equal(result, expected)
921923

922924

925+
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)")
923926
@pytest.mark.parametrize(
924927
"group_column_dtlike",
925928
[datetime.today(), datetime.today().date(), datetime.today().time()],

pandas/tests/indexes/base_class/test_formats.py

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010

1111
class TestIndexRendering:
12+
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)")
1213
def test_repr_is_valid_construction_code(self):
1314
# for the case of Index, where the repr is traditional rather than
1415
# stylized

pandas/tests/indexes/multi/test_setops.py

+3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import numpy as np
22
import pytest
33

4+
from pandas._config import using_string_dtype
5+
46
import pandas as pd
57
from pandas import (
68
CategoricalIndex,
@@ -752,6 +754,7 @@ def test_intersection_keep_ea_dtypes(val, any_numeric_ea_dtype):
752754
tm.assert_index_equal(result, expected)
753755

754756

757+
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)")
755758
def test_union_with_na_when_constructing_dataframe():
756759
# GH43222
757760
series1 = Series(

pandas/tests/indexes/test_old_base.py

+1
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ def test_logical_compat(self, simple_index):
228228
with pytest.raises(TypeError, match=msg):
229229
idx.any()
230230

231+
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)", strict=False)
231232
def test_repr_roundtrip(self, simple_index):
232233
if isinstance(simple_index, IntervalIndex):
233234
pytest.skip(f"Not a valid repr for {type(simple_index).__name__}")

pandas/tests/io/excel/test_readers.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -692,7 +692,9 @@ def test_dtype_backend_and_dtype(self, read_ext, tmp_excel):
692692
)
693693
tm.assert_frame_equal(result, df)
694694

695-
@pytest.mark.xfail(using_string_dtype(), reason="infer_string takes precedence")
695+
@pytest.mark.xfail(
696+
using_string_dtype(), reason="infer_string takes precedence", strict=False
697+
)
696698
def test_dtype_backend_string(self, read_ext, string_storage, tmp_excel):
697699
# GH#36712
698700
if read_ext in (".xlsb", ".xls"):

pandas/tests/io/json/test_json_table_schema.py

+6
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import numpy as np
88
import pytest
99

10+
from pandas._config import using_string_dtype
11+
1012
from pandas.core.dtypes.dtypes import (
1113
CategoricalDtype,
1214
DatetimeTZDtype,
@@ -25,6 +27,10 @@
2527
set_default_names,
2628
)
2729

30+
pytestmark = pytest.mark.xfail(
31+
using_string_dtype(), reason="TODO(infer_string)", strict=False
32+
)
33+
2834

2935
@pytest.fixture
3036
def df_schema():

pandas/tests/io/json/test_pandas.py

+2
Original file line numberDiff line numberDiff line change
@@ -1560,6 +1560,7 @@ def test_data_frame_size_after_to_json(self):
15601560

15611561
assert size_before == size_after
15621562

1563+
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)", strict=False)
15631564
@pytest.mark.parametrize(
15641565
"index", [None, [1, 2], [1.0, 2.0], ["a", "b"], ["1", "2"], ["1.", "2."]]
15651566
)
@@ -1572,6 +1573,7 @@ def test_from_json_to_json_table_index_and_columns(self, index, columns):
15721573
result = read_json(StringIO(dfjson), orient="table")
15731574
tm.assert_frame_equal(result, expected)
15741575

1576+
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)")
15751577
def test_from_json_to_json_table_dtypes(self):
15761578
# GH21345
15771579
expected = DataFrame({"a": [1, 2], "b": [3.0, 4.0], "c": ["5", "6"]})

pandas/tests/io/parser/dtypes/test_dtypes_basic.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ def test_dtype_backend_and_dtype(all_parsers):
461461
tm.assert_frame_equal(result, expected)
462462

463463

464-
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)")
464+
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)", strict=False)
465465
def test_dtype_backend_string(all_parsers, string_storage):
466466
# GH#36712
467467
pa = pytest.importorskip("pyarrow")

pandas/tests/io/parser/test_upcast.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def test_maybe_upcaste_all_nan():
8686
tm.assert_extension_array_equal(result, expected)
8787

8888

89-
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)")
89+
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)", strict=False)
9090
@pytest.mark.parametrize("val", [na_values[np.object_], "c"])
9191
def test_maybe_upcast_object(val, string_storage):
9292
# GH#36712

pandas/tests/io/parser/usecols/test_usecols_basic.py

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
import numpy as np
99
import pytest
1010

11+
from pandas._config import using_string_dtype
12+
1113
from pandas.errors import ParserError
1214

1315
from pandas import (
@@ -529,6 +531,7 @@ def test_usecols_additional_columns_integer_columns(all_parsers):
529531
tm.assert_frame_equal(result, expected)
530532

531533

534+
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)")
532535
def test_usecols_dtype(all_parsers):
533536
parser = all_parsers
534537
data = """

pandas/tests/io/test_feather.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,12 @@
1616

1717
from pandas.io.feather_format import read_feather, to_feather # isort:skip
1818

19-
pytestmark = pytest.mark.filterwarnings(
20-
"ignore:Passing a BlockManager to DataFrame:DeprecationWarning"
21-
)
19+
pytestmark = [
20+
pytest.mark.filterwarnings(
21+
"ignore:Passing a BlockManager to DataFrame:DeprecationWarning"
22+
),
23+
pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)", strict=False),
24+
]
2225

2326
pa = pytest.importorskip("pyarrow")
2427

@@ -148,7 +151,6 @@ def test_path_pathlib(self):
148151
result = tm.round_trip_pathlib(df.to_feather, read_feather)
149152
tm.assert_frame_equal(df, result)
150153

151-
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)")
152154
def test_passthrough_keywords(self):
153155
df = pd.DataFrame(
154156
1.1 * np.arange(120).reshape((30, 4)),
@@ -167,7 +169,6 @@ def test_http_path(self, feather_file, httpserver):
167169
res = read_feather(httpserver.url)
168170
tm.assert_frame_equal(expected, res)
169171

170-
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)", strict=False)
171172
def test_read_feather_dtype_backend(self, string_storage, dtype_backend):
172173
# GH#50765
173174
df = pd.DataFrame(

pandas/tests/io/test_fsspec.py

+1
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,7 @@ def test_not_present_exception():
283283
read_csv("memory://test/test.csv")
284284

285285

286+
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)")
286287
def test_feather_options(fsspectest):
287288
pytest.importorskip("pyarrow")
288289
df = DataFrame({"a": [0]})

pandas/tests/reshape/test_get_dummies.py

+3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
import numpy as np
55
import pytest
66

7+
from pandas._config import using_string_dtype
8+
79
import pandas.util._test_decorators as td
810

911
from pandas.core.dtypes.common import is_integer_dtype
@@ -214,6 +216,7 @@ def test_dataframe_dummies_all_obj(self, df, sparse):
214216

215217
tm.assert_frame_equal(result, expected)
216218

219+
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)")
217220
def test_dataframe_dummies_string_dtype(self, df, using_infer_string):
218221
# GH44965
219222
df = df[["A", "B"]]

pandas/tests/series/methods/test_convert_dtypes.py

+3
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,16 @@
33
import numpy as np
44
import pytest
55

6+
from pandas._config import using_string_dtype
7+
68
from pandas._libs import lib
79

810
import pandas as pd
911
import pandas._testing as tm
1012

1113

1214
class TestSeriesConvertDtypes:
15+
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)", strict=False)
1316
@pytest.mark.parametrize(
1417
"data, maindtype, expected_default, expected_other",
1518
[

0 commit comments

Comments
 (0)