Skip to content

Commit 543548c

Browse files
WillAydjorisvandenbossche
authored andcommitted
TST (string dtype): fix IO dtype_backend tests for storage of str dtype of columns' Index (pandas-dev#59509)
1 parent d241c0f commit 543548c

File tree

5 files changed

+18
-10
lines changed

5 files changed

+18
-10
lines changed

pandas/tests/io/json/test_pandas.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -2088,7 +2088,9 @@ def test_read_json_dtype_backend(
20882088
if orient == "values":
20892089
expected.columns = list(range(8))
20902090

2091-
tm.assert_frame_equal(result, expected)
2091+
# the storage of the str columns' Index is also affected by the
2092+
# string_storage setting -> ignore that for checking the result
2093+
tm.assert_frame_equal(result, expected, check_column_type=False)
20922094

20932095
@pytest.mark.parametrize("orient", ["split", "records", "index"])
20942096
def test_read_json_nullable_series(self, string_storage, dtype_backend, orient):

pandas/tests/io/parser/dtypes/test_dtypes_basic.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -470,12 +470,12 @@ def test_dtype_backend_string(all_parsers, string_storage):
470470
"""
471471
result = parser.read_csv(StringIO(data), dtype_backend="numpy_nullable")
472472

473-
expected = DataFrame(
474-
{
475-
"a": pd.array(["a", "b"], dtype=pd.StringDtype(string_storage)),
476-
"b": pd.array(["x", pd.NA], dtype=pd.StringDtype(string_storage)),
477-
}
478-
)
473+
expected = DataFrame(
474+
{
475+
"a": pd.array(["a", "b"], dtype=pd.StringDtype(string_storage)),
476+
"b": pd.array(["x", pd.NA], dtype=pd.StringDtype(string_storage)),
477+
},
478+
)
479479
tm.assert_frame_equal(result, expected)
480480

481481

pandas/tests/io/parser/test_read_fwf.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -1001,7 +1001,9 @@ def test_dtype_backend(string_storage, dtype_backend):
10011001
)
10021002
expected["i"] = ArrowExtensionArray(pa.array([None, None]))
10031003

1004-
tm.assert_frame_equal(result, expected)
1004+
# the storage of the str columns' Index is also affected by the
1005+
# string_storage setting -> ignore that for checking the result
1006+
tm.assert_frame_equal(result, expected, check_column_type=False)
10051007

10061008

10071009
def test_invalid_dtype_backend():

pandas/tests/io/test_html.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,9 @@ def test_dtype_backend(self, string_storage, dtype_backend, flavor_read_html):
211211
}
212212
)
213213

214-
tm.assert_frame_equal(result, expected)
214+
# the storage of the str columns' Index is also affected by the
215+
# string_storage setting -> ignore that for checking the result
216+
tm.assert_frame_equal(result, expected, check_column_type=False)
215217

216218
@pytest.mark.network
217219
@pytest.mark.single_cpu

pandas/tests/io/xml/test_xml.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -2065,7 +2065,9 @@ def test_read_xml_nullable_dtypes(
20652065
)
20662066
expected["g"] = ArrowExtensionArray(pa.array([None, None]))
20672067

2068-
tm.assert_frame_equal(result, expected)
2068+
# the storage of the str columns' Index is also affected by the
2069+
# string_storage setting -> ignore that for checking the result
2070+
tm.assert_frame_equal(result, expected, check_column_type=False)
20692071

20702072

20712073
def test_invalid_dtype_backend():

0 commit comments

Comments
 (0)