Back to index

python3.2  3.2.2
Classes | Public Member Functions | Private Member Functions
test.test_pyexpat.ParseTest Class Reference

List of all members.

Classes

class  Outputter

Public Member Functions

def test_unicode
def test_parse_file

Private Member Functions

def _hookup_callbacks
def _verify_parse_output

Detailed Description

Definition at line 60 of file test_pyexpat.py.


Member Function Documentation

def test.test_pyexpat.ParseTest._hookup_callbacks (   self,
  parser,
  handler 
) [private]
Set each of the callbacks defined on handler and named in
self.handler_names on the given parser.

Definition at line 158 of file test_pyexpat.py.

00158 
00159     def _hookup_callbacks(self, parser, handler):
00160         """
00161         Set each of the callbacks defined on handler and named in
00162         self.handler_names on the given parser.
00163         """
00164         for name in self.handler_names:
00165             setattr(parser, name, getattr(handler, name))

Here is the call graph for this function:

Here is the caller graph for this function:

def test.test_pyexpat.ParseTest._verify_parse_output (   self,
  operations 
) [private]

Definition at line 166 of file test_pyexpat.py.

00166 
00167     def _verify_parse_output(self, operations):
00168         expected_operations = [
00169             ('XML declaration', ('1.0', 'iso-8859-1', 0)),
00170             'PI: \'xml-stylesheet\' \'href="stylesheet.css"\'',
00171             "Comment: ' comment data '",
00172             "Not standalone",
00173             ("Start doctype", ('quotations', 'quotations.dtd', None, 1)),
00174             ('Element declaration', ('root', (2, 0, None, ()))),
00175             ('Attribute list declaration', ('root', 'attr1', 'CDATA', None,
00176                 1)),
00177             ('Attribute list declaration', ('root', 'attr2', 'CDATA', None,
00178                 0)),
00179             "Notation declared: ('notation', None, 'notation.jpeg', None)",
00180             ('Entity declaration', ('acirc', 0, '\xe2', None, None, None, None)),
00181             ('Entity declaration', ('external_entity', 0, None, None,
00182                 'entity.file', None, None)),
00183             "Unparsed entity decl: ('unparsed_entity', None, 'entity.file', None, 'notation')",
00184             "Not standalone",
00185             "End doctype",
00186             "Start element: 'root' {'attr1': 'value1', 'attr2': 'value2\u1f40'}",
00187             "NS decl: 'myns' 'http://www.python.org/namespace'",
00188             "Start element: 'http://www.python.org/namespace!subelement' {}",
00189             "Character data: 'Contents of subelements'",
00190             "End element: 'http://www.python.org/namespace!subelement'",
00191             "End of NS decl: 'myns'",
00192             "Start element: 'sub2' {}",
00193             'Start of CDATA section',
00194             "Character data: 'contents of CDATA section'",
00195             'End of CDATA section',
00196             "End element: 'sub2'",
00197             "External entity ref: (None, 'entity.file', None)",
00198             ('Skipped entity', ('skipped_entity', 0)),
00199             "End element: 'root'",
00200         ]
00201         for operation, expected_operation in zip(operations, expected_operations):
00202             self.assertEqual(operation, expected_operation)

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 216 of file test_pyexpat.py.

00216 
00217     def test_parse_file(self):
00218         # Try parsing a file
00219         out = self.Outputter()
00220         parser = expat.ParserCreate(namespace_separator='!')
00221         self._hookup_callbacks(parser, out)
00222         file = BytesIO(data)
00223 
00224         parser.ParseFile(file)
00225 
00226         operations = out.out
00227         self._verify_parse_output(operations)

Here is the call graph for this function:

Definition at line 203 of file test_pyexpat.py.

00203 
00204     def test_unicode(self):
00205         # Try the parse again, this time producing Unicode output
00206         out = self.Outputter()
00207         parser = expat.ParserCreate(namespace_separator='!')
00208         self._hookup_callbacks(parser, out)
00209 
00210         parser.Parse(data, 1)
00211 
00212         operations = out.out
00213         self._verify_parse_output(operations)
00214         # Issue #6697.
00215         self.assertRaises(AttributeError, getattr, parser, '\uD800')

Here is the call graph for this function:


The documentation for this class was generated from the following file: