Skip to content

Commit cfdcf0e

Browse files
[backport 2.3.x] TST (string dtype): clean-up assorted xfails (#60345) (#60349)
TST (string dtype): clean-up assorted xfails (#60345) (cherry picked from commit e7d1964)
1 parent c079337 commit cfdcf0e

File tree

6 files changed

+10
-31
lines changed

6 files changed

+10
-31
lines changed

pandas/tests/base/test_conversion.py

+2-7
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.compat import HAS_PYARROW
75
from pandas.compat.numpy import np_version_gt2
86

@@ -391,9 +389,6 @@ def test_to_numpy(arr, expected, zero_copy, index_or_series_or_array):
391389
assert np.may_share_memory(result_nocopy1, result_nocopy2)
392390

393391

394-
@pytest.mark.xfail(
395-
using_string_dtype() and not HAS_PYARROW, reason="TODO(infer_string)", strict=False
396-
)
397392
@pytest.mark.parametrize("as_series", [True, False])
398393
@pytest.mark.parametrize(
399394
"arr", [np.array([1, 2, 3], dtype="int64"), np.array(["a", "b", "c"], dtype=object)]
@@ -405,13 +400,13 @@ def test_to_numpy_copy(arr, as_series, using_infer_string):
405400

406401
# no copy by default
407402
result = obj.to_numpy()
408-
if using_infer_string and arr.dtype == object:
403+
if using_infer_string and arr.dtype == object and obj.dtype.storage == "pyarrow":
409404
assert np.shares_memory(arr, result) is False
410405
else:
411406
assert np.shares_memory(arr, result) is True
412407

413408
result = obj.to_numpy(copy=False)
414-
if using_infer_string and arr.dtype == object:
409+
if using_infer_string and arr.dtype == object and obj.dtype.storage == "pyarrow":
415410
assert np.shares_memory(arr, result) is False
416411
else:
417412
assert np.shares_memory(arr, result) is True

pandas/tests/indexes/multi/test_setops.py

+1-4
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
import pandas as pd
75
from pandas import (
86
CategoricalIndex,
@@ -760,13 +758,12 @@ def test_intersection_keep_ea_dtypes(val, any_numeric_ea_dtype):
760758
tm.assert_index_equal(result, expected)
761759

762760

763-
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)")
764761
def test_union_with_na_when_constructing_dataframe():
765762
# GH43222
766763
series1 = Series(
767764
(1,),
768765
index=MultiIndex.from_arrays(
769-
[Series([None], dtype="string"), Series([None], dtype="string")]
766+
[Series([None], dtype="str"), Series([None], dtype="str")]
770767
),
771768
)
772769
series2 = Series((10, 20), index=MultiIndex.from_tuples(((None, None), ("a", "b"))))

pandas/tests/indexes/test_base.py

+1-11
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,7 @@
88
import numpy as np
99
import pytest
1010

11-
from pandas._config import using_string_dtype
12-
13-
from pandas.compat import (
14-
HAS_PYARROW,
15-
IS64,
16-
)
11+
from pandas.compat import IS64
1712
from pandas.errors import InvalidIndexError
1813
import pandas.util._test_decorators as td
1914

@@ -862,11 +857,6 @@ def test_isin(self, values, index, expected):
862857
result = index.isin(values)
863858
tm.assert_numpy_array_equal(result, expected)
864859

865-
@pytest.mark.xfail(
866-
using_string_dtype() and not HAS_PYARROW,
867-
reason="TODO(infer_string)",
868-
strict=False,
869-
)
870860
def test_isin_nan_common_object(
871861
self, nulls_fixture, nulls_fixture2, using_infer_string
872862
):

pandas/tests/io/excel/test_readers.py

-1
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,6 @@ def test_reader_dtype_str(self, read_ext, dtype, expected):
591591
actual = pd.read_excel(basename + read_ext, dtype=dtype)
592592
tm.assert_frame_equal(actual, expected)
593593

594-
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)", strict=False)
595594
def test_dtype_backend(self, read_ext, dtype_backend, engine):
596595
# GH#36712
597596
if read_ext in (".xlsb", ".xls"):

pandas/tests/io/excel/test_writers.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
import numpy as np
1212
import pytest
1313

14-
from pandas._config import using_string_dtype
15-
1614
from pandas.compat import is_platform_windows
1715
from pandas.compat._constants import PY310
1816
from pandas.compat._optional import import_optional_dependency
@@ -1316,12 +1314,11 @@ def test_freeze_panes(self, path):
13161314
result = pd.read_excel(path, index_col=0)
13171315
tm.assert_frame_equal(result, expected)
13181316

1319-
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)")
13201317
def test_path_path_lib(self, engine, ext):
13211318
df = DataFrame(
13221319
1.1 * np.arange(120).reshape((30, 4)),
13231320
columns=Index(list("ABCD")),
1324-
index=Index([f"i-{i}" for i in range(30)], dtype=object),
1321+
index=Index([f"i-{i}" for i in range(30)]),
13251322
)
13261323
writer = partial(df.to_excel, engine=engine)
13271324

pandas/tests/reshape/test_union_categoricals.py

+5-4
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.concat import union_categoricals
75

86
import pandas as pd
@@ -124,12 +122,15 @@ def test_union_categoricals_nan(self):
124122
exp = Categorical([np.nan, np.nan, np.nan, np.nan])
125123
tm.assert_categorical_equal(res, exp)
126124

127-
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)", strict=False)
128125
@pytest.mark.parametrize("val", [[], ["1"]])
129126
def test_union_categoricals_empty(self, val, request, using_infer_string):
130127
# GH 13759
131128
if using_infer_string and val == ["1"]:
132-
request.applymarker(pytest.mark.xfail("object and strings dont match"))
129+
request.applymarker(
130+
pytest.mark.xfail(
131+
reason="TDOD(infer_string) object and strings dont match"
132+
)
133+
)
133134
res = union_categoricals([Categorical([]), Categorical(val)])
134135
exp = Categorical(val)
135136
tm.assert_categorical_equal(res, exp)

0 commit comments

Comments
 (0)