Skip to content

Backport PR #49286 on branch 1.5.x (TST: update exception messages for lxml tests) #49303

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
Show file tree
Hide file tree
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
13 changes: 10 additions & 3 deletions pandas/tests/io/xml/test_to_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -1037,9 +1037,16 @@ def test_stylesheet_wrong_path():
def test_empty_string_stylesheet(val):
from lxml.etree import XMLSyntaxError

with pytest.raises(
XMLSyntaxError, match=("Document is empty|Start tag expected, '<' not found")
):
msg = "|".join(
[
"Document is empty",
"Start tag expected, '<' not found",
# Seen on Mac with lxml 4.9.1
r"None \(line 0\)",
]
)

with pytest.raises(XMLSyntaxError, match=msg):
geom_df.to_xml(stylesheet=val)


Expand Down
9 changes: 8 additions & 1 deletion pandas/tests/io/xml/test_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,14 @@ def test_file_handle_close(datapath, parser):
def test_empty_string_lxml(val):
from lxml.etree import XMLSyntaxError

with pytest.raises(XMLSyntaxError, match="Document is empty"):
msg = "|".join(
[
"Document is empty",
# Seen on Mac with lxml 4.91
r"None \(line 0\)",
]
)
with pytest.raises(XMLSyntaxError, match=msg):
read_xml(val, parser="lxml")


Expand Down