示例#1
0
 def test_Raises_NO_MODIFICATION_ALLOWED_ERR(self):
     # ======================================
     # <document>
     #     <parent_node readonly="true"/>
     #     <new_child_node/>
     # <document>
     # ======================================
     parent_node_readonly = Node(node_type=Node.ELEMENT_NODE,
                                 node_name='tagName',
                                 owner_document=self.document,
                                 read_only=True)
     new_child_node = _create_element_node(self.document)
     # Testing
     with self.assertRaises(DOMException) as context_manager:
         parent_node_readonly.append_child(new_child_node)
     self.assertEqual(context_manager.exception.code,
                      DOMException.NO_MODIFICATION_ALLOWED_ERR)
示例#2
0
 def test_AppendDocumentFragmentNode(self):
     # ======================================
     # <document>
     #     <parent_node/>
     #
     #     <docfrag_node>
     #         <first_child_node/>
     #         <second_child_node/>
     #     </docfrag_node>
     # <document>
     # ======================================
     parent_node = _create_element_node(self.document)
     docfrag_node = Node(node_type=Node.DOCUMENT_FRAGMENT_NODE,
                         node_name='#document-fragment',
                         owner_document=self.document)
     first_child_node = _create_element_node(self.document)
     second_child_node = _create_element_node(self.document)
     docfrag_node.append_child(first_child_node)
     docfrag_node.append_child(second_child_node)
     # Testing
     parent_node.append_child(docfrag_node)
     self.assertEqual(parent_node.child_nodes.item(0), first_child_node)
     self.assertEqual(parent_node.child_nodes.item(1), second_child_node)
     self.assertEqual(parent_node.child_nodes.length, 2)