From d7056f49c8bb3a448cec2f1a6f2de55e93c8e8d6 Mon Sep 17 00:00:00 2001 From: Leonard Richardson Date: Sat, 26 Feb 2011 21:26:15 -0500 Subject: First stab at HTML entity replacement. --- tests/test_tree.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'tests/test_tree.py') diff --git a/tests/test_tree.py b/tests/test_tree.py index 0b3d72e..249e7ae 100644 --- a/tests/test_tree.py +++ b/tests/test_tree.py @@ -830,6 +830,19 @@ class TestPersistence(SoupTest): class TestSubstitutions(SoupTest): + def test_entity_substitution(self): + soup = self.soup( + u"Sacr\N{LATIN SMALL LETTER E WITH ACUTE} bleu!") + encoded = soup.encode("utf-8", replace_with_html_entities=True) + self.assertEquals(encoded, + self.document_for("Sacré bleu!")) + + def test_entity_substitution_off_by_default(self): + markup = u"Sacr\N{LATIN SMALL LETTER E WITH ACUTE} bleu!" + soup = self.soup(markup) + encoded = soup.b.encode("utf-8") + self.assertEquals(encoded, markup.encode('utf-8')) + def test_encoding_substitution(self): # Here's the tag saying that a document is # encoded in Shift-JIS. -- cgit v1.2.3