diff options
-rw-r--r-- | src/beautifulsoup/tests/treebuilder.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/beautifulsoup/tests/treebuilder.py b/src/beautifulsoup/tests/treebuilder.py index 25be325..489708d 100644 --- a/src/beautifulsoup/tests/treebuilder.py +++ b/src/beautifulsoup/tests/treebuilder.py @@ -9,6 +9,7 @@ handle _good_ HTML in the same way. import unittest from beautifulsoup import BeautifulSoup +from beautifulsoup.element import SoupStrainer from test_soup import SoupTest class CompatibilityTest(SoupTest): @@ -21,6 +22,8 @@ class CompatibilityTest(SoupTest): def test(self): self.test_bare_string() self.test_tag_nesting() + self.test_self_closing() + self.test_soupstrainer() def test_bare_string(self): self.assertSoupEquals("A bare string") @@ -28,3 +31,16 @@ class CompatibilityTest(SoupTest): def test_tag_nesting(self): self.assertSoupEquals("<b>Inside a B tag</b>") self.assertSoupEquals("<p>A <i>nested <b>tag</b></i></p>") + + def test_self_closing(self): + self.assertSoupEquals("A <meta> tag", "A <meta /> tag") + + def test_soupstrainer(self): + strainer = SoupStrainer("b") + soup = BeautifulSoup("A <b>bold</b> <i>statement</i>", + parseOnlyThese=strainer) + self.assertEquals(soup.decode(), "<b>bold</b>") + + soup = BeautifulSoup("A <b>bold</b> <meta> <i>statement</i>", + parseOnlyThese=strainer) + self.assertEquals(soup.decode(), "<b>bold</b>") |