Back to index

python3.2  3.2.2
Classes | Public Member Functions
test.test_sax.ExpatReaderTest Class Reference
Inheritance diagram for test.test_sax.ExpatReaderTest:
Inheritance graph
[legend]
Collaboration diagram for test.test_sax.ExpatReaderTest:
Collaboration graph
[legend]

List of all members.

Classes

class  AttrGatherer
class  TestDTDHandler
class  TestEntityResolver

Public Member Functions

def test_expat_file
def test_expat_dtdhandler
def test_expat_entityresolver
def test_expat_attrs_empty
def test_expat_attrs_wattr
def test_expat_nsattrs_empty
def test_expat_nsattrs_wattr
def test_expat_inpsource_filename
def test_expat_inpsource_sysid
def test_expat_inpsource_stream
def test_expat_incremental
def test_expat_incremental_reset
def test_expat_locator_noinfo
def test_expat_locator_withinfo
def verify_empty_attrs
def verify_empty_nsattrs
def verify_attrs_wattr

Detailed Description

Definition at line 469 of file test_sax.py.


Member Function Documentation

Definition at line 548 of file test_sax.py.

00548 
00549     def test_expat_attrs_empty(self):
00550         parser = create_parser()
00551         gather = self.AttrGatherer()
00552         parser.setContentHandler(gather)
00553 
00554         parser.feed("<doc/>")
00555         parser.close()
00556 
00557         self.verify_empty_attrs(gather._attrs)

Here is the call graph for this function:

Definition at line 558 of file test_sax.py.

00558 
00559     def test_expat_attrs_wattr(self):
00560         parser = create_parser()
00561         gather = self.AttrGatherer()
00562         parser.setContentHandler(gather)
00563 
00564         parser.feed("<doc attr='val'/>")
00565         parser.close()
00566 
00567         self.verify_attrs_wattr(gather._attrs)

Here is the call graph for this function:

Definition at line 498 of file test_sax.py.

00498 
00499     def test_expat_dtdhandler(self):
00500         parser = create_parser()
00501         handler = self.TestDTDHandler()
00502         parser.setDTDHandler(handler)
00503 
00504         parser.feed('<!DOCTYPE doc [\n')
00505         parser.feed('  <!ENTITY img SYSTEM "expat.gif" NDATA GIF>\n')
00506         parser.feed('  <!NOTATION GIF PUBLIC "-//CompuServe//NOTATION Graphics Interchange Format 89a//EN">\n')
00507         parser.feed(']>\n')
00508         parser.feed('<doc></doc>')
00509         parser.close()
00510 
00511         self.assertEqual(handler._notations,
00512             [("GIF", "-//CompuServe//NOTATION Graphics Interchange Format 89a//EN", None)])
00513         self.assertEqual(handler._entities, [("img", None, "expat.gif", "GIF")])

Here is the call graph for this function:

Definition at line 523 of file test_sax.py.

00523 
00524     def test_expat_entityresolver(self):
00525         parser = create_parser()
00526         parser.setEntityResolver(self.TestEntityResolver())
00527         result = StringIO()
00528         parser.setContentHandler(XMLGenerator(result))
00529 
00530         parser.feed('<!DOCTYPE doc [\n')
00531         parser.feed('  <!ENTITY test SYSTEM "whatever">\n')
00532         parser.feed(']>\n')
00533         parser.feed('<doc>&test;</doc>')
00534         parser.close()
00535 
00536         self.assertEqual(result.getvalue(), start +
00537                          "<doc><entity></entity></doc>")

Here is the call graph for this function:

Definition at line 473 of file test_sax.py.

00473 
00474     def test_expat_file(self):
00475         parser = create_parser()
00476         result = StringIO()
00477         xmlgen = XMLGenerator(result)
00478 
00479         parser.setContentHandler(xmlgen)
00480         with open(TEST_XMLFILE) as f:
00481             parser.parse(f)
00482 
00483         self.assertEqual(result.getvalue(), xml_test_out)

Here is the call graph for this function:

Definition at line 638 of file test_sax.py.

00638 
00639     def test_expat_incremental(self):
00640         result = StringIO()
00641         xmlgen = XMLGenerator(result)
00642         parser = create_parser()
00643         parser.setContentHandler(xmlgen)
00644 
00645         parser.feed("<doc>")
00646         parser.feed("</doc>")
00647         parser.close()
00648 
00649         self.assertEqual(result.getvalue(), start + "<doc></doc>")

Here is the call graph for this function:

Definition at line 650 of file test_sax.py.

