Skip to content

Commit

Permalink
TST (string dtype): fix IO dtype_backend tests for storage of str dty…
Browse files Browse the repository at this point in the history
…pe of columns' Index (pandas-dev#59509)
  • Loading branch information
WillAyd committed Aug 22, 2024
1 parent c94c4f9 commit 054b5d8
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 10 deletions.
4 changes: 3 additions & 1 deletion pandas/tests/io/json/test_pandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -2088,7 +2088,9 @@ def test_read_json_dtype_backend(
if orient == "values":
expected.columns = list(range(8))

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

@pytest.mark.parametrize("orient", ["split", "records", "index"])
def test_read_json_nullable_series(self, string_storage, dtype_backend, orient):
Expand Down
12 changes: 6 additions & 6 deletions pandas/tests/io/parser/dtypes/test_dtypes_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,12 +470,12 @@ def test_dtype_backend_string(all_parsers, string_storage):
"""
result = parser.read_csv(StringIO(data), dtype_backend="numpy_nullable")

expected = DataFrame(
{
"a": pd.array(["a", "b"], dtype=pd.StringDtype(string_storage)),
"b": pd.array(["x", pd.NA], dtype=pd.StringDtype(string_storage)),
}
)
expected = DataFrame(
{
"a": pd.array(["a", "b"], dtype=pd.StringDtype(string_storage)),
"b": pd.array(["x", pd.NA], dtype=pd.StringDtype(string_storage)),
},
)
tm.assert_frame_equal(result, expected)


Expand Down
4 changes: 3 additions & 1 deletion pandas/tests/io/parser/test_read_fwf.py
Original file line number Diff line number Diff line change
Expand Up @@ -1001,7 +1001,9 @@ def test_dtype_backend(string_storage, dtype_backend):
)
expected["i"] = ArrowExtensionArray(pa.array([None, None]))

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


def test_invalid_dtype_backend():
Expand Down
4 changes: 3 additions & 1 deletion pandas/tests/io/test_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,9 @@ def test_dtype_backend(self, string_storage, dtype_backend, flavor_read_html):
}
)

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

@pytest.mark.network
@pytest.mark.single_cpu
Expand Down
4 changes: 3 additions & 1 deletion pandas/tests/io/xml/test_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -2065,7 +2065,9 @@ def test_read_xml_nullable_dtypes(
)
expected["g"] = ArrowExtensionArray(pa.array([None, None]))

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


def test_invalid_dtype_backend():
Expand Down

0 comments on commit 054b5d8

Please sign in to comment.