Skip to content

Commit eba59fa

Browse files
TST (string dtype): fix IO dtype_backend tests for storage of str dtype of columns' Index (#59509)
* TST (string dtype): fix failure in csv test_dtype_backend_string test * ignore storage of Index str dtype
1 parent e2ed477 commit eba59fa

File tree

6 files changed

+21
-11
lines changed

6 files changed

+21
-11
lines changed

pandas/tests/io/excel/test_readers.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,9 @@ def test_dtype_backend_string(self, read_ext, string_storage, tmp_excel):
712712
"b": Series(["x", None], dtype=pd.StringDtype(string_storage)),
713713
}
714714
)
715-
tm.assert_frame_equal(result, expected)
715+
# the storage of the str columns' Index is also affected by the
716+
# string_storage setting -> ignore that for checking the result
717+
tm.assert_frame_equal(result, expected, check_column_type=False)
716718

717719
@pytest.mark.parametrize("dtypes, exp_value", [({}, 1), ({"a.1": "int64"}, 1)])
718720
def test_dtype_mangle_dup_cols(self, read_ext, dtypes, exp_value):

pandas/tests/io/json/test_pandas.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -2194,7 +2194,9 @@ def test_read_json_dtype_backend(
21942194
if orient == "values":
21952195
expected.columns = list(range(8))
21962196

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

21992201
@pytest.mark.parametrize("orient", ["split", "records", "index"])
22002202
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
@@ -974,7 +974,9 @@ def test_dtype_backend(string_storage, dtype_backend):
974974
)
975975
expected["i"] = ArrowExtensionArray(pa.array([None, None]))
976976

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

979981

980982
def test_invalid_dtype_backend():

pandas/tests/io/test_html.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,9 @@ def test_dtype_backend(self, string_storage, dtype_backend, flavor_read_html):
207207
}
208208
)
209209

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

212214
@pytest.mark.network
213215
@pytest.mark.single_cpu

pandas/tests/io/xml/test_xml.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -2050,7 +2050,9 @@ def test_read_xml_nullable_dtypes(
20502050
)
20512051
expected["g"] = ArrowExtensionArray(pa.array([None, None]))
20522052

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

20552057

20562058
def test_invalid_dtype_backend():

0 commit comments

Comments
 (0)