@@ -1163,14 +1163,10 @@ def testEncodings(self):
11631163
11641164 # Verify that character decoding errors raise exceptions instead
11651165 # 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+ )
11741170
11751171 doc .unlink ()
11761172
@@ -1631,13 +1627,11 @@ def testEmptyXMLNSValue(self):
16311627 self .confirm (doc2 .namespaceURI == xml .dom .EMPTY_NAMESPACE )
16321628
16331629 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+ )
16411635
16421636 def testDocRemoveChild (self ):
16431637 doc = parse (tstfile )
0 commit comments