示例#1
0
 def test_close_after_root(self):
     log = tutil.TestLog()
     html = u'<html><body>foo</body></html></superfluous>'
     parse_html(html, "http://example.site", log=log)
     log.assertFound(u'superfluous')
     log.assertFound(u'after root')
     self.assertEqual(len(log.entries), 1)
示例#2
0
 def test_parse_text_after_root(self):
     log = tutil.TestLog()
     html = u'<b/>c_textAfter'
     parse_html(html, "http://example.site", log=log)
     log.assert_found(u'Text')
     log.assert_found(u'textAfter')
     log.assert_count(1)
示例#3
0
 def test_parse_text_before_root(self):
     log = tutil.TestLog()
     html = u'textBefore<b></b>'
     parse_html(html, "http://example.site", log=log)
     log.assert_found(u'Text')
     log.assert_found(u'textBefore')
     log.assert_count(1)
示例#4
0
 def test_close_after_root(self):
     log = tutil.TestLog()
     html = u'<html><body>foo</body></html></superfluous>'
     parse_html(html, "http://example.site", log=log)
     log.assert_found(u'superfluous')
     log.assert_found(u'after root')
     log.assert_count(1)
示例#5
0
 def test_forgot_close(self):
     log = tutil.TestLog()
     html = u'<html><body><theforgottentag>foo</body></html>'
     parse_html(html, "http://example.site", log=log)
     log.assert_found(u'Unclosed')
     log.assert_found(u'theforgottentag')
     log.assert_count(1)
示例#6
0
 def test_forgot_close(self):
     log = tutil.TestLog()
     html = u'<html><body><theforgottentag>foo</body></html>'
     parse_html(html, "http://example.site", log=log)
     log.assert_found(u'Unclosed')
     log.assert_found(u'theforgottentag')
     log.assert_count(1)
示例#7
0
 def test_close_after_root(self):
     log = tutil.TestLog()
     html = u'<html><body>foo</body></html></superfluous>'
     parse_html(html, "http://example.site", log=log)
     log.assert_found(u'superfluous')
     log.assert_found(u'after root')
     log.assert_count(1)
示例#8
0
 def test_parse_text_before_root(self):
     log = tutil.TestLog()
     html = u'textBefore<b></b>'
     parse_html(html, "http://example.site", log=log)
     log.assert_found(u'Text')
     log.assert_found(u'textBefore')
     log.assert_count(1)
示例#9
0
 def test_parse_text_after_root(self):
     log = tutil.TestLog()
     html = u'<b/>c_textAfter'
     parse_html(html, "http://example.site", log=log)
     log.assert_found(u'Text')
     log.assert_found(u'textAfter')
     log.assert_count(1)
示例#10
0
 def test_forgot_close_2(self):
     log = tutil.TestLog()
     html = u'<html><body><theforgottentag><alsonot>foo</body></html>'
     parse_html(html, "http://example.site", log=log)
     log.assertFound(u'Unclosed')
     log.assertFound(u'theforgottentag')
     log.assertFound(u'alsonot')
     self.assertEqual(len(log.entries), 2)
示例#11
0
 def test_fixup_forgotten_closing(self):
     log = tutil.TestLog()
     html = u'<html><body>go</body>'
     doc = parse_html(html, "http://example.site", log=log)
     self.assertEqual(tostring(doc), b'<html><body>go</body></html>')
     log.assert_found(u'html')
     log.assert_count(1)
示例#12
0
 def test_fixup_forgotten_closing(self):
     log = tutil.TestLog()
     html = u'<html><body>go</body>'
     doc = parse_html(html, "http://example.site", log=log)
     self.assertEqual(tostring(doc), b'<html><body>go</body></html>')
     log.assert_found(u'html')
     log.assert_count(1)
示例#13
0
 def test_parse_empty(self):
     log = tutil.TestLog()
     html = u''
     doc = parse_html(html, "http://example.site", log=log)
     assert doc is not None
     log.assert_count(1)
