diff options
author | Leonard Richardson <leonard.richardson@canonical.com> | 2012-01-20 16:18:45 -0500 |
---|---|---|
committer | Leonard Richardson <leonard.richardson@canonical.com> | 2012-01-20 16:18:45 -0500 |
commit | 703ee4a184e491be056ae5c4c7549e004be12622 (patch) | |
tree | 4dd26ef0757cae50fa9bfeb4a3a216a9319785a6 /bs4/tests/test_soup.py | |
parent | df26dc64d868875d7cd8ca550f1a174d68dd7c67 (diff) |
Made it easier to convert BS3 code to BS4.
Diffstat (limited to 'bs4/tests/test_soup.py')
-rw-r--r-- | bs4/tests/test_soup.py | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/bs4/tests/test_soup.py b/bs4/tests/test_soup.py index 404a468..b588561 100644 --- a/bs4/tests/test_soup.py +++ b/bs4/tests/test_soup.py @@ -5,7 +5,29 @@ import unittest from bs4.element import SoupStrainer from bs4.dammit import EntitySubstitution, UnicodeDammit from bs4.testing import SoupTest - +import warnings + +class TestDeprecatedConstructorArguments(SoupTest): + + def test_parseOnlyThese_renamed_to_parse_only(self): + with warnings.catch_warnings(record=True) as w: + soup = self.soup("<a><b></b></a>", parseOnlyThese=SoupStrainer("b")) + msg = str(w[0].message) + self.assertTrue("parseOnlyThese" in msg) + self.assertTrue("parse_only" in msg) + self.assertEquals("<b></b>", soup.encode()) + + def test_fromEncoding_renamed_to_from_encoding(self): + with warnings.catch_warnings(record=True) as w: + soup = self.soup("<a>", fromEncoding=("shift_jis")) + msg = str(w[0].message) + self.assertTrue("fromEncoding" in msg) + self.assertTrue("from_encoding" in msg) + self.assertEquals("shift_jis", soup.original_encoding) + + def test_unrecognized_keyword_argument(self): + self.assertRaises( + TypeError, self.soup, "<a>", no_such_argument=True) class TestSelectiveParsing(SoupTest): |