Mercurial > cpython-lru_cache-weakref
annotate Lib/test/test_pyexpat.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 | 88d76b9206e6 |
| children | 6ac1478d9b0e |
| rev | line source |
|---|---|
|
12183
242458503b13
Added test case for pyexpat module that tries to exercise all the handlers
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
1 # XXX TypeErrors on calling handlers, or on bad return values from a |
|
242458503b13
Added test case for pyexpat module that tries to exercise all the handlers
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
2 # handler, are obscure and unhelpful. |
|
15305
07f24261c6e6
Make reindent.py happy (convert everything to 4-space indents!).
Fred Drake <fdrake@acm.org>
parents:
14786
diff
changeset
|
3 |
|
44594
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
4 import StringIO, sys |
|
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:
38977
diff
changeset
|
5 import 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:
38977
diff
changeset
|
6 |
|
18883
0ce35e7d6e33
Fix when pyexpat not built
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
17815
diff
changeset
|
7 import pyexpat |
|
14786
ad0d932cce32
Rename the public interface from "pyexpat" to "xml.parsers.expat".
Fred Drake <fdrake@acm.org>
parents:
14730
diff
changeset
|
8 from xml.parsers import expat |
|
15305
07f24261c6e6
Make reindent.py happy (convert everything to 4-space indents!).
Fred Drake <fdrake@acm.org>
parents:
14786
diff
changeset
|
9 |
|
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:
38977
diff
changeset
|
10 from test.test_support import sortdict, run_unittest |
|
12183
242458503b13
Added test case for pyexpat module that tries to exercise all the handlers
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
11 |
|
242458503b13
Added test case for pyexpat module that tries to exercise all the handlers
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
12 |
|
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:
38977
diff
changeset
|
13 class SetAttributeTest(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:
38977
diff
changeset
|
14 def setUp(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:
38977
diff
changeset
|
15 self.parser = expat.ParserCreate(namespace_separator='!') |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
16 self.set_get_pairs = [ |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
17 [0, 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:
38977
diff
changeset
|
18 [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:
38977
diff
changeset
|
19 [2, 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:
38977
diff
changeset
|
20 [0, 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:
38977
diff
changeset
|
21 ] |
|
41532
4b9fa8092e82
Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents:
41318
diff
changeset
|
22 |
|
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:
38977
diff
changeset
|
23 def test_returns_unicode(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:
38977
diff
changeset
|
24 for x, y in self.set_get_pairs: |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
25 self.parser.returns_unicode = x |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
26 self.assertEquals(self.parser.returns_unicode, y) |
|
41532
4b9fa8092e82
Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents:
41318
diff
changeset
|
27 |
|
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:
38977
diff
changeset
|
28 def test_ordered_attributes(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:
38977
diff
changeset
|
29 for x, y in self.set_get_pairs: |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
30 self.parser.ordered_attributes = x |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
31 self.assertEquals(self.parser.ordered_attributes, y) |
|
13026
ca96d8ce12f3
Change pyexpat test suite to exercise the .returns_unicode attribute,
Andrew M. Kuchling <amk@amk.ca>
parents:
12212
diff
changeset
|
32 |
|
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:
38977
diff
changeset
|
33 def test_specified_attributes(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:
38977
diff
changeset
|
34 for x, y in self.set_get_pairs: |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
35 self.parser.specified_attributes = x |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
36 self.assertEquals(self.parser.specified_attributes, y) |
|
17624
d91fc02268d8
Update test to accomodate the change to the namespace_separator parameter
Fred Drake <fdrake@acm.org>
parents:
15658
diff
changeset
|
37 |
|
12183
242458503b13
Added test case for pyexpat module that tries to exercise all the handlers
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
38 |
|
14730
ffc300e9d867
Revise the test case for pyexpat to avoid using asserts. Conform better
Fred Drake <fdrake@acm.org>
parents:
13026
diff
changeset
|
39 data = '''\ |
|
ffc300e9d867
Revise the test case for pyexpat to avoid using asserts. Conform better
Fred Drake <fdrake@acm.org>
parents:
13026
diff
changeset
|
40 <?xml version="1.0" encoding="iso-8859-1" standalone="no"?> |
|
12183
242458503b13
Added test case for pyexpat module that tries to exercise all the handlers
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
41 <?xml-stylesheet href="stylesheet.css"?> |
|
242458503b13
Added test case for pyexpat module that tries to exercise all the handlers
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
42 <!-- comment data --> |
|
242458503b13
Added test case for pyexpat module that tries to exercise all the handlers
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
43 <!DOCTYPE quotations SYSTEM "quotations.dtd" [ |
|
242458503b13
Added test case for pyexpat module that tries to exercise all the handlers
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
44 <!ELEMENT root ANY> |
|
242458503b13
Added test case for pyexpat module that tries to exercise all the handlers
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
45 <!NOTATION notation SYSTEM "notation.jpeg"> |
|
242458503b13
Added test case for pyexpat module that tries to exercise all the handlers
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
46 <!ENTITY acirc "â"> |
|
242458503b13
Added test case for pyexpat module that tries to exercise all the handlers
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
47 <!ENTITY external_entity SYSTEM "entity.file"> |
|
242458503b13
Added test case for pyexpat module that tries to exercise all the handlers
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
48 <!ENTITY unparsed_entity SYSTEM "entity.file" NDATA notation> |
|
242458503b13
Added test case for pyexpat module that tries to exercise all the handlers
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
49 %unparsed_entity; |
|
242458503b13
Added test case for pyexpat module that tries to exercise all the handlers
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
50 ]> |
|
242458503b13
Added test case for pyexpat module that tries to exercise all the handlers
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
51 |
|
13026
ca96d8ce12f3
Change pyexpat test suite to exercise the .returns_unicode attribute,
Andrew M. Kuchling <amk@amk.ca>
parents:
12212
diff
changeset
|
52 <root attr1="value1" attr2="value2ὀ"> |
|
12183
242458503b13
Added test case for pyexpat module that tries to exercise all the handlers
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
53 <myns:subelement xmlns:myns="http://www.python.org/namespace"> |
|
242458503b13
Added test case for pyexpat module that tries to exercise all the handlers
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
54 Contents of subelements |
|
242458503b13
Added test case for pyexpat module that tries to exercise all the handlers
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
55 </myns:subelement> |
|
242458503b13
Added test case for pyexpat module that tries to exercise all the handlers
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
56 <sub2><![CDATA[contents of CDATA section]]></sub2> |
|
242458503b13
Added test case for pyexpat module that tries to exercise all the handlers
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
57 &external_entity; |
|
242458503b13
Added test case for pyexpat module that tries to exercise all the handlers
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
58 </root> |
|
14730
ffc300e9d867
Revise the test case for pyexpat to avoid using asserts. Conform better
Fred Drake <fdrake@acm.org>
parents:
13026
diff
changeset
|
59 ''' |
|
12183
242458503b13
Added test case for pyexpat module that tries to exercise all the handlers
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
60 |
|
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:
38977
diff
changeset
|
61 |
|
13026
ca96d8ce12f3
Change pyexpat test suite to exercise the .returns_unicode attribute,
Andrew M. Kuchling <amk@amk.ca>
parents:
12212
diff
changeset
|
62 # Produce UTF-8 output |
|
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:
38977
diff
changeset
|
63 class ParseTest(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:
38977
diff
changeset
|
64 class Outputter: |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
65 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:
38977
diff
changeset
|
66 self.out = [] |
|
41532
4b9fa8092e82
Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents:
41318
diff
changeset
|
67 |
|
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:
38977
diff
changeset
|
68 def StartElementHandler(self, name, attrs): |
|
41532
4b9fa8092e82
Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents:
41318
diff
changeset
|
69 self.out.append('Start element: ' + repr(name) + ' ' + |
|
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:
38977
diff
changeset
|
70 sortdict(attrs)) |
|
41532
4b9fa8092e82
Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents:
41318
diff
changeset
|
71 |
|
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:
38977
diff
changeset
|
72 def EndElementHandler(self, 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:
38977
diff
changeset
|
73 self.out.append('End element: ' + repr(name)) |
|
41532
4b9fa8092e82
Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents:
41318
diff
changeset
|
74 |
|
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:
38977
diff
changeset
|
75 def CharacterDataHandler(self, 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:
38977
diff
changeset
|
76 data = data.strip() |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
77 if 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:
38977
diff
changeset
|
78 self.out.append('Character data: ' + repr(data)) |
|
41532
4b9fa8092e82
Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents:
41318
diff
changeset
|
79 |
|
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:
38977
diff
changeset
|
80 def ProcessingInstructionHandler(self, target, 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:
38977
diff
changeset
|
81 self.out.append('PI: ' + repr(target) + ' ' + repr(data)) |
|
41532
4b9fa8092e82
Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents:
41318
diff
changeset
|
82 |
|
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:
38977
diff
changeset
|
83 def StartNamespaceDeclHandler(self, prefix, 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:
38977
diff
changeset
|
84 self.out.append('NS decl: ' + repr(prefix) + ' ' + repr(uri)) |
|
41532
4b9fa8092e82
Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents:
41318
diff
changeset
|
85 |
|
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:
38977
diff
changeset
|
86 def EndNamespaceDeclHandler(self, prefix): |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
87 self.out.append('End of NS decl: ' + repr(prefix)) |
|
41532
4b9fa8092e82
Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents:
41318
diff
changeset
|
88 |
|
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:
38977
diff
changeset
|
89 def StartCdataSectionHandler(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:
38977
diff
changeset
|
90 self.out.append('Start of CDATA section') |
|
41532
4b9fa8092e82
Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents:
41318
diff
changeset
|
91 |
|
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:
38977
diff
changeset
|
92 def EndCdataSectionHandler(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:
38977
diff
changeset
|
93 self.out.append('End of CDATA section') |
|
41532
4b9fa8092e82
Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents:
41318
diff
changeset
|
94 |
|
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:
38977
diff
changeset
|
95 def CommentHandler(self, 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:
38977
diff
changeset
|
96 self.out.append('Comment: ' + repr(text)) |
|
41532
4b9fa8092e82
Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents:
41318
diff
changeset
|
97 |
|
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:
38977
diff
changeset
|
98 def NotationDeclHandler(self, *args): |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
99 name, base, sysid, pubid = args |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
100 self.out.append('Notation declared: %s' %(args,)) |
|
41532
4b9fa8092e82
Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents:
41318
diff
changeset
|
101 |
|
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:
38977
diff
changeset
|
102 def UnparsedEntityDeclHandler(self, *args): |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
103 entityName, base, systemId, publicId, notationName = args |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
104 self.out.append('Unparsed entity decl: %s' %(args,)) |
|
41532
4b9fa8092e82
Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents:
41318
diff
changeset
|
105 |
|
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:
38977
diff
changeset
|
106 def NotStandaloneHandler(self, userData): |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
107 self.out.append('Not standalone') |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
108 return 1 |
|
41532
4b9fa8092e82
Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents:
41318
diff
changeset
|
109 |
|
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:
38977
diff
changeset
|
110 def ExternalEntityRefHandler(self, *args): |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
111 context, base, sysId, pubId = args |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
112 self.out.append('External entity ref: %s' %(args[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:
38977
diff
changeset
|
113 return 1 |
|
41532
4b9fa8092e82
Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents:
41318
diff
changeset
|
114 |
|
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:
38977
diff
changeset
|
115 def DefaultHandler(self, userData): |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
116 pass |
|
41532
4b9fa8092e82
Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents:
41318
diff
changeset
|
117 |
|
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:
38977
diff
changeset
|
118 def DefaultHandlerExpand(self, userData): |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
119 pass |
|
12183
242458503b13
Added test case for pyexpat module that tries to exercise all the handlers
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
120 |
|
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:
38977
diff
changeset
|
121 handler_names = [ |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
122 'StartElementHandler', 'EndElementHandler', |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
123 'CharacterDataHandler', 'ProcessingInstructionHandler', |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
124 'UnparsedEntityDeclHandler', 'NotationDeclHandler', |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
125 'StartNamespaceDeclHandler', 'EndNamespaceDeclHandler', |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
126 'CommentHandler', 'StartCdataSectionHandler', |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
127 'EndCdataSectionHandler', |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
128 'DefaultHandler', 'DefaultHandlerExpand', |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
129 #'NotStandaloneHandler', |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
130 'ExternalEntityRefHandler' |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
131 ] |
|
41532
4b9fa8092e82
Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents:
41318
diff
changeset
|
132 |
|
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:
38977
diff
changeset
|
133 def test_utf8(self): |
|
13026
ca96d8ce12f3
Change pyexpat test suite to exercise the .returns_unicode attribute,
Andrew M. Kuchling <amk@amk.ca>
parents:
12212
diff
changeset
|
134 |
|
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:
38977
diff
changeset
|
135 out = self.Outputter() |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
136 parser = expat.ParserCreate(namespace_separator='!') |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
137 for name in self.handler_names: |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
138 setattr(parser, name, getattr(out, 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:
38977
diff
changeset
|
139 parser.returns_unicode = 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:
38977
diff
changeset
|
140 parser.Parse(data, 1) |
|
41532
4b9fa8092e82
Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents:
41318
diff
changeset
|
141 |
|
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:
38977
diff
changeset
|
142 # Verify output |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
143 op = out.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:
38977
diff
changeset
|
144 self.assertEquals(op[0], 'PI: \'xml-stylesheet\' \'href="stylesheet.css"\'') |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
145 self.assertEquals(op[1], "Comment: ' comment 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:
38977
diff
changeset
|
146 self.assertEquals(op[2], "Notation declared: ('notation', None, 'notation.jpeg', 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:
38977
diff
changeset
|
147 self.assertEquals(op[3], "Unparsed entity decl: ('unparsed_entity', None, 'entity.file', None, 'notation')") |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
148 self.assertEquals(op[4], "Start element: 'root' {'attr1': 'value1', 'attr2': 'value2\\xe1\\xbd\\x80'}") |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
149 self.assertEquals(op[5], "NS decl: 'myns' 'http://www.python.org/namespace'") |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
150 self.assertEquals(op[6], "Start element: 'http://www.python.org/namespace!subelement' {}") |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
151 self.assertEquals(op[7], "Character data: 'Contents of subelements'") |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
152 self.assertEquals(op[8], "End element: 'http://www.python.org/namespace!subelement'") |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
153 self.assertEquals(op[9], "End of NS decl: 'myns'") |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
154 self.assertEquals(op[10], "Start element: 'sub2' {}") |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
155 self.assertEquals(op[11], 'Start of CDATA section') |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
156 self.assertEquals(op[12], "Character data: 'contents of CDATA section'") |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
157 self.assertEquals(op[13], 'End of CDATA section') |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
158 self.assertEquals(op[14], "End element: 'sub2'") |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
159 self.assertEquals(op[15], "External entity ref: (None, 'entity.file', 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:
38977
diff
changeset
|
160 self.assertEquals(op[16], "End element: 'root'") |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
161 |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
162 def test_unicode(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:
38977
diff
changeset
|
163 # Try the parse again, this time producing Unicode output |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
164 out = self.Outputter() |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
165 parser = expat.ParserCreate(namespace_separator='!') |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
166 parser.returns_unicode = 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:
38977
diff
changeset
|
167 for name in self.handler_names: |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
168 setattr(parser, name, getattr(out, name)) |
|
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:
38977
diff
changeset
|
170 parser.Parse(data, 1) |
|
13026
ca96d8ce12f3
Change pyexpat test suite to exercise the .returns_unicode attribute,
Andrew M. Kuchling <amk@amk.ca>
parents:
12212
diff
changeset
|
171 |
|
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:
38977
diff
changeset
|
172 op = out.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:
38977
diff
changeset
|
173 self.assertEquals(op[0], 'PI: u\'xml-stylesheet\' u\'href="stylesheet.css"\'') |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
174 self.assertEquals(op[1], "Comment: u' comment 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:
38977
diff
changeset
|
175 self.assertEquals(op[2], "Notation declared: (u'notation', None, u'notation.jpeg', 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:
38977
diff
changeset
|
176 self.assertEquals(op[3], "Unparsed entity decl: (u'unparsed_entity', None, u'entity.file', None, u'notation')") |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
177 self.assertEquals(op[4], "Start element: u'root' {u'attr1': u'value1', u'attr2': u'value2\\u1f40'}") |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
178 self.assertEquals(op[5], "NS decl: u'myns' u'http://www.python.org/namespace'") |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
179 self.assertEquals(op[6], "Start element: u'http://www.python.org/namespace!subelement' {}") |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
180 self.assertEquals(op[7], "Character data: u'Contents of subelements'") |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
181 self.assertEquals(op[8], "End element: u'http://www.python.org/namespace!subelement'") |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
182 self.assertEquals(op[9], "End of NS decl: u'myns'") |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
183 self.assertEquals(op[10], "Start element: u'sub2' {}") |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
184 self.assertEquals(op[11], 'Start of CDATA section') |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
185 self.assertEquals(op[12], "Character data: u'contents of CDATA section'") |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
186 self.assertEquals(op[13], 'End of CDATA section') |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
187 self.assertEquals(op[14], "End element: u'sub2'") |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
188 self.assertEquals(op[15], "External entity ref: (None, u'entity.file', 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:
38977
diff
changeset
|
189 self.assertEquals(op[16], "End element: u'root'") |
|
13026
ca96d8ce12f3
Change pyexpat test suite to exercise the .returns_unicode attribute,
Andrew M. Kuchling <amk@amk.ca>
parents:
12212
diff
changeset
|
190 |
|
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:
38977
diff
changeset
|
191 def test_parse_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:
38977
diff
changeset
|
192 # Try parsing a file |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
193 out = self.Outputter() |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
194 parser = expat.ParserCreate(namespace_separator='!') |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
195 parser.returns_unicode = 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:
38977
diff
changeset
|
196 for name in self.handler_names: |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
197 setattr(parser, name, getattr(out, 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:
38977
diff
changeset
|
198 file = StringIO.StringIO(data) |
|
41532
4b9fa8092e82
Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents:
41318
diff
changeset
|
199 |
|
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:
38977
diff
changeset
|
200 parser.ParseFile(file) |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
201 |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
202 op = out.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:
38977
diff
changeset
|
203 self.assertEquals(op[0], 'PI: u\'xml-stylesheet\' u\'href="stylesheet.css"\'') |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
204 self.assertEquals(op[1], "Comment: u' comment 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:
38977
diff
changeset
|
205 self.assertEquals(op[2], "Notation declared: (u'notation', None, u'notation.jpeg', 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:
38977
diff
changeset
|
206 self.assertEquals(op[3], "Unparsed entity decl: (u'unparsed_entity', None, u'entity.file', None, u'notation')") |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
207 self.assertEquals(op[4], "Start element: u'root' {u'attr1': u'value1', u'attr2': u'value2\\u1f40'}") |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
208 self.assertEquals(op[5], "NS decl: u'myns' u'http://www.python.org/namespace'") |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
209 self.assertEquals(op[6], "Start element: u'http://www.python.org/namespace!subelement' {}") |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
210 self.assertEquals(op[7], "Character data: u'Contents of subelements'") |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
211 self.assertEquals(op[8], "End element: u'http://www.python.org/namespace!subelement'") |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
212 self.assertEquals(op[9], "End of NS decl: u'myns'") |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
213 self.assertEquals(op[10], "Start element: u'sub2' {}") |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
214 self.assertEquals(op[11], 'Start of CDATA section') |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
215 self.assertEquals(op[12], "Character data: u'contents of CDATA section'") |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
216 self.assertEquals(op[13], 'End of CDATA section') |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
217 self.assertEquals(op[14], "End element: u'sub2'") |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
218 self.assertEquals(op[15], "External entity ref: (None, u'entity.file', 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:
38977
diff
changeset
|
219 self.assertEquals(op[16], "End element: u'root'") |
|
15658
56ce38e57502
The "context" parameter to the ExternalEntityRefParameter exposes internal
Fred Drake <fdrake@acm.org>
parents:
15305
diff
changeset
|
220 |
|
56ce38e57502
The "context" parameter to the ExternalEntityRefParameter exposes internal
Fred Drake <fdrake@acm.org>
parents:
15305
diff
changeset
|
221 |
|
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:
38977
diff
changeset
|
222 class NamespaceSeparatorTest(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:
38977
diff
changeset
|
223 def test_legal(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:
38977
diff
changeset
|
224 # Tests that make sure we get errors when the namespace_separator value |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
225 # is illegal, and that we don't for good values: |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
226 expat.ParserCreate() |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
227 expat.ParserCreate(namespace_separator=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:
38977
diff
changeset
|
228 expat.ParserCreate(namespace_separator=' ') |
|
41532
4b9fa8092e82
Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents:
41318
diff
changeset
|
229 |
|
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:
38977
diff
changeset
|
230 def test_illegal(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:
38977
diff
changeset
|
231 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:
38977
diff
changeset
|
232 expat.ParserCreate(namespace_separator=42) |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
233 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:
38977
diff
changeset
|
234 except TypeError, e: |
|
41532
4b9fa8092e82
Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents:
41318
diff
changeset
|
235 self.assertEquals(str(e), |
|
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:
38977
diff
changeset
|
236 'ParserCreate() argument 2 must be string or None, not int') |
|
41532
4b9fa8092e82
Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents:
41318
diff
changeset
|
237 |
|
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:
38977
diff
changeset
|
238 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:
38977
diff
changeset
|
239 expat.ParserCreate(namespace_separator='too long') |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
240 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:
38977
diff
changeset
|
241 except ValueError, 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:
38977
diff
changeset
|
242 self.assertEquals(str(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:
38977
diff
changeset
|
243 'namespace_separator must be at most one character, omitted, or None') |
|
17624
d91fc02268d8
Update test to accomodate the change to the namespace_separator parameter
Fred Drake <fdrake@acm.org>
parents:
15658
diff
changeset
|
244 |
|
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:
38977
diff
changeset
|
245 def test_zero_length(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:
38977
diff
changeset
|
246 # ParserCreate() needs to accept a namespace_separator of zero length |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
247 # to satisfy the requirements of RDF applications that are required |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
248 # to simply glue together the namespace URI and the localname. Though |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
249 # considered a wart of the RDF specifications, it needs to be supported. |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
250 # |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
251 # See XML-SIG mailing list thread starting 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:
38977
diff
changeset
|
252 # http://mail.python.org/pipermail/xml-sig/2001-April/005202.html |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
253 # |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
254 expat.ParserCreate(namespace_separator='') # too short |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
255 |
|
24028
9b6d259c25eb
Integrate the tests for name interning from PyXML (test_pyexpat.py
Fred Drake <fdrake@acm.org>
parents:
18883
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:
38977
diff
changeset
|
257 class InterningTest(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:
38977
diff
changeset
|
258 def test(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:
38977
diff
changeset
|
259 # Test the interning machinery. |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
260 p = expat.ParserCreate() |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
261 L = [] |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
262 def collector(name, *args): |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
263 L.append(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:
38977
diff
changeset
|
264 p.StartElementHandler = collector |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
265 p.EndElementHandler = collector |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
266 p.Parse("<e> <e/> <e></e> </e>", 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:
38977
diff
changeset
|
267 tag = L[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:
38977
diff
changeset
|
268 self.assertEquals(len(L), 6) |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
269 for entry in L: |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
270 # L should have the same string repeated over and over. |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
271 self.assertTrue(tag is entry) |
|
24040
a78d41ee9474
Added character data buffering to pyexpat parser objects.
Fred Drake <fdrake@acm.org>
parents:
24028
diff
changeset
|
272 |
|
a78d41ee9474
Added character data buffering to pyexpat parser objects.
Fred Drake <fdrake@acm.org>
parents:
24028
diff
changeset
|
273 |
|
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:
38977
diff
changeset
|
274 class BufferTextTest(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:
38977
diff
changeset
|
275 def setUp(self): |
|
24040
a78d41ee9474
Added character data buffering to pyexpat parser objects.
Fred Drake <fdrake@acm.org>
parents:
24028
diff
changeset
|
276 self.stuff = [] |
|
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:
38977
diff
changeset
|
277 self.parser = expat.ParserCreate() |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
278 self.parser.buffer_text = 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:
38977
diff
changeset
|
279 self.parser.CharacterDataHandler = self.CharacterDataHandler |
|
41532
4b9fa8092e82
Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents:
41318
diff
changeset
|
280 |
|
24040
a78d41ee9474
Added character data buffering to pyexpat parser objects.
Fred Drake <fdrake@acm.org>
parents:
24028
diff
changeset
|
281 def check(self, expected, label): |
|
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:
38977
diff
changeset
|
282 self.assertEquals(self.stuff, expected, |
|
31515
71a294bd7950
Replace backticks with repr() or "%r"
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
283 "%s\nstuff = %r\nexpected = %r" |
|
71a294bd7950
Replace backticks with repr() or "%r"
Walter Dörwald <walter@livinglogic.de>
parents:
24364
diff
changeset
|
284 % (label, self.stuff, map(unicode, expected))) |
|
24040
a78d41ee9474
Added character data buffering to pyexpat parser objects.
Fred Drake <fdrake@acm.org>
parents:
24028
diff
changeset
|
285 |
|
a78d41ee9474
Added character data buffering to pyexpat parser objects.
Fred Drake <fdrake@acm.org>
parents:
24028
diff
changeset
|
286 def CharacterDataHandler(self, text): |
|
a78d41ee9474
Added character data buffering to pyexpat parser objects.
Fred Drake <fdrake@acm.org>
parents:
24028
diff
changeset
|
287 self.stuff.append(text) |
|
a78d41ee9474
Added character data buffering to pyexpat parser objects.
Fred Drake <fdrake@acm.org>
parents:
24028
diff
changeset
|
288 |
|
a78d41ee9474
Added character data buffering to pyexpat parser objects.
Fred Drake <fdrake@acm.org>
parents:
24028
diff
changeset
|
289 def StartElementHandler(self, name, attrs): |
|
a78d41ee9474
Added character data buffering to pyexpat parser objects.
Fred Drake <fdrake@acm.org>
parents:
24028
diff
changeset
|
290 self.stuff.append("<%s>" % name) |
|
a78d41ee9474
Added character data buffering to pyexpat parser objects.
Fred Drake <fdrake@acm.org>
parents:
24028
diff
changeset
|
291 bt = attrs.get("buffer-text") |
|
a78d41ee9474
Added character data buffering to pyexpat parser objects.
Fred Drake <fdrake@acm.org>
parents:
24028
diff
changeset
|
292 if bt == "yes": |
|
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:
38977
diff
changeset
|
293 self.parser.buffer_text = 1 |
|
24040
a78d41ee9474
Added character data buffering to pyexpat parser objects.
Fred Drake <fdrake@acm.org>
parents:
24028
diff
changeset
|
294 elif bt == "no": |
|
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:
38977
diff
changeset
|
295 self.parser.buffer_text = 0 |
|
24040
a78d41ee9474
Added character data buffering to pyexpat parser objects.
Fred Drake <fdrake@acm.org>
parents:
24028
diff
changeset
|
296 |
|
a78d41ee9474
Added character data buffering to pyexpat parser objects.
Fred Drake <fdrake@acm.org>
parents:
24028
diff
changeset
|
297 def EndElementHandler(self, name): |
|
a78d41ee9474
Added character data buffering to pyexpat parser objects.
Fred Drake <fdrake@acm.org>
parents:
24028
diff
changeset
|
298 self.stuff.append("</%s>" % name) |
|
a78d41ee9474
Added character data buffering to pyexpat parser objects.
Fred Drake <fdrake@acm.org>
parents:
24028
diff
changeset
|
299 |
|
a78d41ee9474
Added character data buffering to pyexpat parser objects.
Fred Drake <fdrake@acm.org>
parents:
24028
diff
changeset
|
300 def CommentHandler(self, data): |
|
a78d41ee9474
Added character data buffering to pyexpat parser objects.
Fred Drake <fdrake@acm.org>
parents:
24028
diff
changeset
|
301 self.stuff.append("<!--%s-->" % data) |
|
a78d41ee9474
Added character data buffering to pyexpat parser objects.
Fred Drake <fdrake@acm.org>
parents:
24028
diff
changeset
|
302 |
|
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:
38977
diff
changeset
|
303 def setHandlers(self, handlers=[]): |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
304 for name in handlers: |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
305 setattr(self.parser, name, getattr(self, name)) |
|
24040
a78d41ee9474
Added character data buffering to pyexpat parser objects.
Fred Drake <fdrake@acm.org>
parents:
24028
diff
changeset
|
306 |
|
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:
38977
diff
changeset
|
307 def test_default_to_disabled(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:
38977
diff
changeset
|
308 parser = expat.ParserCreate() |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
309 self.assertFalse(parser.buffer_text) |
|
41532
4b9fa8092e82
Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents:
41318
diff
changeset
|
310 |
|
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:
38977
diff
changeset
|
311 def test_buffering_enabled(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:
38977
diff
changeset
|
312 # Make sure buffering is turned on |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
313 self.assertTrue(self.parser.buffer_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:
38977
diff
changeset
|
314 self.parser.Parse("<a>1<b/>2<c/>3</a>", 1) |
|
41532
4b9fa8092e82
Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents:
41318
diff
changeset
|
315 self.assertEquals(self.stuff, ['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:
38977
diff
changeset
|
316 "buffered text not properly collapsed") |
|
24040
a78d41ee9474
Added character data buffering to pyexpat parser objects.
Fred Drake <fdrake@acm.org>
parents:
24028
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:
38977
diff
changeset
|
318 def test1(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:
38977
diff
changeset
|
319 # XXX This test exposes more detail of Expat's text chunking than we |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
320 # XXX like, but it tests what we need to concisely. |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
321 self.setHandlers(["StartElementHandler"]) |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
322 self.parser.Parse("<a>1<b buffer-text='no'/>2\n3<c buffer-text='yes'/>4\n5</a>", 1) |
|
41532
4b9fa8092e82
Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents:
41318
diff
changeset
|
323 self.assertEquals(self.stuff, |
|
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:
38977
diff
changeset
|
324 ["<a>", "1", "<b>", "2", "\n", "3", "<c>", "4\n5"], |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
325 "buffering control not reacting as expected") |
|
41532
4b9fa8092e82
Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents:
41318
diff
changeset
|
326 |
|
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:
38977
diff
changeset
|
327 def test2(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:
38977
diff
changeset
|
328 self.parser.Parse("<a>1<b/><2><c/> \n 3</a>", 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:
38977
diff
changeset
|
329 self.assertEquals(self.stuff, ["1<2> \n 3"], |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
330 "buffered text not properly collapsed") |
|
24040
a78d41ee9474
Added character data buffering to pyexpat parser objects.
Fred Drake <fdrake@acm.org>
parents:
24028
diff
changeset
|
331 |
|
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:
38977
diff
changeset
|
332 def test3(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:
38977
diff
changeset
|
333 self.setHandlers(["StartElementHandler"]) |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
334 self.parser.Parse("<a>1<b/>2<c/>3</a>", 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:
38977
diff
changeset
|
335 self.assertEquals(self.stuff, ["<a>", "1", "<b>", "2", "<c>", "3"], |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
336 "buffered text not properly split") |
|
24040
a78d41ee9474
Added character data buffering to pyexpat parser objects.
Fred Drake <fdrake@acm.org>
parents:
24028
diff
changeset
|
337 |
|
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:
38977
diff
changeset
|
338 def test4(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:
38977
diff
changeset
|
339 self.setHandlers(["StartElementHandler", "EndElementHandler"]) |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
340 self.parser.CharacterDataHandler = 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:
38977
diff
changeset
|
341 self.parser.Parse("<a>1<b/>2<c/>3</a>", 1) |
|
41532
4b9fa8092e82
Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents:
41318
diff
changeset
|
342 self.assertEquals(self.stuff, |
|
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:
38977
diff
changeset
|
343 ["<a>", "<b>", "</b>", "<c>", "</c>", "</a>"]) |
|
24040
a78d41ee9474
Added character data buffering to pyexpat parser objects.
Fred Drake <fdrake@acm.org>
parents:
24028
diff
changeset
|
344 |
|
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:
38977
diff
changeset
|
345 def test5(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:
38977
diff
changeset
|
346 self.setHandlers(["StartElementHandler", "EndElementHandler"]) |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
347 self.parser.Parse("<a>1<b></b>2<c/>3</a>", 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:
38977
diff
changeset
|
348 self.assertEquals(self.stuff, |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
349 ["<a>", "1", "<b>", "</b>", "2", "<c>", "</c>", "3", "</a>"]) |
|
24040
a78d41ee9474
Added character data buffering to pyexpat parser objects.
Fred Drake <fdrake@acm.org>
parents:
24028
diff
changeset
|
350 |
|
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:
38977
diff
changeset
|
351 def test6(self): |
|
41532
4b9fa8092e82
Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents:
41318
diff
changeset
|
352 self.setHandlers(["CommentHandler", "EndElementHandler", |
|
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:
38977
diff
changeset
|
353 "StartElementHandler"]) |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
354 self.parser.Parse("<a>1<b/>2<c></c>345</a> ", 1) |
|
41532
4b9fa8092e82
Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents:
41318
diff
changeset
|
355 self.assertEquals(self.stuff, |
|
4b9fa8092e82
Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents:
41318
diff
changeset
|
356 ["<a>", "1", "<b>", "</b>", "2", "<c>", "</c>", "345", "</a>"], |
|
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:
38977
diff
changeset
|
357 "buffered text not properly split") |
|
24040
a78d41ee9474
Added character data buffering to pyexpat parser objects.
Fred Drake <fdrake@acm.org>
parents:
24028
diff
changeset
|
358 |
|
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:
38977
diff
changeset
|
359 def test7(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:
38977
diff
changeset
|
360 self.setHandlers(["CommentHandler", "EndElementHandler", |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
361 "StartElementHandler"]) |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
362 self.parser.Parse("<a>1<b/>2<c></c>3<!--abc-->4<!--def-->5</a> ", 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:
38977
diff
changeset
|
363 self.assertEquals(self.stuff, |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
364 ["<a>", "1", "<b>", "</b>", "2", "<c>", "</c>", "3", |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
365 "<!--abc-->", "4", "<!--def-->", "5", "</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:
38977
diff
changeset
|
366 "buffered text not properly split") |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
367 |
|
33112
a77c0372a1d7
include at least one example of an exception passing through pyexpat
Fred Drake <fdrake@acm.org>
parents:
31515
diff
changeset
|
368 |
|
a77c0372a1d7
include at least one example of an exception passing through pyexpat
Fred Drake <fdrake@acm.org>
parents:
31515
diff
changeset
|
369 # Test handling of exception from callback: |
|
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:
38977
diff
changeset
|
370 class HandlerExceptionTest(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:
38977
diff
changeset
|
371 def StartElementHandler(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:
38977
diff
changeset
|
372 raise RuntimeError(name) |
|
33112
a77c0372a1d7
include at least one example of an exception passing through pyexpat
Fred Drake <fdrake@acm.org>
parents:
31515
diff
changeset
|
373 |
|
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:
38977
diff
changeset
|
374 def test(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:
38977
diff
changeset
|
375 parser = expat.ParserCreate() |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
376 parser.StartElementHandler = self.StartElementHandler |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
377 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:
38977
diff
changeset
|
378 parser.Parse("<a><b><c/></b></a>", 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:
38977
diff
changeset
|
379 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:
38977
diff
changeset
|
380 except RuntimeError, 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:
38977
diff
changeset
|
381 self.assertEquals(e.args[0], '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:
38977
diff
changeset
|
382 "Expected RuntimeError for element 'a', but" + \ |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
383 " found %r" % e.args[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:
38977
diff
changeset
|
384 |
|
33279
b25cb2045dac
Patch #1014930. Expose current parse location to XMLParser.
Dave Cole <djc@object-craft.com.au>
parents:
33112
diff
changeset
|
385 |
|
b25cb2045dac
Patch #1014930. Expose current parse location to XMLParser.
Dave Cole <djc@object-craft.com.au>
parents:
33112
diff
changeset
|
386 # Test Current* members: |
|
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:
38977
diff
changeset
|
387 class PositionTest(unittest.TestCase): |
|
33279
b25cb2045dac
Patch #1014930. Expose current parse location to XMLParser.
Dave Cole <djc@object-craft.com.au>
parents:
33112
diff
changeset
|
388 def StartElementHandler(self, name, attrs): |
|
b25cb2045dac
Patch #1014930. Expose current parse location to XMLParser.
Dave Cole <djc@object-craft.com.au>
parents:
33112
diff
changeset
|
389 self.check_pos('s') |
|
b25cb2045dac
Patch #1014930. Expose current parse location to XMLParser.
Dave Cole <djc@object-craft.com.au>
parents:
33112
diff
changeset
|
390 |
|
b25cb2045dac
Patch #1014930. Expose current parse location to XMLParser.
Dave Cole <djc@object-craft.com.au>
parents:
33112
diff
changeset
|
391 def EndElementHandler(self, name): |
|
b25cb2045dac
Patch #1014930. Expose current parse location to XMLParser.
Dave Cole <djc@object-craft.com.au>
parents:
33112
diff
changeset
|
392 self.check_pos('e') |
|
b25cb2045dac
Patch #1014930. Expose current parse location to XMLParser.
Dave Cole <djc@object-craft.com.au>
parents:
33112
diff
changeset
|
393 |
|
b25cb2045dac
Patch #1014930. Expose current parse location to XMLParser.
Dave Cole <djc@object-craft.com.au>
parents:
33112
diff
changeset
|
394 def check_pos(self, event): |
|
b25cb2045dac
Patch #1014930. Expose current parse location to XMLParser.
Dave Cole <djc@object-craft.com.au>
parents:
33112
diff
changeset
|
395 pos = (event, |
|
b25cb2045dac
Patch #1014930. Expose current parse location to XMLParser.
Dave Cole <djc@object-craft.com.au>
parents:
33112
diff
changeset
|
396 self.parser.CurrentByteIndex, |
|
b25cb2045dac
Patch #1014930. Expose current parse location to XMLParser.
Dave Cole <djc@object-craft.com.au>
parents:
33112
diff
changeset
|
397 self.parser.CurrentLineNumber, |
|
b25cb2045dac
Patch #1014930. Expose current parse location to XMLParser.
Dave Cole <djc@object-craft.com.au>
parents:
33112
diff
changeset
|
398 self.parser.CurrentColumnNumber) |
|
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:
38977
diff
changeset
|
399 self.assertTrue(self.upto < len(self.expected_list), |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
400 'too many parser events') |
|
33279
b25cb2045dac
Patch #1014930. Expose current parse location to XMLParser.
Dave Cole <djc@object-craft.com.au>
parents:
33112
diff
changeset
|
401 expected = self.expected_list[self.upto] |
|
41532
4b9fa8092e82
Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents:
41318
diff
changeset
|
402 self.assertEquals(pos, expected, |
|
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:
38977
diff
changeset
|
403 'Expected position %s, got position %s' %(pos, expected)) |
|
33279
b25cb2045dac
Patch #1014930. Expose current parse location to XMLParser.
Dave Cole <djc@object-craft.com.au>
parents:
33112
diff
changeset
|
404 self.upto += 1 |
|
b25cb2045dac
Patch #1014930. Expose current parse location to XMLParser.
Dave Cole <djc@object-craft.com.au>
parents:
33112
diff
changeset
|
405 |
|
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:
38977
diff
changeset
|
406 def test(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:
38977
diff
changeset
|
407 self.parser = expat.ParserCreate() |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
408 self.parser.StartElementHandler = self.StartElementHandler |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
409 self.parser.EndElementHandler = self.EndElementHandler |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
410 self.upto = 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:
38977
diff
changeset
|
411 self.expected_list = [('s', 0, 1, 0), ('s', 5, 2, 1), ('s', 11, 3, 2), |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
412 ('e', 15, 3, 6), ('e', 17, 4, 1), ('e', 22, 5, 0)] |
|
33279
b25cb2045dac
Patch #1014930. Expose current parse location to XMLParser.
Dave Cole <djc@object-craft.com.au>
parents:
33112
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:
38977
diff
changeset
|
414 xml = '<a>\n <b>\n <c/>\n </b>\n</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:
38977
diff
changeset
|
415 self.parser.Parse(xml, 1) |
|
38977
e076e3d76f77
SF bug #1296433 (Expat bug #1515266): Unchecked calls to character data
Fred Drake <fdrake@acm.org>
parents:
33279
diff
changeset
|
416 |
|
e076e3d76f77
SF bug #1296433 (Expat bug #1515266): Unchecked calls to character data
Fred Drake <fdrake@acm.org>
parents:
33279
diff
changeset
|
417 |
|
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:
38977
diff
changeset
|
418 class sf1296433Test(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:
38977
diff
changeset
|
419 def test_parse_only_xml_data(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:
38977
diff
changeset
|
420 # http://python.org/sf/1296433 |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
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:
38977
diff
changeset
|
422 xml = "<?xml version='1.0' encoding='iso8859'?><s>%s</s>" % ('a' * 1025) |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
423 # this one doesn't crash |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
424 #xml = "<?xml version='1.0'?><s>%s</s>" % ('a' * 10000) |
|
41532
4b9fa8092e82
Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents:
41318
diff
changeset
|
425 |
|
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:
38977
diff
changeset
|
426 class SpecificException(Exception): |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
427 pass |
|
41532
4b9fa8092e82
Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents:
41318
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:
38977
diff
changeset
|
429 def handler(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:
38977
diff
changeset
|
430 raise SpecificException |
|
41532
4b9fa8092e82
Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents:
41318
diff
changeset
|
431 |
|
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:
38977
diff
changeset
|
432 parser = expat.ParserCreate() |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
433 parser.CharacterDataHandler = handler |
|
41532
4b9fa8092e82
Whitespace normalization. Ugh, we really need to do this more often.
Neal Norwitz <nnorwitz@gmail.com>
parents:
41318
diff
changeset
|
434 |
|
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:
38977
diff
changeset
|
435 self.assertRaises(Exception, parser.Parse, xml) |
|
38977
e076e3d76f77
SF bug #1296433 (Expat bug #1515266): Unchecked calls to character data
Fred Drake <fdrake@acm.org>
parents:
33279
diff
changeset
|
436 |
|
44594
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
437 class ChardataBufferTest(unittest.TestCase): |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
438 """ |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
439 test setting of chardata buffer size |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
440 """ |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
441 |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
442 def test_1025_bytes(self): |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
443 self.assertEquals(self.small_buffer_test(1025), 2) |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
444 |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
445 def test_1000_bytes(self): |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
446 self.assertEquals(self.small_buffer_test(1000), 1) |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
447 |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
448 def test_wrong_size(self): |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
449 parser = expat.ParserCreate() |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
450 parser.buffer_text = 1 |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
451 def f(size): |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
452 parser.buffer_size = size |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
453 |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
454 self.assertRaises(TypeError, f, sys.maxint+1) |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
455 self.assertRaises(ValueError, f, -1) |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
456 self.assertRaises(ValueError, f, 0) |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
457 |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
458 def test_unchanged_size(self): |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
459 xml1 = ("<?xml version='1.0' encoding='iso8859'?><s>%s" % ('a' * 512)) |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
460 xml2 = 'a'*512 + '</s>' |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
461 parser = expat.ParserCreate() |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
462 parser.CharacterDataHandler = self.counting_handler |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
463 parser.buffer_size = 512 |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
464 parser.buffer_text = 1 |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
465 |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
466 # Feed 512 bytes of character data: the handler should be called |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
467 # once. |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
468 self.n = 0 |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
469 parser.Parse(xml1) |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
470 self.assertEquals(self.n, 1) |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
471 |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
472 # Reassign to buffer_size, but assign the same size. |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
473 parser.buffer_size = parser.buffer_size |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
474 self.assertEquals(self.n, 1) |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
475 |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
476 # Try parsing rest of the document |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
477 parser.Parse(xml2) |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
478 self.assertEquals(self.n, 2) |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
479 |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
480 |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
481 def test_disabling_buffer(self): |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
482 xml1 = "<?xml version='1.0' encoding='iso8859'?><a>%s" % ('a' * 512) |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
483 xml2 = ('b' * 1024) |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
484 xml3 = "%s</a>" % ('c' * 1024) |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
485 parser = expat.ParserCreate() |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
486 parser.CharacterDataHandler = self.counting_handler |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
487 parser.buffer_text = 1 |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
488 parser.buffer_size = 1024 |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
489 self.assertEquals(parser.buffer_size, 1024) |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
490 |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
491 # Parse one chunk of XML |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
492 self.n = 0 |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
493 parser.Parse(xml1, 0) |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
494 self.assertEquals(parser.buffer_size, 1024) |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
495 self.assertEquals(self.n, 1) |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
496 |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
497 # Turn off buffering and parse the next chunk. |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
498 parser.buffer_text = 0 |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
499 self.assertFalse(parser.buffer_text) |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
500 self.assertEquals(parser.buffer_size, 1024) |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
501 for i in range(10): |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
502 parser.Parse(xml2, 0) |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
503 self.assertEquals(self.n, 11) |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
504 |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
505 parser.buffer_text = 1 |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
506 self.assertTrue(parser.buffer_text) |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
507 self.assertEquals(parser.buffer_size, 1024) |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
508 parser.Parse(xml3, 1) |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
509 self.assertEquals(self.n, 12) |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
510 |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
511 |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
512 |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
513 def make_document(self, bytes): |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
514 return ("<?xml version='1.0'?><tag>" + bytes * 'a' + '</tag>') |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
515 |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
516 def counting_handler(self, text): |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
517 self.n += 1 |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
518 |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
519 def small_buffer_test(self, buffer_len): |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
520 xml = "<?xml version='1.0' encoding='iso8859'?><s>%s</s>" % ('a' * buffer_len) |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
521 parser = expat.ParserCreate() |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
522 parser.CharacterDataHandler = self.counting_handler |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
523 parser.buffer_size = 1024 |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
524 parser.buffer_text = 1 |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
525 |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
526 self.n = 0 |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
527 parser.Parse(xml) |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
528 return self.n |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
529 |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
530 def test_change_size_1(self): |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
531 xml1 = "<?xml version='1.0' encoding='iso8859'?><a><s>%s" % ('a' * 1024) |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
532 xml2 = "aaa</s><s>%s</s></a>" % ('a' * 1025) |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
533 parser = expat.ParserCreate() |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
534 parser.CharacterDataHandler = self.counting_handler |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
535 parser.buffer_text = 1 |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
536 parser.buffer_size = 1024 |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
537 self.assertEquals(parser.buffer_size, 1024) |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
538 |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
539 self.n = 0 |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
540 parser.Parse(xml1, 0) |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
541 parser.buffer_size *= 2 |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
542 self.assertEquals(parser.buffer_size, 2048) |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
543 parser.Parse(xml2, 1) |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
544 self.assertEquals(self.n, 2) |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
545 |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
546 def test_change_size_2(self): |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
547 xml1 = "<?xml version='1.0' encoding='iso8859'?><a>a<s>%s" % ('a' * 1023) |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
548 xml2 = "aaa</s><s>%s</s></a>" % ('a' * 1025) |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
549 parser = expat.ParserCreate() |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
550 parser.CharacterDataHandler = self.counting_handler |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
551 parser.buffer_text = 1 |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
552 parser.buffer_size = 2048 |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
553 self.assertEquals(parser.buffer_size, 2048) |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
554 |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
555 self.n=0 |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
556 parser.Parse(xml1, 0) |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
557 parser.buffer_size /= 2 |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
558 self.assertEquals(parser.buffer_size, 1024) |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
559 parser.Parse(xml2, 1) |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
560 self.assertEquals(self.n, 4) |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
561 |
|
38977
e076e3d76f77
SF bug #1296433 (Expat bug #1515266): Unchecked calls to character data
Fred Drake <fdrake@acm.org>
parents:
33279
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:
38977
diff
changeset
|
563 def test_main(): |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
564 run_unittest(SetAttributeTest, |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
565 ParseTest, |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
566 NamespaceSeparatorTest, |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
567 InterningTest, |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
568 BufferTextTest, |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
569 HandlerExceptionTest, |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
570 PositionTest, |
|
44594
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
571 sf1296433Test, |
|
88d76b9206e6
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
Andrew M. Kuchling <amk@amk.ca>
parents:
41532
diff
changeset
|
572 ChardataBufferTest) |
|
38977
e076e3d76f77
SF bug #1296433 (Expat bug #1515266): Unchecked calls to character data
Fred Drake <fdrake@acm.org>
parents:
33279
diff
changeset
|
573 |
|
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:
38977
diff
changeset
|
574 if __name__ == "__main__": |
|
39e4386d71f6
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Collin Winter <collinw@gmail.com>
parents:
38977
diff
changeset
|
575 test_main() |
