from xml.dom import pulldom import unittest SMALL_SAMPLE = """ Introduction to XSL

""" class Test(unittest.TestCase): def test_comment(self): items = pulldom.parseString(SMALL_SAMPLE) for evt, node in items: if evt == pulldom.COMMENT: break else: self.fail("No comment was encountered") def test_end_document(self): items = pulldom.parseString(SMALL_SAMPLE) # Read all of the nodes up to and including : for evt, node in items: if evt == pulldom.END_ELEMENT and node.tagName == "html": break try: # Assert that the next node is END_DOCUMENT: evt, node = next(items) self.assertEqual(pulldom.END_DOCUMENT, evt) except StopIteration as stop: self.fail( "Ran out of events, but should have received END_DOCUMENT") if __name__ == "__main__": unittest.main()