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