| 1 | Fix test failure with newer Expat:
|
| 2 |
|
| 3 | https://bugs.python.org/issue46811
|
| 4 |
|
| 5 | This is a backport of this upstream commit:
|
| 6 |
|
| 7 | https://github.com/python/cpython/commit/2cae93832f46b245847bdc252456ddf7742ef45e
|
| 8 |
|
| 9 | diff --git a/Lib/test/test_minidom.py b/Lib/test/test_minidom.py
|
| 10 | index 2eb642395b..1793f9365d 100644
|
| 11 | |
| 12 | |
| 13 | @@ -6,12 +6,14 @@ from StringIO import StringIO
|
| 14 | from test import support
|
| 15 | import unittest
|
| 16 |
|
| 17 | +import pyexpat
|
| 18 | import xml.dom
|
| 19 | import xml.dom.minidom
|
| 20 | import xml.parsers.expat
|
| 21 |
|
| 22 | from xml.dom.minidom import parse, Node, Document, parseString
|
| 23 | from xml.dom.minidom import getDOMImplementation
|
| 24 | +from xml.parsers.expat import ExpatError
|
| 25 |
|
| 26 |
|
| 27 | tstfile = support.findfile("test.xml", subdir="xmltestdata")
|
| 28 | @@ -1051,7 +1053,13 @@ class MinidomTest(unittest.TestCase):
|
| 29 |
|
| 30 | # Verify that character decoding errors raise exceptions instead
|
| 31 | # of crashing
|
| 32 | - self.assertRaises(UnicodeDecodeError, parseString,
|
| 33 | + if pyexpat.version_info >= (2, 4, 5):
|
| 34 | + self.assertRaises(ExpatError, parseString,
|
| 35 | + b'<fran\xe7ais></fran\xe7ais>')
|
| 36 | + self.assertRaises(ExpatError, parseString,
|
| 37 | + b'<franais>Comment \xe7a va ? Tr\xe8s bien ?</franais>')
|
| 38 | + else:
|
| 39 | + self.assertRaises(UnicodeDecodeError, parseString,
|
| 40 | '<fran\xe7ais>Comment \xe7a va ? Tr\xe8s bien ?</fran\xe7ais>')
|
| 41 |
|
| 42 | doc.unlink()
|
| 43 | diff --git a/Lib/test/test_xml_etree.py b/Lib/test/test_xml_etree.py
|
| 44 | index c75d55f05c..0855bc07ca 100644
|
| 45 | |
| 46 | |
| 47 | @@ -1482,12 +1482,6 @@ class BugsTest(unittest.TestCase):
|
| 48 | b"<?xml version='1.0' encoding='ascii'?>\n"
|
| 49 | b'<body>tãg</body>')
|
| 50 |
|
| 51 | - def test_issue3151(self):
|
| 52 | - e = ET.XML('<prefix:localname xmlns:prefix="${stuff}"/>')
|
| 53 | - self.assertEqual(e.tag, '{${stuff}}localname')
|
| 54 | - t = ET.ElementTree(e)
|
| 55 | - self.assertEqual(ET.tostring(e), b'<ns0:localname xmlns:ns0="${stuff}" />')
|
| 56 | -
|
| 57 | def test_issue6565(self):
|
| 58 | elem = ET.XML("<body><tag/></body>")
|
| 59 | self.assertEqual(summarize_list(elem), ['tag'])
|