Issue #6676: Ensure a meaningful exception is raised when attempting

to parse more than one XML document per pyexpat xmlparser instance.
(Original patches by Hirokazu Yamamoto and Amaury Forgeot d'Arc, with
suggested wording by David Gutteridge)
This commit is contained in:
Ned Deily 2014-03-27 16:39:58 -07:00
parent 2542b66bb0
commit e7d532fbc9
4 changed files with 26 additions and 2 deletions

View file

@ -236,6 +236,18 @@ class ParseTest(unittest.TestCase):
operations = out.out
self._verify_parse_output(operations)
def test_parse_again(self):
parser = expat.ParserCreate()
file = BytesIO(data)
parser.ParseFile(file)
# Issue 6676: ensure a meaningful exception is raised when attempting
# to parse more than one XML document per xmlparser instance,
# a limitation of the Expat library.
with self.assertRaises(expat.error) as cm:
parser.ParseFile(file)
self.assertEqual(expat.ErrorString(cm.exception.code),
expat.errors.XML_ERROR_FINISHED)
class NamespaceSeparatorTest(unittest.TestCase):
def test_legal(self):
# Tests that make sure we get errors when the namespace_separator value