From 4496b6853ead6e2a985bc1d2be03a9859d406803 Mon Sep 17 00:00:00 2001 From: jbrockmendel Date: Tue, 25 Oct 2022 07:06:37 -0700 Subject: [PATCH] Backport PR #49286: TST: update exception messages for lxml tests --- pandas/tests/io/xml/test_to_xml.py | 13 ++++++++++--- pandas/tests/io/xml/test_xml.py | 9 ++++++++- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/pandas/tests/io/xml/test_to_xml.py b/pandas/tests/io/xml/test_to_xml.py index d3247eb9dd47e..0f42c7e070c4a 100644 --- a/pandas/tests/io/xml/test_to_xml.py +++ b/pandas/tests/io/xml/test_to_xml.py @@ -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) diff --git a/pandas/tests/io/xml/test_xml.py b/pandas/tests/io/xml/test_xml.py index fd4ba87bd302c..33a98f57310c2 100644 --- a/pandas/tests/io/xml/test_xml.py +++ b/pandas/tests/io/xml/test_xml.py @@ -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")