diff --git a/Lib/test/test_pyexpat.py b/Lib/test/test_pyexpat.py index eba9058..2c8a164 100644 --- a/Lib/test/test_pyexpat.py +++ b/Lib/test/test_pyexpat.py @@ -610,11 +610,9 @@ class MalformedInputText(unittest.TestCase): def test2(self): xml = "\r\n" parser = expat.ParserCreate() - try: + err_pattern = r'XML declaration not well-formed: line 1, column \d+' + with self.assertRaisesRegexp(expat.ExpatError, err_pattern): parser.Parse(xml, True) - self.fail() - except expat.ExpatError as e: - self.assertEqual(str(e), 'XML declaration not well-formed: line 1, column 14') class ForeignDTDTests(unittest.TestCase): """