8000 bpo-46811: Make test suite support Expat >=2.4.5 by hartwork · Pull Request #31453 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-46811: Make test suite support Expat >=2.4.5 #31453

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 3 commits into from
Feb 21, 2022
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
test_minidom.py: Support Expat >=2.4.5
  • Loading branch information
hartwork committed Feb 20, 2022
commit aa7523fef6e3759d02a02fa484acfebf9d0bd852
17 changes: 15 additions & 2 deletions Lib/test/test_minidom.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
from test import support
import unittest

import pyexpat
import xml.dom.minidom

from xml.dom.minidom import parse, Node, Document, parseString
from xml.dom.minidom import getDOMImplementation
from xml.parsers.expat import ExpatError


tstfile = support.findfile("test.xml", subdir="xmltestdata")
Expand Down Expand Up @@ -1147,7 +1149,13 @@ def testEncodings(self):

# Verify that character decoding errors raise exceptions instead
# of crashing
self.assertRaises(UnicodeDecodeError, parseString,
if pyexpat.version_info >= (2, 4, 5):
self.assertRaises(ExpatError, parseString,
b'<fran\xe7ais></fran\xe7ais>')
self.assertRaises(ExpatError, parseString,
b'<franais>Comment \xe7a va ? Tr\xe8s bien ?</franais>')
else:
self.assertRaises(UnicodeDecodeError, parseString,
b'<fran\xe7ais>Comment \xe7a va ? Tr\xe8s bien ?</fran\xe7ais>')

doc.unlink()
Expand Down Expand Up @@ -1609,7 +1617,12 @@ def testEmptyXMLNSValue(self):
self.confirm(doc2.namespaceURI == xml.dom.EMPTY_NAMESPACE)

def testExceptionOnSpacesInXMLNSValue(self):
with self.assertRaisesRegex(ValueError, 'Unsupported syntax'):
if pyexpat.version_info >= (2, 4, 5):
context = self.assertRaisesRegex(ExpatError, 'syntax error')
else:
context = self.assertRaisesRegex(ValueError, 'Unsupported syntax')

with context:
parseString('<element xmlns:abc="http:abc.com/de f g/hi/j k"><abc:foo /></element>')

def testDocRemoveChild(self):
Expand Down
0