summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeonard Richardson <leonard.richardson@canonical.com>2010-12-29 10:49:57 -0500
committerLeonard Richardson <leonard.richardson@canonical.com>2010-12-29 10:49:57 -0500
commit1b20c5a032271dde35659d6089de6521969b1d02 (patch)
treece42ce5a2e0d305ed0a763824c1cbe580ca7e932
parent4d4241a9ef27cfb08082d8388831893ff9f8ee94 (diff)
Added test suites.
-rw-r--r--src/beautifulsoup/tests/test_html5lib.py23
-rw-r--r--src/beautifulsoup/tests/test_strainer.py12
2 files changed, 35 insertions, 0 deletions
diff --git a/src/beautifulsoup/tests/test_html5lib.py b/src/beautifulsoup/tests/test_html5lib.py
new file mode 100644
index 0000000..f92771b
--- /dev/null
+++ b/src/beautifulsoup/tests/test_html5lib.py
@@ -0,0 +1,23 @@
+from helpers import SoupTest
+from beautifulsoup.builder.html5lib_builder import HTML5TreeBuilder
+
+
+class TestHTML5Builder(SoupTest):
+
+ def setUp(self):
+ self.default_builder = HTML5TreeBuilder()
+
+ def test_bare_string(self):
+ self.assertSoupEquals("A bare string")
+
+ def test_tag_nesting(self):
+ b_tag = "<b>Inside a B tag</b>"
+ self.assertSoupEquals(b_tag)
+
+ nested_b_tag = "<p>A <i>nested <b>tag</b></i></p>"
+ self.assertSoupEquals(nested_b_tag)
+
+ def test_self_closing(self):
+ self.assertSoupEquals(
+ "<p>A <meta> tag</p>", "<p>A <meta /> tag</p>")
+
diff --git a/src/beautifulsoup/tests/test_strainer.py b/src/beautifulsoup/tests/test_strainer.py
new file mode 100644
index 0000000..9a91463
--- /dev/null
+++ b/src/beautifulsoup/tests/test_strainer.py
@@ -0,0 +1,12 @@
+import unittest
+from helpers import SoupTest
+from beautifulsoup import BeautifulSoup
+from beautifulsoup.element import SoupStrainer
+
+class TestSoupStrainer(unittest.TestCase):
+
+ def test_soupstrainer(self):
+ strainer = SoupStrainer("b")
+ soup = BeautifulSoup("A <b>bold</b> <meta /> <i>statement</i>",
+ parseOnlyThese=strainer)
+ self.assertEquals(soup.decode(), "<b>bold</b>")