示例#1
0
 def test_to_text(self):
     raw = '<p>A <strong>Text</strong> Element</p>'
     strong_attrs = HTMLAttributes(raw='', attributes=[])
     strong_open_tag = HTMLOpenTag(raw='<strong>',
                                   tag='strong',
                                   attributes=strong_attrs)
     strong_close_tag = HTMLCloseTag(raw='</strong>', tag='strong')
     strong_text = HTMLText(raw='Text')
     strong_elem = HTMLElement(raw='<strong>Text</strong>',
                               open_tag=strong_open_tag,
                               close_tag=strong_close_tag,
                               children=[strong_text])
     p_attrs = HTMLAttributes(raw='', attributes=[])
     p_open_tag = HTMLOpenTag(raw='<p>', tag='p', attributes=p_attrs)
     p_close_tag = HTMLCloseTag(raw='</p>', tag='p')
     text1 = HTMLText(raw='A ')
     text2 = HTMLText(raw=' Element')
     p_elem = HTMLElement(raw=raw,
                          open_tag=p_open_tag,
                          close_tag=p_close_tag,
                          children=[text1, strong_elem, text2])
     self.assertEqual('A Text Element', p_elem.to_text())
示例#2
0
 def test_to_text(self):
     raw = '<p>A <strong>Text</strong> Element</p>'
     strong_attrs = HTMLAttributes(raw="", attributes=[])
     strong_open_tag = HTMLOpenTag(raw="<strong>",
                                   tag="strong",
                                   attributes=strong_attrs)
     strong_close_tag = HTMLCloseTag(raw="</strong>", tag="strong")
     strong_text = HTMLText(raw="Text")
     strong_elem = HTMLElement(raw="<strong>Text</strong>",
                               open_tag=strong_open_tag,
                               close_tag=strong_close_tag,
                               children=[strong_text])
     p_attrs = HTMLAttributes(raw="", attributes=[])
     p_open_tag = HTMLOpenTag(raw="<p>", tag="p", attributes=p_attrs)
     p_close_tag = HTMLCloseTag(raw="</p>", tag="p")
     text1 = HTMLText(raw="A ")
     text2 = HTMLText(raw=" Element")
     p_elem = HTMLElement(raw=raw,
                          open_tag=p_open_tag,
                          close_tag=p_close_tag,
                          children=[text1, strong_elem, text2])
     self.assertEqual('A Text Element', p_elem.to_text())
示例#3
0
 def test_bom_removed(self):
     text = HTMLText(raw='BOM -> \ufeff')
     self.assertEqual('BOM ->', text.to_text())
示例#4
0
 def test_to_text(self):
     text = HTMLText(raw='\nSome Text\n')
     self.assertEqual('Some Text', text.to_text())
示例#5
0
 def test_str(self):
     text = HTMLText(raw='\nSome Text\n')
     self.assertEqual('Some Text', text_type(text))
示例#6
0
 def test_bom_removed(self):
     text = HTMLText(raw='BOM -> \ufeff')
     self.assertEqual('BOM ->', text.to_text())
示例#7
0
 def test_to_text(self):
     text = HTMLText(raw='\nSome Text\n')
     self.assertEqual('Some Text', text.to_text())