Skip to content

Commit d36a5aa

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 0167265 commit d36a5aa

25 files changed

+78
-15
lines changed

pandas/_testing/asserters.py

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

594594
if isinstance(left, np.ndarray):
595595
left = pprint_thing(left)
596-
elif isinstance(left, (CategoricalDtype, NumpyEADtype, StringDtype)):
596+
elif isinstance(left, (CategoricalDtype, NumpyEADtype)):
597597
left = repr(left)
598+
elif isinstance(left, StringDtype):
599+
# TODO(infer_string) this special case could be avoided if we have
600+
# a more informative repr https://github.com/pandas-dev/pandas/issues/59342
601+
left = f"StringDtype(storage={left.storage}, na_value={left.na_value})"
598602

599603
if isinstance(right, np.ndarray):
600604
right = pprint_thing(right)
601-
elif isinstance(right, (CategoricalDtype, NumpyEADtype, StringDtype)):
605+
elif isinstance(right, (CategoricalDtype, NumpyEADtype)):
602606
right = repr(right)
607+
elif isinstance(right, StringDtype):
608+
right = f"StringDtype(storage={right.storage}, na_value={right.na_value})"
603609

604610
msg += f"""
605611
[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
@@ -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.compat.pyarrow import pa_version_under12p0
1113

1214
from pandas.core.dtypes.common import is_dtype_equal
@@ -513,6 +515,7 @@ def test_arrow_array(dtype):
513515
assert arr.equals(expected)
514516

515517

518+
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)", strict=False)
516519
@pytest.mark.filterwarnings("ignore:Passing a BlockManager:DeprecationWarning")
517520
def test_arrow_roundtrip(dtype, string_storage2, request, using_infer_string):
518521
# roundtrip possible from arrow 1.0.0
@@ -541,6 +544,7 @@ def test_arrow_roundtrip(dtype, string_storage2, request, using_infer_string):
541544
assert result.loc[2, "a"] is result["a"].dtype.na_value
542545

543546

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

pandas/tests/arrays/test_array.py

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

9+
from pandas._config import using_string_dtype
10+
911
import pandas as pd
1012
import pandas._testing as tm
1113
from pandas.api.extensions import register_extension_dtype
@@ -275,6 +277,7 @@ def test_array_copy():
275277
cet = pytz.timezone("CET")
276278

277279

280+
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)", strict=False)
278281
@pytest.mark.parametrize(
279282
"data, expected",
280283
[

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
@@ -757,6 +759,7 @@ def test_astype_tz_object_conversion(self, tz):
757759
result = result.astype({"tz": "datetime64[ns, Europe/London]"})
758760
tm.assert_frame_equal(result, expected)
759761

762+
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)")
760763
def test_astype_dt64_to_string(
761764
self, frame_or_series, tz_naive_fixture, using_infer_string
762765
):

pandas/tests/frame/test_arithmetic.py

+1
Original file line numberDiff line numberDiff line change
@@ -2124,6 +2124,7 @@ def test_enum_column_equality():
21242124
tm.assert_series_equal(result, expected)
21252125

21262126

2127+
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)")
21272128
def test_mixed_col_index_dtype():
21282129
# GH 47382
21292130
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,
@@ -940,6 +942,7 @@ def test_func_returns_object():
940942
tm.assert_series_equal(result, expected)
941943

942944

945+
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)")
943946
@pytest.mark.parametrize(
944947
"group_column_dtlike",
945948
[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,
@@ -758,6 +760,7 @@ def test_intersection_keep_ea_dtypes(val, any_numeric_ea_dtype):
758760
tm.assert_index_equal(result, expected)
759761

760762

763+
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)")
761764
def test_union_with_na_when_constructing_dataframe():
762765
# GH43222
763766
series1 = Series(

pandas/tests/indexes/test_old_base.py

+1
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ def test_logical_compat(self, simple_index):
232232
with pytest.raises(TypeError, match=msg):
233233
idx.any()
234234

235+
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)", strict=False)
235236
def test_repr_roundtrip(self, simple_index):
236237
if isinstance(simple_index, IntervalIndex):
237238
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
@@ -660,7 +660,9 @@ def test_dtype_backend_and_dtype(self, read_ext):
660660
)
661661
tm.assert_frame_equal(result, df)
662662

663-
@pytest.mark.xfail(using_string_dtype(), reason="infer_string takes precedence")
663+
@pytest.mark.xfail(
664+
using_string_dtype(), reason="infer_string takes precedence", strict=False
665+
)
664666
def test_dtype_backend_string(self, read_ext, string_storage):
665667
# GH#36712
666668
if read_ext in (".xlsb", ".xls"):

pandas/tests/io/json/test_json_table_schema.py

+6
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
from pandas.core.dtypes.dtypes import (
1012
CategoricalDtype,
1113
DatetimeTZDtype,
@@ -24,6 +26,10 @@
2426
set_default_names,
2527
)
2628

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

2834
@pytest.fixture
2935
def df_schema():

pandas/tests/io/json/test_pandas.py

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

14801480
assert size_before == size_after
14811481

1482+
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)", strict=False)
14821483
@pytest.mark.parametrize(
14831484
"index", [None, [1, 2], [1.0, 2.0], ["a", "b"], ["1", "2"], ["1.", "2."]]
14841485
)
@@ -1491,6 +1492,7 @@ def test_from_json_to_json_table_index_and_columns(self, index, columns):
14911492
result = read_json(StringIO(dfjson), orient="table")
14921493
tm.assert_frame_equal(result, expected)
14931494

1495+
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)")
14941496
def test_from_json_to_json_table_dtypes(self):
14951497
# GH21345
14961498
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
@@ -463,7 +463,7 @@ def test_dtype_backend_and_dtype(all_parsers):
463463
tm.assert_frame_equal(result, expected)
464464

465465

466-
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)")
466+
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)", strict=False)
467467
def test_dtype_backend_string(all_parsers, string_storage):
468468
# GH#36712
469469
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
@@ -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.errors import ParserError
1113

1214
from pandas import (
@@ -545,6 +547,7 @@ def test_usecols_additional_columns_integer_columns(all_parsers):
545547
tm.assert_frame_equal(result, expected)
546548

547549

550+
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)")
548551
def test_usecols_dtype(all_parsers):
549552
parser = all_parsers
550553
data = """

pandas/tests/io/test_feather.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,12 @@
1313

1414
from pandas.io.feather_format import read_feather, to_feather # isort:skip
1515

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

2023
pa = pytest.importorskip("pyarrow")
2124

@@ -170,7 +173,6 @@ def test_http_path(self, feather_file, httpserver):
170173
res = read_feather(httpserver.url)
171174
tm.assert_frame_equal(expected, res)
172175

173-
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)", strict=False)
174176
def test_read_feather_dtype_backend(self, string_storage, dtype_backend):
175177
# GH#50765
176178
df = pd.DataFrame(

pandas/tests/io/test_fsspec.py

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

279279

280+
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)")
280281
def test_feather_options(fsspectest):
281282
pytest.importorskip("pyarrow")
282283
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,6 +3,8 @@
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
@@ -181,6 +183,7 @@ def test_cases(request):
181183

182184

183185
class TestSeriesConvertDtypes:
186+
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)", strict=False)
184187
@pytest.mark.parametrize("params", product(*[(True, False)] * 5))
185188
def test_convert_dtypes(
186189
self,

0 commit comments

Comments
 (0)