MCPcopy Index your code
hub / github.com/python/cpython / testCloneDocumentDeep

Method testCloneDocumentDeep

Lib/test/test_minidom.py:814–837  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

812 " shallow cloning of documents makes no sense!")
813
814 def testCloneDocumentDeep(self):
815 doc = parseString("<?xml version='1.0'?>\n"
816 "<!-- comment -->"
817 "<!DOCTYPE doc [\n"
818 "<!NOTATION notation SYSTEM 'http://xml.python.org/'>\n"
819 "]>\n"
820 "<doc attr='value'/>")
821 doc2 = doc.cloneNode(1)
822 self.assertFalse((doc.isSameNode(doc2) or doc2.isSameNode(doc)),
823 "testCloneDocumentDeep: document objects not distinct")
824 self.assertEqual(len(doc.childNodes), len(doc2.childNodes),
825 "testCloneDocumentDeep: wrong number of Document children")
826 self.assertEqual(doc2.documentElement.nodeType, Node.ELEMENT_NODE,
827 "testCloneDocumentDeep: documentElement not an ELEMENT_NODE")
828 self.assertTrue(doc2.documentElement.ownerDocument.isSameNode(doc2),
829 "testCloneDocumentDeep: documentElement owner is not new document")
830 self.assertFalse(doc.documentElement.isSameNode(doc2.documentElement),
831 "testCloneDocumentDeep: documentElement should not be shared")
832 if doc.doctype is not None:
833 # check the doctype iff the original DOM maintained it
834 self.assertEqual(doc2.doctype.nodeType, Node.DOCUMENT_TYPE_NODE,
835 "testCloneDocumentDeep: doctype not a DOCUMENT_TYPE_NODE")
836 self.assertTrue(doc2.doctype.ownerDocument.isSameNode(doc2))
837 self.assertFalse(doc.doctype.isSameNode(doc2.doctype))
838
839 def testCloneDocumentTypeDeepOk(self):
840 doctype = create_nonempty_doctype()

Callers

nothing calls this directly

Calls 6

parseStringFunction · 0.90
assertFalseMethod · 0.80
isSameNodeMethod · 0.80
assertTrueMethod · 0.80
cloneNodeMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected