diff options
author | Leonard Richardson <leonard.richardson@canonical.com> | 2010-12-30 21:00:57 -0500 |
---|---|---|
committer | Leonard Richardson <leonard.richardson@canonical.com> | 2010-12-30 21:00:57 -0500 |
commit | 020bab27f80446db8780f43c893451bb98b06e4d (patch) | |
tree | 357e5f5d3f41cae0ef7f306c477588f28e89b1c8 /src | |
parent | fa925f92375ef42c16cdd6580d29a1a61106dd36 (diff) |
Ported a test of the selective parsing argument to the Beautiful Soup constructor.
Diffstat (limited to 'src')
-rw-r--r-- | src/beautifulsoup/tests/test_soup.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/beautifulsoup/tests/test_soup.py b/src/beautifulsoup/tests/test_soup.py index b9f9dbd..d95cba6 100644 --- a/src/beautifulsoup/tests/test_soup.py +++ b/src/beautifulsoup/tests/test_soup.py @@ -3,6 +3,7 @@ import unittest from helpers import SoupTest +from beautifulsoup.element import SoupStrainer from beautifulsoup.dammit import UnicodeDammit @@ -47,6 +48,17 @@ class TestEncodingConversion(SoupTest): soup_from_unicode = self.soup(self.unicode_data) self.assertEquals(soup_from_unicode.encode('utf-8'), self.utf8_data) + +class TestSelectiveParsing(SoupTest): + + def test_parse_with_soupstrainer(self): + markup = "No<b>Yes</b><a>No<b>Yes <c>Yes</c></b>" + strainer = SoupStrainer("b") + soup = self.soup(markup, parseOnlyThese=strainer) + self.assertEquals(soup.encode(), "<b>Yes</b><b>Yes <c>Yes</c></b>") + + + class TestUnicodeDammit(unittest.TestCase): """Standalone tests of Unicode, Dammit.""" |