Exemplo n.º 1
0
 def test_non_node(self):
     obj = 'not a node'
     self.assertFalse(htree.is_node(obj))
     self.assertFalse(htree.is_text(obj))
     self.assertFalse(htree.is_text(obj, strict=True))
     self.assertFalse(htree.is_raw_text(obj))
     self.assertFalse(htree.is_comment(obj))
     self.assertFalse(htree.is_element(obj))
     self.assertFalse(htree.is_entity(obj))
Exemplo n.º 2
0
 def test_Entity_type(self):
     node = htree.Entity('amp')
     self.assertTrue(htree.is_node(node))
     self.assertFalse(htree.is_text(node))
     self.assertFalse(htree.is_text(node, strict=True))
     self.assertFalse(htree.is_raw_text(node))
     self.assertFalse(htree.is_comment(node))
     self.assertFalse(htree.is_element(node))
     self.assertTrue(htree.is_entity(node))
     self.assertTrue(repr(node).startswith('<Entity("&amp;") at '))
     self.assertEqual(node.parent, None)
Exemplo n.º 3
0
 def test_Comment_type(self):
     node = htree.Comment('Some text.')
     self.assertTrue(htree.is_node(node))
     self.assertFalse(htree.is_text(node))
     self.assertFalse(htree.is_text(node, strict=True))
     self.assertFalse(htree.is_raw_text(node))
     self.assertTrue(htree.is_comment(node))
     self.assertFalse(htree.is_element(node))
     self.assertFalse(htree.is_entity(node))
     self.assertTrue(repr(node).startswith('<Comment("Some t...") at '))
     self.assertEqual(node.parent, None)
Exemplo n.º 4
0
 def test_Element_type(self):
     node = htree.Element()
     self.assertTrue(htree.is_node(node))
     self.assertFalse(htree.is_text(node))
     self.assertFalse(htree.is_text(node, strict=True))
     self.assertFalse(htree.is_raw_text(node))
     self.assertFalse(htree.is_comment(node))
     self.assertTrue(htree.is_element(node))
     self.assertFalse(htree.is_entity(node))
     self.assertTrue(repr(node).startswith('<Element("None") at '))
     self.assertEqual(node.parent, None)
     self.assertEqual(node.tag, None)
Exemplo n.º 5
0
 def test_Text_subclass_type(self):
     class TextSubclass(htree.Text):
         pass
     node = TextSubclass('Some text.')
     self.assertTrue(isinstance(node, TextSubclass))
     self.assertTrue(htree.is_node(node))
     self.assertTrue(htree.is_text(node))
     self.assertFalse(htree.is_text(node, strict=True))
     self.assertFalse(htree.is_raw_text(node))
     self.assertFalse(htree.is_comment(node))
     self.assertFalse(htree.is_element(node))
     self.assertFalse(htree.is_entity(node))
     self.assertTrue(repr(node).startswith('<TextSubclass("Some t...") at '))
     self.assertEqual(node.parent, None)