diff options
author | Leonard Richardson <leonard.richardson@canonical.com> | 2011-02-20 15:10:48 -0500 |
---|---|---|
committer | Leonard Richardson <leonard.richardson@canonical.com> | 2011-02-20 15:10:48 -0500 |
commit | 784dca53bc03943472f58b05b6fcdff801343dac (patch) | |
tree | 76d78c8831f0acb5a3a41bc628ffbd62b0bbfc6d /tests/test_lxml.py | |
parent | 232311a2f682e59078012e5b05e382982862f627 (diff) | |
parent | 89961f4de3ab1e88b15dd9c0aaa0af77a7c32262 (diff) |
Discovered that html5lib can't be made to support SoupStrainers, and changed the test suite appropriately.
Diffstat (limited to 'tests/test_lxml.py')
-rw-r--r-- | tests/test_lxml.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/tests/test_lxml.py b/tests/test_lxml.py index 88c866d..de2ce7b 100644 --- a/tests/test_lxml.py +++ b/tests/test_lxml.py @@ -3,8 +3,8 @@ import re from beautifulsoup import BeautifulSoup -from beautifulsoup.builder.lxml_builder import LXMLTreeBuilder -from beautifulsoup.element import Comment, Doctype +from beautifulsoup.builder import LXMLTreeBuilder, LXMLTreeBuilderForXML +from beautifulsoup.element import Comment, Doctype, SoupStrainer from beautifulsoup.testing import SoupTest @@ -320,6 +320,12 @@ class TestLXMLBuilder(SoupTest): self.assertFalse(soup.p.is_empty_element) self.assertEquals(str(soup.p), "<p></p>") + def test_soupstrainer(self): + strainer = SoupStrainer("b") + soup = self.soup("A <b>bold</b> <meta /> <i>statement</i>", + parseOnlyThese=strainer) + self.assertEquals(soup.decode(), "<b>bold</b>") + class TestLXMLBuilderInvalidMarkup(SoupTest): """Tests of invalid markup for the LXML tree builder. @@ -505,7 +511,6 @@ class TestLXMLBuilderEncodingConversion(SoupTest): self.HEBREW_DOCUMENT.decode("iso-8859-8").encode("utf-8")) -from beautifulsoup.builder.lxml_builder import LXMLTreeBuilderForXML class TestLXMLXMLBuilder(SoupTest): """Test XML-specific parsing behavior. |