Adapt to BeautifulSoup 4 changes (test_web.py)
@@ -311,7 +311,9 @@ class TestPlaintext(unittest.TestCase):
( "<p>text</p>", "text\n\n"),
( "<li>text</li>", "* text\n"),
( "<td>text</td>", "text\t"),
- ( "<br /><br/><br>", "\n\n\n")):
+ ( "<br>", "\n"),
+ ( "<br/>", "\n\n"),
+ ( "<br /><br/><br>", "\n\n\n\n\n")):
self.assertEqual(web.strip_tags(html), plain)
# Assert exclude tags and attributes
v = web.strip_tags("<a href=\"\" onclick=\"\">text</a>", exclude={"a": ["href"]})
@@ -766,17 +768,17 @@ class TestDOM(unittest.TestCase):
# Assert Node properties.
v1 = web.Document(self.html)
self.assertEqual(v1.type, web.DOCUMENT)
- self.assertEqual(v1.source[:10], "<!doctype ") # Note: BeautifulSoup strips whitespace.
+ self.assertEqual(v1.source[:10], "<!DOCTYPE ") # Note: BeautifulSoup strips whitespace.
self.assertEqual(v1.parent, None)
# Assert Node traversal.
v2 = v1.children[0].next
- self.assertEqual(v2.type, web.TEXT)
+ self.assertEqual(v2.type, web.ELEMENT)
self.assertEqual(v2.previous, v1.children[0])
# Assert Document properties.
v3 = v1.declaration
self.assertEqual(v3, v1.children[0])
self.assertEqual(v3.parent, v1)
- self.assertEqual(v3.source, "<!doctype html>")
+ self.assertEqual(v3.source, "html")
self.assertEqual(v1.head.type, web.ELEMENT)
self.assertEqual(v1.body.type, web.ELEMENT)
self.assertTrue(v1.head.source.startswith("<head"))
@@ -800,7 +802,7 @@ class TestDOM(unittest.TestCase):
v = web.DOM(self.html).body
self.assertEqual(v.tag, "body")
self.assertEqual(v.attributes["id"], "front")
- self.assertEqual(v.attributes["class"], "comments")
+ self.assertEqual(v.attributes["class"], ["comments"])
self.assertTrue(v.content.startswith("\n<script"))
# Assert Element.getElementsByTagname() (test navigation links).
a = v.by_tag("a")
@@ -811,8 +813,8 @@ class TestDOM(unittest.TestCase):
# Assert Element.getElementsByClassname() (test <p class="comment">).
a = v.by_class("comment")
self.assertEqual(a[0].tag, "p")
- self.assertEqual(a[0].by_tag("span")[0].attributes["class"], "date")
- self.assertEqual(a[0].by_tag("span")[1].attributes["class"], "author")
+ self.assertEqual(a[0].by_tag("span")[0].attributes["class"], ["date"])
+ self.assertEqual(a[0].by_tag("span")[1].attributes["class"], ["author"])
for selector in (".comment", "p.comment", "*.comment"):
self.assertEqual(v.by_tag(selector)[0], a[0])
# Assert Element.getElementById() (test <div id="content">).
