Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes
test.test_pyexpat.BufferTextTest Class Reference

List of all members.

Public Member Functions

def setUp
def check
def CharacterDataHandler
def StartElementHandler
def EndElementHandler
def CommentHandler
def setHandlers
def test_default_to_disabled
def test_buffering_enabled
def test1
def test2
def test3
def test4
def test5
def test6
def test7

Public Attributes

 stuff
 parser

Detailed Description

Definition at line 299 of file test_pyexpat.py.


Member Function Documentation

Definition at line 311 of file test_pyexpat.py.

00311 
00312     def CharacterDataHandler(self, text):
00313         self.stuff.append(text)

def test.test_pyexpat.BufferTextTest.check (   self,
  expected,
  label 
)

Definition at line 306 of file test_pyexpat.py.

00306 
00307     def check(self, expected, label):
00308         self.assertEqual(self.stuff, expected,
00309                 "%s\nstuff    = %r\nexpected = %r"
00310                 % (label, self.stuff, map(str, expected)))

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 325 of file test_pyexpat.py.

00325 
00326     def CommentHandler(self, data):
00327         self.stuff.append("<!--%s-->" % data)

Definition at line 322 of file test_pyexpat.py.

00322 
00323     def EndElementHandler(self, name):
00324         self.stuff.append("</%s>" % name)

def test.test_pyexpat.BufferTextTest.setHandlers (   self,
  handlers = [] 
)

Definition at line 328 of file test_pyexpat.py.

00328 
00329     def setHandlers(self, handlers=[]):
00330         for name in handlers:
00331             setattr(self.parser, name, getattr(self, name))

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 300 of file test_pyexpat.py.

00300 
00301     def setUp(self):
00302         self.stuff = []
00303         self.parser = expat.ParserCreate()
00304         self.parser.buffer_text = 1
00305         self.parser.CharacterDataHandler = self.CharacterDataHandler

Here is the caller graph for this function:

def test.test_pyexpat.BufferTextTest.StartElementHandler (   self,
  name,
  attrs 
)

Definition at line 314 of file test_pyexpat.py.

00314 
00315     def StartElementHandler(self, name, attrs):
00316         self.stuff.append("<%s>" % name)
00317         bt = attrs.get("buffer-text")
00318         if bt == "yes":
00319             self.parser.buffer_text = 1
00320         elif bt == "no":
00321             self.parser.buffer_text = 0

Here is the caller graph for this function:

Definition at line 343 of file test_pyexpat.py.

00343 
00344     def test1(self):
00345         # XXX This test exposes more detail of Expat's text chunking than we
00346         # XXX like, but it tests what we need to concisely.
00347         self.setHandlers(["StartElementHandler"])
00348         self.parser.Parse("<a>1<b buffer-text='no'/>2\n3<c buffer-text='yes'/>4\n5</a>", 1)
00349         self.assertEqual(self.stuff,
00350                          ["<a>", "1", "<b>", "2", "\n", "3", "<c>", "4\n5"],
00351                          "buffering control not reacting as expected")

Here is the call graph for this function:

Definition at line 352 of file test_pyexpat.py.

00352 
00353     def test2(self):
00354         self.parser.Parse("<a>1<b/>&lt;2&gt;<c/>&#32;\n&#x20;3</a>", 1)
00355         self.assertEqual(self.stuff, ["1<2> \n 3"],
00356                          "buffered text not properly collapsed")

Here is the call graph for this function:

Definition at line 357 of file test_pyexpat.py.

00357 
00358     def test3(self):
00359         self.setHandlers(["StartElementHandler"])
00360         self.parser.Parse("<a>1<b/>2<c/>3</a>", 1)
00361         self.assertEqual(self.stuff, ["<a>", "1", "<b>", "2", "<c>", "3"],
00362                          "buffered text not properly split")

Here is the call graph for this function:

Definition at line 363 of file test_pyexpat.py.

00363 
00364     def test4(self):
00365         self.setHandlers(["StartElementHandler", "EndElementHandler"])
00366         self.parser.CharacterDataHandler = None
00367         self.parser.Parse("<a>1<b/>2<c/>3</a>", 1)
00368         self.assertEqual(self.stuff,
00369                          ["<a>", "<b>", "</b>", "<c>", "</c>", "</a>"])

Here is the call graph for this function:

Definition at line 370 of file test_pyexpat.py.

00370 
00371     def test5(self):
00372         self.setHandlers(["StartElementHandler", "EndElementHandler"])
00373         self.parser.Parse("<a>1<b></b>2<c/>3</a>", 1)
00374         self.assertEqual(self.stuff,
00375             ["<a>", "1", "<b>", "</b>", "2", "<c>", "</c>", "3", "</a>"])

Here is the call graph for this function:

Definition at line 376 of file test_pyexpat.py.

00376 
00377     def test6(self):
00378         self.setHandlers(["CommentHandler", "EndElementHandler",
00379                     "StartElementHandler"])
00380         self.parser.Parse("<a>1<b/>2<c></c>345</a> ", 1)
00381         self.assertEqual(self.stuff,
00382             ["<a>", "1", "<b>", "</b>", "2", "<c>", "</c>", "345", "</a>"],
00383             "buffered text not properly split")

Here is the call graph for this function:

Definition at line 384 of file test_pyexpat.py.

00384 
00385     def test7(self):
00386         self.setHandlers(["CommentHandler", "EndElementHandler",
00387                     "StartElementHandler"])
00388         self.parser.Parse("<a>1<b/>2<c></c>3<!--abc-->4<!--def-->5</a> ", 1)
00389         self.assertEqual(self.stuff,
00390                          ["<a>", "1", "<b>", "</b>", "2", "<c>", "</c>", "3",
00391                           "<!--abc-->", "4", "<!--def-->", "5", "</a>"],
00392                          "buffered text not properly split")
00393 
00394 
# Test handling of exception from callback:

Here is the call graph for this function:

Definition at line 336 of file test_pyexpat.py.

00336 
00337     def test_buffering_enabled(self):
00338         # Make sure buffering is turned on
00339         self.assertTrue(self.parser.buffer_text)
00340         self.parser.Parse("<a>1<b/>2<c/>3</a>", 1)
00341         self.assertEqual(self.stuff, ['123'],
00342                          "buffered text not properly collapsed")

Here is the call graph for this function:

Definition at line 332 of file test_pyexpat.py.

00332 
00333     def test_default_to_disabled(self):
00334         parser = expat.ParserCreate()
00335         self.assertFalse(parser.buffer_text)

Here is the call graph for this function:


Member Data Documentation

Definition at line 302 of file test_pyexpat.py.

Definition at line 301 of file test_pyexpat.py.


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