Exemplo n.º 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())
Exemplo n.º 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())
Exemplo n.º 3
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())
Exemplo n.º 4
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())
Exemplo n.º 5
0
 def test_str(self):
     raw = '<p class="first">A Text Element</p>'
     attr = HTMLAttribute(raw='class="first"',
                          start=3,
                          ident='class',
                          value='first')
     attrs = HTMLAttributes(raw='class="first"', start=3, attributes=[attr])
     open_tag = HTMLOpenTag(raw='<p class="first">',
                            tag='p',
                            attributes=attrs)
     close_tag = HTMLCloseTag(raw='</p>', start=31, tag='p')
     children = [HTMLInterval(raw='A Text Element', start=17)]
     element = HTMLElement(raw=raw,
                           open_tag=open_tag,
                           close_tag=close_tag,
                           children=children)
     self.assertEqual(raw, str(element))
Exemplo n.º 6
0
 def test_br_to_html_drop_tag(self):
     raw = '<br>'
     attrs = HTMLAttributes()
     open_tag = HTMLOpenTag(raw=raw, tag='br', attributes=attrs)
     element = HTMLElement(raw=raw, open_tag=open_tag, drop_tag=True)
     self.assertEqual('', element.to_html())
Exemplo n.º 7
0
 def test_br_to_html_drop_tag(self):
     raw = '<br>'
     attrs = HTMLAttributes()
     open_tag = HTMLOpenTag(raw=raw, tag='br', attributes=attrs)
     element = HTMLElement(raw=raw, open_tag=open_tag, drop_tag=True)
     self.assertEqual('', element.to_html())