コード例 #1
0
ファイル: test_nodes.py プロジェクト: zenwalker/python-xmltag
 def test_is_last(self):
     doc = mock_document()
     root = XmlNode(doc, 'html')
     child_one = XmlNode(doc, 'head').append_to(root)
     child_two = XmlNode(doc, 'body').append_to(root)
     test.assert_false(child_one._is_last())
     test.assert_true(child_two._is_last())
コード例 #2
0
ファイル: test_nodes.py プロジェクト: zenwalker/python-xmltag
 def test_render_pretty(self):
     doc = mock_document()
     doc.indent = '..'
     node = XmlNode(doc, 'html')
     node.level = 0
     node.child_nodes.append(XmlNode(doc, 'body'))
     test.assert_equal(node.render(), '\n<html>\n..<body></body>\n</html>')
コード例 #3
0
 def test_render(self):
     doc = mock_document()
     node = XmlNode(doc, 'html', attrs={'lang': 'en'})
     body = XmlNode(doc, 'body', content='hello world')
     node.child_nodes.append(body)
     test.assert_equal(node.render(),
                       '<html><body>hello world</body></html>')
コード例 #4
0
 def test_render_pretty(self):
     doc = mock_document()
     doc.indent = '..'
     node = XmlNode(doc, 'html')
     node.level = 0
     node.child_nodes.append(XmlNode(doc, 'body'))
     test.assert_equal(node.render(), '\n<html>\n..<body></body>\n</html>')
コード例 #5
0
ファイル: test_nodes.py プロジェクト: zenwalker/python-xmltag
 def test_remove(self):
     doc = mock_document()
     root = XmlNode(doc, 'html')
     child_node = XmlNode(doc, 'head')
     root.child_nodes.append(child_node)
     child_node.parent_node = root
     test.assert_in(child_node, root.child_nodes)
     child_node.remove()
     test.assert_not_in(child_node, root.child_nodes)
コード例 #6
0
 def test_is_last(self):
     doc = mock_document()
     root = XmlNode(doc, 'html')
     child_one = XmlNode(doc, 'head').append_to(root)
     child_two = XmlNode(doc, 'body').append_to(root)
     test.assert_false(child_one._is_last())
     test.assert_true(child_two._is_last())
コード例 #7
0
 def test_render_escape(self):
     doc = mock_document()
     node = XmlNode(doc, 'body', content='<div>"hello"</div>')
     test.assert_equal(node.render(),
                       '<body>&lt;div&gt;"hello"&lt;/div&gt;</body>')
     node = XmlNode(doc, 'body', content='<div>"hello"</div>', safe=True)
     test.assert_equal(node.render(), '<body><div>"hello"</div></body>')
コード例 #8
0
 def test_remove(self):
     doc = mock_document()
     root = XmlNode(doc, 'html')
     child_node = XmlNode(doc, 'head')
     root.child_nodes.append(child_node)
     child_node.parent_node = root
     test.assert_in(child_node, root.child_nodes)
     child_node.remove()
     test.assert_not_in(child_node, root.child_nodes)
コード例 #9
0
ファイル: test_nodes.py プロジェクト: zenwalker/python-xmltag
 def test_render_escape(self):
     doc = mock_document()
     node = XmlNode(doc, 'body', content='<div>"hello"</div>')
     test.assert_equal(node.render(), '<body>&lt;div&gt;"hello"&lt;/div&gt;</body>')
     node = XmlNode(doc, 'body', content='<div>"hello"</div>', safe=True)
     test.assert_equal(node.render(), '<body><div>"hello"</div></body>')
コード例 #10
0
ファイル: test_nodes.py プロジェクト: zenwalker/python-xmltag
 def test_render(self):
     doc = mock_document()
     node = XmlNode(doc, 'html', attrs={'lang': 'en'})
     body = XmlNode(doc, 'body', content='hello world')
     node.child_nodes.append(body)
     test.assert_equal(node.render(), '<html><body>hello world</body></html>')
コード例 #11
0
ファイル: test_nodes.py プロジェクト: zenwalker/python-xmltag
 def test_append_to(self):
     doc = mock_document()
     root = XmlNode(doc, 'html')
     child = XmlNode(doc, 'body')
     child.append_to(root)
     test.assert_equal(root.child_nodes, [child])
コード例 #12
0
 def test_repr(self):
     node = XmlNode(mock_document(), 'html', attrs={'lang': 'ru'})
     test.assert_equal(repr(node), 'XmlNode(html, lang=ru)')
コード例 #13
0
 def test_init(self):
     doc = mock_document()
     node = XmlNode(doc, 'html', attrs={'lang': 'en'})
     test.assert_equal(node.tag_name, 'html')
     test.assert_equal(node.attrs, {'lang': 'en'})
コード例 #14
0
 def test_append_to(self):
     doc = mock_document()
     root = XmlNode(doc, 'html')
     child = XmlNode(doc, 'body')
     child.append_to(root)
     test.assert_equal(root.child_nodes, [child])