cybertools/xml/tests.py
helmutm 589238c76f created cybertools.xml package
git-svn-id: svn://svn.cy55.de/Zope3/src/cybertools/trunk@1477 fd906abe-77d9-0310-91a1-e0d9ade77398
2006-11-06 20:46:40 +00:00

49 lines
1.2 KiB
Python
Executable file

#! /usr/bin/python
"""
Tests for the 'cyberdev.xml' package.
$Id$
"""
import unittest, doctest
from zope.testing.doctestunit import DocFileSuite
from cStringIO import StringIO
from cybertools.xml.element import elements as e, fromXML
class TestXml(unittest.TestCase):
"Basic tests for the xml package."
baseHtml = e.html(
e.head(e.title(u'Page Title')),
e.body(
e.div(u'The top bar', class_='top'),
e.div(u'The body stuff', class_='body'),
))
def testBasicStuff(self):
doc = self.baseHtml
tree = doc.makeTree()
out = StringIO()
tree.write(out)
text = out.getvalue()
def testParsing(self):
xml = ('<html><head><title>Page Title</title></head>'
'<body><div class="top">The top bar</div>'
'<div class="body">The body stuff</div></body></html>')
doc = fromXML(xml)
text = doc.render()
def test_suite():
flags = doctest.NORMALIZE_WHITESPACE | doctest.ELLIPSIS
return unittest.TestSuite((
DocFileSuite('README.txt', optionflags=flags),
unittest.makeSuite(TestXml),
))
if __name__ == '__main__':
unittest.main(defaultTest='test_suite')