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

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

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
@@ -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

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

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
@@ -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

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

0 commit comments

Comments
 (0)