summaryrefslogtreecommitdiff
path: root/Lib/test/test_minidom.py
diff options
context:
space:
mode:
authorFred Drake <fdrake@acm.org>2001-12-06 04:32:18 +0000
committerFred Drake <fdrake@acm.org>2001-12-06 04:32:18 +0000
commitca2b6592ec3de28764edad30ded0acbb012ed66e (patch)
tree24c85b26765e9f1750d9d8f55833aa0c0772f11f /Lib/test/test_minidom.py
parent632aefe8647db09a32bfc5fc672dcce39a1378eb (diff)
downloadcpython-ca2b6592ec3de28764edad30ded0acbb012ed66e.tar.gz
Fix appendChild() and insertBefore() (and replaceChild() indirectly) when
the node being added is a fragment node. This closes SF bug #487929.
Diffstat (limited to 'Lib/test/test_minidom.py')
-rw-r--r--Lib/test/test_minidom.py45
1 files changed, 45 insertions, 0 deletions
diff --git a/Lib/test/test_minidom.py b/Lib/test/test_minidom.py
index ab985b83e6..adac990045 100644
--- a/Lib/test/test_minidom.py
+++ b/Lib/test/test_minidom.py
@@ -79,6 +79,34 @@ def testInsertBefore():
, "testInsertBefore -- node properly placed in tree")
dom.unlink()
+def _create_fragment_test_nodes():
+ dom = parseString("<doc/>")
+ orig = dom.createTextNode("original")
+ c1 = dom.createTextNode("foo")
+ c2 = dom.createTextNode("bar")
+ c3 = dom.createTextNode("bat")
+ dom.documentElement.appendChild(orig)
+ frag = dom.createDocumentFragment()
+ frag.appendChild(c1)
+ frag.appendChild(c2)
+ frag.appendChild(c3)
+ return dom, orig, c1, c2, c3, frag
+
+def testInsertBeforeFragment():
+ dom, orig, c1, c2, c3, frag = _create_fragment_test_nodes()
+ dom.documentElement.insertBefore(frag, None)
+ confirm(tuple(dom.documentElement.childNodes) == (orig, c1, c2, c3),
+ "insertBefore(<fragment>, None)")
+ frag.unlink()
+ dom.unlink()
+ #
+ dom, orig, c1, c2, c3, frag = _create_fragment_test_nodes()
+ dom.documentElement.insertBefore(frag, orig)
+ confirm(tuple(dom.documentElement.childNodes) == (c1, c2, c3, orig),
+ "insertBefore(<fragment>, orig)")
+ frag.unlink()
+ dom.unlink()
+
def testAppendChild():
dom = parse(tstfile)
dom.documentElement.appendChild(dom.createComment(u"Hello"))
@@ -86,6 +114,23 @@ def testAppendChild():
confirm(dom.documentElement.childNodes[-1].data == "Hello")
dom.unlink()
+def testAppendChildFragment():
+ dom, orig, c1, c2, c3, frag = _create_fragment_test_nodes()
+ dom.documentElement.appendChild(frag)
+ confirm(tuple(dom.documentElement.childNodes) == (orig, c1, c2, c3),
+ "appendChild(<fragment>)")
+ frag.unlink()
+ dom.unlink()
+
+def testReplaceChildFragment():
+ dom, orig, c1, c2, c3, frag = _create_fragment_test_nodes()
+ dom.documentElement.replaceChild(frag, orig)
+ orig.unlink()
+ confirm(tuple(dom.documentElement.childNodes) == (c1, c2, c3),
+ "replaceChild(<fragment>)")
+ frag.unlink()
+ dom.unlink()
+
def testLegalChildren():
dom = Document()
elem = dom.createElement('element')