diff options
Diffstat (limited to 'bs4/tests')
-rw-r--r-- | bs4/tests/test_htmlparser.py | 4 | ||||
-rw-r--r-- | bs4/tests/test_soup.py | 24 |
2 files changed, 27 insertions, 1 deletions
diff --git a/bs4/tests/test_htmlparser.py b/bs4/tests/test_htmlparser.py index d2db38e..8aa2471 100644 --- a/bs4/tests/test_htmlparser.py +++ b/bs4/tests/test_htmlparser.py @@ -44,6 +44,10 @@ class TestHTMLParserTreeBuilder(TestLXMLBuilder): self.assertSoupEquals( "<p>Foo<br/>bar</p>", "<p>Foo<br />bar</p>") + def test_hex_entities_in_text(self): + # XXX This tests a workaround for a bug in HTMLParser. + self.assertSoupEquals("ñ", u"\xf1") + def test_entities_in_attribute_values_converted_during_parsing(self): # The numeric entity isn't recognized without the closing 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): |