Esempio n. 1
0
 def test_no_end_tag(self):
     html = '<p>This is <strong>bold</p></strong>'
     narrow_pos, narrow_end = narrow_parse_error(html, 0)
     expected_pos = html.index('<strong')
     expected_end = html.index('</p>', expected_pos)
     self.assertEqual(expected_pos, narrow_pos)
     self.assertEqual(expected_end, narrow_end)
Esempio n. 2
0
 def test_no_end_tag(self):
     html = '<p>This is <strong>bold</p></strong>'
     narrow_pos, narrow_end = narrow_parse_error(html, 0)
     expected_pos = html.index('<strong')
     expected_end = html.index('</p>', expected_pos)
     self.assertEqual(expected_pos, narrow_pos)
     self.assertEqual(expected_end, narrow_end)
Esempio n. 3
0
 def test_unknown_with_attributes(self):
     html = '<p><unknown class="foo">foo</unknown></p>'
     narrow_pos, narrow_end = narrow_parse_error(html, 3)
     expected_pos = html.index('<unknown')
     expected_end = html.index('</p>', expected_pos)
     self.assertEqual(expected_pos, narrow_pos)
     self.assertEqual(expected_end, narrow_end)
Esempio n. 4
0
 def test_unknown_with_attributes(self):
     html = '<p><unknown class="foo">foo</unknown></p>'
     narrow_pos, narrow_end = narrow_parse_error(html, 3)
     expected_pos = html.index('<unknown')
     expected_end = html.index('</p>', expected_pos)
     self.assertEqual(expected_pos, narrow_pos)
     self.assertEqual(expected_end, narrow_end)
Esempio n. 5
0
    def test_unknown_element(self):
        html = """\
<ul>
  <li>Plain</li>
  <li><strong>Bold</strong></li>
  <li><unknown>Strange</unknown></li>
  <li><em>Emphasized</em></li>
</ul>"""
        narrow_pos, narrow_end = narrow_parse_error(html, 0)
        expected_pos = html.index('<unknown>')
        expected_end = html.index('</li>', expected_pos)
        self.assertEqual(expected_pos, narrow_pos)
        self.assertEqual(expected_end, narrow_end)
Esempio n. 6
0
    def test_unknown_element(self):
        html = """\
<ul>
  <li>Plain</li>
  <li><strong>Bold</strong></li>
  <li><unknown>Strange</unknown></li>
  <li><em>Emphasized</em></li>
</ul>"""
        narrow_pos, narrow_end = narrow_parse_error(html, 0)
        expected_pos = html.index('<unknown>')
        expected_end = html.index('</li>', expected_pos)
        self.assertEqual(expected_pos, narrow_pos)
        self.assertEqual(expected_end, narrow_end)
Esempio n. 7
0
 def test_non_element_error(self):
     html = '<p>unknown [error]</p>'
     narrow_pos, narrow_end = narrow_parse_error(html, 10)
     self.assertEqual(10, narrow_pos)
     self.assertEqual(len(html), narrow_end)
Esempio n. 8
0
 def test_naked_lt(self):
     html = "Here's a naked < Wow that might cause problems."
     pos = html.index('<')
     narrow_pos, narrow_end = narrow_parse_error(html, pos)
     self.assertEqual(pos, narrow_pos)
     self.assertEqual(len(html), narrow_end)
Esempio n. 9
0
 def test_inner_lt(self):
     html = '<p><div>4 < 5</div></p>'
     narrow_pos, narrow_end = narrow_parse_error(html, 0)
     self.assertEqual(html.index('<div>'), narrow_pos)
     self.assertEqual(html.index('</p>'), narrow_end)
Esempio n. 10
0
 def test_non_element_error(self):
     html = '<p>unknown [error]</p>'
     narrow_pos, narrow_end = narrow_parse_error(html, 10)
     self.assertEqual(10, narrow_pos)
     self.assertEqual(len(html), narrow_end)
Esempio n. 11
0
 def test_naked_lt(self):
     html = "Here's a naked < Wow that might cause problems."
     pos = html.index('<')
     narrow_pos, narrow_end = narrow_parse_error(html, pos)
     self.assertEqual(pos, narrow_pos)
     self.assertEqual(len(html), narrow_end)
Esempio n. 12
0
 def test_inner_lt(self):
     html = '<p><div>4 < 5</div></p>'
     narrow_pos, narrow_end = narrow_parse_error(html, 0)
     self.assertEqual(html.index('<div>'), narrow_pos)
     self.assertEqual(html.index('</p>'), narrow_end)
Esempio n. 13
0
 def test_inner_lt(self):
     html = "<p><div>4 < 5</div></p>"
     narrow_pos, narrow_end = narrow_parse_error(html, 0)
     self.assertEqual(html.index("<div>"), narrow_pos)
     self.assertEqual(html.index("</p>"), narrow_end)