00650 
00651     def test_expat_incremental_reset(self):
00652         result = StringIO()
00653         xmlgen = XMLGenerator(result)
00654         parser = create_parser()
00655         parser.setContentHandler(xmlgen)
00656 
00657         parser.feed("<doc>")
00658         parser.feed("text")
00659 
00660         result = StringIO()
00661         xmlgen = XMLGenerator(result)
00662         parser.setContentHandler(xmlgen)
00663         parser.reset()
00664 
00665         parser.feed("<doc>")
00666         parser.feed("text")
00667         parser.feed("</doc>")
00668         parser.close()
00669 
00670         self.assertEqual(result.getvalue(), start + "<doc>text</doc>")

Here is the call graph for this function:

Definition at line 603 of file test_sax.py.

00603 
00604     def test_expat_inpsource_filename(self):
00605         parser = create_parser()
00606         result = StringIO()
00607         xmlgen = XMLGenerator(result)
00608 
00609         parser.setContentHandler(xmlgen)
00610         parser.parse(TEST_XMLFILE)
00611 
00612         self.assertEqual(result.getvalue(), xml_test_out)

Here is the call graph for this function:

Definition at line 623 of file test_sax.py.

00623 
00624     def test_expat_inpsource_stream(self):
00625         parser = create_parser()
00626         result = StringIO()
00627         xmlgen = XMLGenerator(result)
00628 
00629         parser.setContentHandler(xmlgen)
00630         inpsrc = InputSource()
00631         with open(TEST_XMLFILE) as f:
00632             inpsrc.setByteStream(f)
00633             parser.parse(inpsrc)
00634 
00635         self.assertEqual(result.getvalue(), xml_test_out)

Here is the call graph for this function:

Definition at line 613 of file test_sax.py.

00613 
00614     def test_expat_inpsource_sysid(self):
00615         parser = create_parser()
00616         result = StringIO()
00617         xmlgen = XMLGenerator(result)
00618 
00619         parser.setContentHandler(xmlgen)
00620         parser.parse(InputSource(TEST_XMLFILE))
00621 
00622         self.assertEqual(result.getvalue(), xml_test_out)

Here is the call graph for this function:

Definition at line 673 of file test_sax.py.

00673 
00674     def test_expat_locator_noinfo(self):
00675         result = StringIO()
00676         xmlgen = XMLGenerator(result)
00677         parser = create_parser()
00678         parser.setContentHandler(xmlgen)
00679 
00680         parser.feed("<doc>")
00681         parser.feed("</doc>")
00682         parser.close()
00683 
00684         self.assertEqual(parser.getSystemId(), None)
00685         self.assertEqual(parser.getPublicId(), None)
00686         self.assertEqual(parser.getLineNumber(), 1)

Here is the call graph for this function:

Definition at line 687 of file test_sax.py.

00687 
00688     def test_expat_locator_withinfo(self):
00689         result = StringIO()
00690         xmlgen = XMLGenerator(result)
00691         parser = create_parser()
00692         parser.setContentHandler(xmlgen)
00693         parser.parse(TEST_XMLFILE)
00694 
00695         self.assertEqual(parser.getSystemId(), TEST_XMLFILE)
00696         self.assertEqual(parser.getPublicId(), None)
00697 
00698 
00699 # ===========================================================================
00700 #
00701 #   error reporting
00702 #
00703 # ===========================================================================

Here is the call graph for this function:

Definition at line 568 of file test_sax.py.

00568 
00569     def test_expat_nsattrs_empty(self):
00570         parser = create_parser(1)
00571         gather = self.AttrGatherer()
00572         parser.setContentHandler(gather)
00573 
00574         parser.feed("<doc/>")
00575         parser.close()
00576 
00577         self.verify_empty_nsattrs(gather._attrs)

Here is the call graph for this function:

Definition at line 578 of file test_sax.py.

00578 
00579     def test_expat_nsattrs_wattr(self):
00580         parser = create_parser(1)
00581         gather = self.AttrGatherer()
00582         parser.setContentHandler(gather)
00583 
00584         parser.feed("<doc xmlns:ns='%s' ns:attr='val'/>" % ns_uri)
00585         parser.close()
00586 
00587         attrs = gather._attrs
00588 
00589         self.assertEqual(attrs.getLength(), 1)
00590         self.assertEqual(attrs.getNames(), [(ns_uri, "attr")])
00591         self.assertTrue((attrs.getQNames() == [] or
00592                          attrs.getQNames() == ["ns:attr"]))
00593         self.assertEqual(len(attrs), 1)
00594         self.assertIn((ns_uri, "attr"), attrs)
00595         self.assertEqual(attrs.get((ns_uri, "attr")), "val")
00596         self.assertEqual(attrs.get((ns_uri, "attr"), 25), "val")
00597         self.assertEqual(list(attrs.items()), [((ns_uri, "attr"), "val")])
00598         self.assertEqual(list(attrs.values()), ["val"])
00599         self.assertEqual(attrs.getValue((ns_uri, "attr")), "val")
00600         self.assertEqual(attrs[(ns_uri, "attr")], "val")

