[Python-checkins] CVS: python/dist/src/Lib/test test_sax.py,1.2,1.3
Lars Marius Garshol
python-dev@python.org
Sun, 24 Sep 2000 11:53:59 -0700
- Previous message: [Python-checkins] CVS: python/dist/src/Lib/test/output test_sax,1.2,1.3
- Next message: [Python-checkins] CVS: python/dist/src/Lib/xml/sax __init__.py,1.9,1.10 expatreader.py,1.7,1.8 saxutils.py,1.5,1.6 xmlreader.py,1.5,1.6
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/python/python/dist/src/Lib/test
In directory slayer.i.sourceforge.net:/tmp/cvs-serv2378
Modified Files:
test_sax.py
Log Message:
Added test cases for the InputSource class.
Index: test_sax.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_sax.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** test_sax.py 2000/09/24 18:40:52 1.2
--- test_sax.py 2000/09/24 18:53:56 1.3
***************
*** 5,9 ****
from xml.sax.saxutils import XMLGenerator, escape, XMLFilterBase
from xml.sax.expatreader import create_parser
! from xml.sax.xmlreader import AttributesImpl, AttributesNSImpl
from xml.sax.handler import ContentHandler
from cStringIO import StringIO
--- 5,9 ----
from xml.sax.saxutils import XMLGenerator, escape, XMLFilterBase
from xml.sax.expatreader import create_parser
! from xml.sax.xmlreader import InputSource, AttributesImpl, AttributesNSImpl
from xml.sax.handler import ContentHandler
from cStringIO import StringIO
***************
*** 239,242 ****
--- 239,278 ----
attrs[(ns_uri, "attr")] == "val"
+ # ===== InputSource support
+
+ xml_test_out = open("test.xml.out").read()
+
+ def test_expat_inpsource_filename():
+ parser = create_parser()
+ result = StringIO()
+ xmlgen = XMLGenerator(result)
+
+ parser.setContentHandler(xmlgen)
+ parser.parse("test.xml")
+
+ return result.getvalue() == xml_test_out
+
+ def test_expat_inpsource_sysid():
+ parser = create_parser()
+ result = StringIO()
+ xmlgen = XMLGenerator(result)
+
+ parser.setContentHandler(xmlgen)
+ parser.parse(InputSource("test.xml"))
+
+ return result.getvalue() == xml_test_out
+
+ def test_expat_inpsource_stream():
+ parser = create_parser()
+ result = StringIO()
+ xmlgen = XMLGenerator(result)
+
+ parser.setContentHandler(xmlgen)
+ inpsrc = InputSource()
+ inpsrc.setByteStream(open("test.xml"))
+ parser.parse(inpsrc)
+
+ return result.getvalue() == xml_test_out
+
# ===========================================================================
#
***************
*** 384,387 ****
--- 420,435 ----
# ===== Main program
+ def make_test_output():
+ parser = create_parser()
+ result = StringIO()
+ xmlgen = XMLGenerator(result)
+
+ parser.setContentHandler(xmlgen)
+ parser.parse("test.xml")
+
+ outf = open("test.xml.out", "w")
+ outf.write(result.getvalue())
+ outf.close()
+
items = locals().items()
items.sort()
***************
*** 393,394 ****
--- 441,444 ----
if fails != 0:
raise TestFailed, "%d of %d tests failed" % (fails, tests)
+
+ make_test_output()
- Previous message: [Python-checkins] CVS: python/dist/src/Lib/test/output test_sax,1.2,1.3
- Next message: [Python-checkins] CVS: python/dist/src/Lib/xml/sax __init__.py,1.9,1.10 expatreader.py,1.7,1.8 saxutils.py,1.5,1.6 xmlreader.py,1.5,1.6
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]