annotate Lib/test/test_sax.py @ 54294:dba767bc3155 legacy-trunk

remove mention of old ctypes version
author Benjamin Peterson <benjamin@python.org>
date Sat, 23 May 2009 20:59:09 +0000
parents bbfcbafeae84
children 6d5abff7fc31
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
24538
8d5e0e3f6445 Add encoding declaration.
Martin v. Löwis <martin@v.loewis.de>
parents: 24364
diff changeset
1 # regression test for SAX 2.0 -*- coding: iso-8859-1 -*-
14796
d6828dd9a927 Added first start on SAX 2.0 tests.
Lars Gustäbel <lars@gustaebel.de>
parents:
diff changeset
2 # $Id$
d6828dd9a927 Added first start on SAX 2.0 tests.
Lars Gustäbel <lars@gustaebel.de>
parents:
diff changeset
3
39275
cb1e432b4919 expunge the xmlcore changes:
Fred Drake <fdrake@acm.org>
parents: 38686
diff changeset
4 from xml.sax import make_parser, ContentHandler, \
cb1e432b4919 expunge the xmlcore changes:
Fred Drake <fdrake@acm.org>
parents: 38686
diff changeset
5 SAXException, SAXReaderNotAvailable, SAXParseException
15056
41bfc9a40fe3 Add SAXReaderNotAvailable, and use it to distinguish between an
Martin v. Löwis <martin@v.loewis.de>
parents: 15003
diff changeset
6 try:
41bfc9a40fe3 Add SAXReaderNotAvailable, and use it to distinguish between an
Martin v. Löwis <martin@v.loewis.de>
parents: 15003
diff changeset
7 make_parser()
15075
3142027b5979 Add a test case for reporting the file name, and for reporting an error
Martin v. Löwis <martin@v.loewis.de>
parents: 15056
diff changeset
8 except SAXReaderNotAvailable:
15056
41bfc9a40fe3 Add SAXReaderNotAvailable, and use it to distinguish between an
Martin v. Löwis <martin@v.loewis.de>
parents: 15003
diff changeset
9 # don't try to test this module if we cannot create a parser
41bfc9a40fe3 Add SAXReaderNotAvailable, and use it to distinguish between an
Martin v. Löwis <martin@v.loewis.de>
parents: 15003
diff changeset
10 raise ImportError("no XML parsers available")
39275
cb1e432b4919 expunge the xmlcore changes:
Fred Drake <fdrake@acm.org>
parents: 38686
diff changeset
11 from xml.sax.saxutils import XMLGenerator, escape, unescape, quoteattr, \
cb1e432b4919 expunge the xmlcore changes:
Fred Drake <fdrake@acm.org>
parents: 38686
diff changeset
12 XMLFilterBase
cb1e432b4919 expunge the xmlcore changes:
Fred Drake <fdrake@acm.org>
parents: 38686
diff changeset
13 from xml.sax.expatreader import create_parser
cb1e432b4919 expunge the xmlcore changes:
Fred Drake <fdrake@acm.org>
parents: 38686
diff changeset
14 from xml.sax.xmlreader import InputSource, AttributesImpl, AttributesNSImpl
14796
d6828dd9a927 Added first start on SAX 2.0 tests.
Lars Gustäbel <lars@gustaebel.de>
parents:
diff changeset
15 from cStringIO import StringIO
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
16 from test.test_support import findfile, run_unittest
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
17 import unittest
20654
edd9d0b3c47e SF patch #474590 -- RISC OS support
Guido van Rossum <guido@python.org>
parents: 19044
diff changeset
18 import os
14796
d6828dd9a927 Added first start on SAX 2.0 tests.
Lars Gustäbel <lars@gustaebel.de>
parents:
diff changeset
19
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
20 ns_uri = "http://www.python.org/xml-ns/saxtest/"
14796
d6828dd9a927 Added first start on SAX 2.0 tests.
Lars Gustäbel <lars@gustaebel.de>
parents:
diff changeset
21
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
22 class XmlTestBase(unittest.TestCase):
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
23 def verify_empty_attrs(self, attrs):
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
24 self.assertRaises(KeyError, attrs.getValue, "attr")
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
25 self.assertRaises(KeyError, attrs.getValueByQName, "attr")
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
26 self.assertRaises(KeyError, attrs.getNameByQName, "attr")
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
27 self.assertRaises(KeyError, attrs.getQNameByName, "attr")
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
28 self.assertRaises(KeyError, attrs.__getitem__, "attr")
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
29 self.assertEquals(attrs.getLength(), 0)
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
30 self.assertEquals(attrs.getNames(), [])
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
31 self.assertEquals(attrs.getQNames(), [])
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
32 self.assertEquals(len(attrs), 0)
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
33 self.assertFalse(attrs.has_key("attr"))
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
34 self.assertEquals(attrs.keys(), [])
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
35 self.assertEquals(attrs.get("attrs"), None)
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
36 self.assertEquals(attrs.get("attrs", 25), 25)
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
37 self.assertEquals(attrs.items(), [])
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
38 self.assertEquals(attrs.values(), [])
41532
4b9fa8092e82 Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents: 41318
diff changeset
39
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
40 def verify_empty_nsattrs(self, attrs):
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
41 self.assertRaises(KeyError, attrs.getValue, (ns_uri, "attr"))
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
42 self.assertRaises(KeyError, attrs.getValueByQName, "ns:attr")
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
43 self.assertRaises(KeyError, attrs.getNameByQName, "ns:attr")
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
44 self.assertRaises(KeyError, attrs.getQNameByName, (ns_uri, "attr"))
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
45 self.assertRaises(KeyError, attrs.__getitem__, (ns_uri, "attr"))
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
46 self.assertEquals(attrs.getLength(), 0)
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
47 self.assertEquals(attrs.getNames(), [])
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
48 self.assertEquals(attrs.getQNames(), [])
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
49 self.assertEquals(len(attrs), 0)
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
50 self.assertFalse(attrs.has_key((ns_uri, "attr")))
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
51 self.assertEquals(attrs.keys(), [])
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
52 self.assertEquals(attrs.get((ns_uri, "attr")), None)
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
53 self.assertEquals(attrs.get((ns_uri, "attr"), 25), 25)
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
54 self.assertEquals(attrs.items(), [])
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
55 self.assertEquals(attrs.values(), [])
14796
d6828dd9a927 Added first start on SAX 2.0 tests.
Lars Gustäbel <lars@gustaebel.de>
parents:
diff changeset
56
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
57 def verify_attrs_wattr(self, attrs):
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
58 self.assertEquals(attrs.getLength(), 1)
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
59 self.assertEquals(attrs.getNames(), ["attr"])
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
60 self.assertEquals(attrs.getQNames(), ["attr"])
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
61 self.assertEquals(len(attrs), 1)
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
62 self.assertTrue(attrs.has_key("attr"))
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
63 self.assertEquals(attrs.keys(), ["attr"])
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
64 self.assertEquals(attrs.get("attr"), "val")
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
65 self.assertEquals(attrs.get("attr", 25), "val")
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
66 self.assertEquals(attrs.items(), [("attr", "val")])
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
67 self.assertEquals(attrs.values(), ["val"])
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
68 self.assertEquals(attrs.getValue("attr"), "val")
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
69 self.assertEquals(attrs.getValueByQName("attr"), "val")
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
70 self.assertEquals(attrs.getNameByQName("attr"), "attr")
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
71 self.assertEquals(attrs["attr"], "val")
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
72 self.assertEquals(attrs.getQNameByName("attr"), "attr")
41532
4b9fa8092e82 Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents: 41318
diff changeset
73
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
74 class MakeParserTest(unittest.TestCase):
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
75 def test_make_parser2(self):
15313
49468c007c0c Added some more tests here and there.
Lars Gustäbel <lars@gustaebel.de>
parents: 15305
diff changeset
76 # Creating parsers several times in a row should succeed.
49468c007c0c Added some more tests here and there.
Lars Gustäbel <lars@gustaebel.de>
parents: 15305
diff changeset
77 # Testing this because there have been failures of this kind
49468c007c0c Added some more tests here and there.
Lars Gustäbel <lars@gustaebel.de>
parents: 15305
diff changeset
78 # before.
39275
cb1e432b4919 expunge the xmlcore changes:
Fred Drake <fdrake@acm.org>
parents: 38686
diff changeset
79 from xml.sax import make_parser
15313
49468c007c0c Added some more tests here and there.
Lars Gustäbel <lars@gustaebel.de>
parents: 15305
diff changeset
80 p = make_parser()
39275
cb1e432b4919 expunge the xmlcore changes:
Fred Drake <fdrake@acm.org>
parents: 38686
diff changeset
81 from xml.sax import make_parser
15313
49468c007c0c Added some more tests here and there.
Lars Gustäbel <lars@gustaebel.de>
parents: 15305
diff changeset
82 p = make_parser()
39275
cb1e432b4919 expunge the xmlcore changes:
Fred Drake <fdrake@acm.org>
parents: 38686
diff changeset
83 from xml.sax import make_parser
15313
49468c007c0c Added some more tests here and there.
Lars Gustäbel <lars@gustaebel.de>
parents: 15305
diff changeset
84 p = make_parser()
39275
cb1e432b4919 expunge the xmlcore changes:
Fred Drake <fdrake@acm.org>
parents: 38686
diff changeset
85 from xml.sax import make_parser
15313
49468c007c0c Added some more tests here and there.
Lars Gustäbel <lars@gustaebel.de>
parents: 15305
diff changeset
86 p = make_parser()
39275
cb1e432b4919 expunge the xmlcore changes:
Fred Drake <fdrake@acm.org>
parents: 38686
diff changeset
87 from xml.sax import make_parser
15313
49468c007c0c Added some more tests here and there.
Lars Gustäbel <lars@gustaebel.de>
parents: 15305
diff changeset
88 p = make_parser()
39275
cb1e432b4919 expunge the xmlcore changes:
Fred Drake <fdrake@acm.org>
parents: 38686
diff changeset
89 from xml.sax import make_parser
15313
49468c007c0c Added some more tests here and there.
Lars Gustäbel <lars@gustaebel.de>
parents: 15305
diff changeset
90 p = make_parser()
15977
f16545f58345 Whitespace normalization. Leaving tokenize_tests.py alone for now.
Tim Peters <tim.peters@gmail.com>
parents: 15957
diff changeset
91
f16545f58345 Whitespace normalization. Leaving tokenize_tests.py alone for now.
Tim Peters <tim.peters@gmail.com>
parents: 15957
diff changeset
92
14796
d6828dd9a927 Added first start on SAX 2.0 tests.
Lars Gustäbel <lars@gustaebel.de>
parents:
diff changeset
93 # ===========================================================================
d6828dd9a927 Added first start on SAX 2.0 tests.
Lars Gustäbel <lars@gustaebel.de>
parents:
diff changeset
94 #
d6828dd9a927 Added first start on SAX 2.0 tests.
Lars Gustäbel <lars@gustaebel.de>
parents:
diff changeset
95 # saxutils tests
d6828dd9a927 Added first start on SAX 2.0 tests.
Lars Gustäbel <lars@gustaebel.de>
parents:
diff changeset
96 #
d6828dd9a927 Added first start on SAX 2.0 tests.
Lars Gustäbel <lars@gustaebel.de>
parents:
diff changeset
97 # ===========================================================================
d6828dd9a927 Added first start on SAX 2.0 tests.
Lars Gustäbel <lars@gustaebel.de>
parents:
diff changeset
98
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
99 class SaxutilsTest(unittest.TestCase):
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
100 # ===== escape
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
101 def test_escape_basic(self):
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
102 self.assertEquals(escape("Donald Duck & Co"), "Donald Duck &amp; Co")
41532
4b9fa8092e82 Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents: 41318
diff changeset
103
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
104 def test_escape_all(self):
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
105 self.assertEquals(escape("<Donald Duck & Co>"),
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
106 "&lt;Donald Duck &amp; Co&gt;")
41532
4b9fa8092e82 Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents: 41318
diff changeset
107
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
108 def test_escape_extra(self):
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
109 self.assertEquals(escape("Hei på deg", {"å" : "&aring;"}),
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
110 "Hei p&aring; deg")
25927
7049268f252d Patch #613256: Add nescape method to xml.sax.saxutils.
Martin v. Löwis <martin@v.loewis.de>
parents: 25234
diff changeset
111
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
112 # ===== unescape
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
113 def test_unescape_basic(self):
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
114 self.assertEquals(unescape("Donald Duck &amp; Co"), "Donald Duck & Co")
41532
4b9fa8092e82 Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents: 41318
diff changeset
115
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
116 def test_unescape_all(self):
41532
4b9fa8092e82 Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents: 41318
diff changeset
117 self.assertEquals(unescape("&lt;Donald Duck &amp; Co&gt;"),
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
118 "<Donald Duck & Co>")
41532
4b9fa8092e82 Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents: 41318
diff changeset
119
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
120 def test_unescape_extra(self):
41532
4b9fa8092e82 Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents: 41318
diff changeset
121 self.assertEquals(unescape("Hei på deg", {"å" : "&aring;"}),
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
122 "Hei p&aring; deg")
41532
4b9fa8092e82 Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents: 41318
diff changeset
123
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
124 def test_unescape_amp_extra(self):
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
125 self.assertEquals(unescape("&amp;foo;", {"&foo;": "splat"}), "&foo;")
18740
1aa7e219f52d Added function xml.sax.saxutils.quoteattr().
Fred Drake <fdrake@acm.org>
parents: 15977
diff changeset
126
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
127 # ===== quoteattr
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
128 def test_quoteattr_basic(self):
41532
4b9fa8092e82 Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents: 41318
diff changeset
129 self.assertEquals(quoteattr("Donald Duck & Co"),
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
130 '"Donald Duck &amp; Co"')
41532
4b9fa8092e82 Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents: 41318
diff changeset
131
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
132 def test_single_quoteattr(self):
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
133 self.assertEquals(quoteattr('Includes "double" quotes'),
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
134 '\'Includes "double" quotes\'')
41532
4b9fa8092e82 Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents: 41318
diff changeset
135
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
136 def test_double_quoteattr(self):
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
137 self.assertEquals(quoteattr("Includes 'single' quotes"),
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
138 "\"Includes 'single' quotes\"")
41532
4b9fa8092e82 Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents: 41318
diff changeset
139
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
140 def test_single_double_quoteattr(self):
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
141 self.assertEquals(quoteattr("Includes 'single' and \"double\" quotes"),
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
142 "\"Includes 'single' and &quot;double&quot; quotes\"")
41532
4b9fa8092e82 Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents: 41318
diff changeset
143
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
144 # ===== make_parser
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
145 def test_make_parser(self):
15056
41bfc9a40fe3 Add SAXReaderNotAvailable, and use it to distinguish between an
Martin v. Löwis <martin@v.loewis.de>
parents: 15003
diff changeset
146 # Creating a parser should succeed - it should fall back
41bfc9a40fe3 Add SAXReaderNotAvailable, and use it to distinguish between an
Martin v. Löwis <martin@v.loewis.de>
parents: 15003
diff changeset
147 # to the expatreader
39275
cb1e432b4919 expunge the xmlcore changes:
Fred Drake <fdrake@acm.org>
parents: 38686
diff changeset
148 p = make_parser(['xml.parsers.no_such_parser'])
15056
41bfc9a40fe3 Add SAXReaderNotAvailable, and use it to distinguish between an
Martin v. Löwis <martin@v.loewis.de>
parents: 15003
diff changeset
149
41bfc9a40fe3 Add SAXReaderNotAvailable, and use it to distinguish between an
Martin v. Löwis <martin@v.loewis.de>
parents: 15003
diff changeset
150
14796
d6828dd9a927 Added first start on SAX 2.0 tests.
Lars Gustäbel <lars@gustaebel.de>
parents:
diff changeset
151 # ===== XMLGenerator
d6828dd9a927 Added first start on SAX 2.0 tests.
Lars Gustäbel <lars@gustaebel.de>
parents:
diff changeset
152
d6828dd9a927 Added first start on SAX 2.0 tests.
Lars Gustäbel <lars@gustaebel.de>
parents:
diff changeset
153 start = '<?xml version="1.0" encoding="iso-8859-1"?>\n'
d6828dd9a927 Added first start on SAX 2.0 tests.
Lars Gustäbel <lars@gustaebel.de>
parents:
diff changeset
154
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
155 class XmlgenTest(unittest.TestCase):
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
156 def test_xmlgen_basic(self):
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
157 result = StringIO()
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
158 gen = XMLGenerator(result)
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
159 gen.startDocument()
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
160 gen.startElement("doc", {})
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
161 gen.endElement("doc")
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
162 gen.endDocument()
41532
4b9fa8092e82 Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents: 41318
diff changeset
163
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
164 self.assertEquals(result.getvalue(), start + "<doc></doc>")
41532
4b9fa8092e82 Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents: 41318
diff changeset
165
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
166 def test_xmlgen_content(self):
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
167 result = StringIO()
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
168 gen = XMLGenerator(result)
41532
4b9fa8092e82 Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents: 41318
diff changeset
169
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
170 gen.startDocument()
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
171 gen.startElement("doc", {})
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
172 gen.characters("huhei")
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
173 gen.endElement("doc")
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
174 gen.endDocument()
41532
4b9fa8092e82 Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents: 41318
diff changeset
175
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
176 self.assertEquals(result.getvalue(), start + "<doc>huhei</doc>")
15305
07f24261c6e6 Make reindent.py happy (convert everything to 4-space indents!).
Fred Drake <fdrake@acm.org>
parents: 15075
diff changeset
177
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
178 def test_xmlgen_pi(self):
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
179 result = StringIO()
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
180 gen = XMLGenerator(result)
14796
d6828dd9a927 Added first start on SAX 2.0 tests.
Lars Gustäbel <lars@gustaebel.de>
parents:
diff changeset
181
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
182 gen.startDocument()
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
183 gen.processingInstruction("test", "data")
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
184 gen.startElement("doc", {})
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
185 gen.endElement("doc")
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
186 gen.endDocument()
15305
07f24261c6e6 Make reindent.py happy (convert everything to 4-space indents!).
Fred Drake <fdrake@acm.org>
parents: 15075
diff changeset
187
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
188 self.assertEquals(result.getvalue(), start + "<?test data?><doc></doc>")
14796
d6828dd9a927 Added first start on SAX 2.0 tests.
Lars Gustäbel <lars@gustaebel.de>
parents:
diff changeset
189
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
190 def test_xmlgen_content_escape(self):
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
191 result = StringIO()
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
192 gen = XMLGenerator(result)
15305
07f24261c6e6 Make reindent.py happy (convert everything to 4-space indents!).
Fred Drake <fdrake@acm.org>
parents: 15075
diff changeset
193
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
194 gen.startDocument()
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
195 gen.startElement("doc", {})
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
196 gen.characters("<huhei&")
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
197 gen.endElement("doc")
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
198 gen.endDocument()
14796
d6828dd9a927 Added first start on SAX 2.0 tests.
Lars Gustäbel <lars@gustaebel.de>
parents:
diff changeset
199
41532
4b9fa8092e82 Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents: 41318
diff changeset
200 self.assertEquals(result.getvalue(),
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
201 start + "<doc>&lt;huhei&amp;</doc>")
14796
d6828dd9a927 Added first start on SAX 2.0 tests.
Lars Gustäbel <lars@gustaebel.de>
parents:
diff changeset
202
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
203 def test_xmlgen_attr_escape(self):
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
204 result = StringIO()
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
205 gen = XMLGenerator(result)
19044
8e60f30037a1 Add a test that xml.sax.saxutils.XMLGenerator does the right thing
Fred Drake <fdrake@acm.org>
parents: 18740
diff changeset
206
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
207 gen.startDocument()
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
208 gen.startElement("doc", {"a": '"'})
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
209 gen.startElement("e", {"a": "'"})
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
210 gen.endElement("e")
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
211 gen.startElement("e", {"a": "'\""})
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
212 gen.endElement("e")
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
213 gen.startElement("e", {"a": "\n\r\t"})
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
214 gen.endElement("e")
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
215 gen.endElement("doc")
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
216 gen.endDocument()
19044
8e60f30037a1 Add a test that xml.sax.saxutils.XMLGenerator does the right thing
Fred Drake <fdrake@acm.org>
parents: 18740
diff changeset
217
41532
4b9fa8092e82 Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents: 41318
diff changeset
218 self.assertEquals(result.getvalue(), start +
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
219 ("<doc a='\"'><e a=\"'\"></e>"
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
220 "<e a=\"'&quot;\"></e>"
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
221 "<e a=\"&#10;&#13;&#9;\"></e></doc>"))
19044
8e60f30037a1 Add a test that xml.sax.saxutils.XMLGenerator does the right thing
Fred Drake <fdrake@acm.org>
parents: 18740
diff changeset
222
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
223 def test_xmlgen_ignorable(self):
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
224 result = StringIO()
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
225 gen = XMLGenerator(result)
14796
d6828dd9a927 Added first start on SAX 2.0 tests.
Lars Gustäbel <lars@gustaebel.de>
parents:
diff changeset
226
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
227 gen.startDocument()
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
228 gen.startElement("doc", {})
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
229 gen.ignorableWhitespace(" ")
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
230 gen.endElement("doc")
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
231 gen.endDocument()
15305
07f24261c6e6 Make reindent.py happy (convert everything to 4-space indents!).
Fred Drake <fdrake@acm.org>
parents: 15075
diff changeset
232
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
233 self.assertEquals(result.getvalue(), start + "<doc> </doc>")
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
234
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
235 def test_xmlgen_ns(self):
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
236 result = StringIO()
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
237 gen = XMLGenerator(result)
14796
d6828dd9a927 Added first start on SAX 2.0 tests.
Lars Gustäbel <lars@gustaebel.de>
parents:
diff changeset
238
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
239 gen.startDocument()
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
240 gen.startPrefixMapping("ns1", ns_uri)
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
241 gen.startElementNS((ns_uri, "doc"), "ns1:doc", {})
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
242 # add an unqualified name
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
243 gen.startElementNS((None, "udoc"), None, {})
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
244 gen.endElementNS((None, "udoc"), None)
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
245 gen.endElementNS((ns_uri, "doc"), "ns1:doc")
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
246 gen.endPrefixMapping("ns1")
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
247 gen.endDocument()
40827
724e0b63a79b Patch 1463026: Support default namespace in XMLGenerator.
Martin v. Löwis <martin@v.loewis.de>
parents: 39275
diff changeset
248
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
249 self.assertEquals(result.getvalue(), start + \
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
250 ('<ns1:doc xmlns:ns1="%s"><udoc></udoc></ns1:doc>' %
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
251 ns_uri))
40827
724e0b63a79b Patch 1463026: Support default namespace in XMLGenerator.
Martin v. Löwis <martin@v.loewis.de>
parents: 39275
diff changeset
252
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
253 def test_1463026_1(self):
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
254 result = StringIO()
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
255 gen = XMLGenerator(result)
40827
724e0b63a79b Patch 1463026: Support default namespace in XMLGenerator.
Martin v. Löwis <martin@v.loewis.de>
parents: 39275
diff changeset
256
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
257 gen.startDocument()
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
258 gen.startElementNS((None, 'a'), 'a', {(None, 'b'):'c'})
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
259 gen.endElementNS((None, 'a'), 'a')
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
260 gen.endDocument()
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
261
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
262 self.assertEquals(result.getvalue(), start+'<a b="c"></a>')
40827
724e0b63a79b Patch 1463026: Support default namespace in XMLGenerator.
Martin v. Löwis <martin@v.loewis.de>
parents: 39275
diff changeset
263
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
264 def test_1463026_2(self):
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
265 result = StringIO()
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
266 gen = XMLGenerator(result)
40827
724e0b63a79b Patch 1463026: Support default namespace in XMLGenerator.
Martin v. Löwis <martin@v.loewis.de>
parents: 39275
diff changeset
267
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
268 gen.startDocument()
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
269 gen.startPrefixMapping(None, 'qux')
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
270 gen.startElementNS(('qux', 'a'), 'a', {})
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
271 gen.endElementNS(('qux', 'a'), 'a')
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
272 gen.endPrefixMapping(None)
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
273 gen.endDocument()
40827
724e0b63a79b Patch 1463026: Support default namespace in XMLGenerator.
Martin v. Löwis <martin@v.loewis.de>
parents: 39275
diff changeset
274
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
275 self.assertEquals(result.getvalue(), start+'<a xmlns="qux"></a>')
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
276
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
277 def test_1463026_3(self):
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
278 result = StringIO()
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
279 gen = XMLGenerator(result)
40827
724e0b63a79b Patch 1463026: Support default namespace in XMLGenerator.
Martin v. Löwis <martin@v.loewis.de>
parents: 39275
diff changeset
280
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
281 gen.startDocument()
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
282 gen.startPrefixMapping('my', 'qux')
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
283 gen.startElementNS(('qux', 'a'), 'a', {(None, 'b'):'c'})
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
284 gen.endElementNS(('qux', 'a'), 'a')
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
285 gen.endPrefixMapping('my')
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
286 gen.endDocument()
40827
724e0b63a79b Patch 1463026: Support default namespace in XMLGenerator.
Martin v. Löwis <martin@v.loewis.de>
parents: 39275
diff changeset
287
41532
4b9fa8092e82 Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents: 41318
diff changeset
288 self.assertEquals(result.getvalue(),
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
289 start+'<my:a xmlns:my="qux" b="c"></my:a>')
41133
01355124ce40 Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 40827
diff changeset
290
14796
d6828dd9a927 Added first start on SAX 2.0 tests.
Lars Gustäbel <lars@gustaebel.de>
parents:
diff changeset
291
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
292 class XMLFilterBaseTest(unittest.TestCase):
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
293 def test_filter_basic(self):
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
294 result = StringIO()
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
295 gen = XMLGenerator(result)
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
296 filter = XMLFilterBase()
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
297 filter.setContentHandler(gen)
15305
07f24261c6e6 Make reindent.py happy (convert everything to 4-space indents!).
Fred Drake <fdrake@acm.org>
parents: 15075
diff changeset
298
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
299 filter.startDocument()
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
300 filter.startElement("doc", {})
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
301 filter.characters("content")
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
302 filter.ignorableWhitespace(" ")
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
303 filter.endElement("doc")
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
304 filter.endDocument()
14796
d6828dd9a927 Added first start on SAX 2.0 tests.
Lars Gustäbel <lars@gustaebel.de>
parents:
diff changeset
305
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
306 self.assertEquals(result.getvalue(), start + "<doc>content </doc>")
14796
d6828dd9a927 Added first start on SAX 2.0 tests.
Lars Gustäbel <lars@gustaebel.de>
parents:
diff changeset
307
d6828dd9a927 Added first start on SAX 2.0 tests.
Lars Gustäbel <lars@gustaebel.de>
parents:
diff changeset
308 # ===========================================================================
d6828dd9a927 Added first start on SAX 2.0 tests.
Lars Gustäbel <lars@gustaebel.de>
parents:
diff changeset
309 #
d6828dd9a927 Added first start on SAX 2.0 tests.
Lars Gustäbel <lars@gustaebel.de>
parents:
diff changeset
310 # expatreader tests
d6828dd9a927 Added first start on SAX 2.0 tests.
Lars Gustäbel <lars@gustaebel.de>
parents:
diff changeset
311 #
d6828dd9a927 Added first start on SAX 2.0 tests.
Lars Gustäbel <lars@gustaebel.de>
parents:
diff changeset
312 # ===========================================================================
d6828dd9a927 Added first start on SAX 2.0 tests.
Lars Gustäbel <lars@gustaebel.de>
parents:
diff changeset
313
20654
edd9d0b3c47e SF patch #474590 -- RISC OS support
Guido van Rossum <guido@python.org>
parents: 19044
diff changeset
314 xml_test_out = open(findfile("test"+os.extsep+"xml"+os.extsep+"out")).read()
14804
7da36f6fd544 Added test cases for the InputSource class.
Lars Gustäbel <lars@gustaebel.de>
parents: 14802
diff changeset
315
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
316 class ExpatReaderTest(XmlTestBase):
41532
4b9fa8092e82 Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents: 41318
diff changeset
317
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
318 # ===== XMLReader support
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
319
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
320 def test_expat_file(self):
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
321 parser = create_parser()
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
322 result = StringIO()
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
323 xmlgen = XMLGenerator(result)
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
324
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
325 parser.setContentHandler(xmlgen)
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
326 parser.parse(open(findfile("test"+os.extsep+"xml")))
14804
7da36f6fd544 Added test cases for the InputSource class.
Lars Gustäbel <lars@gustaebel.de>
parents: 14802
diff changeset
327
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
328 self.assertEquals(result.getvalue(), xml_test_out)
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
329
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
330 # ===== DTDHandler support
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
331
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
332 class TestDTDHandler:
14804
7da36f6fd544 Added test cases for the InputSource class.
Lars Gustäbel <lars@gustaebel.de>
parents: 14802
diff changeset
333
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
334 def __init__(self):
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
335 self._notations = []
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
336 self._entities = []
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
337
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
338 def notationDecl(self, name, publicId, systemId):
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
339 self._notations.append((name, publicId, systemId))
14804
7da36f6fd544 Added test cases for the InputSource class.
Lars Gustäbel <lars@gustaebel.de>
parents: 14802
diff changeset
340
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
341 def unparsedEntityDecl(self, name, publicId, systemId, ndata):
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
342 self._entities.append((name, publicId, systemId, ndata))
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
343
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
344 def test_expat_dtdhandler(self):
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
345 parser = create_parser()
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
346 handler = self.TestDTDHandler()
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
347 parser.setDTDHandler(handler)
14804
7da36f6fd544 Added test cases for the InputSource class.
Lars Gustäbel <lars@gustaebel.de>
parents: 14802
diff changeset
348
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
349 parser.feed('<!DOCTYPE doc [\n')
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
350 parser.feed(' <!ENTITY img SYSTEM "expat.gif" NDATA GIF>\n')
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
351 parser.feed(' <!NOTATION GIF PUBLIC "-//CompuServe//NOTATION Graphics Interchange Format 89a//EN">\n')
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
352 parser.feed(']>\n')
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
353 parser.feed('<doc></doc>')
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
354 parser.close()
14804
7da36f6fd544 Added test cases for the InputSource class.
Lars Gustäbel <lars@gustaebel.de>
parents: 14802
diff changeset
355
41532
4b9fa8092e82 Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents: 41318
diff changeset
356 self.assertEquals(handler._notations,
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
357 [("GIF", "-//CompuServe//NOTATION Graphics Interchange Format 89a//EN", None)])
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
358 self.assertEquals(handler._entities, [("img", None, "expat.gif", "GIF")])
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
359
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
360 # ===== EntityResolver support
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
361
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
362 class TestEntityResolver:
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
363
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
364 def resolveEntity(self, publicId, systemId):
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
365 inpsrc = InputSource()
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
366 inpsrc.setByteStream(StringIO("<entity/>"))
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
367 return inpsrc
14804
7da36f6fd544 Added test cases for the InputSource class.
Lars Gustäbel <lars@gustaebel.de>
parents: 14802
diff changeset
368
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
369 def test_expat_entityresolver(self):
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
370 parser = create_parser()
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
371 parser.setEntityResolver(self.TestEntityResolver())
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
372 result = StringIO()
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
373 parser.setContentHandler(XMLGenerator(result))
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
374
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
375 parser.feed('<!DOCTYPE doc [\n')
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
376 parser.feed(' <!ENTITY test SYSTEM "whatever">\n')
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
377 parser.feed(']>\n')
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
378 parser.feed('<doc>&test;</doc>')
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
379 parser.close()
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
380
41532
4b9fa8092e82 Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents: 41318
diff changeset
381 self.assertEquals(result.getvalue(), start +
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
382 "<doc><entity></entity></doc>")
14804
7da36f6fd544 Added test cases for the InputSource class.
Lars Gustäbel <lars@gustaebel.de>
parents: 14802
diff changeset
383
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
384 # ===== Attributes support
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
385
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
386 class AttrGatherer(ContentHandler):
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
387
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
388 def startElement(self, name, attrs):
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
389 self._attrs = attrs
14804
7da36f6fd544 Added test cases for the InputSource class.
Lars Gustäbel <lars@gustaebel.de>
parents: 14802
diff changeset
390
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
391 def startElementNS(self, name, qname, attrs):
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
392 self._attrs = attrs
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
393
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
394 def test_expat_attrs_empty(self):
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
395 parser = create_parser()
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
396 gather = self.AttrGatherer()
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
397 parser.setContentHandler(gather)
14804
7da36f6fd544 Added test cases for the InputSource class.
Lars Gustäbel <lars@gustaebel.de>
parents: 14802
diff changeset
398
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
399 parser.feed("<doc/>")
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
400 parser.close()
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
401
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
402 self.verify_empty_attrs(gather._attrs)
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
403
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
404 def test_expat_attrs_wattr(self):
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
405 parser = create_parser()
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
406 gather = self.AttrGatherer()
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
407 parser.setContentHandler(gather)
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
408
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
409 parser.feed("<doc attr='val'/>")
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
410 parser.close()
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
411
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
412 self.verify_attrs_wattr(gather._attrs)
15313
49468c007c0c Added some more tests here and there.
Lars Gustäbel <lars@gustaebel.de>
parents: 15305
diff changeset
413
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
414 def test_expat_nsattrs_empty(self):
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
415 parser = create_parser(1)
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
416 gather = self.AttrGatherer()
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
417 parser.setContentHandler(gather)
15313
49468c007c0c Added some more tests here and there.
Lars Gustäbel <lars@gustaebel.de>
parents: 15305
diff changeset
418
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
419 parser.feed("<doc/>")
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
420 parser.close()
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
421
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
422 self.verify_empty_nsattrs(gather._attrs)
15313
49468c007c0c Added some more tests here and there.
Lars Gustäbel <lars@gustaebel.de>
parents: 15305
diff changeset
423
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
424 def test_expat_nsattrs_wattr(self):
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
425 parser = create_parser(1)
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
426 gather = self.AttrGatherer()
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
427 parser.setContentHandler(gather)
15313
49468c007c0c Added some more tests here and there.
Lars Gustäbel <lars@gustaebel.de>
parents: 15305
diff changeset
428
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
429 parser.feed("<doc xmlns:ns='%s' ns:attr='val'/>" % ns_uri)
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
430 parser.close()
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
431
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
432 attrs = gather._attrs
15313
49468c007c0c Added some more tests here and there.
Lars Gustäbel <lars@gustaebel.de>
parents: 15305
diff changeset
433
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
434 self.assertEquals(attrs.getLength(), 1)
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
435 self.assertEquals(attrs.getNames(), [(ns_uri, "attr")])
41532
4b9fa8092e82 Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents: 41318
diff changeset
436 self.assertTrue((attrs.getQNames() == [] or
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
437 attrs.getQNames() == ["ns:attr"]))
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
438 self.assertEquals(len(attrs), 1)
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
439 self.assertTrue(attrs.has_key((ns_uri, "attr")))
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
440 self.assertEquals(attrs.get((ns_uri, "attr")), "val")
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
441 self.assertEquals(attrs.get((ns_uri, "attr"), 25), "val")
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
442 self.assertEquals(attrs.items(), [((ns_uri, "attr"), "val")])
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
443 self.assertEquals(attrs.values(), ["val"])
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
444 self.assertEquals(attrs.getValue((ns_uri, "attr")), "val")
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
445 self.assertEquals(attrs[(ns_uri, "attr")], "val")
15313
49468c007c0c Added some more tests here and there.
Lars Gustäbel <lars@gustaebel.de>
parents: 15305
diff changeset
446
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
447 # ===== InputSource support
41532
4b9fa8092e82 Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents: 41318
diff changeset
448
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
449 def test_expat_inpsource_filename(self):
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
450 parser = create_parser()
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
451 result = StringIO()
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
452 xmlgen = XMLGenerator(result)
41532
4b9fa8092e82 Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents: 41318
diff changeset
453
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
454 parser.setContentHandler(xmlgen)
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
455 parser.parse(findfile("test"+os.extsep+"xml"))
15313
49468c007c0c Added some more tests here and there.
Lars Gustäbel <lars@gustaebel.de>
parents: 15305
diff changeset
456
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
457 self.assertEquals(result.getvalue(), xml_test_out)
41532
4b9fa8092e82 Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents: 41318
diff changeset
458
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
459 def test_expat_inpsource_sysid(self):
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
460 parser = create_parser()
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
461 result = StringIO()
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
462 xmlgen = XMLGenerator(result)
41532
4b9fa8092e82 Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents: 41318
diff changeset
463
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
464 parser.setContentHandler(xmlgen)
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
465 parser.parse(InputSource(findfile("test"+os.extsep+"xml")))
15313
49468c007c0c Added some more tests here and there.
Lars Gustäbel <lars@gustaebel.de>
parents: 15305
diff changeset
466
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
467 self.assertEquals(result.getvalue(), xml_test_out)
41532
4b9fa8092e82 Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents: 41318
diff changeset
468
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
469 def test_expat_inpsource_stream(self):
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
470 parser = create_parser()
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
471 result = StringIO()
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
472 xmlgen = XMLGenerator(result)
41532
4b9fa8092e82 Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents: 41318
diff changeset
473
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
474 parser.setContentHandler(xmlgen)
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
475 inpsrc = InputSource()
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
476 inpsrc.setByteStream(open(findfile("test"+os.extsep+"xml")))
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
477 parser.parse(inpsrc)
41532
4b9fa8092e82 Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents: 41318
diff changeset
478
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
479 self.assertEquals(result.getvalue(), xml_test_out)
41532
4b9fa8092e82 Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents: 41318
diff changeset
480
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
481 # ===== IncrementalParser support
41532
4b9fa8092e82 Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents: 41318
diff changeset
482
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
483 def test_expat_incremental(self):
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
484 result = StringIO()
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
485 xmlgen = XMLGenerator(result)
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
486 parser = create_parser()
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
487 parser.setContentHandler(xmlgen)
41532
4b9fa8092e82 Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents: 41318
diff changeset
488
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
489 parser.feed("<doc>")
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
490 parser.feed("</doc>")
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
491 parser.close()
41532
4b9fa8092e82 Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents: 41318
diff changeset
492
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
493 self.assertEquals(result.getvalue(), start + "<doc></doc>")
41532
4b9fa8092e82 Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents: 41318
diff changeset
494
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
495 def test_expat_incremental_reset(self):
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
496 result = StringIO()
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
497 xmlgen = XMLGenerator(result)
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
498 parser = create_parser()
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
499 parser.setContentHandler(xmlgen)
41532
4b9fa8092e82 Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents: 41318
diff changeset
500
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
501 parser.feed("<doc>")
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
502 parser.feed("text")
41532
4b9fa8092e82 Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents: 41318
diff changeset
503
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
504 result = StringIO()
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
505 xmlgen = XMLGenerator(result)
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
506 parser.setContentHandler(xmlgen)
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
507 parser.reset()
41532
4b9fa8092e82 Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents: 41318
diff changeset
508
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
509 parser.feed("<doc>")
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
510 parser.feed("text")
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
511 parser.feed("</doc>")
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
512 parser.close()
15313
49468c007c0c Added some more tests here and there.
Lars Gustäbel <lars@gustaebel.de>
parents: 15305
diff changeset
513
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
514 self.assertEquals(result.getvalue(), start + "<doc>text</doc>")
41532
4b9fa8092e82 Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents: 41318
diff changeset
515
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
516 # ===== Locator support
41532
4b9fa8092e82 Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents: 41318
diff changeset
517
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
518 def test_expat_locator_noinfo(self):
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
519 result = StringIO()
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
520 xmlgen = XMLGenerator(result)
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
521 parser = create_parser()
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
522 parser.setContentHandler(xmlgen)
41532
4b9fa8092e82 Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents: 41318
diff changeset
523
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
524 parser.feed("<doc>")
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
525 parser.feed("</doc>")
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
526 parser.close()
41532
4b9fa8092e82 Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents: 41318
diff changeset
527
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
528 self.assertEquals(parser.getSystemId(), None)
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
529 self.assertEquals(parser.getPublicId(), None)
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
530 self.assertEquals(parser.getLineNumber(), 1)
41532
4b9fa8092e82 Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents: 41318
diff changeset
531
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
532 def test_expat_locator_withinfo(self):
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
533 result = StringIO()
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
534 xmlgen = XMLGenerator(result)
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
535 parser = create_parser()
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
536 parser.setContentHandler(xmlgen)
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
537 parser.parse(findfile("test.xml"))
41532
4b9fa8092e82 Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents: 41318
diff changeset
538
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
539 self.assertEquals(parser.getSystemId(), findfile("test.xml"))
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
540 self.assertEquals(parser.getPublicId(), None)
41532
4b9fa8092e82 Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents: 41318
diff changeset
541
4b9fa8092e82 Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents: 41318
diff changeset
542
15075
3142027b5979 Add a test case for reporting the file name, and for reporting an error
Martin v. Löwis <martin@v.loewis.de>
parents: 15056
diff changeset
543 # ===========================================================================
3142027b5979 Add a test case for reporting the file name, and for reporting an error
Martin v. Löwis <martin@v.loewis.de>
parents: 15056
diff changeset
544 #
3142027b5979 Add a test case for reporting the file name, and for reporting an error
Martin v. Löwis <martin@v.loewis.de>
parents: 15056
diff changeset
545 # error reporting
3142027b5979 Add a test case for reporting the file name, and for reporting an error
Martin v. Löwis <martin@v.loewis.de>
parents: 15056
diff changeset
546 #
3142027b5979 Add a test case for reporting the file name, and for reporting an error
Martin v. Löwis <martin@v.loewis.de>
parents: 15056
diff changeset
547 # ===========================================================================
3142027b5979 Add a test case for reporting the file name, and for reporting an error
Martin v. Löwis <martin@v.loewis.de>
parents: 15056
diff changeset
548
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
549 class ErrorReportingTest(unittest.TestCase):
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
550 def test_expat_inpsource_location(self):
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
551 parser = create_parser()
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
552 parser.setContentHandler(ContentHandler()) # do nothing
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
553 source = InputSource()
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
554 source.setByteStream(StringIO("<foo bar foobar>")) #ill-formed
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
555 name = "a file name"
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
556 source.setSystemId(name)
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
557 try:
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
558 parser.parse(source)
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
559 self.fail()
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
560 except SAXException, e:
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
561 self.assertEquals(e.getSystemId(), name)
41532
4b9fa8092e82 Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents: 41318
diff changeset
562
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
563 def test_expat_incomplete(self):
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
564 parser = create_parser()
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
565 parser.setContentHandler(ContentHandler()) # do nothing
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
566 self.assertRaises(SAXParseException, parser.parse, StringIO("<foo>"))
41532
4b9fa8092e82 Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents: 41318
diff changeset
567
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
568 def test_sax_parse_exception_str(self):
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
569 # pass various values from a locator to the SAXParseException to
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
570 # make sure that the __str__() doesn't fall apart when None is
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
571 # passed instead of an integer line and column number
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
572 #
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
573 # use "normal" values for the locator:
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
574 str(SAXParseException("message", None,
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
575 self.DummyLocator(1, 1)))
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
576 # use None for the line number:
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
577 str(SAXParseException("message", None,
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
578 self.DummyLocator(None, 1)))
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
579 # use None for the column number:
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
580 str(SAXParseException("message", None,
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
581 self.DummyLocator(1, None)))
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
582 # use None for both:
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
583 str(SAXParseException("message", None,
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
584 self.DummyLocator(None, None)))
41532
4b9fa8092e82 Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents: 41318
diff changeset
585
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
586 class DummyLocator:
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
587 def __init__(self, lineno, colno):
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
588 self._lineno = lineno
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
589 self._colno = colno
41532
4b9fa8092e82 Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents: 41318
diff changeset
590
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
591 def getPublicId(self):
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
592 return "pubid"
41532
4b9fa8092e82 Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents: 41318
diff changeset
593
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
594 def getSystemId(self):
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
595 return "sysid"
41532
4b9fa8092e82 Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents: 41318
diff changeset
596
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
597 def getLineNumber(self):
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
598 return self._lineno
41532
4b9fa8092e82 Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents: 41318
diff changeset
599
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
600 def getColumnNumber(self):
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
601 return self._colno
15075
3142027b5979 Add a test case for reporting the file name, and for reporting an error
Martin v. Löwis <martin@v.loewis.de>
parents: 15056
diff changeset
602
14802
1d78033a53d7 Added test cases for the Attributes interface.
Lars Gustäbel <lars@gustaebel.de>
parents: 14796
diff changeset
603 # ===========================================================================
1d78033a53d7 Added test cases for the Attributes interface.
Lars Gustäbel <lars@gustaebel.de>
parents: 14796
diff changeset
604 #
1d78033a53d7 Added test cases for the Attributes interface.
Lars Gustäbel <lars@gustaebel.de>
parents: 14796
diff changeset
605 # xmlreader tests
1d78033a53d7 Added test cases for the Attributes interface.
Lars Gustäbel <lars@gustaebel.de>
parents: 14796
diff changeset
606 #
1d78033a53d7 Added test cases for the Attributes interface.
Lars Gustäbel <lars@gustaebel.de>
parents: 14796
diff changeset
607 # ===========================================================================
1d78033a53d7 Added test cases for the Attributes interface.
Lars Gustäbel <lars@gustaebel.de>
parents: 14796
diff changeset
608
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
609 class XmlReaderTest(XmlTestBase):
41532
4b9fa8092e82 Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents: 41318
diff changeset
610
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
611 # ===== AttributesImpl
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
612 def test_attrs_empty(self):
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
613 self.verify_empty_attrs(AttributesImpl({}))
41532
4b9fa8092e82 Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents: 41318
diff changeset
614
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
615 def test_attrs_wattr(self):
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
616 self.verify_attrs_wattr(AttributesImpl({"attr" : "val"}))
41532
4b9fa8092e82 Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents: 41318
diff changeset
617
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
618 def test_nsattrs_empty(self):
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
619 self.verify_empty_nsattrs(AttributesNSImpl({}, {}))
41532
4b9fa8092e82 Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents: 41318
diff changeset
620
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
621 def test_nsattrs_wattr(self):
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
622 attrs = AttributesNSImpl({(ns_uri, "attr") : "val"},
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
623 {(ns_uri, "attr") : "ns:attr"})
41532
4b9fa8092e82 Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents: 41318
diff changeset
624
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
625 self.assertEquals(attrs.getLength(), 1)
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
626 self.assertEquals(attrs.getNames(), [(ns_uri, "attr")])
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
627 self.assertEquals(attrs.getQNames(), ["ns:attr"])
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
628 self.assertEquals(len(attrs), 1)
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
629 self.assertTrue(attrs.has_key((ns_uri, "attr")))
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
630 self.assertEquals(attrs.keys(), [(ns_uri, "attr")])
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
631 self.assertEquals(attrs.get((ns_uri, "attr")), "val")
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
632 self.assertEquals(attrs.get((ns_uri, "attr"), 25), "val")
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
633 self.assertEquals(attrs.items(), [((ns_uri, "attr"), "val")])
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
634 self.assertEquals(attrs.values(), ["val"])
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
635 self.assertEquals(attrs.getValue((ns_uri, "attr")), "val")
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
636 self.assertEquals(attrs.getValueByQName("ns:attr"), "val")
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
637 self.assertEquals(attrs.getNameByQName("ns:attr"), (ns_uri, "attr"))
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
638 self.assertEquals(attrs[(ns_uri, "attr")], "val")
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
639 self.assertEquals(attrs.getQNameByName((ns_uri, "attr")), "ns:attr")
15305
07f24261c6e6 Make reindent.py happy (convert everything to 4-space indents!).
Fred Drake <fdrake@acm.org>
parents: 15075
diff changeset
640
14802
1d78033a53d7 Added test cases for the Attributes interface.
Lars Gustäbel <lars@gustaebel.de>
parents: 14796
diff changeset
641
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
642 # During the development of Python 2.5, an attempt to move the "xml"
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
643 # package implementation to a new package ("xmlcore") proved painful.
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
644 # The goal of this change was to allow applications to be able to
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
645 # obtain and rely on behavior in the standard library implementation
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
646 # of the XML support without needing to be concerned about the
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
647 # availability of the PyXML implementation.
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
648 #
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
649 # While the existing import hackery in Lib/xml/__init__.py can cause
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
650 # PyXML's _xmlpus package to supplant the "xml" package, that only
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
651 # works because either implementation uses the "xml" package name for
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
652 # imports.
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
653 #
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
654 # The move resulted in a number of problems related to the fact that
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
655 # the import machinery's "package context" is based on the name that's
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
656 # being imported rather than the __name__ of the actual package
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
657 # containment; it wasn't possible for the "xml" package to be replaced
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
658 # by a simple module that indirected imports to the "xmlcore" package.
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
659 #
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
660 # The following two tests exercised bugs that were introduced in that
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
661 # attempt. Keeping these tests around will help detect problems with
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
662 # other attempts to provide reliable access to the standard library's
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
663 # implementation of the XML support.
41532
4b9fa8092e82 Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents: 41318
diff changeset
664
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
665 def test_sf_1511497(self):
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
666 # Bug report: http://www.python.org/sf/1511497
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
667 import sys
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
668 old_modules = sys.modules.copy()
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
669 for modname in sys.modules.keys():
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
670 if modname.startswith("xml."):
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
671 del sys.modules[modname]
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
672 try:
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
673 import xml.sax.expatreader
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
674 module = xml.sax.expatreader
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
675 self.assertEquals(module.__name__, "xml.sax.expatreader")
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
676 finally:
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
677 sys.modules.update(old_modules)
41532
4b9fa8092e82 Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents: 41318
diff changeset
678
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
679 def test_sf_1513611(self):
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
680 # Bug report: http://www.python.org/sf/1513611
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
681 sio = StringIO("invalid")
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
682 parser = make_parser()
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
683 from xml.sax import SAXParseException
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
684 self.assertRaises(SAXParseException, parser.parse, sio)
39275
cb1e432b4919 expunge the xmlcore changes:
Fred Drake <fdrake@acm.org>
parents: 38686
diff changeset
685
14804
7da36f6fd544 Added test cases for the InputSource class.
Lars Gustäbel <lars@gustaebel.de>
parents: 14802
diff changeset
686
46156
bbfcbafeae84 Name the main method correctly so the test is run
Neal Norwitz <nnorwitz@gmail.com>
parents: 41532
diff changeset
687 def test_main():
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
688 run_unittest(MakeParserTest,
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
689 SaxutilsTest,
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
690 XmlgenTest,
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
691 ExpatReaderTest,
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
692 ErrorReportingTest,
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
693 XmlReaderTest)
14804
7da36f6fd544 Added test cases for the InputSource class.
Lars Gustäbel <lars@gustaebel.de>
parents: 14802
diff changeset
694
41318
39e4386d71f6 Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents: 41133
diff changeset
695 if __name__ == "__main__":
46156
bbfcbafeae84 Name the main method correctly so the test is run
Neal Norwitz <nnorwitz@gmail.com>
parents: 41532
diff changeset
696 test_main()