summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorBrett Cannon <bcannon@gmail.com>2009-08-13 19:59:04 (GMT)
committerBrett Cannon <bcannon@gmail.com>2009-08-13 19:59:04 (GMT)
commit0c8110734a42d31396d0a30b289c3e817b72a3b5 (patch)
treea14e188c8f3adefa0b82e3cd126f8cbd46f15674 /Lib
parent790da2383f272d462834d709cb14995acc0828a4 (diff)
downloadcpython-0c8110734a42d31396d0a30b289c3e817b72a3b5.zip
cpython-0c8110734a42d31396d0a30b289c3e817b72a3b5.tar.gz
cpython-0c8110734a42d31396d0a30b289c3e817b72a3b5.tar.bz2
Backport of r74435. Not merged/blocked w/ svnmerge.py as the tool is erroring out on me.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_pyexpat.py21
1 files changed, 20 insertions, 1 deletions
diff --git a/Lib/test/test_pyexpat.py b/Lib/test/test_pyexpat.py
index 4947c8b..72795be 100644
--- a/Lib/test/test_pyexpat.py
+++ b/Lib/test/test_pyexpat.py
@@ -510,6 +510,24 @@ class ChardataBufferTest(unittest.TestCase):
parser.Parse(xml2, 1)
self.assertEquals(self.n, 4)
+class MalformedInputText(unittest.TestCase):
+ def test1(self):
+ xml = "\0\r\n"
+ parser = expat.ParserCreate()
+ try:
+ parser.Parse(xml, True)
+ self.fail()
+ except expat.ExpatError as e:
+ self.assertEquals(str(e), 'no element found: line 2, column 1')
+
+ def test2(self):
+ xml = "<?xml version\xc2\x85='1.0'?>\r\n"
+ parser = expat.ParserCreate()
+ try:
+ parser.Parse(xml, True)
+ self.fail()
+ except expat.ExpatError as e:
+ self.assertEquals(str(e), 'XML declaration not well-formed: line 1, column 14')
def test_main():
run_unittest(SetAttributeTest,
@@ -520,7 +538,8 @@ def test_main():
HandlerExceptionTest,
PositionTest,
sf1296433Test,
- ChardataBufferTest)
+ ChardataBufferTest,
+ MalformedInputText)
if __name__ == "__main__":
test_main()