Skip to content

Commit 220960f

Browse files
fix more tests + remove some xfails
1 parent 757ea8a commit 220960f

17 files changed

+22
-29
lines changed

pandas/tests/arrays/interval/test_interval_pyarrow.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
import pandas as pd
75
import pandas._testing as tm
86
from pandas.core.arrays import IntervalArray
@@ -82,7 +80,6 @@ def test_arrow_array_missing():
8280
assert result.storage.equals(expected)
8381

8482

85-
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)")
8683
@pytest.mark.filterwarnings(
8784
"ignore:Passing a BlockManager to DataFrame:DeprecationWarning"
8885
)

pandas/tests/arrays/period/test_arrow_compat.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import pytest
22

3-
from pandas._config import using_string_dtype
4-
53
from pandas.compat.pyarrow import pa_version_under10p1
64

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

8179

82-
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)")
8380
def test_arrow_table_roundtrip():
8481
from pandas.core.arrays.arrow.extension_types import ArrowPeriodType
8582

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

10198

102-
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)")
10399
def test_arrow_load_from_zero_chunks():
104100
# GH-41040
105101

pandas/tests/frame/methods/test_reset_index.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,7 @@ def test_reset_index_dtypes_on_empty_frame_with_multiindex(
662662
idx = MultiIndex.from_product([[0, 1], [0.5, 1.0], array])
663663
result = DataFrame(index=idx)[:0].reset_index().dtypes
664664
if using_infer_string and dtype == object:
665-
dtype = "string"
665+
dtype = "str"
666666
expected = Series({"level_0": np.int64, "level_1": np.float64, "level_2": dtype})
667667
tm.assert_series_equal(result, expected)
668668

pandas/tests/frame/methods/test_select_dtypes.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
from pandas.core.dtypes.dtypes import ExtensionDtype
57

68
import pandas as pd
@@ -345,6 +347,7 @@ def test_select_dtypes_datetime_with_tz(self):
345347
expected = df3.reindex(columns=[])
346348
tm.assert_frame_equal(result, expected)
347349

350+
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)", strict=False)
348351
@pytest.mark.parametrize("dtype", [str, "str", np.bytes_, "S1", np.str_, "U1"])
349352
@pytest.mark.parametrize("arg", ["include", "exclude"])
350353
def test_select_dtypes_str_raises(self, dtype, arg):

pandas/tests/frame/test_constructors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ def test_emptylike_constructor(self, emptylike, expected_index, expected_columns
256256
tm.assert_frame_equal(result, expected)
257257

258258
def test_constructor_mixed(self, float_string_frame, using_infer_string):
259-
dtype = "string" if using_infer_string else np.object_
259+
dtype = "str" if using_infer_string else np.object_
260260
assert float_string_frame["foo"].dtype == dtype
261261

262262
def test_constructor_cast_failure(self):

pandas/tests/frame/test_stack_unstack.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,7 @@ def test_unstack_dtypes(self, using_infer_string):
658658
df2["D"] = "foo"
659659
df3 = df2.unstack("B")
660660
result = df3.dtypes
661-
dtype = "string" if using_infer_string else np.dtype("object")
661+
dtype = "str" if using_infer_string else np.dtype("object")
662662
expected = Series(
663663
[np.dtype("float64")] * 2 + [dtype] * 2,
664664
index=MultiIndex.from_arrays(

pandas/tests/groupby/test_apply.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1017,7 +1017,7 @@ def test_groupby_apply_datetime_result_dtypes(using_infer_string):
10171017
msg = "DataFrameGroupBy.apply operated on the grouping columns"
10181018
with tm.assert_produces_warning(DeprecationWarning, match=msg):
10191019
result = data.groupby("color").apply(lambda g: g.iloc[0]).dtypes
1020-
dtype = "string" if using_infer_string else object
1020+
dtype = "str" if using_infer_string else object
10211021
expected = Series(
10221022
[np.dtype("datetime64[us]"), dtype, dtype, np.int64, dtype],
10231023
index=["observation", "color", "mood", "intensity", "score"],

pandas/tests/indexes/base_class/test_formats.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010

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

pandas/tests/indexing/test_indexing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ def test_dups_fancy_indexing_only_missing_label(self, using_infer_string):
259259
with pytest.raises(
260260
KeyError,
261261
match=re.escape(
262-
"\"None of [Index(['E'], dtype='string')] are in the [index]\""
262+
"\"None of [Index(['E'], dtype='str')] are in the [index]\""
263263
),
264264
):
265265
dfnu.loc[["E"]]

pandas/tests/indexing/test_loc.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,17 @@ def test_not_change_nan_loc(series, new_series, expected_ser):
6262

6363

6464
class TestLoc:
65-
def test_none_values_on_string_columns(self):
65+
def test_none_values_on_string_columns(self, using_infer_string):
6666
# Issue #32218
67-
df = DataFrame(["1", "2", None], columns=["a"], dtype="str")
68-
67+
df = DataFrame(["1", "2", None], columns=["a"], dtype=object)
6968
assert df.loc[2, "a"] is None
7069

70+
df = DataFrame(["1", "2", None], columns=["a"], dtype="str")
71+
if using_infer_string:
72+
assert np.isnan(df.loc[2, "a"])
73+
else:
74+
assert df.loc[2, "a"] is None
75+
7176
def test_loc_getitem_int(self, frame_or_series):
7277
# int label
7378
obj = frame_or_series(range(3), index=Index(list("abc"), dtype=object))

0 commit comments

Comments
 (0)