Here is the call graph for this function:

def test.test_sax.XmlTestBase.verify_attrs_wattr (   self,
  attrs 
) [inherited]

Definition at line 65 of file test_sax.py.

00065 
00066     def verify_attrs_wattr(self, attrs):
00067         self.assertEqual(attrs.getLength(), 1)
00068         self.assertEqual(attrs.getNames(), ["attr"])
00069         self.assertEqual(attrs.getQNames(), ["attr"])
00070         self.assertEqual(len(attrs), 1)
00071         self.assertIn("attr", attrs)
00072         self.assertEqual(list(attrs.keys()), ["attr"])
00073         self.assertEqual(attrs.get("attr"), "val")
00074         self.assertEqual(attrs.get("attr", 25), "val")
00075         self.assertEqual(list(attrs.items()), [("attr", "val")])
00076         self.assertEqual(list(attrs.values()), ["val"])
00077         self.assertEqual(attrs.getValue("attr"), "val")
00078         self.assertEqual(attrs.getValueByQName("attr"), "val")
00079         self.assertEqual(attrs.getNameByQName("attr"), "attr")
00080         self.assertEqual(attrs["attr"], "val")
00081         self.assertEqual(attrs.getQNameByName("attr"), "attr")

Here is the call graph for this function:

Here is the caller graph for this function:

def test.test_sax.XmlTestBase.verify_empty_attrs (   self,
  attrs 
) [inherited]

Definition at line 31 of file test_sax.py.

00031 
00032     def verify_empty_attrs(self, attrs):
00033         self.assertRaises(KeyError, attrs.getValue, "attr")
00034         self.assertRaises(KeyError, attrs.getValueByQName, "attr")
00035         self.assertRaises(KeyError, attrs.getNameByQName, "attr")
00036         self.assertRaises(KeyError, attrs.getQNameByName, "attr")
00037         self.assertRaises(KeyError, attrs.__getitem__, "attr")
00038         self.assertEqual(attrs.getLength(), 0)
00039         self.assertEqual(attrs.getNames(), [])
00040         self.assertEqual(attrs.getQNames(), [])
00041         self.assertEqual(len(attrs), 0)
00042         self.assertNotIn("attr", attrs)
00043         self.assertEqual(list(attrs.keys()), [])
00044         self.assertEqual(attrs.get("attrs"), None)
00045         self.assertEqual(attrs.get("attrs", 25), 25)
00046         self.assertEqual(list(attrs.items()), [])
00047         self.assertEqual(list(attrs.values()), [])

Here is the call graph for this function:

Here is the caller graph for this function:

def test.test_sax.XmlTestBase.verify_empty_nsattrs (   self,
  attrs 
) [inherited]

Definition at line 48 of file test_sax.py.

00048 
00049     def verify_empty_nsattrs(self, attrs):
00050         self.assertRaises(KeyError, attrs.getValue, (ns_uri, "attr"))
00051         self.assertRaises(KeyError, attrs.getValueByQName, "ns:attr")
00052         self.assertRaises(KeyError, attrs.getNameByQName, "ns:attr")
00053         self.assertRaises(KeyError, attrs.getQNameByName, (ns_uri, "attr"))
00054         self.assertRaises(KeyError, attrs.__getitem__, (ns_uri, "attr"))
00055         self.assertEqual(attrs.getLength(), 0)
00056         self.assertEqual(attrs.getNames(), [])
00057         self.assertEqual(attrs.getQNames(), [])
00058         self.assertEqual(len(attrs), 0)
00059         self.assertNotIn((ns_uri, "attr"), attrs)
00060         self.assertEqual(list(attrs.keys()), [])
00061         self.assertEqual(attrs.get((ns_uri, "attr")), None)
00062         self.assertEqual(attrs.get((ns_uri, "attr"), 25), 25)
00063         self.assertEqual(list(attrs.items()), [])
00064         self.assertEqual(list(attrs.values()), [])

Here is the call graph for this function:

Here is the caller graph for this function:


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