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

Lines changed: 8 additions & 2 deletions
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

Lines changed: 3 additions & 0 deletions
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

Lines changed: 9 additions & 3 deletions
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

Lines changed: 0 additions & 3 deletions
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

Lines changed: 4 additions & 0 deletions
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

Lines changed: 4 additions & 0 deletions
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

Lines changed: 3 additions & 0 deletions
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

Lines changed: 3 additions & 0 deletions
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

Lines changed: 3 additions & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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])

0 commit comments

Comments
 (0)