From ad2850dfe321856331c939ad0f5c5a636a07091b Mon Sep 17 00:00:00 2001 From: Leonard Richardson Date: Sun, 15 Jul 2018 19:50:15 -0400 Subject: Introduced the Formatter system. [bug=1716272]. --- bs4/tests/test_tree.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'bs4/tests/test_tree.py') diff --git a/bs4/tests/test_tree.py b/bs4/tests/test_tree.py index e75cf1d..e8903e3 100644 --- a/bs4/tests/test_tree.py +++ b/bs4/tests/test_tree.py @@ -1439,13 +1439,21 @@ class TestSubstitutions(SoupTest): u"<<Sacr\N{LATIN SMALL LETTER E WITH ACUTE} bleu!>>")) def test_formatter_html(self): - markup = u"<<Sacr\N{LATIN SMALL LETTER E WITH ACUTE} bleu!>>" + markup = u"
<<Sacr\N{LATIN SMALL LETTER E WITH ACUTE} bleu!>>" soup = self.soup(markup) decoded = soup.decode(formatter="html") self.assertEqual( decoded, - self.document_for("<<Sacré bleu!>>")) + self.document_for("
<<Sacré bleu!>>")) + def test_formatter_html5(self): + markup = u"
<<Sacr\N{LATIN SMALL LETTER E WITH ACUTE} bleu!>>" + soup = self.soup(markup) + decoded = soup.decode(formatter="html5") + self.assertEqual( + decoded, + self.document_for("
<<Sacré bleu!>>")) + def test_formatter_minimal(self): markup = u"<<Sacr\N{LATIN SMALL LETTER E WITH ACUTE} bleu!>>" soup = self.soup(markup) @@ -1518,7 +1526,7 @@ class TestSubstitutions(SoupTest): u'
\n foo\n
  \tbar\n  \n  
\n baz\n
', soup.div.prettify()) - def test_prettify_accepts_formatter(self): + def test_prettify_accepts_formatter_function(self): soup = BeautifulSoup("foo", 'html.parser') pretty = soup.prettify(formatter = lambda x: x.upper()) self.assertTrue("FOO" in pretty) -- cgit v1.2.3