@@ -1163,14 +1163,10 @@ def testEncodings(self):
1163
1163
1164
1164
# Verify that character decoding errors raise exceptions instead
1165
1165
# of crashing
1166
- if pyexpat .version_info >= (2 , 4 , 5 ):
1167
- self .assertRaises (ExpatError , parseString ,
1168
- b'<fran\xe7 ais></fran\xe7 ais>' )
1169
- self .assertRaises (ExpatError , parseString ,
1170
- b'<franais>Comment \xe7 a va ? Tr\xe8 s bien ?</franais>' )
1171
- else :
1172
- self .assertRaises (UnicodeDecodeError , parseString ,
1173
- b'<fran\xe7 ais>Comment \xe7 a va ? Tr\xe8 s bien ?</fran\xe7 ais>' )
1166
+ with self .assertRaises ((UnicodeDecodeError , ExpatError )):
1167
+ parseString (
1168
+ b'<fran\xe7 ais>Comment \xe7 a va ? Tr\xe8 s bien ?</fran\xe7 ais>'
1169
+ )
1174
1170
1175
1171
doc .unlink ()
1176
1172
@@ -1631,13 +1627,11 @@ def testEmptyXMLNSValue(self):
1631
1627
self .confirm (doc2 .namespaceURI == xml .dom .EMPTY_NAMESPACE )
1632
1628
1633
1629
def testExceptionOnSpacesInXMLNSValue (self ):
1634
- if pyexpat .version_info >= (2 , 4 , 5 ):
1635
- context = self .assertRaisesRegex (ExpatError , 'syntax error' )
1636
- else :
1637
- context = self .assertRaisesRegex (ValueError , 'Unsupported syntax' )
1638
-
1639
- with context :
1640
- parseString ('<element xmlns:abc="http:abc.com/de f g/hi/j k"><abc:foo /></element>' )
1630
+ with self .assertRaises ((ValueError , ExpatError )):
1631
+ parseString (
1632
+ '<element xmlns:abc="http:abc.com/de f g/hi/j k">' +
1633
+ '<abc:foo /></element>'
1634
+ )
1641
1635
1642
1636
def testDocRemoveChild (self ):
1643
1637
doc = parse (tstfile )
0 commit comments