mirror of
https://github.com/Hopiu/linkchecker.git
synced 2026-04-27 01:24:42 +00:00
more test coverage
git-svn-id: https://linkchecker.svn.sourceforge.net/svnroot/linkchecker/trunk/linkchecker@3344 e7d03fd6-7b0d-0410-9947-9c21f3af8025
This commit is contained in:
parent
9a84b42326
commit
12946ec9f7
2 changed files with 74 additions and 2 deletions
|
|
@ -242,6 +242,19 @@ class TestParser (unittest.TestCase):
|
|||
self.check_results(self.htmlparser, _in, _out, out)
|
||||
self.check_results(self.htmlparser2, _in, _out, out2)
|
||||
|
||||
def test_handler (self):
|
||||
for _in, _out in parsetests:
|
||||
out = StringIO.StringIO()
|
||||
out2 = StringIO.StringIO()
|
||||
handler = linkcheck.HtmlParser.htmllib.HtmlPrinter(out)
|
||||
self.htmlparser.handler = handler
|
||||
handler2 = linkcheck.HtmlParser.htmllib.HtmlPrinter(out2)
|
||||
self.htmlparser2.handler = handler2
|
||||
for c in _in:
|
||||
self.htmlparser.feed(c)
|
||||
self.htmlparser2.feed(c)
|
||||
self.assertEquals(out.getvalue(), out2.getvalue())
|
||||
|
||||
def test_flush (self):
|
||||
"""
|
||||
Test parser flushing.
|
||||
|
|
@ -257,9 +270,10 @@ class TestParser (unittest.TestCase):
|
|||
"""
|
||||
Test entity resolving.
|
||||
"""
|
||||
resolve = linkcheck.HtmlParser.resolve_entities
|
||||
for c in "abcdefghijklmnopqrstuvwxyz":
|
||||
self.assertEqual(
|
||||
linkcheck.HtmlParser.resolve_entities("&#%d;" % ord(c)), c)
|
||||
self.assertEqual(resolve("&#%d;" % ord(c)), c)
|
||||
self.assertEqual(resolve("�"), u"")
|
||||
|
||||
|
||||
def test_suite ():
|
||||
|
|
|
|||
|
|
@ -48,6 +48,55 @@ class TestRobotsTxt (unittest.TestCase):
|
|||
self.rp.parse(lines)
|
||||
self.assertEquals(str(self.rp), "\n".join(lines))
|
||||
|
||||
def test_robotstxt3 (self):
|
||||
lines = [
|
||||
"Disallow: /search",
|
||||
"",
|
||||
"Allow: /search",
|
||||
"",
|
||||
"Crawl-Delay: 5",
|
||||
"",
|
||||
"Blabla",
|
||||
"",
|
||||
"Bla: bla",
|
||||
]
|
||||
self.rp.parse(lines)
|
||||
self.assertEquals(str(self.rp), "")
|
||||
|
||||
def test_robotstxt4 (self):
|
||||
lines = [
|
||||
"User-agent: Bla",
|
||||
"Disallow: /cgi-bin",
|
||||
"User-agent: *",
|
||||
"Disallow: /search",
|
||||
]
|
||||
self.rp.parse(lines)
|
||||
lines.insert(2, "")
|
||||
self.assertEquals(str(self.rp), "\n".join(lines))
|
||||
|
||||
def test_robotstxt5 (self):
|
||||
lines = [
|
||||
"#one line comment",
|
||||
"User-agent: Bla",
|
||||
"Disallow: /cgi-bin # comment",
|
||||
"Allow: /search",
|
||||
]
|
||||
lines2 = [
|
||||
"User-agent: Bla",
|
||||
"Disallow: /cgi-bin",
|
||||
"Allow: /search",
|
||||
]
|
||||
self.rp.parse(lines)
|
||||
self.assertEquals(str(self.rp), "\n".join(lines2))
|
||||
|
||||
def test_robotstxt6 (self):
|
||||
lines = [
|
||||
"User-agent: Bla",
|
||||
"",
|
||||
]
|
||||
self.rp.parse(lines)
|
||||
self.assertEquals(str(self.rp), "")
|
||||
|
||||
def test_crawldelay (self):
|
||||
lines = [
|
||||
"User-agent: Blubb",
|
||||
|
|
@ -65,6 +114,15 @@ class TestRobotsTxt (unittest.TestCase):
|
|||
self.assertEquals(self.rp.get_crawldelay("Hulla"), 5)
|
||||
self.assertEquals(self.rp.get_crawldelay("Bulla"), 1)
|
||||
|
||||
def test_crawldelay2 (self):
|
||||
lines = [
|
||||
"User-agent: Blubb",
|
||||
"Crawl-delay: X",
|
||||
]
|
||||
self.rp.parse(lines)
|
||||
del lines[1]
|
||||
self.assertEquals(str(self.rp), "\n".join(lines))
|
||||
|
||||
|
||||
def test_suite ():
|
||||
"""
|
||||
|
|
|
|||
Loading…
Reference in a new issue