示例#14
0
 def test_valid(self):
     log = tutil.TestLog()
     html = u'<html><head>&uuml; &auml;</head></html>'
     parser = parse_html(html, "http://example.site", log=log)
     self.assertEqual(len(log.entries), 0)
示例#15
0
 def test_superflupus_close(self):
     log = tutil.TestLog()
     html = u'<html><body>foo</superfluous></body></html>'
     parse_html(html, "http://example html", log=log)
     log.assert_found(u'superfluous')
     log.assert_count(1)
示例#16
0
 def test_superflupus_close(self):
     log = tutil.TestLog()
     html = u'<html><body>foo</superfluous></body></html>'
     parse_html(html, "http://example html", log=log)
     log.assert_found(u'superfluous')
     log.assert_count(1)
示例#17
0
 def test_empty_tags(self):
     log = tutil.TestLog()
     html = u'<html><meta><body><input><br><img><hr></body></html>'
     doc = parse_html(html, "http://example.site", log=log)
     log.assert_count(0)
示例#18
0
 def test_superflupus_close(self):
     log = tutil.TestLog()
     html = u'<html><body>foo</superfluous></body></html>'
     parse_html(html, "http://example html", log=log)
     log.assertFound(u'superfluous')
     self.assertEqual(len(log.entries), 1)
示例#19
0
 def test_parse_text_after_root(self):
     log = tutil.TestLog()
     html = u'<b/>c'
     parse_html(html, "http://example.site", log=log)
     log.assertFound(u'Text')
     self.assertEqual(len(log.entries), 1)
示例#20
0
 def test_parse_textroot(self):
     log = tutil.TestLog()
     html = u'someText'
     parse_html(html, "http://example.site", log=log)
     log.assert_found(u'someText')
     self.assertTrue(len(log.entries) >= 1)
示例#21
0
 def test_parse_empty(self):
     log = tutil.TestLog()
     html = u''
     doc = parse_html(html, "http://example.site", log=log)
     assert doc is not None
     log.assert_count(1)
示例#22
0
 def test_parse_textroot(self):
     log = tutil.TestLog()
     html = u'someText'
     parse_html(html, "http://example.site", log=log)
     log.assert_found(u'someText')
     self.assertTrue(len(log.entries) >= 1)
示例#23
0
 def test_valid(self):
     log = tutil.TestLog()
     html = u'<html><head>&uuml; &auml;</head></html>'
     parser = parse_html(html, "http://example.site", log=log)
     log.assert_count(0)
示例#24
0
 def test_parse_empty(self):
     log = tutil.TestLog()
     html = u''
     doc = parse_html(html, "http://example.site", log=log)
     assert doc is not None
     self.assertEqual(len(log.entries), 1)
示例#25
0
 def test_parse_whitespace_before_root(self):
     log = tutil.TestLog()
     html = u' <b></b>'
     parse_html(html, "http://example.site", log=log)
     log.assert_count(0)
示例#26
0
 def test_parse_whitespace_before_root(self):
     log = tutil.TestLog()
     html = u' <b></b>'
     parse_html(html, "http://example.site", log=log)
     log.assert_count(0)
示例#27
0
 def test_parse_whitespace_after_root(self):
     log = tutil.TestLog()
     html = u'<b/>\n\r\t'
     parse_html(html, "http://example.site", log=log)
     log.assert_count(0)
示例#28
0
 def test_valid(self):
     log = tutil.TestLog()
     html = u'<html><head>&uuml; &auml;</head></html>'
     parser = parse_html(html, "http://example.site", log=log)
     log.assert_count(0)
示例#29
0
 def test_empty_tags(self):
     log = tutil.TestLog()
     html = u'<html><meta><body><input><br><img><hr></body></html>'
     doc = parse_html(html, "http://example.site", log=log)
     log.assert_count(0)
示例#30
0
 def test_parse_whitespace_after_root(self):
     log = tutil.TestLog()
     html = u'<b/>\n\r\t'
     parse_html(html, "http://example.site", log=log)
     log.assert_count(0)