Skip to content

Adjust tests in xml folder for new string option #56198

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions pandas/tests/io/xml/test_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
ArrowStringArray,
StringArray,
)
from pandas.core.arrays.string_arrow import ArrowStringArrayNumpySemantics

from pandas.io.common import get_handle
from pandas.io.xml import read_xml
Expand Down Expand Up @@ -2004,7 +2005,9 @@ def test_s3_parser_consistency(s3_public_bucket_with_data, s3so):
tm.assert_frame_equal(df_lxml, df_etree)


def test_read_xml_nullable_dtypes(parser, string_storage, dtype_backend):
def test_read_xml_nullable_dtypes(
parser, string_storage, dtype_backend, using_infer_string
):
# GH#50500
data = """<?xml version='1.0' encoding='utf-8'?>
<data xmlns="http://example.com">
Expand Down Expand Up @@ -2032,7 +2035,12 @@ def test_read_xml_nullable_dtypes(parser, string_storage, dtype_backend):
</row>
</data>"""

if string_storage == "python":
if using_infer_string:
pa = pytest.importorskip("pyarrow")
string_array = ArrowStringArrayNumpySemantics(pa.array(["x", "y"]))
string_array_na = ArrowStringArrayNumpySemantics(pa.array(["x", None]))

elif string_storage == "python":
string_array = StringArray(np.array(["x", "y"], dtype=np.object_))
string_array_na = StringArray(np.array(["x", NA], dtype=np.object_))

Expand Down