'Ensure SAX2DOM expands nodes as expected.'

def testSAX2DOM(self):

    sax2dom = pulldom.SAX2DOM()
    sax2dom.startDocument()
    sax2dom.startElement('doc', {})
    sax2dom.characters('text')
    sax2dom.startElement('subelm', {})
    sax2dom.characters('text')
    sax2dom.endElement('subelm')
    sax2dom.characters('text')
    sax2dom.endElement('doc')
    sax2dom.endDocument()
    doc = sax2dom.document
    root = doc.documentElement
    (text1, elm1, text2) = root.childNodes
    text3 = elm1.childNodes[0]
    self.assertIsNone(text1.previousSibling)
    self.assertIs(text1.nextSibling, elm1)
    self.assertIs(elm1.previousSibling, text1)
    self.assertIs(elm1.nextSibling, text2)
    self.assertIs(text2.previousSibling, elm1)
    self.assertIsNone(text2.nextSibling)
    self.assertIsNone(text3.previousSibling)
    self.assertIsNone(text3.nextSibling)
    self.assertIs(root.parentNode, doc)
    self.assertIs(text1.parentNode, root)
    self.assertIs(elm1.parentNode, root)
    self.assertIs(text2.parentNode, root)
    self.assertIs(text3.parentNode, elm1)
    doc.unlink()
